Commit Graph
1 Commits
Author SHA1 Message Date
yetone 511c4a765e redact: code naming a secret (secretKey: Uint8Array, toBase64Url(…)) is not masked as one
Kieran Zhang on X (10-25) showed TypeScript masked as secrets:
`secretKey: Uint8Array;`, `details.2`, `toBase64Url(...)`. The SECRET
rules took any letters-and-digits value after a secret's name, and an
identifier like Uint8Array or a call like toBase64Url has both.

Both SECRET rules (the named-secret one and the bare "key" one) now ask
notCode: a value that is an identifier path (a.b.c) is code, not a
secret, when a "(" follows it (a call), or when it sits unquoted after a
":" and code punctuation (; , ) } ] | ? & < >) or the end follows (a
type or an object member). A quoted value, an `=` assignment, or a YAML
style `password: Passw0rd123` line is masked as before.

Run at this head:
- internal/redact TestCodeIsNoSecret: the reporter's four literal lines,
  a union type, an object member and a spaced call go as written; seven
  real secrets (quoted, escaped JSON, env, YAML, query-like) still mask.
  Red on the old code (6 of them masked), green after.
- go test -timeout 45m ./internal/gateway ./internal/gui ./internal/otlp
  ./internal/pii ./internal/redact ./internal/sessions ./internal/settings:
  all ok except internal/gui TestMainWindowCorners, an AppKit window
  killed at its 40s deadline at load ~146; it is red alone too, filed as
  #1936 and #2645, and this change doesn't reach it.
- go vet on darwin, linux and windows; gofmt -l clean.

Not tried: the reporter's own file in a live session; an unquoted
`apiKey: SomeIdent,` in YAML now goes as written, which reads as code.
2026-10-25 03:53:35 +08:00