Skip to content

Dev#23

Merged
FutureUnreal merged 4 commits intomainfrom
dev
Feb 8, 2026
Merged

Dev#23
FutureUnreal merged 4 commits intomainfrom
dev

Conversation

@FutureUnreal
Copy link
Member

@FutureUnreal FutureUnreal commented Feb 8, 2026

变更说明

关联 Issue / 需求

自测方式

  • 后端:cd backend && uv run uvicorn app.main:app --reload --port 8090
  • 前端:cd frontend && pnpm --filter @whalewhisper/web dev

风险 & 回滚

Checklist

  • 已保证改动聚焦(不混杂无关重构)
  • 已更新相关文档(如 README / 配置示例)
  • 未提交任何密钥/个人信息
  • CI(PR Checks)通过

📝 PR 说明(Codex 自动生成)

  • 变更概览:将 PR 描述自动生成从 Codex PR Descriptionopenai/codex-action)切换为 Claude PR Descriptionanthropics/claude-code-action),并在 .github/CI_CD_SETUP.md 中同步更新触发条件与所需密钥(由 OPENAI_API_KEY 改为 ANTHROPIC_API_KEY)。同时删除旧的 Codex 描述工作流/Prompt 文件与仓库 PR 模板,并为现有 Claude 系列 workflows 增加可通过 vars.CLAUDE_MODEL 覆盖的模型参数(默认 claude-sonnet-4-5-20250929)。
  • 影响范围:ci、docs
  • 如何验证
    1. 配置仓库 Secrets:ANTHROPIC_API_KEY(可选 ANTHROPIC_BASE_URL);如不使用默认 secrets.GITHUB_TOKEN,则提供 GH_PAT(workflow 使用 secrets.GITHUB_TOKEN || secrets.GH_PAT)。
    2. 新开一个 PR(该 workflow 仅在 pull_request_target: opened 触发),并保持 PR 描述较短/不完整以便触发生成逻辑。
    3. 在 Actions 中确认 Claude PR Description 成功执行,并检查 PR body 是否被更新为中文结构化模板;同时确认旧的 Codex PR Description workflow 不再出现。
      4.(可选)设置仓库变量 CLAUDE_MODEL,验证其他 Claude workflows 的 claude_args 会携带该 model。
  • 风险点
    • 新 workflow 使用 pull_request_target 且会 checkout PR 的 head.sha,并允许 Claude 执行 Bash(*)/gh pr edit 来直接改写整段 PR body;对来自 fork/非写权限贡献者的安全策略需要确认(allowed_non_write_users: "*")。
    • 触发仅限 opened:后续提交(synchronize)不会自动刷新描述,可能导致描述与最终代码不一致。
    • 删除 codex-pr-description 后,如分支保护/required checks 仍引用旧检查项名称,可能造成合并被阻塞。
    • 移除 .github/pull_request_template.md 可能降低提交 PR 时的填写引导。

- Delete codex-pr-description.yml and its prompt file
- Add claude-pr-description.yml: generates structured Chinese PR
  descriptions using Claude, with deep Issue/PR discovery
- Only triggers on PR opened (not every sync)
- Directly replaces PR body instead of marker-based upsert
- Update CI_CD_SETUP.md to reflect the change
All 8 Claude workflows now read vars.CLAUDE_MODEL, defaulting to
claude-sonnet-4-5-20250929. Change the model for all workflows at
once via Settings → Variables → CLAUDE_MODEL.
@github-actions github-actions bot added area/ci Touches CI/CD (.github) size/M PR size: < 500 lines changed labels Feb 8, 2026
@qodo-code-review
Copy link

Review Summary by Qodo

Replace Codex PR Description with Claude and make model configurable

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Replace Codex PR Description with Claude-based auto-generation
  - Deletes OpenAI Codex workflow and prompt
  - Adds new Claude workflow with deep Issue/PR discovery
  - Triggers only on PR opened (not every sync)
  - Directly replaces PR body instead of marker-based upsert
• Make Claude model configurable across all 8 workflows
  - All workflows now read vars.CLAUDE_MODEL variable
  - Defaults to claude-sonnet-4-5-20250929
  - Enables centralized model management via Settings
