From 1cab41c893caf09a9bb578ce3b94f8faeaeeaf4a Mon Sep 17 00:00:00 2001 From: Kin Ueng Date: Tue, 15 Aug 2023 10:42:15 -0500 Subject: [PATCH 1/3] fix: hide sensitive data from debug logs --- lib/utils/debug.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/utils/debug.ts b/lib/utils/debug.ts index 7523e119..57db8558 100644 --- a/lib/utils/debug.ts +++ b/lib/utils/debug.ts @@ -62,12 +62,24 @@ export default function genDebugFunction( return; // no-op } + let sanitizeString = false; // we skip the first arg because that is the message for (let i = 1; i < args.length; i++) { - const str = getStringValue(args[i]); - if (typeof str === "string" && str.length > MAX_ARGUMENT_LENGTH) { - args[i] = genRedactedString(str, MAX_ARGUMENT_LENGTH); - } + const str = getStringValue(args[i]);; + if(sanitizeString) { + // The previous array index indicates this current index + // needs to be removed from the logs. + args[i] = '***********'; + sanitizeString = false; + continue; + } + if(typeof str === "string" && str === 'auth') { + // Expect the next array index will contain + // sensitive data that should not be in plaintext + sanitizeString = true; + } else if (typeof str === "string" && str.length > MAX_ARGUMENT_LENGTH) { + args[i] = genRedactedString(str, MAX_ARGUMENT_LENGTH); + } } return fn.apply(null, args); From 5f02df94a4a9f2f6f76f41512fd50576035b915e Mon Sep 17 00:00:00 2001 From: Kin Ueng Date: Tue, 15 Aug 2023 10:58:36 -0500 Subject: [PATCH 2/3] chore: remove extra semicolon --- lib/utils/debug.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/debug.ts b/lib/utils/debug.ts index 57db8558..cd57a141 100644 --- a/lib/utils/debug.ts +++ b/lib/utils/debug.ts @@ -65,7 +65,7 @@ export default function genDebugFunction( let sanitizeString = false; // we skip the first arg because that is the message for (let i = 1; i < args.length; i++) { - const str = getStringValue(args[i]);; + const str = getStringValue(args[i]); if(sanitizeString) { // The previous array index indicates this current index // needs to be removed from the logs. From 6de63ab829b2da1a613b80a1615c9a25bc09230e Mon Sep 17 00:00:00 2001 From: Kin Ueng Date: Mon, 6 Nov 2023 10:34:24 -0600 Subject: [PATCH 3/3] refactor: compare against lower case strings --- lib/utils/debug.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/debug.ts b/lib/utils/debug.ts index cd57a141..bcfc38ef 100644 --- a/lib/utils/debug.ts +++ b/lib/utils/debug.ts @@ -73,7 +73,7 @@ export default function genDebugFunction( sanitizeString = false; continue; } - if(typeof str === "string" && str === 'auth') { + if(typeof str === "string" && str.toLowerCase() === 'auth') { // Expect the next array index will contain // sensitive data that should not be in plaintext sanitizeString = true;