Skip to content

Commit 2746589

Browse files
committed
compose query string from parsed params, redacting based on key if needed
1 parent de453b6 commit 2746589

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/Controllers/LoggerController.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,25 @@ export class LoggerController extends AdaptableController {
4646
}
4747

4848
maskSensitiveUrl(urlString) {
49-
const password = url.parse(urlString, true).query.password;
50-
51-
if (password) {
52-
urlString = urlString.replace('password=' + encodeURIComponent(password), 'password=********');
49+
const urlObj = url.parse(urlString, true);
50+
const query = urlObj.query;
51+
let sanitizedQuery = '?';
52+
53+
for(const key in query) {
54+
if(key !== 'password') {
55+
// normal value
56+
sanitizedQuery += key + '=' + query[key] + '&';
57+
} else {
58+
// password value, redact it
59+
sanitizedQuery += key + '=' + '********' + '&';
60+
}
5361
}
54-
return urlString;
62+
63+
// trim last character, ? or &
64+
sanitizedQuery = sanitizedQuery.slice(0, -1);
65+
66+
// return original path name with sanitized params attached
67+
return urlObj.pathname + sanitizedQuery;
5568
}
5669

5770
maskSensitive(argArray) {

0 commit comments

Comments
 (0)