Scrub Passwords with URL Encoded Characters (#4433)
* scrub passwords with url encoded characters from logs * compose query string from parsed params, redacting based on key if needed
This commit is contained in:
committed by
Florent Vilmart
parent
04f8673edd
commit
7a9d4044af
@@ -46,12 +46,25 @@ export class LoggerController extends AdaptableController {
|
||||
}
|
||||
|
||||
maskSensitiveUrl(urlString) {
|
||||
const password = url.parse(urlString, true).query.password;
|
||||
const urlObj = url.parse(urlString, true);
|
||||
const query = urlObj.query;
|
||||
let sanitizedQuery = '?';
|
||||
|
||||
if (password) {
|
||||
urlString = urlString.replace('password=' + password, 'password=********');
|
||||
for(const key in query) {
|
||||
if(key !== 'password') {
|
||||
// normal value
|
||||
sanitizedQuery += key + '=' + query[key] + '&';
|
||||
} else {
|
||||
// password value, redact it
|
||||
sanitizedQuery += key + '=' + '********' + '&';
|
||||
}
|
||||
}
|
||||
return urlString;
|
||||
|
||||
// trim last character, ? or &
|
||||
sanitizedQuery = sanitizedQuery.slice(0, -1);
|
||||
|
||||
// return original path name with sanitized params attached
|
||||
return urlObj.pathname + sanitizedQuery;
|
||||
}
|
||||
|
||||
maskSensitive(argArray) {
|
||||
|
||||
Reference in New Issue
Block a user