Hiding sensitive text from the monitor in queries #896
Replies: 2 comments 3 replies
-
Your issue isn't with this library, but with the database that stores passwords in the open form, which should never be the case. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Filters in this library define how to format values, and if you encrypt password in the query string, it can no longer execute. So a custom filter would not help you here. The only thing you can do is to pause logging when executing security-sensitive queries: import pgPromise from 'pg-promise';
import monitor from 'pg-monitor';
let pauseLogging = false;
const opt = {
query(data: any) {
if (!pauseLogging) {
monitor.query(data); // monitor queries when not paused
}
}
};
const pgp = pgPromise(opt);
const db = pgp({
database: '...',
allowExitOnIdle: true
});
(async function () {
// execute security-sensitive query, without logging it:
pauseLogging = true;
const data = await db.any('select * from users where login <> $1', ['password']);
pauseLogging = false;
})(); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Say I run the query:
and
credentials
is an object with a string password in it, then the password is written to the logs.At the moment, I avoid this by detaching the monitor before running sensitive queries, and reattaching it afterwards.
However, a custom filter like
:password
or:mask
would be nice, e.g.Aside from this, how else should I avoid this issue?
Beta Was this translation helpful? Give feedback.
All reactions