-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redact passwords provided in URL when passing errors to callbacks #283
Redact passwords provided in URL when passing errors to callbacks #283
Conversation
b8ee96b
to
a7527e0
Compare
a7527e0
to
cbb04f5
Compare
cbb04f5
to
bad0701
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alxndrsn before I merge this in, would you take one more look to and see if there's another property that could be used to uniquely identify the type of error that's leaking these credentials? (Since using a regular expression for this has the potential for false positives, it'd be good to see if there's another way before resorting to that.)
@rachaelshaw I understand and share your hesitation - this is hardly pretty code. OTOH I've found it very hard to trace through exactly where these errors are generated, and at this level it would be hard to match which errors are affected (at least at this level), as it seems that:
Perhaps a lower-level fix would happen in |
@rachaelshaw any more thoughts on this? |
False positives is much better than leaving this out there. I would say merge this. |
var REDACT_REGEX_MULTI = /(postgres:\/\/[^:\s]*):[^@\s]*@/g; | ||
|
||
if(err) { | ||
if(err.meta && typeof err.meta === 'object' && err.meta.url && typeof err.meta.url === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified to:
if(typeof err.meta === 'object' && typeof err.meta.url === 'string') {
if(err.meta && typeof err.meta === 'object' && err.meta.url && typeof err.meta.url === 'string') { | ||
err.meta.url = err.meta.url.replace(REDACT_REGEX_SINGLE, REDACT_REPLACEMENT); | ||
} | ||
if(err.message && typeof err.message === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, I think the initial check can be removed, so this line would just be:
if(typeof err.message === 'string') {
@alxndrsn Sorry for the delay, after fully testing the new code, I was able to successfully hide/censor the PostgreSQL database passwords with asterisks. Merging this in, thanks again! |
@johnabrams7 thanks for the merge. Any idea when this might get a public release? |
Has this been publically released? |
Fixes balderdashy/sails#4595