• Remove PR template, replaced by Claude auto-description
  - Deletes .github/pull_request_template.md
  - Reduces manual template maintenance burden
• Update CI/CD documentation to reflect changes
  - Updates .github/CI_CD_SETUP.md with new workflow details
  - Documents new trigger conditions and API requirements
Diagram
flowchart LR
  A["Codex PR Description<br/>OpenAI API"] -->|removed| B["Claude PR Description<br/>Anthropic API"]
  C["PR opened event"] -->|triggers| B
  B -->|deep discovery| D["Issue/PR linking"]
  B -->|generates| E["Structured Chinese<br/>description"]
  F["vars.CLAUDE_MODEL"] -->|configures| B
  F -->|configures| G["8 Claude workflows"]
  H["PR template"] -->|removed| I["Auto-generated<br/>descriptions"]
Loading

Grey Divider

File Changes

1. .github/CI_CD_SETUP.md 📝 Documentation +4/-4

Update documentation for Claude PR Description workflow

.github/CI_CD_SETUP.md


2. .github/prompts/codex-pr-description.md Miscellaneous +0/-37

Remove Codex PR Description prompt file

.github/prompts/codex-pr-description.md


3. .github/pull_request_template.md Miscellaneous +0/-24

Remove PR template replaced by Claude auto-generation

.github/pull_request_template.md


View more (8)
4. .github/workflows/claude-pr-description.yml ✨ Enhancement +195/-0

Add new Claude-based PR description generation workflow

.github/workflows/claude-pr-description.yml


5. .github/workflows/codex-pr-description.yml Miscellaneous +0/-133

Remove Codex PR Description workflow

.github/workflows/codex-pr-description.yml


6. .github/workflows/claude-ci-autofix.yml ⚙️ Configuration changes +2/-2

Make Claude model configurable via CLAUDE_MODEL variable

.github/workflows/claude-ci-autofix.yml


7. .github/workflows/claude-issue-auto-response.yml ⚙️ Configuration changes +1/-1

Make Claude model configurable via CLAUDE_MODEL variable

.github/workflows/claude-issue-auto-response.yml


8. .github/workflows/claude-issue-duplicate-check.yml ⚙️ Configuration changes +1/-1

Make Claude model configurable via CLAUDE_MODEL variable

.github/workflows/claude-issue-duplicate-check.yml


9. .github/workflows/claude-mention-responder.yml ⚙️ Configuration changes +1/-1

Make Claude model configurable via CLAUDE_MODEL variable

.github/workflows/claude-mention-responder.yml


10. .github/workflows/claude-pr-review.yml ⚙️ Configuration changes +1/-1

Make Claude model configurable via CLAUDE_MODEL variable

.github/workflows/claude-pr-review.yml


11. .github/workflows/claude-review-responder.yml ⚙️ Configuration changes +1/-1

Make Claude model configurable via CLAUDE_MODEL variable

.github/workflows/claude-review-responder.yml


Grey Divider

Qodo Logo

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 8, 2026

Greptile Overview

Greptile Summary

此 PR 将 PR 描述生成从 OpenAI Codex 迁移到 Anthropic Claude,并在所有 Claude 工作流中添加了可配置的模型参数。

主要变更

  • 替换 PR 描述生成器:删除 codex-pr-description.yml,新增 claude-pr-description.yml,使用 Claude Code Action 分析 PR diff 并生成中文描述
  • 删除 PR 模板:移除 .github/pull_request_template.md,完全依赖 AI 生成描述
  • 模型可配置化:所有 Claude 工作流(autofix、issue response、duplicate check、mention responder、PR review、review responder)现在支持通过 CLAUDE_MODEL 变量配置模型,默认为 claude-sonnet-4-5-20250929
  • 更新文档CI_CD_SETUP.md 已更新以反映从 Codex 到 Claude 的迁移

发现的问题

关键问题

  1. .github/workflows/claude-pr-description.yml:30 - github_token 配置错误:使用了不存在的 secrets.GITHUB_TOKEN(应为 github.token),会导致 fallback 逻辑失效
  2. .github/workflows/claude-pr-description.yml:19-22 - checkout 配置不明确:未指定 ref 参数,可能导致分析的代码版本不一致

