Repository navigation
Dataset CI shims run on pull_request_target, so fork pull requests get BIDS validation and version-check - #1784
Conversation
…idation and version-check On pull_request GitHub gives a fork's run no secrets, so 'Mint App token' failed (Input required and not supplied: app-id) and the central check was never dispatched (nemarDatasets/nm000182#3, nm000232#4, on003825#2). pull_request_target runs the shim from main with the secrets; the job checks out and runs nothing from the PR, event fields reach bash through env and are shape-checked before the dispatch, and the branch name is no longer echoed.
|
The |
|
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged, thank you. The change takes effect per dataset repository when the shims are next redeployed; we will follow up with extra test pins and a decision-record note on why pull_request_target is safe here. |
Fork pull requests never get BIDS validation or version-check
The per-dataset shims
bids-validation.ymlandversion-check.ymlrun onpull_request. For a pull request from a fork, GitHub gives that run no secrets, so the first step fails (Error: Input required and not supplied: app-id) andrun-bids-validation/run-version-checkinnemarDatasets/.githubare never dispatched. Every fork PR shows a red "Dispatch central BIDS validation" and has no central checks until someone runs the central workflows by hand. Seen on nemarDatasets/nm000182#3, nm000183#3, nm000232#4 and on003825#2 (run 38716890974). For contributors with no role on the repository, the run also waits for approval first.Change
Both shims (template in
backend/src/services/github/workflows.ts):pull_request->pull_request_target(branches[main]). The run uses the file as it is on main and gets the secrets.pr-merge.ymlalready usespull_request_targetand runs fine for fork PRs (nm000182#3 merged today).repository.name,pull_request.head.sha,head.ref,number) are passed throughenv. Before, they were written into therun:script with${{ }}, so a branch name could inject shell code. That was harmless without secrets, and must not exist with them.nm|on|xx+ 6 digits), the head sha (40 hex characters) and the PR number before callinggh. The branch name is passed on as data and no longer echoed (it could carry::workflow commands).Why this is safe on
pull_request_target: the job checks out nothing and runs nothing from the pull request. It sends four checked fields to.github, whose central workflow already checks out the head commit by sha and validates it as data, as it does for same-repository PRs. The header comment of each shim says this, so a later edit doesn't add a checkout.Tests
test/workflow-fork-shims.test.ts(22 tests): for each shim, the trigger ispull_request_targetand notpull_request; no step usesactions/checkout,git clone/fetch/checkoutor${{insiderun:; the env carries the four fields. The dispatch script is then run in real bash with a stubgh:$(touch pwned)`touch pwned2`";echo ::add-mask::xis passed through literally, nothing runs, nothing is echoed;ghis called.test/workflow-yaml.test.ts,test/workflow-gh-calls.test.tsandtest/tree-batched-commit.test.tsstill pass (100 tests with the new file).tsc --noEmit -p backendand biome are clean.Rollout
Dataset repos get the new shims when their CI workflows are redeployed (
nemar admin ci sync/ the fleet deploy), and their trigger changes only once the new file is on each repo'smain. Until then a fork PR's central checks can be run by hand fromnemarDatasets/.github(run-bids-validation.yml/run-version-check.yml, workflow_dispatch with dataset_id, ref, head_sha, pr_number).