Repository navigation
Fix Check ToolHandler.cpp / Check AUTHORS File failing on every fork PR - #9786
timosachsenberg wants to merge 4 commits into
Conversation
actions/checkout@v6 now refuses to check out a fork's PR head from a pull_request_target job (the "pwn request" guard), which made both checks fail unconditionally for every externally-forked PR since ~2026-07-16 instead of running their intended AUTHORS/ToolHandler diff check. Split each into an unprivileged pull_request-triggered check job (safe to checkout fork code, no secrets) that uploads its result as an artifact, plus a privileged workflow_run-triggered companion job that never touches fork code and posts the PR comment. This mirrors GitHub's recommended replacement for pull_request_target + fork-checkout. Fixes #9785 Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ELBxffE1E3xZ9ar5Fvs7xZ
|
@timosachsenberg The following names might be missing from the
Please consider applying the following patch: --- AUTHORS 2026-07-23 09:12:56.072553585 +0000
+++ AUTHORS.new 2026-07-23 09:13:02.073464308 +0000
@@ -27,6 +27,7 @@
- Chris Bielow
- Christian Ehrlich
- Christie Mathews
+ - Claude
- Clemens Groepl
- Cornelia Friedle
- Daniel Jameson |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe AUTHORS and ToolHandler checks now run on ChangesFork-safe check workflows
Sequence Diagram(s)sequenceDiagram
participant PullRequest
participant CheckWorkflows
participant CommentArtifacts
participant CommentWorkflows
participant GitHubPullRequest
PullRequest->>CheckWorkflows: open pull request into develop
CheckWorkflows->>CommentArtifacts: upload optional comment body
CheckWorkflows-->>CommentWorkflows: successful workflow_run
CommentWorkflows->>CommentArtifacts: download matching artifact
CommentWorkflows->>GitHubPullRequest: resolve PR from head SHA and post comment
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8).github/workflows/check-authors-file-comment.ymlTraceback (most recent call last): .github/workflows/check-authors-file.ymlTraceback (most recent call last): .github/workflows/check-tool-handler-comment.ymlTraceback (most recent call last):
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/check-authors-file-comment.yml:
- Around line 19-32: The “Post comment on the PR” step must not trust
pr-comment/pr-number from the untrusted artifact. Derive the target PR from
trusted workflow_run metadata or API data, or validate the artifact number is
numeric and corresponds to the workflow_run head SHA before invoking gh pr
comment; only post after that validation succeeds.
In @.github/workflows/check-tool-handler-comment.yml:
- Around line 28-32: Update the workflow step’s condition to use `test -s
pr-comment/body` so the `gh pr comment` command runs only when the comment body
file exists and contains text; preserve the existing repository, token, and
body-file arguments.
- Around line 27-32: Update the “Post comment on the PR” step to stop using the
artifact-controlled pr-comment/pr-number as the target. Derive the PR number
from trusted workflow_run metadata, preferably
github.event.workflow_run.pull_requests[0].number, or resolve the run-to-PR
association through the GitHub API before invoking gh pr comment; preserve the
existing body-file posting behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 04512de1-8a4f-45a4-9137-4a696e12e0a6
📒 Files selected for processing (4)
.github/workflows/check-authors-file-comment.yml.github/workflows/check-authors-file.yml.github/workflows/check-tool-handler-comment.yml.github/workflows/check-tool-handler.yml
The privileged workflow_run "comment" jobs were trusting a PR number written into an artifact by the unprivileged pull_request "check" job. Unlike pull_request_target, pull_request runs execute the workflow file as it exists on the fork's own branch, so a malicious fork could rewrite that step to fabricate an arbitrary PR number and get our privileged bot to post a comment on an unrelated PR. Resolve the target PR instead from workflow_run.head_sha (set by GitHub itself, not influenced by the fork's workflow content) via the "list pull requests associated with a commit" API. The artifact is now only used for the comment body, never for PR targeting. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ELBxffE1E3xZ9ar5Fvs7xZ
hashFiles('pr-comment/body') only checks that the file exists, not
that it has content — the check step always creates the file via
shell redirection even when there's nothing to report, so an empty
artifact would still pass and produce a comment with an empty body.
Use a real shell -s (exists-and-non-empty) test instead.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ELBxffE1E3xZ9ar5Fvs7xZ
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/check-tool-handler-comment.yml (1)
23-29: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winHandle missing comment artifacts before downloading.
The producer skips creating
tool-handler-pr-commentwhen no finding is written (if-no-files-found: ignore), andactions/download-artifact@v4fails for a missing named artifact. A clean PR therefore exits the privileged check before the empty-body guard runs. Upload an emptybodyfor clean checks, or make the download conditional on artifact existence and keep the-scheck.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/check-tool-handler-comment.yml around lines 23 - 29, Update the “Download PR comment artifact” step so missing tool-handler-pr-comment artifacts do not fail the workflow before the empty-body guard; either always upload an empty body for clean checks or conditionally download only when the artifact exists, while preserving the existing `-s` check.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/check-authors-file-comment.yml:
- Around line 31-37: Update the Resolve the PR for this run's head commit step
to query all associated PRs and select a target only when exactly one open PR
points to workflow_run.head_sha; remove the unconditional `.[0].number`
selection. Leave `pr_number` empty when zero or multiple matching open PRs exist
so subsequent privileged comment posting is skipped.
In @.github/workflows/check-tool-handler-comment.yml:
- Around line 31-37: Update the “Resolve the PR for this run's head commit” step
to filter the pull-request API results using the workflow run’s head SHA, head
branch, and repository context, then require exactly one matching PR before
writing pr_number to GITHUB_OUTPUT. Fail the step when zero or multiple PRs
match instead of selecting `.[0]`.
---
Outside diff comments:
In @.github/workflows/check-tool-handler-comment.yml:
- Around line 23-29: Update the “Download PR comment artifact” step so missing
tool-handler-pr-comment artifacts do not fail the workflow before the empty-body
guard; either always upload an empty body for clean checks or conditionally
download only when the artifact exists, while preserving the existing `-s`
check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4d462fca-55a3-47f0-93ef-7456f2495828
📒 Files selected for processing (4)
.github/workflows/check-authors-file-comment.yml.github/workflows/check-authors-file.yml.github/workflows/check-tool-handler-comment.yml.github/workflows/check-tool-handler.yml
💤 Files with no reviewable changes (2)
- .github/workflows/check-tool-handler.yml
- .github/workflows/check-authors-file.yml
Two more issues in the fork-safe check workflows:
- actions/download-artifact@v4 hard-fails when the named artifact
doesn't exist, and upload-artifact (with if-no-files-found: ignore)
skipped creating the artifact whenever pr-comment/ was empty, which
was the common "nothing to report" case. Always `touch
pr-comment/body` so the artifact (and its non-empty check) exists
regardless of outcome.
- The commit-to-PRs API doesn't document a response order and can
return more than one PR for a commit, so blindly taking `.[0].number`
could target the wrong PR. Require exactly one open PR whose head
SHA matches the run's head_sha, and skip commenting otherwise.
Also moved the ${{ }} expressions used inside `run:` shell blocks into
`env:` vars per zizmor's template-injection lint, even though the
values involved (a repo slug, a commit SHA, a numeric PR id) aren't
actually attacker-controllable.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ELBxffE1E3xZ9ar5Fvs7xZ
|
Re the outside-diff finding on Generated by Claude Code |
Summary
actions/checkout@v6now refuses to check out a fork's PR head SHA from apull_request_targetjob (the "pwn request" guard: https://gh.io/securely-using-pull_request_target). BothCheck ToolHandler.cppandCheck AUTHORS Filedo exactly that, so they've been failing unconditionally for every PR opened from an actual fork since ~2026-07-16, instead of running their intended diff check. PRs from branches withinOpenMS/OpenMSitself are unaffected, which is why this went unnoticed.What changed
Split each workflow into two:
check-tool-handler.yml/check-authors-file.yml— now triggered on plainpull_request(not_target), so checking out the fork's head is safe and unrestricted. Runs the existingci-toolscheck script and, instead of posting the PR comment directly (this job only gets a read-only token when triggered from a fork), uploads the PR number + comment body as an artifact.check-tool-handler-comment.yml/check-authors-file-comment.yml(new) — triggered onworkflow_runonce the corresponding check completes. This job runs in the base repo's context (never checks out fork code) and can safely hold apull-requests: writetoken. It downloads the artifact and posts the comment.Note:
github.event.workflow_run.pull_requestsis empty for fork-originated PRs, so the PR number is carried through the artifact rather than read off theworkflow_runevent.This mirrors GitHub's documented secure replacement pattern for
pull_request_targetcombined with fork-code checkout.Test plan
python3 -c "import yaml; yaml.safe_load(...)")workflow_run-triggered cross-run artifact download locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01ELBxffE1E3xZ9ar5Fvs7xZ
Generated by Claude Code
Summary by CodeRabbit