改进建议

  1. .github/pull_request_template.md - 完全删除 PR 模板可能影响手动创建 PR 或 AI 生成失败时的用户体验

Confidence Score: 2/5

  • 此 PR 存在关键的配置错误,会导致新工作流无法正常工作
  • 新的 Claude PR Description 工作流包含两个需要修复的问题:(1) github_token 使用了错误的语法 secrets.GITHUB_TOKEN,这会导致认证失败;(2) checkout 步骤缺少显式的 ref 参数,可能导致行为不一致。虽然其他文件的模型配置更改是安全的,但新工作流的核心功能受到影响。
  • .github/workflows/claude-pr-description.yml 需要修复 github_token 语法错误和 checkout 配置

Important Files Changed

Filename Overview
.github/workflows/claude-pr-description.yml New workflow replacing Codex - has security concern with checkout configuration and missing validation
.github/workflows/codex-pr-description.yml File deleted - replaced by Claude PR Description workflow
.github/pull_request_template.md Template removed - relying on AI generation, may impact manual PR creation workflow

Sequence Diagram

sequenceDiagram
    participant User
    participant GitHub
    participant PR as Pull Request
    participant Claude as Claude PR Description
    participant API as Anthropic API
    
    User->>GitHub: Open Pull Request
    GitHub->>Claude: Trigger workflow (pull_request_target: opened)
    
    Note over Claude: Check if actor ends with [bot]
    
    Claude->>GitHub: Checkout repository (base branch)
    Claude->>GitHub: gh pr view - Get PR metadata
    Claude->>GitHub: gh pr diff - Get changes
    Claude->>GitHub: gh search issues - Find related issues
    Claude->>GitHub: gh issue list - List all issues
    
    Note over Claude: Analyze changes and relevance<br/>Generate Chinese description
    
    Claude->>API: Call Anthropic API with prompt
    API-->>Claude: Return AI-generated description
    
    Claude->>GitHub: gh pr edit - Update PR body
    GitHub->>PR: Update description
    
    Note over PR: Description now contains:<br/>概要, 问题, 解决方案, 变更内容<br/>由 Claude AI 自动生成
    
    PR-->>User: Show updated description
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +19 to +22
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Security concern: when using pull_request_target without specifying a ref, checkout@v5 checks out the base branch (not PR head), which is safe. However, this differs from the old Codex workflow which explicitly checked out base.sha. The current config may checkout the latest base commit instead of the merge base, potentially analyzing different code than what will be merged.

Consider explicitly specifying:

Suggested change
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.base.sha }}
fetch-depth: 0

ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Using secrets.GITHUB_TOKEN as fallback will fail because secrets.GITHUB_TOKEN doesn't exist - the correct syntax is just github.token. The current expression will always evaluate to secrets.GH_PAT when github.token is empty.

Suggested change
github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
github_token: ${{ github.token }}

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 8, 2026

Additional Comments (1)

.github/pull_request_template.md
Removed the PR template entirely - contributors opening PRs manually (when AI generation is skipped or fails) won't have guidance on expected format.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@qodo-code-review
Copy link

qodo-code-review bot commented Feb 8, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider


Action required

1. pull_request_target allows untrusted runs 📘 Rule violation ⛨ Security
Description
• The new workflow runs on pull_request_target with pull-requests: write and provides
  ANTHROPIC_API_KEY/GITHUB_TOKEN (or GH_PAT) to an action that can execute Bash(*) tools.
• It explicitly sets allowed_non_write_users: "*", meaning untrusted external contributors can
  trigger a privileged workflow, creating a high risk of secret exfiltration or unauthorized PR
  modification.
• This violates the requirement to implement proper authentication/authorization controls when
  handling external inputs (PRs from non-trusted users).
Code

.github/workflows/claude-pr-description.yml[R3-32]

+on:
+  pull_request_target:
+    types: [opened]
+
+jobs:
+  pr-description:
+    if: "!endsWith(github.actor, '[bot]')"
+    runs-on: ubuntu-latest
+    concurrency:
+      group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
+      cancel-in-progress: false
+    permissions:
+      contents: read
+      pull-requests: write
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v5
+        with:
+          fetch-depth: 0
+
+      - name: Run Claude Code for PR Description Enhancement
+        uses: anthropics/claude-code-action@v1
+        env:
+          ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
+        with:
+          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+          github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
+          allowed_non_write_users: "*"
+
Evidence
Compliance requires proper authentication/authorization for external inputs. The workflow is
triggered via pull_request_target and grants write permissions while allowing any non-write user
to run it, and it passes sensitive secrets/tokens to an action capable of running shell commands,
which together constitute a missing authorization control for untrusted PR authors.

