summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/hooks/security_reminder_hook.py
AgeCommit message (Collapse)Author
2026-11-09Merge pull request #7032 from anthropics/mhegazy/sg-refused-verdict-countMohamed Hegazy
security-guidance: count reviewer verdicts the CLI refused
2026-11-09Merge pull request #7031 from anthropics/mhegazy/sg-credential-routingMohamed Hegazy
security-guidance: send a claude.ai token as a bearer, hold back a gateway's
2026-11-09Merge mainMohamed Hegazy
Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-09Merge pull request #7033 from anthropics/mhegazy/sg-unseen-commit-countMohamed Hegazy
security-guidance: count commits that no commit hook saw
2026-11-09Merge pull request #6838 from anthropics/mhegazy/sg-stop-finding-names-unwrittenMohamed Hegazy
security-guidance: say when a Stop finding is in a file the session has no record of editing
2026-11-07security-guidance: keep an incomplete edit record incomplete for the whole turnmhegazy/sg-stop-finding-names-unwrittenMohamed Hegazy
A record lost before one Stop was treated as whole by the next, and a prompt that was never stored as having no edits, so the note could name the session's own file. File names in the note are quoted as JSON. Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-07security-guidance: count reviewer verdicts the CLI refusedmhegazy/sg-refused-verdict-countMohamed Hegazy
Measure only, for #5746: one key on the commit and push review row when the reviewer's verdict was refused, and how many were wrapped in their own key. Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-07security-guidance: send a claude.ai token as a bearer, hold back a gateway'smhegazy/sg-credential-routingMohamed Hegazy
A claude.ai token that arrives as ANTHROPIC_API_KEY (from an apiKeyHelper) is refused by the API as a key; send it as a bearer. On hosts other than Claude Code, a bearer that is not a claude.ai token is not sent without a base URL. Other hosts' base URLs and cloud providers are left alone. Fixes #6955 Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-07security-guidance: count commits that no commit hook sawmhegazy/sg-unseen-commit-countMohamed Hegazy
A commit review starts from a hook on the Bash tool, so a commit made any other way starts none. The Stop row now carries turn_commits: how many commits the turn made, how many have no review, and how many of those no commit hook saw. Count only; what is reviewed does not change, and no hook entry is added. Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-07security-guidance: count how custom rules are writtenMohamed Hegazy
Measure only: path globs a wider reading would change, refused and counted repeats in regexes, and the slowest custom regex, on the Stop row. Which rules apply does not change. Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-06Merge remote-tracking branch 'origin/main' into ↵Claude
mhegazy/sg-stop-finding-names-unwritten # Conflicts: # plugins/security-guidance/hooks/security_reminder_hook.py
2026-11-05Merge main into mhegazy/sg-net-err-on-verdictmhegazy/sg-net-err-on-verdictClaude
Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-05Merge pull request #6965 from anthropics/mhegazy/sg-agentic-stop-on-authMohamed Hegazy
security-guidance: stop the commit reviewer on refused credentials, end hung reviews in time
2026-11-05Merge pull request #6998 from anthropics/mhegazy/sg-count-unmatched-bash-startsMohamed Hegazy
security-guidance: count Bash hook starts that match no commit or push
2026-11-05Merge pull request #6922 from anthropics/mhegazy/sg-prompt-snapshotMohamed Hegazy
security-guidance: take the turn baseline without git stash create
2026-11-05Merge pull request #6919 from anthropics/mhegazy/sg-add-failure-fixMohamed Hegazy
security-guidance: keep new files in the Stop review when git add -N fails
2026-11-05Merge pull request #6930 from anthropics/fix/sg-blank-base-urlMohamed Hegazy
security-guidance: treat a blank ANTHROPIC_BASE_URL as unset
2026-11-05Merge pull request #6918 from anthropics/mhegazy/sg-launcher-alias-real-pathMohamed Hegazy
security-guidance: stop starting the packaged Python alias on every hook
2026-11-04security-guidance: name new files the Stop review could not seeMohamed Hegazy
When git add -N fails on both tries or times out, wake Claude once per set of files with their names, so the review no longer ends as "no changes". A timed-out add now keeps the tracked files' diff, so a timeout on every turn cannot stop their reviews. Private object directory cleanup no longer chmods through a link. Fixes #6996 Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-04security-guidance: end a commit or push review's single-shot review at the ↵mhegazy/sg-agentic-stop-on-authMohamed Hegazy
hook's time limit A single-shot review that follows a fast agentic failure, or runs with the agentic review off, had no deadline: with no answer it ran 739 s, past Claude Code's 600 s kill, so the session heard nothing. It now ends at 570 s into the hook with the usual notice. The limit counts from hook start, so a push review's wait and the work before the review count. Failed push rows keep inflight_wait_s, and CLAUDE_CODE_REMOTE is read the same way in both places. Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-04security-guidance: keep the state folder to its usermhegazy/sg-state-dir-owner-onlyMohamed Hegazy
Create ~/.claude/security with mode 0700 from every place that makes it, and narrow the default folder on the next run, so a umask such as 002 does not leave the reviewer's venv group-writable. The in-place state write replaces a link instead of following it, and creates a 0600 file. Co-authored-by: mhegazy <mhegazy@anthropic.com>
2026-11-04security-guidance: count Bash hook starts that match no commit or pushClaude
Measurement only. One Bash call in ten that starts the hook without a commit or push reports bash_no_match, and precheck_skip when a plain text check on the hook input could have told so before Python started. precheck_miss marks a reviewed command that such a check would have dropped. Nothing is skipped and no review changes.
2026-11-04security-guidance: clear net_err when a review gets throughMohamed Hegazy
A failed first probe, a lost race fallback or a failed dual leg left its class (and api_error) on the row of a review that got a verdict.
2026-11-04security-guidance: count a push review's wait against the hook's time limitMohamed Hegazy
2026-10-31security-guidance: stop the commit reviewer on refused credentials, end hung ↵Mohamed Hegazy
reviews in time
2026-10-28security-guidance: treat a blank ANTHROPIC_BASE_URL as unsetfix/sg-blank-base-urlMohamed Hegazy
A set but empty value left the request URL as /v1/messages, so urllib raised and every Stop, push and single-shot commit review failed. The SDK and Claude Code read a blank value as the default endpoint; the plugin now does too.
2026-10-27security-guidance: take the turn baseline without git stash createmhegazy/sg-prompt-snapshotMohamed Hegazy
stash create checks the work tree on one thread. add -u into the throwaway index copy, write-tree and commit-tree produce the same commit and use git's index preload instead, which matters where each file status is slow. See #6854.
2026-10-27security-guidance: keep new files in the Stop review when git add -N failsMohamed Hegazy
Retry the add with a private object directory for users who cannot write the object store. Drop the pathspec settings git refuses alongside literal pathspecs, which hid new files since 2.0.16. When a failure stays and nothing is reviewed, keep the files for a later turn.
2026-10-27security-guidance: stop starting the packaged Python alias on every hookmhegazy/sg-launcher-alias-real-pathmhegazy
On Windows with the Python Install Manager, python, python3 and py are packaged aliases under ...\Microsoft\WindowsApps, and each start of one makes Windows run an App Installer update check for the package. The launcher started the chosen alias twice per hook (probe, then the hook), on every Edit, prompt and Stop. See anthropics/claude-code#98929. When the name that answers is such an alias and its interpreter is a regular python*.exe elsewhere, the launcher now checks that interpreter once (same version, reads the hook script when started by itself), runs the hook with it, and keeps its path in the state folder for a day. Later hooks start it directly: one process, none through the alias. The remembered path is used only while PATH and the hook folder are unchanged and the file is still there. A hook that fails on it empties the entry so the next hook searches again. Not used while VIRTUAL_ENV is set. Other systems, regular installs and Microsoft Store Python are unchanged. Hooks report launcher_direct (1 remembered, 2 just checked) as the last metric key on rows they already send.
2026-10-26Merge remote-tracking branch 'origin/main' into HEADmhegazy/sg-reviewer-stage-metricsClaude
2026-10-26Merge pull request #6861 from anthropics/mhegazy/sg-add-fail-metricMohamed Hegazy
security-guidance: count failed git add -N calls in the Stop review
2026-10-26Merge pull request #6839 from anthropics/mhegazy/sg-network-failure-classMohamed Hegazy
security-guidance: report why a review call got no HTTP response
2026-10-26Merge pull request #6836 from anthropics/mhegazy/sg-diff-seen-countMohamed Hegazy
security-guidance: count reviews of a diff that was already reviewed
2026-10-26security-guidance: report how many turns and how much model time a commit ↵Mohamed Hegazy
review took review_ms says how long an agentic commit review took but not why. Add one count-only key, rv_effort, on rows where the agentic reviewer ran: the turns it took and the time it spent waiting on the model, summed over all stages and packed as turns * 10,000,000 + model ms. It is emitted after every other key, so it never displaces one at the metric key cap. No behaviour change.
2026-10-23security-guidance: count failed git add -N calls in the Stop reviewmhegazy/sg-add-fail-metricMohamed Hegazy
A failed add leaves new files out of the diff with no sign of it. Measure only; behaviour is unchanged.
2026-10-22security-guidance: report where a slow prompt's time goesmhegazy/sg-prompt-capture-timeMohamed Hegazy
Prompts that wait a second or more in the UserPromptSubmit hook send one metrics row: total, baseline and untracked listing time, index size, and whether the repository is on a Windows drive under WSL. Measures only; capture is unchanged. See #6854.
2026-10-22Merge branch 'main' into mhegazy/sg-diff-seen-countmhegazy/sg-diff-seen-countMohamed Hegazy
Keeps both sides in emit_metrics: diff_seen stays after the other review tail keys, and the launcher probe keys stay after everything else.
2026-10-22Merge branch 'main' into mhegazy/sg-network-failure-classMohamed Hegazy
2026-10-21security-guidance: reviews run when the Windows certificate store has an ↵Claude
unreadable entry Older Python releases load each Windows certificate store in one call, so one certificate OpenSSL cannot parse makes the default TLS context fail to build and every review call fails before a request is sent. When that happens the plugin's API calls now use a default context built from the store entries that do parse. Verification of the chain and the host name is unchanged. Review rows carry tls_store_skipped (a count) when this route is in use.
2026-10-20Merge pull request #6591 from anthropics/mhegazy/sg-stop-pathspecMohamed Hegazy
security-guidance: keep the Stop review working when the changed paths do not fit one command
2026-10-20Merge pull request #6626 from anthropics/mhegazy/sg-pattern-fired-telemetryMohamed Hegazy
security-guidance: report which pattern rules fired on every Stop row
2026-10-20security-guidance: report why a review call got no HTTP responseMohamed Hegazy
A review call that never gets an HTTP response is reported as api_error -1 whatever the cause, so a certificate failure, a refused connection and a timeout look the same. Rows whose last call failed that way now carry a count-only net_err key: the failure class, the TLS verify code, and whether CA files, a proxy or TLS variables are in play. No behaviour change.
2026-10-20security-guidance: say when a Stop finding is in a file the session has no ↵Mohamed Hegazy
record of editing The Stop review takes its files from git, so it can report a finding in a file another session or process changed in the same checkout, or in earlier uncommitted work when no turn-start snapshot could be taken. The finding then read as an instruction to fix code the session did not write. A finding in a reviewed file with no record of the session's edit tools writing it since the prompt now carries a note naming the file: the change may have been made another way, leave it and tell the user if it is not yours, handle it as usual if it is. What gets reviewed is unchanged. The note is left out when the record is known to be incomplete (state file lost or overwritten, or more edited paths than the list keeps). Stop rows with findings carry finding_no_edit_record: the number of such findings, or -1 when the record was incomplete. Refs #4524
2026-10-20security-guidance: count reviews of a diff that was already reviewedMohamed Hegazy
A change that comes back under a new commit (undo and re-commit, rebase before the first push) is unknown to the reviewed-shas record, so the commit or push review runs on it again. Nothing says how often. Each commit and push review now notes a hash of every hunk it is sent in .git/sg-reviewed-diffs, once when it starts and once when it has a verdict, and reports one new metric, diff_seen: 0 some hunk was never reviewed in this clone 1 all were seen, but a review of one has no verdict (yet) 2 all had a finished review, on different repo contents 3 all had a finished review, on the same tree -1 the record could not be read or written Count only: no review is skipped, delayed or changed. The record is bounded (1 MB, 7 days), is not written in portable output mode, and its lock is never waited on for more than half a second.
2026-10-20Merge branch 'main' into mhegazy/sg-stop-pathspecMohamed Hegazy
The batched path commands now read each diff through the bounded reader that main added, so both changes apply to get_git_diff.
2026-10-20security-guidance: test the mask order, not that the masks come lastmhegazy/sg-pattern-fired-telemetryMohamed Hegazy
Other tail metrics are now added after the two warning masks, so the masks are no longer the last keys on the Stop row. What matters is that the fired mask comes after the unresolved one, so a row cut at the key cap loses the fired mask first. Test that, and say so in the comment.
2026-10-20Merge branch 'main' into mhegazy/sg-pattern-fired-telemetryMohamed Hegazy
2026-10-20Merge branch 'main' into mhegazy/sg-launcher-probe-timingmhegazy/sg-launcher-probe-timingClaude
2026-10-20Merge branch 'main' into mhegazy/sg-sdk-bootstrap-switchesmhegazy/sg-sdk-bootstrap-switchesClaude
2026-10-20Merge pull request #6808 from anthropics/mhegazy/sg-secret-named-telemetryMohamed Hegazy
security-guidance: count secret-named data files in the Stop review set