From a32a240d40aca7cd73414c5196b74b16c5cacf00 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Sun, 15 Feb 2026 10:18:19 -0500 Subject: [PATCH] refactor(config): normalize whitelist suffixes once --- src/config/schema.hints.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/config/schema.hints.ts b/src/config/schema.hints.ts index 5eb5dd722fe3..214678821be6 100644 --- a/src/config/schema.hints.ts +++ b/src/config/schema.hints.ts @@ -101,14 +101,19 @@ const SENSITIVE_KEY_WHITELIST_SUFFIXES = [ "tokencount", "tokenlimit", "tokenbudget", - "passwordfile", + "passwordFile", ] as const; +const NORMALIZED_SENSITIVE_KEY_WHITELIST_SUFFIXES = SENSITIVE_KEY_WHITELIST_SUFFIXES.map((suffix) => + suffix.toLowerCase(), +); const SENSITIVE_PATTERNS = [/token$/i, /password/i, /secret/i, /api.?key/i]; export function isSensitiveConfigPath(path: string): boolean { const lowerPath = path.toLowerCase(); - const whitelisted = SENSITIVE_KEY_WHITELIST_SUFFIXES.some((suffix) => lowerPath.endsWith(suffix)); + const whitelisted = NORMALIZED_SENSITIVE_KEY_WHITELIST_SUFFIXES.some((suffix) => + lowerPath.endsWith(suffix), + ); return !whitelisted && SENSITIVE_PATTERNS.some((pattern) => pattern.test(path)); }