summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/tests/conftest.py
AgeCommit message (Collapse)Author
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-22security-guidance: let the test API stub serve servers that keep no request ↵Mohamed Hegazy
bodies
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: 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-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-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-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-09security-guidance: never report a failed review as cleanmhegazy/sg-review-failuresMohamed Hegazy
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.
2026-09-09Adjust SubagentStop handling and repository precedenceOctavian Guzu
- SubagentStop reviews without consuming or advancing the session's Stop state; an identical diff is not reviewed twice. - SubagentStop from a different working tree than the project is skipped. - An explicit `git -C <dir>` / `cd <dir>` naming another repository takes precedence over the hook cwd. - Narrows the `git -C … commit` matcher; keeps Windows path separators when tokenizing; adds `--no-textconv` to diff/show invocations. - Adds tests. :house: Remote-Dev: homespace
2026-09-09security-guidance: resolve repository from command and edited paths (2.0.7 ↵Octavian Guzu
→ 2.0.8) - Adds repository resolution from `git -C <dir>` / `cd <dir>` in the hook command, from the commit SHA, and from edited file paths when the hook cwd is not a git repository. - Adds PostToolUse matchers for `git -C … commit|push`. - Registers SubagentStop. - Adds `repo_resolution` / `cwd_is_repo` metric fields. - Adds tests. :house: Remote-Dev: homespace