diff --git a/changelog.d/redactor-catches-secrets-after-a-slash.md b/changelog.d/redactor-catches-secrets-after-a-slash.md new file mode 100644 index 000000000..894b414b0 --- /dev/null +++ b/changelog.d/redactor-catches-secrets-after-a-slash.md @@ -0,0 +1,4 @@ +--- +important: security +--- +- **Secret values written as `name=value` at the end of a path are now hidden.** gstack's redactor only recognized `password=…`, `api_key=…` or `token=…` at the start of a line, so the same thing after a slash (`../password=…`, `cfg/api_key=…`, `https://host/cb/token=…`) came back unredacted. `/cso` was the visible case: its retained Git history kept such a value from a symlink target, a link that only exists in history, or ordinary file content, and `gstack-cso history` printed it. The same redactor covers review packets, telemetry and ship logs, so they now hide these values too. Paths and code that only mention these words, values that are placeholders or `${VAR}` references, and regex literals in code are left as they were. diff --git a/lib/redact-patterns.ts b/lib/redact-patterns.ts index 6137672da..0f97cb836 100644 --- a/lib/redact-patterns.ts +++ b/lib/redact-patterns.ts @@ -1205,11 +1205,36 @@ function concatenationHoldsSecret(match: RegExpExecArray): boolean { * match that starts after other text on its line is a comment's, and its value, * less trailing punctuation, reports only when it is a secret run by * isSecretRun. Code before the comment is matched from the line start and - * checked as before. + * checked as before. GST-3297: a match that starts after a path's `/` is not + * a comment's (`a/token=…`), so it is checked like a line-start match; one + * after a comment marker that opens a quoted string or bracket (`"// key: …"`) + * is still a comment's. */ +const COMMENT_MARKER_BEFORE = /(?:^|[ \t"'`([])(?:#{1,6}|\/{2,3}|\/\*{1,2}|