Skip to content

Harden Lint workflow: run on pull_request instead of pull_request_target#5198

Open
RomanIakovlev wants to merge 2 commits into
mainfrom
harden-lint-pull-request
Open

Harden Lint workflow: run on pull_request instead of pull_request_target#5198
RomanIakovlev wants to merge 2 commits into
mainfrom
harden-lint-pull-request

Conversation

@RomanIakovlev

Copy link
Copy Markdown

What

Re-enables the Lint workflow (temporarily disabled) and changes its trigger from pull_request_target to pull_request.

Why

The lint job checks out and runs PR-author code — bundle install and bundle exec rubocop both evaluate repository files (Gemfile, .rubocop.yml) as code. Under pull_request_target that untrusted code runs in a context with access to repository secrets and a privileged GITHUB_TOKEN. The lint job needs neither, so pull_request is the correct trigger: fork PR code then runs with a read-only token and no secret access.

Notes

  • The autocorrect job is unchanged and keeps its existing same-repo guard (if: …head.repo.full_name == github.repository), so it still pushes auto-fixes for same-repo PRs.
  • workflow_dispatch and merge_group triggers are preserved.
  • Validated with actionlint (only pre-existing SC2086 info notes on the unchanged autocorrect job).

The lint job checks out and runs untrusted PR code (bundle install / rubocop)
and does not need repository secrets, so pull_request is the correct, safer
trigger. Also re-enables the workflow (previously disabled). The autocorrect
job is unchanged and keeps its existing same-repo guard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@RomanIakovlev RomanIakovlev requested a review from a team as a code owner June 10, 2026 14:43
Copilot AI review requested due to automatic review settings June 10, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR re-enables the previously disabled Lint GitHub Actions workflow and hardens it by switching the trigger from pull_request_target to pull_request, reducing exposure when running PR-author code.

Changes:

  • Re-enables the Lint workflow definition (was fully commented out).
  • Switches the workflow trigger to pull_request while preserving workflow_dispatch and merge_group.
  • Keeps the autocorrect job and its same-repo guard intact.
Show a summary per file
File Description
.github/workflows/lint.yml Re-enables linting and adjusts workflow triggers/checkout behavior for safer PR execution.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 3

Comment on lines +16 to +19
- uses: actions/checkout@v6.0.2
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
Comment thread .github/workflows/lint.yml Outdated
Comment thread .github/workflows/lint.yml Outdated
Matches the SHA pin used in test.yml and jekyll_build.yml
(ruby/setup-ruby@afeafc3 # v1.310.0)
for supply-chain consistency. Addresses PR review feedback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants