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:
@@ -212,7 +212,7 @@ function userIdForLog(auth) {
|
||||
}
|
||||
|
||||
function logTriggerAfterHook(triggerType, className, input, auth) {
|
||||
const cleanInput = logger.truncateLogMessage(JSON.stringify(input));
|
||||
const cleanInput = logger.cleanAndTruncateLogMessage(JSON.stringify(input));
|
||||
logger.info(`${triggerType} triggered for ${className} for user ${userIdForLog(auth)}:\n Input: ${cleanInput}`, {
|
||||
className,
|
||||
triggerType,
|
||||
@@ -221,8 +221,8 @@ function logTriggerAfterHook(triggerType, className, input, auth) {
|
||||
}
|
||||
|
||||
function logTriggerSuccessBeforeHook(triggerType, className, input, result, auth) {
|
||||
const cleanInput = logger.truncateLogMessage(JSON.stringify(input));
|
||||
const cleanResult = logger.truncateLogMessage(JSON.stringify(result));
|
||||
const cleanInput = logger.cleanAndTruncateLogMessage(JSON.stringify(input));
|
||||
const cleanResult = logger.cleanAndTruncateLogMessage(JSON.stringify(result));
|
||||
logger.info(`${triggerType} triggered for ${className} for user ${userIdForLog(auth)}:\n Input: ${cleanInput}\n Result: ${cleanResult}`, {
|
||||
className,
|
||||
triggerType,
|
||||
@@ -231,7 +231,7 @@ function logTriggerSuccessBeforeHook(triggerType, className, input, result, auth
|
||||
}
|
||||
|
||||
function logTriggerErrorBeforeHook(triggerType, className, input, auth, error) {
|
||||
const cleanInput = logger.truncateLogMessage(JSON.stringify(input));
|
||||
const cleanInput = logger.cleanAndTruncateLogMessage(JSON.stringify(input));
|
||||
logger.error(`${triggerType} failed for ${className} for user ${userIdForLog(auth)}:\n Input: ${cleanInput}\n Error: ${JSON.stringify(error)}`, {
|
||||
className,
|
||||
triggerType,
|
||||
|
||||
Reference in New Issue
Block a user