Redact MiniMax secrets with whitespace around colons

Update redactMiniMaxSecret to allow and match optional whitespace
surrounding the colon when redacting quoted cookie values. This matches
the spacing tolerance used during parsing.
This commit is contained in:
Jinjing
2026-07-05 00:01:25 -07:00
parent 685792e1c0
commit 3946edab1e
2 changed files with 8 additions and 1 deletions
@@ -108,6 +108,12 @@ describe('redactMiniMaxSecret', () => {
expect(redacted).not.toContain('x.y')
})
it('redacts quoted values with whitespace around the colon', () => {
const redacted = redactMiniMaxSecret('_token : "spaced.secret"')
expect(redacted).not.toContain('spaced.secret')
expect(redacted).toContain('_token:[REDACTED]')
})
it('redacts minimax_group_id_v2', () => {
expect(redactMiniMaxSecret('minimax_group_id_v2=99999 trailing')).not.toContain('99999')
})
@@ -83,7 +83,8 @@ export function redactMiniMaxSecret(value: string): string {
for (const name of SENSITIVE_COOKIE_NAMES) {
redacted = redacted
.replace(new RegExp(`${name}=([^;\\s]+)`, 'g'), `${name}=[REDACTED]`)
.replace(new RegExp(`${name}:["'][^"']+["']`, 'g'), `${name}:[REDACTED]`)
// Match parseCookiePairs' `\s*:\s*` tolerance so `name : "secret"` is redacted too.
.replace(new RegExp(`${name}\\s*:\\s*["'][^"']+["']`, 'g'), `${name}:[REDACTED]`)
}
return redacted
}