mirror of
https://github.com/stablyai/orca.git
synced 2026-10-29 08:07:18 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user