Rule 6: Generic: Security-First Input Validation and Data Handling
.github/workflows/claude-pr-description.yml[3-17]
.github/workflows/claude-pr-description.yml[25-32]
.github/workflows/claude-pr-description.yml[194-195]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow `.github/workflows/claude-pr-description.yml` is triggered by `pull_request_target` and allows any non-write user (`allowed_non_write_users: &amp;amp;quot;*&amp;amp;quot;`) to run an action that can execute `Bash(*)` while receiving secrets/tokens and `pull-requests: write` permission. This is a missing authorization control for untrusted PR authors and can enable secret exfiltration or unauthorized PR edits.
## Issue Context
PR content (title/body/diff) is an external/untrusted input. Using `pull_request_target` + secrets + write permissions should be restricted to trusted actors (e.g., repo members) or redesigned to avoid exposing secrets on untrusted PRs.
## Fix Focus Areas
- .github/workflows/claude-pr-description.yml[3-32]
- .github/workflows/claude-pr-description.yml[14-17]
- .github/workflows/claude-pr-description.yml[25-32]
- .github/workflows/claude-pr-description.yml[194-195]

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



Remediation recommended

2. Mis-sourced github_token 🐞 Bug ⛯ Reliability
Description
• 新工作流将 github_token 取自 secrets.GITHUB_TOKEN || secrets.GH_PAT,但 Actions 内置 token 通常应使用
  github.token;若两者 secrets 均未配置,会导致 gh 命令鉴权失败。
• 即使配置了 GH_PAT,在该场景(仅写 PR 描述)也可能不必要地扩大权限范围,增加误用/泄露后的影响面。
Code

.github/workflows/claude-pr-description.yml[R29-31]

+          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+          github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
+          allowed_non_write_users: "*"
Evidence
同仓库内其它 Claude workflow(PR Review)使用 github.token,而新工作流改用 secrets 组合,造成配置不一致;结合
pull_request_target,该 token 会在 base repo 上下文使用,优先应使用可由 permissions 约束的 github.token

.github/workflows/claude-pr-description.yml[24-32]
.github/workflows/claude-pr-review.yml[107-114]
Best Practice: GitHub Actions token usage guidance

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`claude-pr-description.yml` 的 `github_token` 目前取自 `secrets.GITHUB_TOKEN || secrets.GH_PAT`,与仓库内其它 workflow(使用 `github.token`)不一致,且在未配置对应 secrets 时会导致鉴权失败。
## Issue Context
该 workflow 仅需对 PR 进行写入(更新 body),已通过 `permissions: pull-requests: write` 约束,适合用 `github.token`。
## Fix Focus Areas
- .github/workflows/claude-pr-description.yml[24-32]
## Suggested change
- 将 `github_token` 改为 `${{ github.token }}`。
- 若确实需要 PAT 作为兜底,使用 `${{ secrets.GH_PAT || github.token }}`,并在文档中明确 PAT 的最小权限范围。

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


3. Docs now inconsistent 🐞 Bug ⛯ Reliability
Description
• 文档已将第 4 项改为 Claude PR Description,但文档其它位置仍写 Codex PR Description(包括 pull_request_target
  说明与分支保护勾选项),会误导维护者配置 Required checks。
• 多个 workflow 现支持 vars.CLAUDE_MODEL 覆盖默认模型,但文档 Variables 部分未包含该变量,导致可配置项不可发现。
Code

.github/CI_CD_SETUP.md[R39-43]

