summaryrefslogtreecommitdiff
path: root/plugins
AgeCommit message (Collapse)Author
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-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 pull request #6755 from anthropics/mhegazy/sg-notebook-edit-patternsMohamed Hegazy
security-guidance: run pattern checks on NotebookEdit cells
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: find Python releases newer than the launcher's listmhegazy/sg-launcher-newer-pythonMohamed Hegazy
sg-python.sh prefers the versioned names python3.13 to python3.10, then python3 / python / py -3 when they are 3.10 or newer. A machine whose `python3` is older (stock macOS: 3.9) and whose only newer interpreter is python3.14 ended up on 3.9, which cannot load the agent SDK, so the commit reviewer was off with no sign that an installed Python had been missed (#4907, #5024). - When none of the existing candidates is 3.10 or newer, try python3.14 to python3.19, oldest first, before settling for an older Python. - An interpreter that is picked today is still picked: the newer names are only reached where the launcher used to fall back to a Python below 3.10 or find none. Names not on PATH cost no process.
2026-10-17security-guidance: run pattern checks on NotebookEdit cellsmhegazy/sg-notebook-edit-patternsMohamed Hegazy
The edit hook is registered for NotebookEdit but read no content from it, so a cell edit never produced a pattern warning. Check the cell's new source, and check a saved notebook by its cell sources so JSON escapes no longer hide code from the rules. Refs #6718
2026-10-15Merge pull request #6380 from anthropics/mhegazy/sg-bump-2.0.12Mohamed Hegazy
security-guidance: bump version to 2.0.14
2026-10-15Merge pull request #6588 from anthropics/mhegazy/sg-inflight-reviewsMohamed Hegazy
security-guidance: do not review a commit twice while its first review is running
2026-10-15Merge pull request #6589 from anthropics/mhegazy/sg-review-cost-logMohamed Hegazy
security-guidance: log each review's token use and estimated cost
2026-10-15Merge pull request #6538 from ↵Mohamed Hegazy
anthropics/mhegazy/sg-launcher-unreadable-plugin-dir security-guidance: never run a hook with a Python that cannot read it
2026-10-15security-guidance: log each review's token use and estimated costmhegazy/sg-review-cost-logMohamed Hegazy
The plugin computed a review's usage but kept it only in its metrics. Each review now writes one line to the plugin's debug log with the kind of review, the Claude Code session, model, tokens and estimated cost.
2026-10-15security-guidance: do not review a commit twice while its first review is ↵mhegazy/sg-inflight-reviewsMohamed Hegazy
running A commit review records its commits only once it has a verdict. A push (or the next commit's reflog scan) that started before then reviewed the same diff again. A running review now holds a lock file per commit in the git dir; a push review waits for it and skips what it recorded, and the reflog scan leaves those commits to it.
2026-10-15Merge remote-tracking branch 'origin/main' into ↵mhegazy/sg-launcher-unreadable-plugin-dirClaude
mhegazy/sg-launcher-unreadable-plugin-dir # Conflicts: # plugins/security-guidance/hooks/security_reminder_hook.py
2026-10-15security-guidance: start fewer processes in the hook launcherMohamed Hegazy
sg-python.sh runs on every hook, and under Git Bash each command substitution is a new Windows process, whether or not the interpreter it probes exists (#6470). On a machine with only `python` it started 13 processes before the hook; it now starts 1. - Skip interpreter names that are not on PATH (a builtin lookup) before probing them. - The probe execs the interpreter in its subshell instead of forking again from it. - Remember the first Python below 3.10 seen in pass 2 instead of probing the same names a second time in pass 3. - Convert drive paths (/c/Users/...) to Windows form in-shell under Git Bash / MSYS2; mount points and Cygwin still go through cygpath. Interpreter order and the choice made are unchanged.
2026-10-15security-guidance: report launcher fallback and give-up as metricsMohamed Hegazy
Two count-only metrics, emitted only when nonzero, so the launcher change can be checked in the field: - launcher_fallback: the hook ran, but only because the launcher started the interpreter by its real path (the names on PATH could not read the plugin files). Added to the hook's and the SessionStart bootstrap's existing metrics. - launcher_unreadable: no interpreter could read the hook script. No Python runs in that case, so the launcher prints the metrics line itself before exiting 1.
2026-10-15security-guidance: never run a hook with a Python that cannot read itMohamed Hegazy
On Windows, python/python3/py can be packaged launcher aliases (Microsoft Store Python, Python Install Manager). Started through the alias, the interpreter answers `-c` but has a different view of %APPDATA% and cannot see a plugin staged there. sg-python.sh picked it, CPython failed with "can't open file ... [Errno 2]" and exit code 2, and exit 2 from the asyncRewake Stop hook was delivered to the model as review findings. The model's reply ran the Stop hook again, so the session looped without ever reviewing anything (#6251, #5781). The launcher's probe now also checks that the interpreter can read the hook script. When no name on PATH qualifies, it tries the other python3/python entries on PATH by full path and the real executable each alias reports. If nothing can read the script it says so and exits 1, so a launch failure is never reported as findings.
2026-10-15Merge pull request #6593 from anthropics/mhegazy/sg-reviewer-context-telemetryMohamed Hegazy
security-guidance: report commit reviewer context in review telemetry
2026-10-15Merge pull request #6625 from anthropics/mhegazy/sg-reviewer-read-only-toolsMohamed Hegazy
security-guidance: give the commit reviewer only read tools
2026-10-15Merge pull request #6590 from anthropics/mhegazy/sg-diff-prefix-configMohamed Hegazy
security-guidance: read diffs the same whatever the user's prefix settings
2026-10-15Merge pull request #6605 from anthropics/mhegazy/sg-state-file-saveMohamed Hegazy
security-guidance: keep the session state when a save is cut short
2026-10-15Merge pull request #6617 from anthropics/mhegazy/sg-skip-untracked-listingMohamed Hegazy
security-guidance: skip the untracked-file listing when the Stop review is off
2026-10-15Merge pull request #6616 from anthropics/mhegazy/sg-user-config-dirMohamed Hegazy
security-guidance: find user-level policy files under CLAUDE_CONFIG_DIR
2026-10-15Merge pull request #6540 from anthropics/mhegazy/sg-portable-hook-outputMohamed Hegazy
security-guidance: leave Claude Code only fields out of hook output on other hosts
2026-10-15Merge pull request #6618 from anthropics/mhegazy/sg-portable-session-startmhegazy/sg-portable-hook-outputMohamed Hegazy
security-guidance: print one JSON document from the SessionStart hook on other hosts
2026-10-15Merge remote-tracking branch 'origin/main' into ↵mhegazy/sg-skip-untracked-listingMohamed Hegazy
mhegazy/sg-skip-untracked-listing
2026-10-15Merge remote-tracking branch 'origin/main' into mhegazy/sg-state-file-savemhegazy/sg-state-file-saveMohamed Hegazy
2026-10-15Merge remote-tracking branch 'origin/main' into mhegazy/sg-diff-prefix-configmhegazy/sg-diff-prefix-configMohamed Hegazy
2026-10-15Merge remote-tracking branch 'origin/main' into mhegazy/sg-user-config-dirmhegazy/sg-user-config-dirClaude
2026-10-15security-guidance: report commit reviewer context in review telemetrymhegazy/sg-reviewer-context-telemetryMohamed Hegazy
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.
2026-10-15Merge remote-tracking branch 'origin/main' into ↵mhegazy/sg-fewer-bash-hook-entriesClaude
mhegazy/sg-fewer-bash-hook-entries
2026-10-15Merge branch 'main' into mhegazy/sg-portable-hook-outputMohamed Hegazy
2026-10-15security-guidance: stop re-reviewing untracked files past the snapshot cap ↵Mohamed Hegazy
(#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.
2026-10-15security-guidance: keep secret-shaped files out of reviews (#6537)Mohamed Hegazy
* 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.
2026-10-15security-guidance: give the commit reviewer only read toolsmhegazy/sg-reviewer-read-only-toolsMohamed Hegazy
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.
2026-10-15security-guidance: recognize more git global options before commit and pushmhegazy/sg-git-valueless-global-optionsMohamed Hegazy
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.
2026-10-15security-guidance: print one JSON document from the SessionStart hook on ↵mhegazy/sg-portable-session-startMohamed Hegazy
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.
2026-10-15security-guidance: skip the untracked-file listing when the Stop review is offMohamed Hegazy
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
2026-10-15security-guidance: find user-level policy files under CLAUDE_CONFIG_DIRMohamed Hegazy
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
2026-10-14security-guidance: keep the session state when a save is cut shortMohamed Hegazy
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
2026-10-14Merge remote-tracking branch 'origin/main' into mhegazy/sg-portable-hook-outputMohamed Hegazy
# Conflicts: # plugins/security-guidance/hooks/security_reminder_hook.py
2026-10-14security-guidance: report gateway routing and inner CLI stderr in review ↵mhegazy/sg-review-telemetryMohamed Hegazy
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.
2026-10-14security-guidance: leave Claude Code only fields out of hook output on other ↵Mohamed Hegazy
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.
2026-10-14Merge pull request #6542 from anthropics/mhegazy/sg-diff-parsingMohamed Hegazy
security-guidance: parse diff sections by header line
2026-10-13security-guidance: start fewer hook processes per Bash callClaude
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.
2026-10-13security-guidance: read diffs the same whatever the user's prefix settingsMohamed Hegazy
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
2026-10-13security-guidance: deliver commit and push findings on stderr (#6379)Mohamed Hegazy
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.
2026-10-13Merge pull request #6378 from anthropics/mhegazy/sg-gateway-headersMohamed Hegazy
security-guidance: send ANTHROPIC_CUSTOM_HEADERS on the plugin's own API calls
2026-10-13Merge pull request #6375 from anthropics/mhegazy/sg-review-failuresMohamed Hegazy
security-guidance: never report a failed review as clean
2026-10-12security-guidance: count diff headers the parser could not readmhegazy/sg-diff-parsingMohamed Hegazy
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.