mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-26 12:35:23 +02:00
refactor(config): normalize whitelist suffixes once
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user