The JWT chain scanner only accepted a header at the start of a segment or
after `-`, so `session_<JWT>` reached the audit and cost logs unredacted.
Treat `_` as a prefix boundary too and cover it in the tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CLASSIFIER_NOTICE matched by prefix, so a pasted notice followed by a
user question was dropped from both summary paths. Anchor it to the
whole message so trailing user text is kept, and add a regression test.
Also pass ECC_SKIP_LLM_SUMMARY=1 in the withTranscript fixture helper so
an inherited ECC_LLM_SUMMARY_INTERVAL=1 cannot trigger claude -p.
Refs #3867
Assisted-by: Claude <noreply@anthropic.com>
Clear CLV2_NO_PROJECT and PYTHON_MANAGER_DEFAULT from the inherited
environment: with CLV2_NO_PROJECT=1 exported, detect-project.sh returned
before hashing and the project-hash test failed.
Add cases where the alias should be kept: Microsoft Store Python also
provides it, so either package may own it, and PYTHON_MANAGER_DEFAULT is
set, which the alias honours and the Python\bin shortcut does not.
Before 3.12 the parser rejects f"{d["k"]}" outright, so the shared sample
stopped at a parse error and the per-finding assertions failed on 3.11.
Samples that every supported Python parses now carry the per-finding
checks; the newer f-string forms run one per sample and accept either the
specific finding or the parse error.
Also flag unquoted X | Y annotations, which can fail at definition time
before 3.10, and check that a quoted union is not flagged.
In double quotes Bash drops a backslash-newline before it expands
anything, so a tail of `$\<newline>HOME` after the substitution's `)` is
`$HOME` and expands. The expansion check read the tail with the
continuation still in it and saw an escaped newline, so the hook
validated `fix: a$HOME` with no warning. Continuations are now dropped
first, while other escapes stay for the check: `\$\<newline>HOME` is
still the literal `$HOME`.
A JWT with a short claims segment such as e30 ({}) matched neither the
full JWT branch nor the cut-tail branch and was saved as is. The payload
segment now only needs one character.
A generic sk- key followed by "-" or "_" failed its lookahead and was
skipped whole. It is now redacted to the end of the token. Branch names
like sk-learn-upgrade stay readable because they have fewer than 20
alphanumerics after the prefix.
Adds a test that the two pattern copies in observe.sh are identical and
that they run in linear time on 300 KB of adversarial input (#2278).
The redaction and privacy cases grew session-activity-tracker.test.js to 845 lines, past the 800 that AGENTS.md allows. They move to session-activity-tracker-output.test.js; the original file is back to 758 lines.
In `-m "$(cat <<'EOF' … EOF\n)."` Bash drops the body's trailing newlines
and adds the period, so Git records `fix: update input.`, but the hook
checked only the here-document and missed the trailing-period warning.
Read the rest of the quoted value after the substitution's `)` and add
it to the message as double-quoted text. Commands or an expansion after
the here-document make the message unverifiable, as an expansion in an
unquoted body already does. The here-document reading moves into
readHeredocMessage, which also returns the Bash 3.2 note.
Bash ends a decoded $'...' string at its first NUL, so `cat <<$'EOF\0X'`
ends at the line EOF, but the splitter looked for EOF\0X and swallowed
the commands after the body. A carriage return or a no-break space is
not a blank to Bash, so `echo foo\r# && npm run dev` runs the dev
server, but the splitter read the # as a comment. And spreading a long
substitution's segments into push() threw RangeError, which the hook's
catch turned into an allow. Truncate the decoded part at the NUL, use
Bash's blanks for word starts, and append the segments one at a time.
printf decoded escapes in %s arguments too, so `printf '%s' 'gi\t push
--no-verify' | sh` read as `gi<tab> push` and passed, while the shell
reads `gi\t` as `git`. Escapes are now decoded in the format and in %b
arguments only. `1<&3` and the move `1>&3-` copy a descriptor like
`1>&3`, so restoring a saved stdout is followed. The format-reuse loop
charges the work budget before each piece, so a short command cannot
expand into a huge string. The bash-backed tests now run what the shell
reads with a stub git, which also sees how the shell unescapes words.
A group or pipeline producer counted whatever its redirections said, so
`{ echo 'git push --no-verify' >/dev/null | cat; } | bash` was blocked
although bash reads nothing, and printf filled no %s, so
`printf 'git %s --no-verify\n' push | sh` got through. shell-scan now
keeps a redirection's descriptor, and a stage's output counts only when
its descriptors, the stages after it and an `exec` earlier in its group
take it to the shell; an `exec` is carried only where it adds output.
printf fills %s, %b and %c and reuses its format; other conversions are
read like an unmodeled command. The header states what the model covers.
The tracker serialized any structured result with JSON.stringify before
redaction, so an encoding nested in it, such as a double-escaped JSON
token, reached tool-usage.jsonl whole, and Claude Code's Bash stdout went
in as text. Keep text only from the adapter's tool_output, as main did,
and from Claude Code's tool_response only the sizes of stdout and stderr
and its interrupted and image flags. Any other structure is left out.
A comment that opened after text in a list item and closed in a later
block quote hid the live link between them, because the paragraph check
only looked for blank lines. Read a comment across lines only where
CommonMark makes it a top-level HTML block, a `<!--` at column 0 after a
blank line, which only its closer ends. Elsewhere a comment is hidden
only when it closes on the line it opens on, so every other line stays
audited Markdown. The fence pass uses the same rule for comment blocks.
Drop the container and ordered-list heuristics this replaces, refresh
the registry digest, and keep the three copies of the script identical.
The safety-classifier notice filter only covered the mechanical summary.
When generateSessionSummary runs (low context or message interval),
extractConversationText read the raw transcript and passed the notice to
the LLM as a user turn, so it could still reach saved context.
Move the check into one shared isClassifierNotice() in
scripts/lib/llm-summary.js and use it in both userMessageText() and
extractConversationText(). Add LLM-path regression tests, and split the
session-end classifier-notice tests into small functions (<50 lines).
Refs #3867
Assisted-by: Claude <noreply@anthropic.com>
The dev-guard half of 7632669d from #3735: segments that the splitter
reads from an expanded here-document body are scanned again, so a dev
command in a substitution nested inside one is still found.
(split from commit 7632669d28)