summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/hooks
AgeCommit message (Collapse)Author
2026-11-03security-guidance: pause for an hour after an SDK install times outMohamed Hegazy
A pip install that runs out of time (a connection too slow to fetch the SDK wheel inside the 120s limit) was retried at every SessionStart and every 5 minutes from the tool hooks, downloading most of the wheel each time. A pip timeout now starts a one-hour cooldown, in the venv build and in the --target fallback. A timeout while creating the venv does not. The skipped runs report the existing SKIP_COOLDOWN outcome, with sdk_timeout_cooldown set so they can be told from signal-kill cooldowns. Refs #6979
2026-11-03security-guidance: keep pip's downloads out of the system temp dirMohamed Hegazy
pip keeps each wheel it downloads in a pip-unpack-* folder under the temp dir and removes it only on a normal exit. The SDK bootstrap kills pip at its 120s timeout, so on a slow connection every attempt left its download in the system temp dir, and attempts repeat while the SDK is missing. Both pip installs (venv and --target fallback) now run with a temp folder of their own under the plugin's state dir. It is removed when the attempt ends, however it ends. A folder left by a bootstrap that was itself killed is removed by a later bootstrap run. Refs #6979
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-27Merge branch 'main' into mhegazy/sg-review-sessions-not-savedmhegazy/sg-review-sessions-not-savedMohamed Hegazy
2026-10-27security-guidance: keep the token where the OAuth variable does not fitMohamed Hegazy
A custom base URL, bare mode and cloud sessions keep ANTHROPIC_AUTH_TOKEN.
2026-10-27security-guidance: hand the reviewer a claude.ai token as its OAuth tokenMohamed Hegazy
As ANTHROPIC_AUTH_TOKEN the inner CLI still renews a stored login it does not run on, which can sign the user out. As CLAUDE_CODE_OAUTH_TOKEN it leaves the stored login alone. Cache writes stay at five minutes.
2026-10-27security-guidance: count Windows sessions whose Python is behind a linkmhegazy
Measurement only. On Windows the SessionStart row gains one key, interp_reparse, saying whether the interpreter that runs the hooks is reached through a symbolic link or junction: 1 executable path, 2 standard library path, 4 that path is under AppData, 8 could not be checked; 0 when neither is. Inside the packaged Claude Desktop app Windows leaks kernel memory on every file opened through such a link under AppData (a uv-managed Python is one), and every hook starts an interpreter. This sizes how many users that is. See anthropics/claude-code#96870. No process is started, no hook behaves differently, and no other row changes. The key is the last one of its row, so it never displaces another.
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-27Merge remote-tracking branch 'origin/main' into mhegazy/sg-secret-rename-pairingmhegazy/sg-secret-rename-pairingMohamed Hegazy
# Conflicts: # plugins/security-guidance/hooks/diffstate.py
2026-10-26Merge pull request #6875 from anthropics/mhegazy/sg-inflight-windows-lockMohamed Hegazy
security-guidance: hold in-flight review markers on native Windows too
2026-10-26Merge remote-tracking branch 'origin/main' into HEADmhegazy/sg-inflight-windows-lockClaude
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: hold in-flight review markers on native Windows tooMohamed Hegazy
A commit or push review marks the commits it is reviewing by holding a lock on .git/sg-inflight-<sha>, so a push made meanwhile waits for that review instead of reviewing the same commit again. The lock was flock only. Native Windows Python has no fcntl, so there were no markers there and a push right after a commit still ran a second full review. On Windows the same shared/exclusive, never-waiting lock is now taken with LockFileEx, on a byte far past the end of the empty marker so that reading or copying the file is never refused. Windows will not delete an open file, so a marker is closed before it is deleted there, with a short retry while another review has it open; what cannot be deleted is left unlocked and swept once old, as before. Also: one marker that cannot be opened, or whose last holder deletes it between this review's open and lock, no longer costs the review its claim on the remaining commits. The in-flight tests no longer require fcntl, so they run on Windows.
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-review-sessions-not-savedMohamed Hegazy
2026-10-22Merge remote-tracking branch 'origin/main' into mhegazy/sg-secret-rename-pairingMohamed Hegazy
2026-10-22Merge branch 'main' into mhegazy/sg-network-failure-classMohamed Hegazy
2026-10-21Merge pull request #6849 from anthropics/mhegazy/sg-unreadable-store-certMohamed Hegazy
security-guidance: reviews run when the Windows certificate store has an unreadable entry
2026-10-21Merge pull request #6837 from anthropics/mhegazy/sg-index-copy-gitlinksMohamed Hegazy
security-guidance: keep nested repositories out of the index copy
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 #6604 from anthropics/mhegazy/sg-baseline-subdirMohamed Hegazy
security-guidance: find a rewritten file's earlier version from a repo subdirectory
2026-10-21Merge branch 'main' into mhegazy/sg-index-copy-gitlinksClaude
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-20Merge pull request #6629 from anthropics/mhegazy/sg-launcher-probe-timingMohamed Hegazy
security-guidance: report how long the launcher waits for interpreter probes
2026-10-20security-guidance: find the earlier version of a file reached through a ↵mhegazy/sg-baseline-subdirMohamed Hegazy
symlinked folder When the tool's path and the session directory name the same repo through different symlinks (/tmp and /var on macOS), the relative path between the two spellings left the repo and the lookup found nothing, so a rewrite re-reported code that was already in the file. The lookup now tries again with both paths resolved. The first attempt is unchanged.
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-20Merge remote-tracking branch 'origin/main' into ↵Claude
mhegazy/sg-stop-finding-names-unwritten
2026-10-20security-guidance: match edited paths when the repo folder is spelled in ↵Mohamed Hegazy
another case On file systems that ignore case, realpath keeps the case a path was given in, so an edit recorded as /TMP/x/REPO/app.py for a repo at /tmp/x/repo was counted as outside the repo. Fold case (and, on macOS, normalize) the whole path and the root before taking the relative path, not only the result.
2026-10-20Merge branch 'main' into mhegazy/sg-baseline-subdirMohamed Hegazy
2026-10-20Merge pull request #6722 from anthropics/mhegazy/sg-patterns-file-shapeMohamed Hegazy
security-guidance: skip an unusable security-patterns file on its own
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: keep nested repositories out of the index copyClaude
The hooks run `git stash create` (the turn baseline) and `git add --intent-to-add` (untracked files) on a throwaway copy of the index. A nested repository that the index records is a gitlink entry there. `git stash create` takes no --ignore-submodules option and `git add` reads the gitlinks its paths cover, so both started a second git inside that directory. Before anything runs on the copy, remove the gitlink entry of every nested repository from the copy, never from the real index. If that removal fails, do not use the copy at all: the baseline falls back to HEAD and runs no stash create, and the diff reads the real index with --ignore-submodules=all. A gitlink whose directory has no `.git` (a submodule that is not checked out) stays; git starts nothing there. Run the intent-to-add `git add` with literal pathspecs, in that one call's environment only. The index file is scanned for a gitlink's mode bytes first, so a repository without one starts no extra git process.
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-20security-guidance: count Stop reviews that kept a secret-shaped old nameMohamed Hegazy
secret_renamed is sent only when it is not zero.
2026-10-20security-guidance: keep a renamed file paired with its old name in the Stop ↵Mohamed Hegazy
review The Stop review limits its diff to the changed paths. For a rename that git already knows about (git mv, or a rename committed during the turn) that list held only the new name, so the diff showed a new file and the parsers could not apply the rule that leaves out a file renamed away from a secret-shaped name. The old name now goes into the list beside the new one, as it already did for a plain mv. The file listings themselves are unchanged.
2026-10-20Merge branch 'main' into mhegazy/sg-review-sessions-not-savedMohamed Hegazy
The inner CLI retry on main (a start refused over --strict-mcp-config) now also covers a CLI that does not know --no-session-persistence, so one helper handles either refused flag, or both on the same start.
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