Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
tests/test_review_one_pr_ci_pending.bats \
tests/test_review_one_pr_decline_verdict.bats \
tests/test_review_one_pr_force_ci_failing.bats \
tests/test_pr_review_force_review_wiring.bats \
tests/test_review_one_pr_nonrequired_gate.bats \
tests/test_review_one_pr_force_re_review.bats \
tests/test_review_one_pr_metadata_rearm.bats \
Expand Down Expand Up @@ -307,7 +308,7 @@
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# NOTE: persist-credentials is intentionally left at the default (true) —

Check warning on line 311 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / Lint

311:9 [comments-indentation] comment not indented like content
# vci_resolve_reusable needs `git fetch origin` to authenticate against this
# private repo when resolving same-repo channel tags. Setting
# persist-credentials: false would silently push every such caller into the
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,26 @@ jobs:
TOKEN_LOG_FILE: /tmp/token-usage-${{ github.run_id }}.jsonl
TOKEN_WORKFLOW: pr-review
# Two distinct force flags (issue #1590 — do NOT re-merge them):
# FORCE_REVIEW — the human @mention break-glass. A repository_dispatch
# (the mention-listener path) bypasses EVERY review gate
# (ci-failing/ci-pending/advisory/maintainer/…). This is a
# deliberate human override and is reachable ONLY here.
# FORCE_REVIEW — the human @mention break-glass. It bypasses EVERY review
# gate (ci-failing/ci-pending/advisory/maintainer/…), so it
# is set ONLY by an explicit `client_payload.force_review:
# true` on the repository_dispatch — never by the event
# name alone (#2034). The mention listener also dispatches
# for machine-added `review_requested: donpetry-bot`
# events, which used to reach this bypass, approve past the
# maintainer-comment gate, and be dismissed by the next
# run — an approve/dismiss loop until the PR budget ran out.
# A dispatch without the flag runs with every gate armed
# and the narrow FORCE_RE_REVIEW idempotency bypass below.
# FORCE_RE_REVIEW — the narrow idempotency bypass. The `force_review` input
# (workflow_dispatch / workflow_call, e.g. the automated
# orphan-rescue sweep in scripts/sweep-stuck-reviews.sh)
# clears ONLY the same-SHA idempotency no-op and leaves the
# quality gates armed — so an automated re-review can never
# silently convert into a gate bypass, and a stale CI
# snapshot (TOCTOU) is re-validated at execution time.
FORCE_REVIEW: ${{ github.event_name == 'repository_dispatch' && 'true' || 'false' }}
FORCE_RE_REVIEW: ${{ inputs.force_review || 'false' }}
FORCE_REVIEW: ${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.force_review == true || github.event.client_payload.force_review == 'true') && 'true' || 'false' }}
FORCE_RE_REVIEW: ${{ inputs.force_review || (github.event_name == 'repository_dispatch' && 'true') || 'false' }}

steps:
- name: Engine token preflight (#1525)
Expand Down
44 changes: 44 additions & 0 deletions tests/test_pr_review_force_review_wiring.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bats
# #2034: FORCE_REVIEW (the human break-glass that bypasses every review gate) must
# come from an explicit client_payload.force_review flag, never from the event
# name alone. The mention listener also dispatches for machine-added
# `review_requested: donpetry-bot` events; when the event name alone set
# FORCE_REVIEW, those runs approved past the maintainer-comment gate and the next
# run dismissed the approval — a loop until the per-PR budget ran out.

setup() {
REPO_ROOT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
WF="$REPO_ROOT/.github/workflows/pr-review.yml"
}

# The value of a job-level env key, exactly as written (the expression text). The
# match is anchored on the key, so re-indenting the file does not break it, and
# exactly one definition must exist.
_env_val() {
local n
n=$(grep -cE "^[[:space:]]+$1:[[:space:]]" "$WF")
[ "$n" -eq 1 ] || { echo "expected exactly one $1 definition, found $n" >&2; return 1; }
grep -E "^[[:space:]]+$1:[[:space:]]" "$WF" | sed -E "s/^[[:space:]]+$1:[[:space:]]+//"
}

# Exact expressions: any broadening (e.g. an added `|| 'true'`) fails the test.
FORCE_REVIEW_EXPR="\${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.force_review == true || github.event.client_payload.force_review == 'true') && 'true' || 'false' }}"
FORCE_RE_REVIEW_EXPR="\${{ inputs.force_review || (github.event_name == 'repository_dispatch' && 'true') || 'false' }}"

@test "FORCE_REVIEW is exactly the explicit client_payload.force_review expression" {
run _env_val FORCE_REVIEW
[ "$status" -eq 0 ]
[ "$output" = "$FORCE_REVIEW_EXPR" ]
}

@test "FORCE_REVIEW is never derived from the event name alone" {
run _env_val FORCE_REVIEW
[ "$status" -eq 0 ]
[[ "$output" != *"github.event_name == 'repository_dispatch' && 'true' ||"* ]]
}

@test "a repository_dispatch without the flag gets only the narrow FORCE_RE_REVIEW bypass" {
run _env_val FORCE_RE_REVIEW
[ "$status" -eq 0 ]
[ "$output" = "$FORCE_RE_REVIEW_EXPR" ]
}
Loading