Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR
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.
The upper-case secret-name rule (
DB_PASSWORD=…,API_TOKEN: "…") was quadratic on a long upper-case name with many credential words and no=:"TOKEN" * 8000took about 5 s in every reply's scrub. It now reads a name once and finds exactly the same matches.What changes
core/tstd/logging.py:_SECRET_ASSIGNMENTwas\b([A-Z][A-Z0-9_]*WORD[A-Z0-9_]*\s*[=:]…. On a run with many credential words and no=, it tried every word against every place the name could end. A name's characters can never be a space,=or:, so the name always runs to the end of its run. A lazy lookahead now finds a credential word after the name's first letter, and a possessive[A-Z][A-Z0-9_]*+reads the run once. The rest of the pattern, groups included, is unchanged._ESCAPED_SECRET_ASSIGNMENT(TD-5450) is built from the same pattern, so it gets the same fix.core/tests/test_security_suite.py, beside TD-5449's:finditerspans (group 1 and group 2) on 20,000 seeded texts, after\band after an escaped line break.TOKEN,PASSWORD,SECRET_,API_KEY, an escapedTOKENandTOKENfollowed by a space must each be read in under 5 s.docs/tst-desk-backlog.md: TD-5454 entry.Before / after
redact_secretsandsecret_spanson 40,000 characters of each run:cb20b685(redact / spans)TOKENPASSWORDSECRET_API_KEYtoken,x_token,apiToken, …), 12 shapesThe regex alone on
"TOKEN" * 8000: 5.07 s on main, under 1 ms here. The new long-name test (128,000TOKEN) was still running when a 120 s limit stopped it on main; here it takes 0.35 s.Same matches: 0 differences from the regex before this change:
Independent review
A separate reviewer, given the diff, main's regex and the ticket, read and probed it. Verdict: MERGE, no defects.
[A-Z0-9_]can never match\sor[=:], so main's name always ends at the end of its run. The lookahead stays inside that run, because every credential word is made of[A-Z_]. The tail of the pattern is unchanged, and the lookahead is zero-width and outside group 1. The escaped variant can only start after\n,\ror\t, so it always starts at a run's start.finditerstarting partway into the text. 0 differences.redact_secretsplussecret_spans. All doubled in time when the input doubled; the worst was 0.31 s at 320k ofTOKEN=".TOKEN×1000 → ×2000 went from 0.048 s to 0.198 s). The equivalence test guards future changes; it passes trivially on main, where both sides are the same regex.\r(added), and the backlog's 1,000,000-text figure came from a fuzz outside the repo (now said so).Tests
tests/test_security_suite.py -k upper_name: 8 passed.tests/test_security_suite.py+tests/test_pem_redaction.py(an earlier run): 962 passed, 1 failed. The failure wastest_connection_scoped_reply_scrubs_memory_content(the WebSocket server's port was 0), in a run made while other test processes were running on the machine. Run alone it passed 2 of 2 on this branch and 1 of 1 on main'slogging.py, and it passed in the 2,243 above.Checks
release_scan --git: 0 hits.🤖 Generated with Claude Code
https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR