You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b5e3b37
Browse filesBrowse the repository at this point in the historyBrowse files
ci(api-review-gate): build the fork detector from the default branch
The merge base is the commit the fork's author branched from, so a
branch cut from an old commit selected an old detector, and a fix to
the detector never reached the PRs an attacker controls. The workflow
itself comes from the default branch, so the detector now does too.
The head is also checked out with its links intact. Flattening them
hid a CRD behind a file link from the detector while Helm still
shipped it, and made the verdict differ from the one the same-repo
gate reaches.
Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <[email protected]>
Copy file name to clipboardExpand all lines: docs/agents/e2e-testing.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -168,7 +168,7 @@ Consequences to keep in mind when touching either workflow:
168
168
169
169
**This pattern now has a second consumer — change it in both places.** `.github/workflows/api-review-gate.yaml` publishes the `API Review Gate` context the same way for same-repo PRs, from an `api-gate-report` job, and `api-review-gate-fork.yaml` publishes it for forks. Two details measured while wiring it up are worth recording here, because they are the load-bearing reason the gate cannot be a job. First, check runs are **not** deduplicated per name: each workflow run gets its own check suite, so `GET /commits/{sha}/check-runs?filter=latest` returns the same set as `filter=all`, and two runs on one head SHA leave two verdicts standing for one context name — the aggregate is worst-of, so a cancelled run poisons the context until the next push. Commit statuses **are** deduplicated per context, newest wins. Second, the read-only-token restriction on fork PRs covers `pull_request_review` as well as `pull_request`, so an approval arriving on a fork PR cannot publish a status either. Together these give the invariant both gates rely on: a run that posts nothing preserves whatever verdict a real run last reached, and can never invent one.
170
170
171
-
The fork half of the API gate departs from `e2e-fork.yaml` in three ways, each forced by a measurement. It does not take a fork from `workflow_run.head_repository` or `workflow_run.pull_requests`: for a `pull_request_review` run on a fork PR the first names the base repository and the second is empty, so it resolves the PR from the base repo's open PR list by head SHA instead. It does not relay the triggering run's conclusion, because a fork's run executes the fork's copy of the gate workflow; it rebuilds the detector from the base branch, runs it over the fetched head as data, and reads the reviews API itself. And it also runs on a schedule, because the repository makes every run from an external contributor wait for a maintainer's approval and a run in `action_required` never fires `workflow_run`, so an API owner's approval on such a PR reaches the status only through the sweep, scheduled every fifteen minutes (GitHub may start a scheduled run late). The sweep moves only a status the full evaluation already set after finding a sizeable change, between "needs an approving review" and "approved"; a fork PR whose push run still awaits approval has no status for it to move, and stays unmergeable until a maintainer lets that run execute, as it does for `E2E Tests`. A status lives on the commit, not on a PR, so a head that an open same-repo PR carries is left to that PR's own reporter, however many fork PRs carry it too, and a fork PR on such a head shows whichever verdict stands there even when its base differs, as two same-repo PRs at different bases already do, because one commit status cannot hold a verdict per base. A head carried only by fork PRs fails closed, since their bases can differ: `resolve` writes the failure and the sweep turns a success already standing there into the same one, and it recovers on the next evaluation once all but one of them are closed.
171
+
The fork half of the API gate departs from `e2e-fork.yaml` in three ways, each forced by a measurement. It does not take a fork from `workflow_run.head_repository` or `workflow_run.pull_requests`: for a `pull_request_review` run on a fork PR the first names the base repository and the second is empty, so it resolves the PR from the base repo's open PR list by head SHA instead. It does not relay the triggering run's conclusion, because a fork's run executes the fork's copy of the gate workflow; it builds the detector from the default branch, not from the merge base a fork's author chooses, runs it over the fetched head as data, and reads the reviews API itself. And it also runs on a schedule, because the repository makes every run from an external contributor wait for a maintainer's approval and a run in `action_required` never fires `workflow_run`, so an API owner's approval on such a PR reaches the status only through the sweep, scheduled every fifteen minutes (GitHub may start a scheduled run late). The sweep moves only a status the full evaluation already set after finding a sizeable change, between "needs an approving review" and "approved"; a fork PR whose push run still awaits approval has no status for it to move, and stays unmergeable until a maintainer lets that run execute, as it does for `E2E Tests`. A status lives on the commit, not on a PR, so a head that an open same-repo PR carries is left to that PR's own reporter, however many fork PRs carry it too, and a fork PR on such a head shows whichever verdict stands there even when its base differs, as two same-repo PRs at different bases already do, because one commit status cannot hold a verdict per base. A head carried only by fork PRs fails closed, since their bases can differ: `resolve` writes the failure and the sweep turns a success already standing there into the same one, and it recovers on the next evaluation once all but one of them are closed.
172
172
173
173
- **Fork TIA reads trusted inputs, but the fork still writes the selector.** `e2e-fork.yaml`'s `e2e` job runs the same `select-e2e.sh` TIA as in-tree (§7), and its inputs are hardened: the changed-file list and the `full-e2e` label come from `resolve`'s base-repo API lookups (`pulls.listFiles` / the PR's labels), the same trusted source as the docs-only decision, passed in as outputs (`changed_b64`, `full_e2e`) rather than re-derived from a `git diff` of the fork-controlled merge ref. Keep that part as it is: re-deriving the selection from the checked-out tree would add a second bypass for no gain.
174
174
- **What the fork lane is, and is not.** The `e2e` job runs from the fork's tree, so `select-e2e.sh`, the suites under `hack/e2e-chainsaw/`, `hack/e2e-install-cozystack.bats` and `packages/core/testing`'s recipes are all fork-authored. A fork that wants its own suite to report green can edit any of them, and hardening the TIA inputs does not change that. Read the lane accordingly: it is a correctness gate that stops an honest contributor shipping a regression, not a boundary against a hostile one. What contains a hostile fork is that no fork run executes without maintainer approval (below), that the job holds no push credential, and that a diff editing the test harness is visible in review.
0 commit comments