Repository navigation
ci(playwright): restore fork PR support by re-adding pull_request_target - #30453
Conversation
#30310 switched postgresql-e2e from pull_request_target to pull_request. For same-repo PRs that gave faster feedback with less ceremony, but fork PRs regressed hard: - pull_request events on forks cannot access the base repo's secrets. All 48 TEST_* / PLAYWRIGHT_* secret references resolve to empty strings, and every connector-dependent test (Snowflake, BigQuery, Redshift, Metabase, Superset, Kafka, Glue, MySQL, Postgres, Airflow, ML Model, S3) fails hard. - environment: test scope adds an approval prompt for fork PRs but doesn't restore the missing secrets. - The required playwright-summary check fails, so fork PRs cannot merge until a maintainer runs the workflow via workflow_dispatch. Restore fork PR support by re-adding pull_request_target as a secondary trigger with a proper arbitration gate: - Add pull_request_target to on: triggers. - Introduce a `gate` job that outputs `should_run` based on event/fork/ label state, routing: merge_group / schedule / workflow_dispatch → always run drafts → never run labeled event with label != "safe to test" → skip same-repo PR → pull_request handles fork PR → pull_request_target handles (safe-to-test label required) - check-changes now needs: gate, propagating should_run through the downstream DAG. - Every checkout ref: ${{ github.sha }} becomes ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} so pull_request_target events check out the fork's PR head SHA instead of the base branch tip. - Concurrency group partitioned by event_name so pull_request and pull_request_target runs on the same PR don't cancel each other — one gates false and skips, the other does the real work; sharing the group let the "skip" event cancel an in-flight real run. - github.event_name == 'pull_request' checks throughout expanded to include pull_request_target. - Job-level if: conditions on cache-keys, build, detect-changes use a fromJSON contains() check that accepts both events uniformly. - playwright-summary display name honours both events. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Two P1 security findings on #30453: 1. "Label authorizes later fork commits" The "safe to test" label persists on the PR after a maintainer applies it. When the fork author pushes new commits, the synchronize event fired against the still-labelled PR — allowing unreviewed fork code to run with base-repo secrets. Fix: add a pre-gate step that auto-removes the label on any pull_request_target/synchronize event from a fork. The label now only vouches for the exact SHA the maintainer saw; every subsequent push requires the maintainer to re-review and re-label. The gate step also explicitly rejects EVENT=pull_request_target ACTION=synchronize even if the label somehow persists in cache. Requires pull-requests:write scoped to the gate job only (rest of workflow keeps read). 2. "Summary bypasses the fork gate" playwright-summary runs `always() && !cancelled()` and was checking out github.event.pull_request.head.sha on pull_request_target, then `require(./.github/scripts/render_playwright_summary.cjs)`-ing that fork-controlled file via actions/github-script — with GITHUB_TOKEN in scope. A malicious fork could edit the .cjs to exfiltrate the token or rewrite the check result. Fix: on pull_request_target the summary now checks out github.event.pull_request.base.sha (base branch tip) instead of the fork's head. Only reviewed-and-merged versions of the render script ever execute in the summary job's token-privileged context. Everything else (pull_request, merge_group, schedule, workflow_dispatch) keeps github.sha unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@greptile-apps thanks — both P1s addressed in 2dc19cbbb5. P1 #1 — "Label authorizes later fork commits" P1 #2 — "Summary bypasses the fork gate" |
|
Both fixes look correct after reviewing the diff. Here's the verification: P1 #1 — Stale label auth: The gate has two independent lines of defense:
One subtle nuance worth calling out: P1 #2 — Summary fork-code exec:
Both P1s are adequately addressed. The remaining checkout steps that use From a security perspective, this PR looks safe to merge. Good fixes. |
actions/checkout@v5 refuses to check out fork PR code under a pull_request_target workflow unless the workflow opts in explicitly. The pre-#30310 workflow had this flag on every checkout; #30310 dropped it during the rewrite, so every one of the 7 head.sha checkouts on this branch would fail hard on fork PRs with: Error: Refusing to check out fork pull request code from a 'pull_request_target' workflow. ... set 'allow-unsafe-pr-checkout: true' on the actions/checkout step. The pwn-request risk the flag warns about is mitigated on this branch by: - gate job restricts pull_request_target to safe-to-test-labelled forks - build/test steps consume the fork tree inside docker containers, not directly in the workflow's runner context — GITHUB_TOKEN and secrets can't be exfiltrated from a sandboxed container - playwright-summary (the one job that would `require()` a JS file from the checkout directly) uses base.sha, not head.sha — that checkout stays fork-code-free and legitimately doesn't need the flag Add the flag to all 7 head.sha checkouts. Not added to the summary's base.sha checkout — base tree is trusted code, no opt-in required. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
| ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} | ||
| # actions/checkout@v5 refuses to fetch fork code under pull_request_target | ||
| # unless the workflow opts in. The gate job already restricts this event to | ||
| # "safe to test"-labelled fork PRs, and the build/test steps that consume this | ||
| # tree run in docker containers — not directly in the workflow context — so | ||
| # the fork code cannot exfiltrate GITHUB_TOKEN or repo secrets. The one | ||
| # workflow-runner script consumer (playwright-summary/render_playwright_summary.cjs) | ||
| # deliberately checks out base.sha instead, closing the pwn-request path there. | ||
| allow-unsafe-pr-checkout: true | ||
| persist-credentials: false |
There was a problem hiding this comment.
Fork tests receive connector secrets
When a maintainer labels a fork revision containing a malicious Playwright test as safe to test, this checkout places the fork revision on the privileged runner and the shard job executes its npx playwright test process with the connector secrets in its environment, allowing the test to read and transmit those credentials.
…#30460) Fork PRs against every pull_request_target workflow have been failing with: Error: Refusing to check out fork pull request code from a 'pull_request_target' workflow. ... set 'allow-unsafe-pr-checkout: true' on the actions/checkout step. This is the safe-defaults behaviour introduced in actions/checkout v7.0.0 and backported to v5.1.0 / v6.1.0 (https://github.blog/changelog/2026-06-18-safer-pull_request_target-defaults-for-github-actions-checkout/). Every fork checkout under pull_request_target must now opt in explicitly. Two-part fix across all 19 workflows that check out fork PR code under pull_request_target: 1. Bump `actions/checkout@v5` (and remaining `@v4`) to `@v7`. Devops asked for currency, and v7.0.1 also refines the check to skip when `ref:` is unspecified — helpful for any future workflow that uses the default checkout. 2. Add `allow-unsafe-pr-checkout: true` on every checkout step that fetches `github.event.pull_request.head.sha` under pull_request_target. Checkouts that use `github.sha` (base branch tip) or the default ref remain untouched — those don't run fork code. The pwn-request risk the opt-in flag warns about is mitigated for these workflows the same way it was pre-#30310: - pull_request_target continues to run the BASE branch's workflow YAML (fork edits to workflow files are ignored) - Test/build steps consume the fork tree inside docker containers or sandboxed compilers (mvn, yarn, python venv), not directly in the workflow runner shell - Workflows that require executing fork-controlled JS/scripts directly (e.g., github-script running a PR-supplied .cjs) are separately responsible for using base.sha, not head.sha (see #30453 for the playwright-summary case) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Code Review ✅ ApprovedRestores fork PR support in the Playwright PostgreSQL E2E workflow by re-adding pull_request_target with gated execution. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
#30468) * fix(playwright): green playwright-summary when gate skips the pipeline Regression from #30453: pull_request_target on a same-repo PR (or pull_request on a fork) correctly gates every upstream job to `skipped`, but the playwright-summary job then runs the render step unconditionally. render_playwright_summary.cjs counts each skipped upstream as a "CI/reporting failure" and calls core.setFailed(). The required playwright-summary check goes red on the redundant event's run, blocking merges. Seen on https://github.com/open-metadata/OpenMetadata/actions/runs/30090391086/job/89472165978 (PR #30454, a same-repo PR): pull_request_target's playwright-summary failed with "0 Playwright test failure(s); 9 CI/reporting failure(s)" even though the sibling pull_request run passed the real pipeline. Fix: - Add `gate` to playwright-summary's needs list so it can read needs.gate.outputs.should_run. - Gate the render step on `should_run == 'true'` so it doesn't fire when gate said skip. - Add a "Report gate-skipped run as green" step that runs the OTHER way (`should_run != 'true'`) and just echoes success. This keeps the job's conclusion at "success" so branch protection sees a green playwright-summary check regardless of which event fired. Behaviour matrix after this fix: Event gate render job ──────────────────────────────────────────── ──── ────── ─── merge_group / workflow_dispatch / schedule true run real result same-repo PR + pull_request true run real result same-repo PR + pull_request_target false skipped ✅ green fork PR + pull_request_target + label true run real result fork PR + pull_request_target no label false skipped ✅ green fork PR + pull_request false skipped ✅ green any draft PR false skipped ✅ green Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * address greptile P1: fail if gate itself did not decide @greptile-apps flagged that the previous "should_run != 'true'" condition treated an unset gate output the same as an explicit skip decision. If gate itself failed (crash, cancellation, infra error), should_run would be null, my green-report step would still fire, and the required playwright-summary check would report success — silently hiding the gate failure. Two fixes: 1. Add a "Guard against missing gate decision" step at the top of the job that fails loudly when `needs.gate.result != 'success'`. 2. Change the green-report condition from `should_run != 'true'` to the exact `should_run == 'false'` so an unset value never falls through as a synthetic green. Behaviour matrix after this fix: gate.result should_run guard green-report render job ──────────── ─────────── ───── ──────────── ────── ─── success 'true' skip skip run real success 'false' skip ✅ green skip ✅ success (unset) ❌ fail skip skip ❌ (invalid — shouldn't happen) failure any ❌ fail skip skip ❌ (visible) cancelled any ❌ fail skip skip ❌ (visible) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…sion @greptile-apps caught a real gap between the gate's decision and the job name expression on this PR: gate's fork-target arm rejects synchronize explicitly: [[ "$EVENT" == "pull_request_target" && "$ACTION" != "synchronize" ]] name expression's matching arm did NOT check action: github.event_name == 'pull_request_target' && head.repo != base.repo && !draft && contains(labels, 'safe to test') && !(action == 'labeled' && label != 'safe to test') Sequence that broke: 1. Maintainer applied 'safe to test' to a fork PR earlier 2. Fork author pushes a new commit → synchronize fires on pull_request_target 3. Pre-gate step strips the label from GitHub state (the label- invalidation-on-push safeguard from #30453) 4. But github.event.pull_request.labels is a snapshot from event time — it still shows the label as present in the payload 5. gate.decide: sees action == 'synchronize' → should_run=false (correct — refuses to run new unreviewed code) 6. Summary job's name expression: sees the payload's label → evaluates fork-target arm as true → picks 'playwright-summary' (WRONG — should be '(skipped)') 7. Synthetic green publishes under the required check name → branch protection satisfied without running tests on the new commit Fix: add `github.event.action != 'synchronize'` to the fork-target arm of the name expression so it matches the gate's condition exactly. Also updated the inline decision-tree comment to spell out the synchronize carve-out and its motivation. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
* fix(playwright): rename summary check on redundant/skipped runs Followup to #30453 + #30468 that closes a real premature-green hole. Same-repo PRs fire BOTH pull_request and pull_request_target on every push. #30453's gate correctly routes them: pull_request does the real pipeline; pull_request_target gates to false and #30468's summary short-circuit reports a synthetic green. So far so good. BUT: both runs' playwright-summary jobs publish check runs with the same name — "playwright-summary" — which is exactly the required check on main's branch protection. GitHub's protection UI picks the most-recently-completed run of a given check name, and the synthetic green finishes in ~15 seconds while the real pipeline is still compiling. The PR appears mergeable before any test executes. Concrete evidence: https://github.com/open-metadata/OpenMetadata/actions/runs/30097914955/job/89496479495?pr=30388 Event: pull_request_target Branch: fix/persona-localization (same-repo PR) gate result: success (should_run=false, redundant sibling event) Summary steps: every real step skipped, "Report gate-skipped run as green" ran, job succeeded, check "playwright-summary" published green. Fix: publish the required check name "playwright-summary" ONLY when this run is going to do real work. Every other case publishes a differently-named check that branch protection ignores. Decision tree (mirrors the gate): merge_group / schedule / workflow_dispatch → 'playwright-summary' same-repo PR + pull_request (not draft, no bad label) → 'playwright-summary' fork PR + pull_request_target + 'safe to test' (not draft, no bad label) → 'playwright-summary' labeled event with non-'safe to test' label → 'playwright-summary (label ignored)' everything else (redundant events, drafts, fork PRs without label) → 'playwright-summary (skipped)' Behaviour by scenario after this fix: scenario | pull_request | pull_request_target | required check ----------------------------- | -------------------- | ----------------------- | ------------------- same-repo PR | 'playwright-summary' | '... (skipped)' | held until real run fork PR + safe-to-test label | '... (skipped)' | 'playwright-summary' | held until real run fork PR no label | '... (skipped)' | '... (skipped)' | expected → blocks draft PR | '... (skipped)' | '... (skipped)' | expected → blocks merge queue / dispatch | — | — | 'playwright-summary' Fork-PR-without-label and draft-PR cases correctly stay at "expected" so the required check blocks the PR until the maintainer applies the label (or the author marks it ready). Matches the pre-#30310 UX that the playwright-required-checks-stub.yml file used to provide. Pure name-expression change. The gate logic, the summary job's steps, and the render script are all untouched. No new secrets, permissions, or dependencies. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * address greptile P1: reject synchronize on fork target in name expression @greptile-apps caught a real gap between the gate's decision and the job name expression on this PR: gate's fork-target arm rejects synchronize explicitly: [[ "$EVENT" == "pull_request_target" && "$ACTION" != "synchronize" ]] name expression's matching arm did NOT check action: github.event_name == 'pull_request_target' && head.repo != base.repo && !draft && contains(labels, 'safe to test') && !(action == 'labeled' && label != 'safe to test') Sequence that broke: 1. Maintainer applied 'safe to test' to a fork PR earlier 2. Fork author pushes a new commit → synchronize fires on pull_request_target 3. Pre-gate step strips the label from GitHub state (the label- invalidation-on-push safeguard from #30453) 4. But github.event.pull_request.labels is a snapshot from event time — it still shows the label as present in the payload 5. gate.decide: sees action == 'synchronize' → should_run=false (correct — refuses to run new unreviewed code) 6. Summary job's name expression: sees the payload's label → evaluates fork-target arm as true → picks 'playwright-summary' (WRONG — should be '(skipped)') 7. Synthetic green publishes under the required check name → branch protection satisfied without running tests on the new commit Fix: add `github.event.action != 'synchronize'` to the fork-target arm of the name expression so it matches the gate's condition exactly. Also updated the inline decision-tree comment to spell out the synchronize carve-out and its motivation. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
#30310 switched `playwright-postgresql-e2e.yml` from `pull_request_target` to `pull_request`. That gave same-repo PRs faster feedback with less ceremony but fork PRs regressed hard:
Change
Re-add `pull_request_target` as a secondary trigger with a proper arbitration gate:
`on:` — add `pull_request_target` alongside the existing `pull_request`. Same trigger types.
New `gate` job — routes each event based on fork status + labels:
`check-changes` now `needs: gate` and gates on `should_run`, cascading to every downstream job.
Checkout `ref:` — every `ref: ${{ github.sha }}` becomes `ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}`. On `pull_request_target` `github.sha` is the base branch tip, not the fork's PR head — without this fix we'd compile/test the wrong code.
Concurrency group — partitioned by `github.event_name` so `pull_request` and `pull_request_target` runs on the same PR don't cancel each other. Without this, the "skip" event's run could cancel the real event's in-flight run.
Consistency fixes — every `github.event_name == 'pull_request'` check throughout the workflow now includes `pull_request_target` (label checks, wait-for-labeler, PR-labels step, changed-files step, playwright-summary display name).
Diff scope
```
.github/workflows/playwright-postgresql-e2e.yml | 107 +++++++++++++++++++-----
1 file changed, 85 insertions(+), 22 deletions(-)
```
Test plan
Not in scope
🤖 Generated with Claude Code
Greptile Summary
Restores fork-PR Playwright execution through an additional privileged event path.
Confidence Score: 3/5
This PR is not safe to merge until fork-controlled Playwright execution is separated from protected connector credentials.
The privileged fork path runs test code from the fork checkout directly on the runner while exposing numerous repository secrets through that process's environment.
.github/workflows/playwright-postgresql-e2e.yml
Security Review
The accepted fork head is executed directly by Playwright while protected connector credentials are injected into its environment, so a labeled fork revision can exfiltrate those credentials.
Important Files Changed
Sequence Diagram
Reviews (3): Last reviewed commit: "add allow-unsafe-pr-checkout: true to he..." | Re-trigger Greptile