| Age | Commit message (Collapse) | Author |
|
security-guidance: keep project rules after the session changes folder
|
|
security-guidance: send a claude.ai token as a bearer, hold back a gateway's
|
|
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>
|
|
Project rules and guidance were read from the session's current folder, so
one cd dropped them silently. Read the project's own folder too while the
session is elsewhere in the project; in a linked worktree, the same folder of
that worktree.
Co-authored-by: mhegazy <mhegazy@anthropic.com>
|
|
|
|
security-guidance: do not save review runs as session transcripts
|
|
security-guidance: treat a blank ANTHROPIC_BASE_URL as unset
|
|
security-guidance: on Windows, name the CLI for the Agent SDK by its full path
|
|
A project guidance or pattern file that is a link, or sits under a .claude that
is one, is skipped, and so is anything that is not a regular file. Guidance
that cannot be decoded no longer drops the other guidance files, and a closing
tag in guidance text no longer ends the block that holds it.
Co-authored-by: mhegazy <mhegazy@anthropic.com>
|
|
On Windows the plugin named no CLI for the Agent SDK unless
SG_AGENTIC_CLI_PATH was set, so the SDK chose one. With none named, the
plugin now chooses there itself and passes a full path: the CLI bundled
with the SDK, else the claude.exe in the native installer's folder, else
a claude.exe on PATH. When there is none, it passes the bundled path
and the start fails. Folders that are not given as full paths are
skipped, and so are the working directory, the project root and folders
inside them.
The macOS and Linux install paths are no longer probed on Windows. The
hooks also set NoDefaultCurrentDirectoryInExePath on Windows when it is
absent.
Co-authored-by: mhegazy <mhegazy@anthropic.com>
|
|
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.
|
|
A custom base URL, bare mode and cloud sessions keep ANTHROPIC_AUTH_TOKEN.
|
|
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.
|
|
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.
|
|
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.
|
|
mhegazy/sg-gateway-login
|
|
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.
|
|
security-guidance: log each review's token use and estimated cost
|
|
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.
|
|
# Conflicts:
# plugins/security-guidance/hooks/security_reminder_hook.py
|
|
security-guidance: find user-level policy files under CLAUDE_CONFIG_DIR
|
|
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.
|
|
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
|
|
# Conflicts:
# plugins/security-guidance/hooks/security_reminder_hook.py
|
|
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.
|
|
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.
|
|
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.
|
|
security-guidance: send ANTHROPIC_CUSTOM_HEADERS on the plugin's own API calls
|
|
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.
|
|
The plugin's own API calls (the /v1/models lookup and the review itself)
never sent ANTHROPIC_CUSTOM_HEADERS, so a gateway that takes its key in a
custom header answered 401 and reviews never ran
(anthropics/claude-code#99857).
The headers are now parsed the way Claude Code parses them (one
`Name: Value` per line, split at the first colon) and sent on every call.
A custom line replaces a header of the same name. anthropic-beta lines are
not forwarded: the review needs none of the user's betas.
|
|
→ 2.0.9)
The review model was hardcoded to claude-opus-4-7, so the plugin fell
behind each time a new Opus shipped.
- The diff review asks the configured endpoint (GET /v1/models) for the
newest Opus it serves, cached for a day; claude-opus-5-5 if it can't say.
- The agentic commit review, and every review on Bedrock, Vertex and
Foundry, use Claude Code's `opus` alias.
- SECURITY_REVIEW_MODEL and SG_AGENTIC_MODEL still pin a model.
- Adds pricing rows for the newer Opus models, and tests.
Co-Authored-By: Claude Code <noreply@anthropic.com>
|
|
|