Repository navigation
ci: enforce PR commit policy - #1775
Conversation
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
|
| - name: Check out trusted policy script | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.sha }} |
There was a problem hiding this comment.
Security: Untrusted code execution via pull_request_target
For pull_request_target events, github.sha resolves to the PR head commit (potentially from a fork). This means the workflow checks out and executes code authored by the PR submitter — specifically scripts/github-actions/check-pr-commit-policy.js loaded via require() in the next step.
Although permissions are scoped to read-only, a malicious PR author could modify this script to exfiltrate repository contents or PR data accessible under those permissions. The step name says "Check out trusted policy script" but the checked-out code is not trusted.
The existing ocr-review.yml in this repo demonstrates the safe pattern: omitting ref: so that actions/checkout defaults to the base branch for pull_request_target.
Suggested fix: Remove the ref: input entirely so the checkout defaults to the base branch (the trusted main branch), or explicitly set ref: ${{ github.event.pull_request.base.sha }}. The sparse-checkout already limits what files are materialized, so only the trusted version of the policy script will be present.
There was a problem hiding this comment.
No change planned here: this workflow uses pull_request_target, where github.sha refers to the trusted default-branch commit, not the PR head (GitHub docs). The explicit ref therefore checks out the trusted policy script.
Description
Add a lightweight
PR Commit Policycheck to reject GitHub Actions skip directives in PR titles and complete commit messages. A historical formatting commit in #956 carried a skip directive into the squash commit and prevented main-branch CI from starting.pull_request_targetso commit-message skip directives cannot disable the policy itself.node:24.18.0container.Type of Change
How Has This Been Tested?
make checkmake testmake buildnpm run test:github-actionsNixOS/nixpkgs#560469: reproduced the GraphQL 250-commit truncation, then fetched and validated all 780 commits through eight compare-API pages with a final metadata recheck.Rollout Notes
This PR does not change branch protection. Merge the workflow first, verify an actual fork PR and title-only edit on the self-hosted runners, then add
PR Commit Policyas a required check. A newly introducedpull_request_targetworkflow does not execute from this PR's untrusted branch.Monitor runner queue time before making the check mandatory. The container provides runtime consistency and resource limits, not an ephemeral host or a security boundary against a compromised shared runner. Keep the title-only squash default and review manually edited merge messages.
Checklist
AI Assistance
Implementation, tests, translations, and this PR description were prepared with OpenAI Codex using
gpt-6-astra. The repository-required automated review used OpenCodeReview with the configured modelclaude-opus-5-5. No AI attribution or co-author trailers are added to the commit. The contributor remains responsible for reviewing the generated material and answering maintainer questions from their own understanding.