Block fork pull request workflow jobs#1
Conversation
📝 WalkthroughWalkthroughThis PR adds job-level conditional guards to GitHub workflow files to restrict execution of build and validation jobs to same-repository PRs and non-PR events, preventing untrusted external pull requests from triggering these jobs. ChangesWorkflow PR Origin Validation
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/build.yml (1)
11-11: Consider adding a “safe fork PR” workflow for basic feedback.Non-blocking suggestion: if you still want CI signal on fork PRs, add a separate workflow with minimal
permissions, no secrets, and only safe read-only checks.Also applies to: 40-40, 62-62
🤖 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/build.yml at line 11, The current workflow uses the condition "if: ${{ github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository }}" which prevents running on forked PRs; add a second minimal “safe fork PR” workflow that runs on pull_request events from forks, sets only read-only permissions, does not reference secrets, and contains only safe checks (linting, unit tests that don’t require secrets, dependency scanning) so maintainers get basic CI feedback; also replicate this change for the other occurrences of the same conditional present in the file so all CI paths have a safe-fork counterpart.
🤖 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.
Nitpick comments:
In @.github/workflows/build.yml:
- Line 11: The current workflow uses the condition "if: ${{
github.event.pull_request == null ||
github.event.pull_request.head.repo.full_name == github.repository }}" which
prevents running on forked PRs; add a second minimal “safe fork PR” workflow
that runs on pull_request events from forks, sets only read-only permissions,
does not reference secrets, and contains only safe checks (linting, unit tests
that don’t require secrets, dependency scanning) so maintainers get basic CI
feedback; also replicate this change for the other occurrences of the same
conditional present in the file so all CI paths have a safe-fork counterpart.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: c041b35f-10b3-464b-a263-a89a659e9125
📒 Files selected for processing (2)
.github/workflows/build.yml.github/workflows/pr-conventional-commit.yml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Node (22) Unit Tests
- GitHub Check: Node (18) Unit Tests
- GitHub Check: Lint
🔇 Additional comments (2)
.github/workflows/pr-conventional-commit.yml (1)
9-9: Fork-PR gating is correctly enforced for this job.This condition cleanly blocks external-fork PR execution while preserving intended same-repo PR behavior.
.github/workflows/build.yml (1)
11-11: Conditional guards are consistent and correctly scoped across all three jobs.The new
ifchecks implement the intended lockdown (skip fork PRs, keep push/same-repo PR paths intact).Also applies to: 40-40, 62-62
Summary
Why
Public fork pull requests can run attacker-controlled workflow code. Skipping those jobs prevents those pull requests from reaching repository secrets through GitHub Actions.
Validation
yq e '.'.Summary by CodeRabbit