+### 4) `Claude PR Description`(`.github/workflows/claude-pr-description.yml`)
-- **触发**:每次 PR(opened/synchronize/reopened/ready_for_review)
-- **功能**:在 PR 描述中 upsert 一段 “AI 自动生成的说明”(带 marker,不覆盖你原本内容)
-- **说明**:需要配置 `OPENAI_API_KEY`
+- **触发**:PR 首次打开时(opened)
+- **功能**:用 Claude 分析 PR diff、搜索关联 Issue/PR,自动生成结构化的中文 PR 描述(直接替换 body);已有完善描述时自动跳过
+- **说明**:需要配置 `ANTHROPIC_API_KEY`(可选 `ANTHROPIC_BASE_URL`)
Evidence
CI/CD 说明文档在不同章节对“PR Description”工作流名称引用不一致;同时 workflows 已引入 vars.CLAUDE_MODEL,但文档 Variables
列表未更新,容易造成维护/配置偏差。

.github/CI_CD_SETUP.md[39-44]
.github/CI_CD_SETUP.md[13-15]
.github/CI_CD_SETUP.md[140-155]
.github/workflows/claude-ci-autofix.yml[185-186]
.github/CI_CD_SETUP.md[119-123]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`.github/CI_CD_SETUP.md` 已更新第 4 项为 Claude PR Description,但其它章节仍引用 Codex PR Description;另外 workflows 支持 `CLAUDE_MODEL` 变量但文档未说明。
## Issue Context
这会导致:
- 维护者在设置分支保护 Required checks 时勾选错误的 check 名称
- 无法发现/理解 `CLAUDE_MODEL` 可配置项
## Fix Focus Areas
- .github/CI_CD_SETUP.md[13-15]
- .github/CI_CD_SETUP.md[136-155]
- .github/CI_CD_SETUP.md[119-123]
## Suggested edits
- 将 pull_request_target 说明中的 `Codex PR Description` 改为 `Claude PR Description`。
- 将分支保护勾选项中的 `Codex PR Description / pr-description` 改为 `Claude PR Description / pr-description`。
- Variables 增加 `CLAUDE_MODEL`:说明用于覆盖默认 Claude 模型,默认值与 workflows 中保持一致。

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


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment on lines +3 to +32
on:
pull_request_target:
types: [opened]

jobs:
pr-description:
if: "!endsWith(github.actor, '[bot]')"
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: false
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Run Claude Code for PR Description Enhancement
uses: anthropics/claude-code-action@v1
env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
allowed_non_write_users: "*"

Choose a reason for hiding this comment

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

Action required

1. pull_request_target allows untrusted runs 📘 Rule violation ⛨ Security

• The new workflow runs on pull_request_target with pull-requests: write and provides
  ANTHROPIC_API_KEY/GITHUB_TOKEN (or GH_PAT) to an action that can execute Bash(*) tools.
• It explicitly sets allowed_non_write_users: "*", meaning untrusted external contributors can
  trigger a privileged workflow, creating a high risk of secret exfiltration or unauthorized PR
  modification.
• This violates the requirement to implement proper authentication/authorization controls when
  handling external inputs (PRs from non-trusted users).
Agent Prompt
## Issue description
The workflow `.github/workflows/claude-pr-description.yml` is triggered by `pull_request_target` and allows any non-write user (`allowed_non_write_users: "*"`) to run an action that can execute `Bash(*)` while receiving secrets/tokens and `pull-requests: write` permission. This is a missing authorization control for untrusted PR authors and can enable secret exfiltration or unauthorized PR edits.

## Issue Context
PR content (title/body/diff) is an external/untrusted input. Using `pull_request_target` + secrets + write permissions should be restricted to trusted actors (e.g., repo members) or redesigned to avoid exposing secrets on untrusted PRs.

## Fix Focus Areas
- .github/workflows/claude-pr-description.yml[3-32]
- .github/workflows/claude-pr-description.yml[14-17]
- .github/workflows/claude-pr-description.yml[25-32]
- .github/workflows/claude-pr-description.yml[194-195]

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

env:
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
Copy link

Choose a reason for hiding this comment

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

[ERROR-SILENT] Missing API key validation

The new claude-pr-description.yml workflow does not validate the presence of ANTHROPIC_API_KEY before attempting to use it. Other Claude workflows in this repo include explicit validation steps.

Evidence:

  • .github/workflows/claude-pr-description.yml:29 - Uses ${{ secrets.ANTHROPIC_API_KEY }} without validation
  • Compare with .github/workflows/claude-pr-review.yml:18-21 which validates the key first

