Skip to content

ci: add Claude Code /security-review workflow on PRs#1285

Merged
tejaskash merged 7 commits into
mainfrom
claude-security-review
May 18, 2026
Merged

ci: add Claude Code /security-review workflow on PRs#1285
tejaskash merged 7 commits into
mainfrom
claude-security-review

Conversation

@tejaskash
Copy link
Copy Markdown
Contributor

@tejaskash tejaskash commented May 18, 2026

Summary

  • Adds .github/workflows/pr-security-review.yml that runs anthropics/claude-code-action@v1 with the built-in /security-review slash command on every PR (pull_request_target: opened/reopened/synchronize) and via workflow_dispatch.
  • Authenticates to Bedrock

Mirrors the auth gate from pr-ai-review.yml: PRs from non-collaborators are skipped to prevent prompt-injection-driven token abuse.

Model: us.anthropic.claude-opus-4-7, max-turns 20, region us-west-2.

Test plan

  • Merge this PR, then open a follow-up PR — pull_request_target reads workflows from main, so the workflow only takes effect once merged.
  • Verify the claude-security-reviewing label appears, the workflow run completes, and a security review comment is posted by the bot.
  • Confirm OIDC role assumption succeeds in the workflow logs.

@tejaskash tejaskash requested a review from a team May 18, 2026 16:43
@github-actions github-actions Bot added the size/m PR size: M label May 18, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label May 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.14.0.tgz

How to install

npm install https://github.com/aws/agentcore-cli/releases/download/pr-1285-tarball/aws-agentcore-0.14.0.tgz

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 43.52% 9179 / 21090
🔵 Statements 42.78% 9739 / 22763
🔵 Functions 40.33% 1588 / 3937
🔵 Branches 40.31% 5974 / 14818
Generated in workflow #3071 for commit 8eb573e by the Vitest Coverage Report Action

Copy link
Copy Markdown

@agentcore-cli-automation agentcore-cli-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflow looks well-structured overall and the auth gate is solid. A few things worth addressing before merge — see inline comments. The biggest concerns are:

  1. The synchronize trigger differs from pr-ai-review.yml despite the PR description claiming to mirror it — this means a full Bedrock review runs on every push, not just PR open/reopen.
  2. Script injection risk via the workflow_dispatch pr_number input being interpolated directly into a github-script step.
  3. No timeout-minutes guard on the job that invokes Bedrock + Claude Code Action with --max-turns 20.

Comment thread .github/workflows/pr-security-review.yml Outdated
Comment thread .github/workflows/pr-security-review.yml Outdated
Comment thread .github/workflows/pr-security-review.yml
Comment thread .github/workflows/pr-security-review.yml
@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 18, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels May 18, 2026
…cript injection, add timeout, inline comments)
Copy link
Copy Markdown
Contributor Author

@tejaskash tejaskash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 0b32025:

  1. synchronize trigger — dropped from pull_request_target types so the workflow now only fires on opened/reopened/labeled, matching pr-ai-review.yml.
  2. Script injection on pr_number — moved inputs.pr_number into env: and read it via process.env.PR_NUMBER_INPUT with explicit base 10. Also applied the same env-var pattern to steps.pr.outputs.number in the two label-management github-script steps as defense in depth.
  3. timeout-minutes — added timeout-minutes: 30 to the security-review job.

Also, per follow-up request: updated the prompt to instruct Claude to post inline line-level review comments instead of a single summary comment (with a fallback top-level comment if there are no findings).

@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels May 18, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels May 18, 2026
Comment thread .github/workflows/pr-security-review.yml
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels May 18, 2026
@github-actions github-actions Bot added claude-security-reviewing Claude Code /security-review in progress and removed claude-security-reviewing Claude Code /security-review in progress labels May 18, 2026
notgitika
notgitika previously approved these changes May 18, 2026
@github-actions github-actions Bot added claude-security-reviewing Claude Code /security-review in progress and removed claude-security-reviewing Claude Code /security-review in progress labels May 18, 2026
…context

The Claude Code Action runs the Agent SDK, which doesn't load the /security-review skill bundled with the local CLI binary. Resolving '/security-review' as a prompt was a no-op (num_turns: 0). Inline the bundled prompt into .github/prompts/security-review.md, gather git status/diff in a workflow step, template them in, and feed the result to the action via prompt:. Bumps --max-turns to 30 to accommodate the skill's sub-task fan-out.
@github-actions github-actions Bot added size/m PR size: M claude-security-reviewing Claude Code /security-review in progress and removed size/m PR size: M claude-security-reviewing Claude Code /security-review in progress labels May 18, 2026
The Claude Code Action provides bundled MCP servers (github_inline_comment, github_comment) that buffer comments and post them via the action's post-step. Direct REST/octokit/curl calls are not available as tools and would not work even if they were. Per anthropics/claude-code-action source:
- The github_inline_comment MCP server only registers when triggered by a PR-context event AND when its tool name appears in --allowedTools.
- Comments are buffered to /tmp/inline-comments-buffer.jsonl and flushed by post-buffered-inline-comments.ts.

Changes:
- Allow-list mcp__github_inline_comment__create_inline_comment and mcp__github_comment__update_claude_comment via claude_args.
- Rewrite POSTING RESULTS section of the prompt to call those MCP tools by name with the correct schema (path, line, body), and to use update_claude_comment for the summary instead of an issue-comment REST call.
- Document that workflow_dispatch will not post inline comments — use only for prompt-plumbing smoke tests.
- Enable show_full_output so the action transcript is visible in run logs.
@github-actions github-actions Bot added size/l PR size: L and removed size/m PR size: M labels May 18, 2026
@github-actions github-actions Bot added the claude-security-reviewing Claude Code /security-review in progress label May 18, 2026
@tejaskash tejaskash merged commit ac6cf4a into main May 18, 2026
26 checks passed
@tejaskash tejaskash deleted the claude-security-review branch May 18, 2026 20:14
@github-actions github-actions Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants