Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
plugins: 'code-review@claude-code-plugins'
Comment on lines +36 to +40
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Unpinned action and plugins 🐞 Bug ⛨ Security

Both workflows execute anthropics/claude-code-action pinned only to the mutable v1 tag, and the
review workflow loads plugins from a remote marketplace without an immutable version/commit pin. If
the tag/plugin changes (or is compromised), different code can run in CI with access to
CLAUDE_CODE_OAUTH_TOKEN.
Agent Prompt
### Issue description
The workflows execute third-party code (`anthropics/claude-code-action@v1`) and remote plugins without immutable pinning. This increases supply-chain risk, especially since the job passes `CLAUDE_CODE_OAUTH_TOKEN`.

### Issue Context
Tags like `v1` can move; remote plugin references can change over time.

### Fix Focus Areas
- .github/workflows/claude.yml[34-37]
- .github/workflows/claude-code-review.yml[36-40]

### Suggested change
- Replace `anthropics/claude-code-action@v1` with a specific commit SHA (and use Dependabot/GitHub tools to keep it updated safely).
- If plugins must be used, pin them to immutable versions/SHAs (if the action supports it) or vendor/lock the plugin source rather than pulling mutable remote code at runtime.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options

50 changes: 50 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
Comment on lines +15 to +19
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Unrestricted @claude triggers 🐞 Bug ⛨ Security

In .github/workflows/claude.yml, the job runs whenever any comment/review/issue text contains
@claude without checking the sender’s repo permission/association, yet it passes
secrets.CLAUDE_CODE_OAUTH_TOKEN into a third-party action. This allows any external commenter to
trigger secret-bearing runs (cost/abuse risk and increased secret exposure surface).
Agent Prompt
### Issue description
`claude` job triggers on any `@claude` text from any commenter, but the job also passes `secrets.CLAUDE_CODE_OAUTH_TOKEN` to a third-party action. Add an authorization gate so only trusted actors (e.g., OWNER/MEMBER/COLLABORATOR, or an explicit allowlist) can trigger the workflow.

### Issue Context
Current job-level `if:` only checks for the substring `@claude` and does not validate `author_association`/permissions.

### Fix Focus Areas
- .github/workflows/claude.yml[15-19]
- .github/workflows/claude.yml[33-38]

### Suggested change
- Extend the job `if:` to also require trusted actors for each event type, e.g. check `github.event.comment.author_association` / `github.event.issue.author_association` / `github.event.review.author_association` is in `{OWNER, MEMBER, COLLABORATOR}` (and optionally exclude bots).
- If you need broader access, use an explicit allowlist of `github.actor` values.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read

# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'

# Optional: Add claude_args to customize behavior and configuration
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr:*)'

Loading