Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/redact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const SENSITIVE_KEY_PATTERN = /^(?:authorization|proxy-authorization|cookie|set-
const CREDENTIAL_HEADER_LABEL_RAW = "x-api-key|x-goog-api-key|x-amz-security-token|api[_-]?key|apiKey|access[_-]?token|accessToken|refresh[_-]?token|refreshToken|id[_-]?token|client[_-]?secret|clientSecret|authorization|proxy-authorization|cookie|set-cookie|password|secret|token";

const CREDENTIAL_HEADER_LABEL = CREDENTIAL_HEADER_LABEL_RAW
.replace(/(?<![\[\\])([A-Za-z])(?![\]\-])/g, "[$1\u0001]");
.replace(/[A-Za-z]/g, "[$&\u0001]");

/**
* Characters that render as a colon separator. Folded to `:` in the matching
Expand Down
3 changes: 3 additions & 0 deletions tests/redact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ describe("redactSecretString", () => {
'<header name="author&ii;zation">opaquecredential123456</header>',
'<header name="s&ee;cret">opaquecredential123456</header>',
'<header name="passwor&DifferentialD;">opaquecredential123456</header>',
"&chi;-api-key: opaquecredential123456",
"x-ap&iota;-key: opaquecredential123456",
'<header name="&chi;-api-key">opaquecredential123456</header>',
]) {
const redacted = redactSecretString(input);
expect(redacted).toContain(REDACTED_SECRET);
Expand Down
Loading