fix(redact): preserve code syntax around auth header redaction (#33801) - #52172
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
fix(redact): preserve code syntax around auth header redaction (#33801)#52172Tranquil-Flow wants to merge 1 commit into
Tranquil-Flow wants to merge 1 commit into
Conversation
…esearch#33801) The \S+ greedy capture in _AUTH_HEADER_RE and _SECRET_HEADER_RE consumed trailing code delimiters (quotes, braces, brackets, parens) along with credential tokens. When _mask_token replaced the entire match with ***, those delimiters vanished, corrupting surrounding code and causing SyntaxError in generated code. Fix: replace \S+ with a _TOKEN_CHARS character class that matches everything except common code-syntax delimiters, so redaction stops cleanly at quotes, braces, brackets, etc. 10 new regression tests cover short/long tokens, Bearer/Basic/Proxy-Auth schemes, api-key/x-api-key headers, dict braces, and code_file mode. All 92 existing redact tests still pass.
Tranquil-Flow
force-pushed
the
fix/33801-auth-redact-syntax-corruption
branch
from
June 25, 2026 04:32
fdc666f to
31d41a1
Compare
Contributor
|
Closing as part of the #33801 secret-redaction-corrupts-code cluster, fixed at the root in #54061 (merged: 674e16e). The real defect was |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
\S+greedy capture in_AUTH_HEADER_REand_SECRET_HEADER_REwas consuming trailing code delimiters (quotes, braces, brackets, parens) when masking credential tokens. When_mask_tokenreplaced the match, those delimiters vanished, corrupting surrounding code syntax in tool output.Fix
Replace
\S+with_TOKEN_CHARS = r"[^\s\"'<>{}\[\]()\\,;]+"— matches everything\S+would except common code-syntax delimiters, so redaction stops at the delimiter and the credential is still masked.Layers addressed (all tested)
{X: "Authorization: Bearer <tok>"})Verification
\S+)Competitor PRs
code_file=Trueat call sites — complementary but does not fix the AUTH_HEADER_RE regex itself$VAR/${{ secrets.X }}— complementary, does not fix the AUTH_HEADER_RE character classThis PR fixes the root regex cause; the competitor approaches address different symptoms (ENV-assignment and JSON-field corruption).
Auto-published by Moonsong via Path B automated pipeline.