ci: charge Copilot reviews to the review owner - #3139
Conversation
Generated-by: Codex
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 3 reviews per rolling hour; 2 remain after this review. 📝 WalkthroughWhat this PR solvesThe workflow now attributes automatic Copilot review requests to The workflow fails closed when the secret is missing or belongs to another account. It also removes permissions from the generated Source of truthThis change extends the existing automatic review workflow. It does not create a parallel review path. The workflow still uses Scope and complexityThe change is the smallest coherent solution described by the diff. It adds token validation, identity checks, and least-privilege permissions because these controls are required to attribute reviews correctly and prevent unintended token use. No public or exported entities changed. Simplification opportunitiesNo deletion or simplification is evident without weakening token validation, security behavior, or regression coverage. Risks and validationThe dedicated token is used for GitHub API identity checks and reviewer requests. A missing, invalid, or incorrectly owned secret prevents review requests. The reported validation includes:
The final status of required checks remains unverified without direct check results. Review-relevant risksThe diff changes GitHub API identity and automatic review attribution. Any material security or governance change in this area requires independent human review under repository policy. No other protected-area effect was identified in the current diff. The person performing the merge must review the final diff, and a maintainer makes the final determination. WalkthroughThe workflow removes default GitHub token permissions. It uses ChangesCopilot review security
Estimated code review effort: 3 (Moderate) | ~15 minutes Merge Risk: ⚪ Minimal · up to This localized workflow change updates automatic review attribution and is merge-ready after normal checks and review; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the Copilot auto-review GitHub Actions workflow to ensure review requests are made using a dedicated repository secret token (COPILOT_REVIEW_TOKEN) tied to a specific owner account, rather than the event-scoped ${{ github.token }} identity. It also hardens the workflow by removing all permissions from the generated GITHUB_TOKEN and failing closed when the dedicated secret is missing or does not match the expected user.
Changes:
- Set workflow
permissions: {}to remove allGITHUB_TOKENpermissions. - Switch
ghauthentication from${{ github.token }}to${{ secrets.COPILOT_REVIEW_TOKEN }}. - Add a runtime identity check to ensure the secret token resolves to the expected requester (
hqhq1025) and fail closed otherwise.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
M4n5ter
left a comment
There was a problem hiding this comment.
English
LGTM. The attribution and security boundaries are correct.
中文
LGTM,归属与安全边界均正确。
|
Thanks for the fix — the core change is minimal (2 lines: Conclusion: PASS — no blocking findings. P2-1 (governance, non-blocking) — a personal PAT as a repo-level automation credential with a hardcoded owner and no rotation/offboarding plan. Optional nits (P3): the new code path has never run in CI (the AI-assisted review disclosure: this review was produced with AI assistance (pi review subagent on 中文摘要(AI 辅助审查)结论:PASS,无阻塞项。核心改动最小(2 行:github.token → secrets.COPILOT_REVIEW_TOKEN),身份检查是廉价的纵深防御,fail-closed 取舍正确(fail-open 会让计费归属静默失效)。已核实 secret 存在、该 check 不阻塞合并(main 无 required checks)。P2-1(治理,不阻塞):个人 PAT 作为仓库级自动化凭据 + owner 硬编码,无轮换/离职预案——token 过期/吊销或 hqhq1025 离职时所有 PR 的 request-review 会红,修复需两步人工操作;个人 token 存共享 secret 任何 repo admin 可读,且 PR 未记录 token 类型/scope 无法外部核验泄露半径。非当前正确性缺陷,建议在 PR 记录 token 类型/scope/过期时间与轮换责任人,或显式接受该运维风险。P3:新代码路径合并前从未在 CI 执行过("Tests cover the change" 是本地一次性断言)、token 失效时是原始 401 而非友好错误、身份检查不验证 pull-requests:write scope、checklist 表述不准确。 |
Summary
Pin automatic GitHub Copilot review requests to the repository secret
COPILOT_REVIEW_TOKEN, which belongs tohqhq1025, instead of using theevent-triggering
${{ github.token }}identity.The workflow now fails closed when the secret is missing or belongs to another
account. It also removes all permissions from the generated
GITHUB_TOKEN.Security
The workflow still uses
pull_request_targetso it can request reviews forfork pull requests, but it never checks out, executes, or otherwise consumes
untrusted pull request code. The dedicated token is used only for GitHub API
identity checks and reviewer requests.
Verification
.github/workflows/copilot-auto-review.ymlwith Ruby YAMLbash -n${{ github.token }}fallback, and absent checkout/head-ref consumptiongit diff --checkCOPILOT_REVIEW_TOKENis configured in repository Actions secretshqhq1025user-token identity by requestingand completing Copilot review on PR chore(deps): bump the official-actions group across 1 directory with 3 updates #2941
The final automatic attribution path can be observed after merge on the next
non-draft, non-bot pull request event.
AI use
Select exactly one:
Tool(s) and scope: Codex audited the attribution path, implemented the
least-privileged identity binding, and ran the verification commands.
Checklist
Does this PR entail a change in behavior?
hqhq1025.