Impact:

  • Workflow will fail silently or with unclear error messages when the secret is not configured
  • Users will not receive actionable feedback about missing configuration

Suggested fix:

    steps:
      - name: Validate Anthropic configuration
        run: |
          if [ -z "${{ secrets.ANTHROPIC_API_KEY }}" ]; then
            echo "::error::Missing required secret ANTHROPIC_API_KEY (Settings → Secrets and variables → Actions)."
            exit 1
          fi

      - name: Checkout repository
        uses: actions/checkout@v5

Confidence: 95 (NEW code +30, Exact line +20, Violated guideline +20, Runtime error +15, Critical path +10)


steps:
- name: Checkout repository
uses: actions/checkout@v5
Copy link

Choose a reason for hiding this comment

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

[SECURITY-VULNERABILITY] Unsafe checkout in pull_request_target

Using pull_request_target with default checkout is a critical security vulnerability. The workflow checks out the base branch (main) instead of the PR branch, so Claude will analyze the wrong code.

Evidence:

  • .github/workflows/claude-pr-description.yml:4 - Uses pull_request_target
  • .github/workflows/claude-pr-description.yml:19-22 - Checks out without specifying ref

Impact:

  • CRITICAL: The workflow will analyze the base branch code, not the PR changes
  • PR descriptions will be incorrect and misleading
  • Wasted API calls analyzing wrong code

Root cause:
pull_request_target runs in the context of the base branch for security. To analyze PR code, you must explicitly check out the PR head ref.

Suggested fix:

      - name: Checkout repository
        uses: actions/checkout@v5
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          fetch-depth: 0

Confidence: 100 (NEW code +30, Exact line +20, Violated guideline +20, Security +15, Critical path +10, Runtime error +15)

ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
Copy link

Choose a reason for hiding this comment

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

[SECURITY-VULNERABILITY] Potential token privilege escalation

Using secrets.GITHUB_TOKEN || secrets.GH_PAT creates a security risk. If GH_PAT has broader permissions than the default GITHUB_TOKEN, it could be exploited by malicious PRs.

Evidence:

  • .github/workflows/claude-pr-description.yml:30 - github_token: ${{ secrets.GITHUB_TOKEN || secrets.GH_PAT }}
  • Combined with pull_request_target and allowed_non_write_users: "*" at line 31

Impact:

  • Malicious PRs from untrusted users could trigger actions with elevated permissions
  • GH_PAT typically has broader repo access than workflow-scoped GITHUB_TOKEN
  • With allowed_non_write_users: "*", any external contributor can trigger this

Root cause:
The fallback to GH_PAT is unnecessary for this workflow. The default github.token has sufficient permissions for PR operations.

Suggested fix:

          github_token: ${{ github.token }}

Remove the GH_PAT fallback entirely. If you need it for specific repos, document why and add explicit security controls.

Confidence: 90 (NEW code +30, Exact line +20, Security +15, Violated guideline +20, User experience +10)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

This PR migrates PR description generation from OpenAI Codex to Claude Code. While the migration is well-intentioned, the new workflow contains critical security vulnerabilities and functional bugs that will prevent it from working correctly.

PR Size: M

Issues Found

Category Critical High Medium Low
Security 2 0 0 0
Error Handling 1 0 0 0
Total 3 0 0 0

Critical Issues

  1. [SECURITY-VULNERABILITY] Unsafe checkout in pull_request_target (.github/workflows/claude-pr-description.yml:20)

    • The workflow checks out the base branch instead of the PR branch
    • Claude will analyze the wrong code, generating incorrect descriptions
    • Must fix before merge
  2. [SECURITY-VULNERABILITY] Token privilege escalation risk (.github/workflows/claude-pr-description.yml:30)

    • Using secrets.GITHUB_TOKEN || secrets.GH_PAT with allowed_non_write_users: "*" allows untrusted users to trigger actions with elevated permissions
    • Must fix before merge
  3. [ERROR-SILENT] Missing API key validation (.github/workflows/claude-pr-description.yml:29)

    • No validation for ANTHROPIC_API_KEY presence
    • Workflow will fail with unclear error messages
    • Other Claude workflows in this repo include proper validation

