Obfuscate password name value pairs in log strings (#2755)

* Unit test to catch password in logs.

* Add clean to logger controller to "look for" password strings in log messages.
This commit is contained in:
Florent Vilmart
2016-09-20 21:45:24 -04:00
committed by GitHub
parent 5feceaa6d6
commit ad707457be
4 changed files with 33 additions and 7 deletions

View File

@@ -61,6 +61,14 @@ export class LoggerController extends AdaptableController {
return null;
}
cleanAndTruncateLogMessage(string) {
return this.truncateLogMessage(this.cleanLogMessage(string));
}
cleanLogMessage(string) {
return string.replace(/password":"[^"]*"/g, 'password":"********"');
}
truncateLogMessage(string) {
if (string && string.length > LOG_STRING_TRUNCATE_LENGTH) {
const truncated = string.substring(0, LOG_STRING_TRUNCATE_LENGTH) + truncationMarker;