-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Fix lint workflow failing on fork PRs #5094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,13 +5,34 @@ | |
| workflow_dispatch: | ||
| merge_group: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| checks: write | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/[email protected] | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha || github.ref }} | ||
| repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | ||
|
|
||
| - name: Setup Ruby | ||
| uses: ruby/[email protected] | ||
| with: | ||
| bundler-cache: false | ||
|
|
||
| - name: Install dependencies | ||
Check failureCode scanning / CodeQL Cache Poisoning via execution of untrusted code High
Potential cache poisoning in the context of the default branch due to privilege checkout of untrusted code. (
pull_request_target Error loading related location Loading |
||
|
Comment on lines
+19
to
+24
|
||
| run: bundle install | ||
|
|
||
| - name: Run RuboCop | ||
Check failureCode scanning / CodeQL Cache Poisoning via execution of untrusted code High
Potential cache poisoning in the context of the default branch due to privilege checkout of untrusted code. (
pull_request_target Error loading related location Loading |
||
|
Comment on lines
+24
to
+27
|
||
| run: | | ||
| bundle exec rubocop | ||
|
|
||
| autocorrect: | ||
Check failureCode scanning / CodeQL Cache Poisoning via execution of untrusted code High
Potential cache poisoning in the context of the default branch due to privilege checkout of untrusted code. (
pull_request_target Error loading related location Loading |
||
|
Comment on lines
+27
to
+31
|
||
| if: github.event.pull_request.head.repo.full_name == github.repository | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/[email protected] | ||
| with: | ||
|
|
@@ -27,7 +48,6 @@ | |
| bundle exec rubocop -A | ||
|
|
||
| - name: Check for changes | ||
| id: changes | ||
| run: | | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
pull_request_targetwhile checking outgithub.event.pull_request.head.shafromhead.repo.full_namemeans the job will execute untrusted fork code with the base repo’sGITHUB_TOKENpermissions (contents: writeat the workflow level). This is a known security footgun: a malicious fork PR can run arbitrary code (e.g., via Bundler/RuboCop) and use the write-scoped token to modify the base repository. Consider splitting into two jobs/workflows: a fork-safe lint job (triggered bypull_requestor with job-levelpermissions: contents: readand no pushing) and a same-repo auto-correct job (only whenhead.repo.full_name == github.repository) that has write permissions and does the commit/push.This issue also appears in the following locations of the same file: