Skip to content

ci: stop fork pull requests running on the self-hosted runners - #522

Merged
thcp merged 1 commit into
0.16.1from
fix/511-fork-pr-runner-guard
Aug 31, 2026
Merged

ci: stop fork pull requests running on the self-hosted runners#522
thcp merged 1 commit into
0.16.1from
fix/511-fork-pr-runner-guard

Conversation

@thcp

@thcp thcp commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Fixes #511.

macos-check.yml and windows-check.yml trigger on pull_request and run on [self-hosted, macOS, ARM64] / [self-hosted, windows, x64] with no fork guard, on a public repository.

cargo fmt, cargo build and cargo clippy all execute code the PR supplies: build.rs, proc-macro crates, a swapped Cargo.toml dependency or [patch], and the test bodies. permissions: {} limits the token, not code execution.

That runner is the same machine that builds, signs and uploads every macOS DMG and runtime pack. Neither check workflow cleans its workspace, and the release workflows only rm -rf .build dist -- so an implant in ~/.cargo, ~/.npm, ~/.rustup or the persistent _work tree survives into the next release. GitHub's public-repo default only gates first-time contributors, so one trivial merged PR unlocks this for a later one.

Change

Both jobs gain:

if: >-
  github.event_name != 'pull_request' ||
  github.event.pull_request.head.repo.full_name == github.repository

Why not move to GitHub-hosted runners

That would lose the reason the trigger exists. ci.yml is entirely ubuntu-latest, and a Linux runner cannot type-check code behind #[cfg(target_os = "macos")] or #[cfg(windows)] at all -- it is stripped before semantic analysis. #421 added ~600 lines of mostly cfg-gated Rust and every CI check passed without compiling any of it.

workflow_dispatch is unaffected, so a fork's Rust change can still get a real compiler pass when a maintainer triggers one.

Verification

Both files parse and the guard resolves as intended:

macos-check.yml   if: github.event_name != 'pull_request' || ...head.repo.full_name == github.repository
windows-check.yml if: github.event_name != 'pull_request' || ...head.repo.full_name == github.repository

Behaviour: workflow_dispatch runs (first clause), same-repo PRs run (second clause), fork PRs are skipped.

Worth pairing later with a workspace clean at the start of the release workflows, so a compromised check run cannot persist into a build. Not done here to keep this change minimal.

macos-check.yml and windows-check.yml trigger on pull_request and run on
[self-hosted, macOS, ARM64] and [self-hosted, windows, x64] with no fork
guard, on a public repository.

cargo fmt/build/clippy all execute code the pull request supplies: build.rs,
proc-macro crates, a swapped Cargo.toml dependency or [patch], and the test
bodies themselves. permissions: {} limits what the token can reach; it does
nothing about code execution on the machine.

That machine is the same one that builds, signs and uploads every macOS DMG
and runtime pack. Neither check workflow cleans its workspace and the release
workflows only remove .build and dist, so an implant in ~/.cargo, ~/.npm,
~/.rustup or the persistent _work tree would survive straight into the next
release. GitHub's public-repo default only gates first-time contributors, so
one trivial merged pull request is enough to unlock this for a later one.

Gate both jobs on the pull request coming from this repository. The
workflow_dispatch path is unaffected, so a fork's Rust change can still get
its compiler pass when a maintainer asks for one -- which keeps the reason
the trigger exists (#421: cfg-gated Rust merging without ever being compiled,
because ci.yml is entirely ubuntu-latest).

Refs #511
@thcp
thcp marked this pull request as ready for review August 31, 2026 21:01
@thcp
thcp merged commit 53ef956 into 0.16.1 Aug 31, 2026
10 checks passed
@thcp
thcp deleted the fix/511-fork-pr-runner-guard branch August 31, 2026 21:01
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.

1 participant