| Age | Commit message (Collapse) | Author |
|
Count-only keys on agentic review rows: Read/Grep/Glob calls made, how
many came back as errors, and whether the reviewer's directory was
missing before or during the review. Appended last in the row so they
never displace an existing key.
|
|
mhegazy/sg-fewer-bash-hook-entries
|
|
|
|
|
|
(#6541)
* security-guidance: stop re-reviewing untracked files past the snapshot cap
The untracked-file snapshot stops at 2,000 entries. Every pre-existing untracked file past the cap looked new on each turn, so the same files were reviewed again and again.
Record when a capped snapshot was taken and treat unlisted files older than that as pre-existing.
* security-guidance: test the metric that shows the capped-snapshot path
preexisting_untracked_excluded stays at the 2,000 cap before this fix and rises above it after, which is how the fix can be confirmed from metrics. No new key.
|
|
* security-guidance: keep secret-shaped files out of reviews
The Stop review covers every dirty file in the work tree, including ones the user changed and Claude never opened. Key files, credential files and encrypted dotfile sources were sent along with the code.
Skip files that are secret stores by naming convention: .env variants, SSH private keys, common credential files, and chezmoi private/encrypted sources.
* security-guidance: report how many secret-shaped files were skipped
The Stop hook now reports secret_shaped_skipped (a count, never names, only when nonzero) so the skip can be confirmed after release and watched for over-matching.
|
|
allowed_tools only pre-approves tools, so the inner Claude Code that runs a
review was still offered the shell, file edits, web access and subagents.
Pass the exact tool list instead: Read, Grep and Glob for the commit
reviewer, none for the single-turn review.
|
|
A commit or push written with a flag that takes no value (git --no-pager
commit), a partly quoted option value (git -c user.name="A B" commit) or
--namespace / --config-env / --attr-source with a separate value was not
recognized by the hook, so it was not reviewed. Commit and push detection
now share one global-option pattern that covers these.
|
|
other hosts
On a host other than Claude Code the SessionStart hook printed an async
declaration line and then a metrics line. A host that reads hook output as
one JSON document with a closed schema rejects that.
In portable mode the hook now skips the async line and prints one object
with only the standard fields. The portable-mode helpers move to _base.py so
both hook scripts share them, and the mode is decided once at start-up.
Output under Claude Code is unchanged.
|
|
UserPromptSubmit listed every untracked file in the worktree and stored the
result in the session state on each prompt, for a snapshot that only the Stop
review reads. With ENABLE_STOP_REVIEW=0 or ENABLE_CODE_SECURITY_REVIEW=0 the
Stop hook skips before reading it, so the listing is now skipped too. The
stash baseline is still captured for the Write pattern filter.
When the review is switched back on, the next prompt takes a fresh snapshot,
including after an interrupted turn whose baseline is kept.
Refs #6612
|
|
claude-security-guidance.md and security-patterns files were only looked
for in ~/.claude, so they were never loaded on installs that keep their
config elsewhere. The directory CLAUDE_CONFIG_DIR names is now read as
well; ~/.claude is still read, so files already placed there keep working.
Fixes #4826
|
|
The state file was rewritten in place, so a hook killed during a save left a truncated file that the next hook read as an empty state: the turn baseline, the touched paths and the shown warnings were gone. Write a temporary file and rename it over the state file. Windows keeps writing in place for now: hooks have no state lock there, and a rename can be refused or make a concurrent read fail.
A state file that cannot be decoded no longer stops the hook. The Stop metrics gain two keys, sent only when nonzero: state_resets (the state file was unreadable and the state started over) and state_overwrites (without a lock, a save replaced one made by another hook since the read).
Refs #1944
|
|
# Conflicts:
# plugins/security-guidance/hooks/security_reminder_hook.py
|
|
telemetry
Review rows gain two diagnostic keys, appended last so they never displace
an existing key:
- gateway_cfg: 1 when ANTHROPIC_BASE_URL names a host other than
api.anthropic.com, 2 when ANTHROPIC_CUSTOM_HEADERS lines are sent, 3 for
both. A number only: no host, header name or value.
- child_stderr: lines the inner CLI wrote to stderr during a commit or
push review.
|
|
hosts
The hooks print metrics and rewakeSummary in their JSON output. A host that validates hook output against a closed schema rejects the whole line, so every Stop and PostToolUse shows a hook error there.
When the host passes PLUGIN_ROOT and does not identify itself as Claude Code, print only the standard fields. Blocking findings and guidance are kept. SECURITY_GUIDANCE_PORTABLE_OUTPUT=1/0 forces it either way. Output under Claude Code is unchanged.
|
|
With no credentials in the hook's environment every Stop, commit and push review is skipped, and nothing told the user. That is the state of a signed-in session started with CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC, DISABLE_TELEMETRY or DO_NOT_TRACK set, where Claude Code does not pass the sign-in to plugin hooks.
Show a notice on an edit in a git repo, at most once a week, naming the setting when one is set. Document where the reviews get credentials, and report no_creds on the skipped reviews.
|
|
security-guidance: parse diff sections by header line
|
|
Claude Code runs every `if`-filtered hook entry when it cannot parse a
Bash command, so the seven commit/push entries started seven processes
on those calls. Use three entries (git commit, git push, gt) and let the
hook's own regex decide what is a commit or a push.
|
|
not fit one command
The Stop review passed every changed path to `git diff` as arguments. With enough of them (an unignored cache, a repo at $HOME) the OS refused to start git, the diff failed twice, and the turn's real edits were never reviewed.
When the OS refuses the argument list, keep only the paths the review can use (reviewable source files) and send them in a few commands under the same time limit. A path list that fits one command is handled exactly as before. Skip review sets of more than 100,000 paths before any diff.
Fixes #4824
|
|
With diff.mnemonicPrefix or diff.noprefix set in the user's git config, diff headers no longer read `a/<path> b/<path>`, the parser matched no file, and the review was skipped with nothing shown. mnemonicPrefix switched off the Stop review; noprefix switched off the commit and push reviews as well.
Pass the default prefix settings on every git call the hook makes.
Fixes #4569
|
|
Commit and push findings went only into
hookSpecificOutput.additionalContext, which Claude Code's asyncRewake path
never reads: it shows Claude stderr, or stdout when stderr is empty. When
the agentic reviewer's inner CLI printed a warning to stderr, Claude got
that warning instead of the findings (anthropics/claude-code#99839, also
anthropics/claude-code#92987).
Findings now go to stderr for every event, as the Stop path already did.
The inner CLI's stderr and the Agent SDK's own log lines go to the
plugin's debug log.
|
|
security-guidance: send ANTHROPIC_CUSTOM_HEADERS on the plugin's own API calls
|
|
security-guidance: never report a failed review as clean
|
|
A file whose header cannot be parsed is left out of the review without a trace. The Stop hook now reports diff_hdr_unparsed (a count, only when nonzero) so a header shape the parser misses shows up in metrics.
|
|
The diff parser split on the text 'diff --git ' anywhere, so a file whose own content contains it was cut short, and the rest of that file was never reviewed. It also dropped files whose names git quotes (a double quote, backslash or control character in the name).
Split only where a line starts with the header, and decode quoted names.
|
|
|
|
When a commit review got no verdict (an API error, an unexpected error in
the call, or a reply that could not be read) it was logged as "no security
issues found" and the commit was marked reviewed, so the push review
skipped it (anthropics/claude-code#99840, also anthropics/claude-code#81057).
- A commit whose review got no verdict is not marked reviewed, so a later
push review from Claude Code still checks it, unless the same command
pushed it. A failed push review does not mark its range either.
- Claude is told once per session for each kind of review and failure.
Later failures of the same kind are only logged.
- In the agentic race, a single-shot fallback with no verdict no longer
wins while the agentic review can still answer, the fallback no longer
starts after the agentic review has answered, and it never runs twice.
- The Stop and SubagentStop reviews use the same signal, so an unreadable
reply no longer records a subagent's diff as reviewed.
|
|
The plugin's own API calls (the /v1/models lookup and the review itself)
never sent ANTHROPIC_CUSTOM_HEADERS, so a gateway that takes its key in a
custom header answered 401 and reviews never ran
(anthropics/claude-code#99857).
The headers are now parsed the way Claude Code parses them (one
`Name: Value` per line, split at the first colon) and sent on every call.
A custom line replaces a header of the same name. anthropic-beta lines are
not forwarded: the review needs none of the user's betas.
|
|
|
|
security-guidance: enable prompt caching for review requests
|
|
|
|
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
Each subagent finish re-reviewed the whole diff since the last prompt, so
a turn with N subagents sent N growing reviews. The end-of-turn review
already covers what subagents changed, so drop the SubagentStop
registration.
|
|
|
|
|
|
Releases before 2.0.10 ran `git stash create` on the real index. When that
git was killed, it left an `index.stash.<pid>` file the size of the index
in the git directory, and nothing removes those: a clone can hold hundreds.
Before it copies the index, the hook now deletes such files once they are
older than 30 minutes. It only touches regular files of the current user
whose name is exactly `index.stash.<digits>`, and never `index.lock`.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QR7edfw5HHkxJvJVgZiWpM
|
|
(2.0.10 → 2.0.11)
In a clone with a very large git index, 2.0.10 could still fill the disk.
It copies the index for each git call that might write it, and a hook that
Claude Code cancels (SIGTERM, then SIGKILL) never reached its cleanup, so
every cancelled hook left index-sized files in the temp directory for up
to 30 minutes. With several agents in one clone the live copies alone
could take many GB.
- A hook told to terminate removes its copies before it exits.
- A copy's name records the hook's pid; the next run deletes copies whose
hook is gone instead of waiting for the age limit.
- Diffs no longer need a copy: diff.autoRefreshIndex is off, so they only
read the index. Only `git stash create` and `git add -N` get one.
- The copy is a hard link where the filesystem allows it.
- Only so many hooks hold a copy at once, fewer as the disk fills. A hook
that gets no slot within 5 s goes without: the baseline falls back to
HEAD, or new untracked files are left out of that review.
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
With a very large git index the hook's git calls hit their time limits and
are killed, so git cannot clean up. Each kill could leave an index-sized
file in the temp directory, index.stash.<pid> files in .git, and a dead
.git/index.lock that fails the user's next git add or commit.
- `git stash create` and the work-tree diff run on a throwaway index copy.
- Every git the hook spawns gets GIT_OPTIONAL_LOCKS=0.
- Copies live in a private per-user folder and are removed together with
the files git writes next to them.
- Leftovers older than 30 minutes are swept, including existing ones.
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
→ 2.0.9)
The review model was hardcoded to claude-opus-4-7, so the plugin fell
behind each time a new Opus shipped.
- The diff review asks the configured endpoint (GET /v1/models) for the
newest Opus it serves, cached for a day; claude-opus-5-5 if it can't say.
- The agentic commit review, and every review on Bedrock, Vertex and
Foundry, use Claude Code's `opus` alias.
- SECURITY_REVIEW_MODEL and SG_AGENTIC_MODEL still pin a model.
- Adds pricing rows for the newer Opus models, and tests.
Co-Authored-By: Claude Code <noreply@anthropic.com>
|
|
mathematics problems (#6322)
Squash merge of 2 commits
|
|
code-modernization: guided workflow with independent proof
|
|
Squash merge of 1 commit
|
|
Usage counts now say what the plugin runs on (system, python status and version, path problems) and which kind of failure happens: a missing or placeholder python, a permission block, a model error, or an error in the plugin's own script. Failures are classified on the machine into a fixed list and only the code is sent, once per kind per session. A session-start ping, once per plugin version, counts machines where nobody gets as far as typing a command. When python cannot run, the shell wrapper reports that itself, and on Windows it falls back to python or the py launcher.
|
|
The plugin now has a version and a changelog. Two hooks record whole-number usage counts (which command ran, how far a system got, how many rules and proofs) through the CLI's own telemetry: counts from 100 up are rounded, nothing is sent when the plugin is not in use, and any of three switches turns it off. The README documents every key and lists what the plugin was tried on, checked against the run files.
|
|
/modernize-review-pane
The pane's bare /modernize-review took the name of the plugin's own review command, so typing the short form in a pane-enabled session opened the pane's cards instead of the pop-up review. The pane's version is now /modernize-review-pane, and /modernize-review always runs the plugin command. Both still write the same review file.
|
|
A rule named only by a skipped or pending test no longer counts as covered. It is listed as "named, not run" and fails the rules check. A test-only folder is listed as tooling and gets no verdict. The verify command tries malformed records only when the person asked for exact behavior, so a proof loop has an end. The report parses rule headings and fields in linear time, and the report and pane show the new status.
|
|
An independent check of a rewritten batch job found differences on two new
inputs of one family (a blank numeric field the rewrite rejects on purpose
and the old program reads as zero). Each input has several output files, so
accepting the deviation meant three or four hand-written entries per input.
A top-level "approvedInputs": {"F23": "reason"} in a cases file now approves
every case that shares that input label. A reason is still required (blank
approves nothing), a case's own reason wins, a missing file is never turned
into a pass, and the result still lists the difference as approved.
|
|
Follow-ups from review of the consolidation pass:
- The agent is a restricted type with the same read-only wording as its
siblings, and every field on its numbered list is a single bounded line, so
a rule name containing a newline cannot fake another entry.
- A group with any number out of range or not an integer is rejected whole
instead of being coerced into a different merge.
- A merge keeps the most conservative review state: the highest priority, the
lowest confidence, and every suspected defect and SME question of the folded
rules.
- Every folded rule is returned with the rule it went into, and the rules
document lists them under "Rules folded into another", so nothing disappears
untraceably. Extra citations show as "Also cited" without the joining word.
|
|
Three ways a same-technology uplift could come out PROVEN too easily:
- The baseline came from a table someone typed. It now counts as measured
only when the script can read per-test results (JUnit or TRX XML, a runner
log with a summary line, or per-test JSON) from analysis/<system>/baseline/
or a "Recorded:" line of BASELINE.md; a counts-only file is ignored, two
measured sources that disagree are a gap, and the typed table must match
what was measured.
- Tests edited during the uplift passed unnoticed. The pack now compares the
legacy and working-copy test files (by walking files only) and lists what
was added, removed or changed; a removed file, more than a quarter of the
files changed, or no legacy tests to compare with is a gap, and it says
plainly that weakened assertions cannot be detected.
- A silent behavioral change with no test at its site. Each Behavioral-silent
delta in the catalog must have a test file naming its site file, or the
module is at most PARTLY PROVEN.
The report's Proof section shows the three new checks, and an uplift pack that
lacks any of them reads as PARTLY PROVEN. 214 script tests pass.
|
|
A numeric library implemented in C, in a C++ header and in a fixed-point
variant produced three "twiddle factor" rules, two "generic butterfly" rules
and two "factorization" rules, because the referee's duplicate key is the
file plus the rule's name. The plan and the review then carry noise.
After verification, one small agent per 150 rules lists the groups that
describe the same behavior implemented in more than one place, told to merge
only what would be implemented and tested as one thing. The kept rule cites
every place (the renderer shows them as "Also cited") and takes the highest
priority of its group; overlapping, out-of-range or self-merging groups are
ignored, and the rule list is fenced as untrusted data. The count is
reported as stats.consolidated.
|