Positive Changes

  • ✅ Consistent model configuration via vars.CLAUDE_MODEL across all workflows
  • ✅ Proper concurrency control with cancel-in-progress: false
  • ✅ Bot filtering with \!endsWith(github.actor, '[bot]')
  • ✅ Comprehensive prompt with prompt injection protection

Review Coverage

  • Logic and correctness
  • Security (OWASP Top 10)
  • Error handling
  • Type safety
  • Documentation accuracy
  • Test coverage
  • Code clarity

Recommendation

REQUEST CHANGES - The critical security vulnerabilities and functional bugs must be fixed before this can be merged. The checkout issue alone will cause the workflow to analyze the wrong code 100% of the time.


Automated review by Claude AI

@github-actions
Copy link

github-actions bot commented Feb 8, 2026

gh cannot reach api.github.com in this runner (“error connecting to api.github.com”), so I can’t actually post the review/labels from here. Below are the exact commands to run (they’re scoped to diff lines only).

REPO="${PR_REPO:-$GITHUB_REPOSITORY}"
PR="${PR_NUMBER:-23}"
LATEST_COMMIT_SHA="a2fa84d4203ce7f2838cb88c04549fd558d1f860"

# Size (computed: 214+205=419 lines across 11 files => M)
gh pr edit "$PR" --repo "$REPO" --add-label "size/M"

Inline comment(s)

REPO="${PR_REPO:-$GITHUB_REPOSITORY}"
PR="${PR_NUMBER:-23}"
LATEST_COMMIT_SHA="a2fa84d4203ce7f2838cb88c04549fd558d1f860"

gh api "repos/$REPO/pulls/$PR/comments" \
  -f body="$(cat <<'EOF'
**[Critical]** [SECURITY-VULNERABILITY] `pull_request_target` checks out PR head SHA with secrets available

**Why this is a problem**: This job runs on `pull_request_target` (base-repo privileges + access to secrets) but checks out the PR head SHA:
- Offending line: `ref: ${{ github.event.pull_request.head.sha }}` (`.github/workflows/claude-pr-description.yml:29`)

That places untrusted PR code into the workspace in the same job that can access `secrets.ANTHROPIC_API_KEY` and a write-capable GitHub token, creating a secret-exfiltration path (especially for fork PRs). This contradicts the repo’s documented security design: `- **不 checkout PR head/merge 代码**,审查基于 GitHub API 获取的 diff(避免执行不受信任代码)` (`.github/CI_CD_SETUP.md:51`) and the existing safe pattern (`.github/workflows/claude-pr-review.yml:101-105`).

**Suggested fix**:
```yaml
on:
  pull_request_target:
    types: [opened]

jobs:
  pr-description:
    if: >
      !endsWith(github.actor, '[bot]') &&
      github.event.pull_request.draft == false
    steps:
      - name: Checkout base (safe)
        uses: actions/checkout@v5
        with:
          ref: ${{ github.event.pull_request.base.sha }}
          fetch-depth: 0

EOF
)"
-f commit_id="$LATEST_COMMIT_SHA"
-f path=".github/workflows/claude-pr-description.yml"
-f line=29
-f side="RIGHT"


## Summary review (MANDATORY)

```bash
REPO="${PR_REPO:-$GITHUB_REPOSITORY}"
PR="${PR_NUMBER:-23}"

gh pr review "$PR" --repo "$REPO" --comment --body "$(cat <<'EOF'
## 🤖 Codex PR Review

This PR replaces the Codex-based PR description automation with a Claude-based workflow and updates related CI documentation. However, the new PR-description workflow checks out the PR head SHA under `pull_request_target`, creating a high-risk path to run untrusted PR code with secrets available.

### PR Size: M
- **Lines changed**: 419
- **Files changed**: 11

### Issues Found

| Category | Critical | High | Medium | Low |
|----------|----------|------|--------|-----|
| Logic/Bugs | 0 | 0 | 0 | 0 |
| Security | 1 | 0 | 0 | 0 |
| Error Handling | 0 | 0 | 0 | 0 |
| Types | 0 | 0 | 0 | 0 |
| Comments/Docs | 0 | 0 | 0 | 0 |
| Tests | 0 | 0 | 0 | 0 |
| Simplification | 0 | 0 | 0 | 0 |

