summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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
2026-10-20Merge pull request #6630 from anthropics/mhegazy/sg-bump-2.0.15Mohamed Hegazy
security-guidance: bump version to 2.0.15
2026-10-20Merge pull request #6608 from anthropics/mhegazy/sg-sdk-bootstrap-switchesMohamed Hegazy
security-guidance: do not install the agent SDK for reviews that are off; rebuild an emptied install
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
2026-10-20Merge pull request #6807 from anthropics/mhegazy/sg-stop-diff-memoryMohamed Hegazy
security-guidance: read the Stop review's git diff without holding it whole
2026-10-20Merge pull request #6628 from anthropics/mhegazy/sg-stop-scope-telemetryMohamed Hegazy
security-guidance: report how Stop reviews relate to the session's own edits
2026-10-20Merge pull request #6811 from anthropics/mhegazy/sg-gateway-loginMohamed Hegazy
security-guidance: review through Claude Code in a Claude apps gateway sign-in
2026-10-20Merge branch 'mhegazy/sg-gateway-login' into mhegazy/sg-sdk-bootstrap-switchesClaude
Resolves the overlap with the bootstrap working-directory change and the gateway sign-in route: the import probe keeps the state-dir working directory, and llm.py keeps both imports.
2026-10-20Merge branch 'main' into mhegazy/sg-stop-scope-telemetrymhegazy/sg-stop-scope-telemetryClaude
Resolves the overlap with the baseline-origin change in security_reminder_hook.py: both sets of state keys are stored beside the baseline.
2026-10-20Merge branch 'main' into mhegazy/sg-gateway-loginmhegazy/sg-gateway-loginClaude
2026-10-20Merge pull request #6721 from anthropics/mhegazy/sg-claude-code-credential-filesMohamed Hegazy
security-guidance: keep Claude Code's own credential files out of reviews
2026-10-20Merge pull request #6812 from anthropics/mhegazy/sg-bootstrap-spawn-cwdMohamed Hegazy
security-guidance: run SDK bootstrap subprocesses from the state dir
2026-10-20Merge pull request #6810 from anthropics/mhegazy/sg-stop-baseline-checkoutMohamed Hegazy
security-guidance: do not review against a baseline from another checkout
2026-10-20Merge pull request #6809 from anthropics/mhegazy/sg-reviewer-managed-mcpMohamed Hegazy
security-guidance: run reviews on machines with a managed MCP config
2026-10-20Merge pull request #6562 from anthropics/bump/stripeDen
bump(stripe): 97b21648 → deae744b
2026-10-20Merge main into mhegazy/sg-stop-diff-memorymhegazy/sg-stop-diff-memoryMohamed Hegazy
Conflict in get_git_diff: main added IGNORE_SUBMODULES to the diff command on the line where this branch resets its read counters. Both are kept.
2026-10-20bump(aws-startup-advisor): 613dc216 → b310d1c4 (#6832)github-actions[bot]
2026-10-19security-guidance: let the tests that start a stand-in claude run on Windowsmhegazy/sg-gateway-login-wintestMohamed Hegazy
The tests' stand-ins for claude were files with a #! line, which Windows cannot start, so the gateway sign-in tests and the inner-CLI warning test failed there. On Windows a stand-in is now an .exe built the way pip builds a console script, and the gateway one writes its call log as UTF-8. Two tests that move the home directory also set USERPROFILE, and the one test that needs the Agent SDK without saying so is skipped without it.
2026-10-19Merge pull request #6813 from anthropics/mhegazy/sg-nested-reposMohamed Hegazy
security-guidance: stay out of repositories nested in the work tree
2026-10-19security-guidance: let the lone-surrogate path test pass on WindowsMohamed Hegazy
Windows file names can hold a lone surrogate, so the path the test uses as unreadable is an ordinary file in the repo there and the Stop row carries review_scope. Elsewhere the path cannot be encoded and the key is left out, as before.
2026-10-19Merge pull request #6607 from anthropics/mhegazy/sg-launcher-newer-pythonMohamed Hegazy
security-guidance: find Python releases newer than the launcher's list
2026-10-19security-guidance: stay out of repositories nested in the work treemhegazy/sg-nested-reposClaude
A directory with its own .git inside the work tree (a submodule, a vendored checkout, an unpacked archive) was added to the throwaway index as a submodule entry, and git then started a second git inside it to see whether it had changed. Nothing in such a directory is reviewed. git status and work-tree git diff now ignore submodule entries, an untracked nested repository is no longer listed as a changed file or added to the index copy, and a commit that moves a submodule is always shown as its two commit ids.
2026-10-19Merge remote-tracking branch 'origin/main' into mhegazy/sg-gateway-loginClaude
# Conflicts: # plugins/security-guidance/README.md # plugins/security-guidance/hooks/security_reminder_hook.py # plugins/security-guidance/tests/test_no_credentials_notice.py
2026-10-19Merge pull request #6755 from anthropics/mhegazy/sg-notebook-edit-patternsMohamed Hegazy
security-guidance: run pattern checks on NotebookEdit cells
2026-10-19Merge pull request #6546 from anthropics/mhegazy/sg-no-credentials-noticeOctavian Guzu
security-guidance: say when the LLM reviews can't run
2026-10-19security-guidance: run SDK bootstrap subprocesses from the state dirmhegazy/sg-bootstrap-spawn-cwdMohamed Hegazy
`python -c` and `python -m` put the working directory first on the import path, and hooks run in the user's repository. A repository file named claude_agent_sdk.py, venv.py or pip.py was imported in place of the real module by the SessionStart check and the venv build. Run those subprocesses from the plugin's state dir, and make state_dir() return an absolute path as its docstring says, so a relative override isn't resolved twice.
2026-10-19security-guidance: keep a turn's review when the gateway sign-in check gives ↵Mohamed Hegazy
no answer When `claude auth status` gives no usable answer, the Stop hook skipped the review and dropped the turn's changes, so they were never reviewed even once the check answered. They are now kept for the next Stop review, as for other transient skips. A gateway review that runs out of time is no longer tried again on Sonnet: what makes it do so (a rejected sign-in, an unreachable gateway) does not depend on the model, and the second attempt doubled the wait. The timeout's log line now says which API statuses the CLI retried, and includes the CLI's stderr. The new tests no longer share one state file across sessions when run inside a remote session.
2026-10-19security-guidance: review through Claude Code in a Claude apps gateway sign-inMohamed Hegazy
In a Claude Code session signed in to a Claude apps gateway with /login, Claude Code gives plugin hooks no credential, so the Stop, commit, push and agentic commit reviews were all skipped. When the plugin has no credential of its own, it now asks the user's installed claude (`claude auth status --json`) whether the session is signed in to a gateway. A yes or no is kept for the session; when the CLI gives no usable answer, the next hook asks again. If apiProvider is "gateway" and loggedIn is true, the reviews run through that same CLI, which restores the stored sign-in by itself, so no credential enters the plugin. A review the CLI cannot complete counts as a failed review, never a clean one. The reviews run even with CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC set, as they do on Bedrock and Vertex: the gateway docs suggest setting it, and the review goes through the gateway like the session's own requests. The CLI is found the way the agentic reviewer already finds it: SG_AGENTIC_CLI_PATH, CLAUDE_CODE_EXECPATH, then fixed install paths, with no PATH search, and it must be a full path. The reviews use Claude Code's opus and sonnet aliases, which resolve to the ids Claude Code itself uses on a gateway, and get the 120 s a direct review gets. Review rows set bit 4 of gateway_cfg, so this route's failure rate can be read apart from first-party reviews. Every Claude Code the plugin starts for a review, on any provider, now runs with SECURITY_GUIDANCE_DISABLE=1. If policy settings enable the plugin inside that CLI, its hooks there don't start reviews of their own. The weekly notice that the reviews are not running is no longer shown in a session signed in to a gateway, since the reviews do run there. The edit that would show it asks claude first, and the notice marker is written either way, so that edit waits for claude at most once a week. Sessions the gateway route cannot review still get the notice, unless, in the past week, an edit's check found a session signed in to a gateway. Their skipped reviews still report no_creds.
2026-10-19security-guidance: keep added lines past the cut, hold the diff timeoutMohamed Hegazy
A reviewable file past the per-file cap now keeps as much again of its added lines, so a rewritten large file still shows what is new, and its diff ends with a line saying it was cut. The read runs on a thread so the 30 s limit holds while a process git started keeps the pipe open; a read that breaks is an error instead of a short diff. SG_MAX_FILE_DIFF_BYTES of zero or less means the default. The parser and the reader share one test for which files are reviewed.
2026-10-19security-guidance: do not review against a baseline from another checkoutmhegazy/sg-stop-baseline-checkoutMohamed Hegazy
The turn baseline (stash SHA, HEAD, untracked snapshot) is kept per session, and the Stop review used it in whatever checkout the turn ended in. After the session entered another worktree, that worktree's older commits looked like commits made this turn and its files were diffed against the first checkout's, so code committed long before was reviewed and reported again (anthropics/claude-code#102567). The prompt hook now stores the repo root and the prompt time beside the baseline. When the Stop review runs in a different checkout it leaves the baseline out and uses what that checkout can say for itself: its own HEAD when the turn began (from its reflog) for the commit range, HEAD for file contents, and file times to leave out uncommitted files last written before the turn. A baseline taken after a finding records the checkout it was taken in. A prompt in a folder that is not a repo no longer replaces the untracked snapshot of the kept baseline with an empty one, which made every untracked file in the repo look new at the next Stop. Stop rows carry `bl_origin`: 0 same checkout, 1 another worktree, 2 another repository, 3 a folder that is gone, 4 no baseline; plus 10 or 20 when the baseline is an earlier turn's.
2026-10-19Merge branch 'mhegazy/sg-reviewer-managed-mcp' into mhegazy/sg-gateway-loginClaude
2026-10-19Merge remote-tracking branch 'origin/mhegazy/sg-no-credentials-notice' into ↵Claude
mhegazy/sg-gateway-login
2026-10-19security-guidance: run reviews on machines with a managed MCP configmhegazy/sg-reviewer-managed-mcpMohamed Hegazy
Since 2.0.14 the plugin starts the reviewing Claude Code with --strict-mcp-config. Claude Code exits at startup with that flag on a machine whose administrator delivers the MCP servers (managed-mcp.json), so the agentic commit review always fell back to the single-shot review, and reviews that only run through Claude Code (Bedrock, Vertex) failed. When the inner CLI refuses the flag, the plugin now starts it once more without it, and leaves it out for the rest of the hook process. Those starts deny every MCP tool (--disallowedTools "mcp__*") instead, so the reviewer still gets only its read tools. Review rows from such a process carry strict_mcp_off: 1.
2026-10-19security-guidance: count secret-named data files in the Stop review setmhegazy/sg-secret-named-telemetryMohamed Hegazy
Data files named like secrets.yml or client_secret.json are reviewed like any other file. The Stop hook now reports how many are in its review set, as a count only (secret_named_reviewed, emitted when nonzero), so the share of reviews that include one can be read from telemetry. No change to what is reviewed. Refs anthropics/claude-code#96276
2026-10-19security-guidance: rebuild an agent SDK install whose package directory was ↵Mohamed Hegazy
emptied The bootstrap called a venv healthy when `import claude_agent_sdk` succeeded. Python imports an empty directory as a namespace package, so an install that had lost its files passed, the reviewer's `from claude_agent_sdk import ...` failed on every commit, and the agentic review fell back until the venv was deleted by hand. The probe now also requires the package to have a __file__, for the venv and for the --target fallback. A venv that fails it takes the rebuild path that was already there. sdk_venv_emptied counts the sessions that found the venv in that state.
2026-10-19security-guidance: do not install the agent SDK for reviews that are offMohamed Hegazy
The SessionStart bootstrap and its PostToolUse rescue built a venv of a few hundred MB for the agent SDK whatever the environment said, including under SECURITY_GUIDANCE_DISABLE=1, and the rescue started the bootstrap again every five minutes on machines whose SDK lives in that venv (#5331). - Nothing is installed when the environment turns off every review that loads the SDK: the kill switch, ENABLE_CODE_SECURITY_REVIEW=0, or ENABLE_STOP_REVIEW=0 with ENABLE_COMMIT_REVIEW=0. Reported as sdk_bootstrap 10. A disabled plugin also no longer shows the "reviewer unavailable" notice on a Python below 3.10. - The rescue leaves a finished install under the state dir alone instead of starting the bootstrap for it every five minutes. - New counts on the bootstrap's metrics row, set only when true and only when the install exists: sdk_no_creds and sdk_no_git (the session cannot run the reviews the install serves), sdk_venv_py (the venv was built by another Python version than the one running the hooks, #5706). They size follow-up changes; no behaviour depends on them. With the reviews on, what is built and when is unchanged.
2026-10-19security-guidance: do not save review runs as session transcriptsMohamed Hegazy
The agentic commit reviewer and reviews on 3rd-party providers run an inner Claude Code through the Agent SDK, which saved each run as a session transcript holding the review prompt and diff. Start it with --no-session-persistence; SECURITY_GUIDANCE_PERSIST_SESSIONS=1 keeps the transcripts. An inner CLI that predates the flag is run again without it.
2026-10-19security-guidance: say when the LLM reviews can't runmhegazy/sg-no-credentials-noticeMohamed Hegazy
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.
2026-10-19security-guidance: report how Stop reviews relate to the session's own editsMohamed Hegazy
The Stop review takes its file list from git state, so it can cover files the session's edit tools never wrote. Add one count-only metric, review_scope, to Stop rows: whether the edit-tool paths lie inside the reviewed repo, how many reviewed files no edit tool wrote, and whether the turn-start snapshot was a real one. No change to what is reviewed. Refs #4524