mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-10 23:19:09 +02:00
fix(redact): interpolation allowance can't swallow a real $word password
The placeholder calibration used optional braces on both sides, which
also suppressed bare $lowercase — a real password starting with '$'
would have passed the HIGH gate. Interpolation now means ${identifier}
(braced, any case) or bare $UPPER_SNAKE only; both connection-string
patterns share one validator so they can't drift. Pins added for the
bare-$word block, $UPPER allowance, and mismatched-brace block.
This commit is contained in:
@@ -114,6 +114,13 @@ describe("HIGH credential patterns", () => {
|
||||
// Assembled at runtime so this file's own diff never contains a
|
||||
// credential-shaped literal (the prepush guard scans exact pushed bytes).
|
||||
expect(ids("postgres://admin:" + "hun" + "ter2@db.internal/app")).toContain("db.url_with_password");
|
||||
// Bare $UPPER_SNAKE is shell convention → suppressed; bare $lowercase is
|
||||
// NOT an interpolation form — a real password starting with `$` must
|
||||
// still block (both-braces-optional would have let it through).
|
||||
expect(ids("postgres://user:$DB_PASSWORD@host/app")).not.toContain("db.url_with_password");
|
||||
expect(ids("postgres://admin:$" + "hun" + "ter2@db.internal/app")).toContain("db.url_with_password");
|
||||
// Mismatched brace is not an interpolation either.
|
||||
expect(ids("postgres://admin:${dbPass@db.internal/app")).toContain("db.url_with_password");
|
||||
});
|
||||
|
||||
test("all HIGH patterns block (exit 3)", () => {
|
||||
|
||||
Reference in New Issue
Block a user