### Critical Issues (Must Fix)
- (Confidence 95) `.github/workflows/claude-pr-description.yml:29` — `pull_request_target` checks out PR `head.sha` with secrets available (untrusted code execution / secret exfil risk).

### High Priority Issues (Should Fix)
- None

### Review Coverage
- [x] Logic and correctness
- [x] Security (OWASP Top 10)
- [x] Error handling
- [x] Type safety
- [x] Documentation accuracy
- [x] Test coverage
- [x] Code clarity

---
*Automated review by Codex AI*
EOF
)"

…tion

- Add ANTHROPIC_API_KEY validation step (consistent with other workflows)
- Checkout PR head SHA instead of base branch so Claude analyzes
  the actual PR changes
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

Critical Security Issue Found

I've identified 1 CRITICAL security vulnerability that must be addressed before merging.


[SECURITY-VULNERABILITY] Untrusted code execution in pull_request_target

Location: .github/workflows/claude-pr-description.yml:4-5, 29, 39, 202

Confidence: 95 (NEW code +30, Exact line +20, Security +15, Violated guideline +20, Critical path +10)

Issue:
This workflow uses pull_request_target with allowed_non_write_users: "*" and checks out untrusted PR code (head.sha), then grants Claude Bash(*) permissions. This allows any external contributor to execute arbitrary commands in the repository context with write access to PRs.

Attack scenario:

  1. Attacker opens PR with malicious code in comments/filenames
  2. Workflow checks out attacker's code (line 29)
  3. Claude reads malicious instructions from PR diff
  4. Despite "prompt injection protection" in line 55, Claude has Bash(*) and can be manipulated through carefully crafted file content
  5. Attacker gains ability to exfiltrate ANTHROPIC_API_KEY, modify other PRs, or access repository secrets

Evidence:

  • Line 4-5: pull_request_target: [opened] - runs in base repo context with secrets
  • Line 29: ref: ${{ github.event.pull_request.head.sha }} - checks out untrusted code
  • Line 39: allowed_non_write_users: "*" - allows any external contributor
  • Line 202: allowedTools Read,Bash(*),Grep,Glob - grants shell access

Recommended Fix:

# Option 1: Use pull_request instead (no write access to base repo)
on:
  pull_request:
    types: [opened]

# Option 2: If pull_request_target is required, restrict to trusted users only
with:
  allowed_non_write_users: ""  # Only allow repo collaborators
  
# Option 3: Don't checkout PR code, only use base branch
- name: Checkout repository
  uses: actions/checkout@v5
  with:
    ref: ${{ github.event.pull_request.base.sha }}  # Safe: base branch only

References:


PR Size: M (419 lines changed, 11 files)

Issues Found

Category Critical High Medium Low
Security 1 0 0 0
Error Handling 0 0 0 0
Type Safety 0 0 0 0
Logic 0 0 0 0
Total 1 0 0 0

Review Coverage

  • Logic and correctness
  • Security (OWASP Top 10)
  • Error handling
  • Type safety
  • Documentation accuracy
  • Test coverage
  • Code clarity

Other Observations (Not Issues)

Positive changes:

  • Migration from OpenAI to Anthropic Claude is well-structured
  • Model parameter override via vars.CLAUDE_MODEL is a good practice for flexibility
  • Prompt injection protection is mentioned in the new workflow (line 55)
  • API key validation step (lines 19-24) prevents silent failures

Non-blocking notes:

  • The new workflow only triggers on opened, not synchronize. This means PR descriptions won't update as code changes. This is intentional per the documentation but may cause description drift.
  • Removal of .github/pull_request_template.md reduces contributor guidance. Consider if this trade-off is acceptable.
  • The workflow replaces entire PR body rather than upserting a section (unlike the old Codex workflow). This is more aggressive but cleaner.

Recommendation: 🔴 DO NOT MERGE until the critical security issue is resolved.


Automated review by Claude AI

@FutureUnreal FutureUnreal merged commit 81e9d35 into main Feb 8, 2026
12 checks passed
This was referenced Feb 8, 2026
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci Touches CI/CD (.github) size/M PR size: < 500 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant