fix(698): parse the recorded base at its FIRST occurrence, not its last
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 17s
PR Gates / Docs update reminder (pull_request) Successful in 19s
PR Gates / decisions lifecycle (pull_request) Successful in 28s
review-verdict/h10 Awaiting review verdict for ef92b46
Review verdict / Set review-verdict status (pull_request_target) Successful in 23s
PR Gates / Script tests (pytest) (pull_request) Successful in 1m21s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 1m31s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 1m31s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m40s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 16m35s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 19m29s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 17s
PR Gates / Docs update reminder (pull_request) Successful in 19s
PR Gates / decisions lifecycle (pull_request) Successful in 28s
review-verdict/h10 Awaiting review verdict for ef92b46
Review verdict / Set review-verdict status (pull_request_target) Successful in 23s
PR Gates / Script tests (pytest) (pull_request) Successful in 1m21s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 1m31s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 1m31s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m40s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 16m35s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 19m29s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Self-found while writing the round-5 review brief, by asking what an attacker who can influence the status description (#697) could do to the parse I had just added. `${ex_desc##*"(base: "}` is greedy, so it reads the LAST occurrence. A description of `Review-verdict: MERGEABLE @ abc1234 (base: probe/scratch) (base: main)` therefore parsed as `main`, matched the PR's base, and the verdict was inherited — reopening the exact hole the base check was added to close, one commit earlier. Measured both forms before choosing: first-match yields `probe/scratch`, mismatches, and fails closed. Two adjacent cases confirmed to fail in the safe direction: a `)` inside a branch name truncates the value (mismatch), and an empty `(base: )` is present-but-different (mismatch), so neither is waved through by the legacy-absent-base allowance. Tests for both, and the appended-base test is mutation-verified: restoring `##` reddens it. 384 tests pass. Refs: #698 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -338,7 +338,14 @@ jobs:
|
||||
if [ "$ex_human" = yes ]; then
|
||||
case "$ex_desc" in
|
||||
*"(base: "*)
|
||||
ex_base=${ex_desc##*"(base: "}
|
||||
# FIRST occurrence (`#`), never the last (`##`). The description is influencable by
|
||||
# anyone who can POST a status (#697), and with greedy matching a real
|
||||
# `(base: probe/scratch)` followed by an appended `(base: main)` parses as `main` and
|
||||
# is inherited. Taking the first occurrence yields the real base, which then
|
||||
# mismatches and fails closed. Measured both ways before choosing.
|
||||
# A `)` inside a branch name truncates the value, which also mismatches — safe
|
||||
# direction. An empty `(base: )` mismatches too.
|
||||
ex_base=${ex_desc#*"(base: "}
|
||||
ex_base=${ex_base%%)*}
|
||||
if [ "$ex_base" != "$BASE_REF" ]; then
|
||||
ex_human=no
|
||||
|
||||
@@ -1491,3 +1491,31 @@ def test_a_LEGACY_verdict_with_no_recorded_base_is_still_honoured(tmp_path):
|
||||
status_creator="timothy",
|
||||
status_desc="Review-verdict: MERGEABLE @ a9e3e23")
|
||||
assert posted is None
|
||||
|
||||
|
||||
def test_an_APPENDED_base_cannot_override_the_real_one(tmp_path):
|
||||
"""The description is attacker-influencable by anyone who can POST a status (#697), so the parse
|
||||
must not be trickable into reading a second, appended base.
|
||||
|
||||
With greedy `${ex_desc##*"(base: "}` this description parses as `main` and the verdict is inherited;
|
||||
with first-match `${ex_desc#*"(base: "}` it parses as `probe/scratch`, mismatches, and fails closed.
|
||||
Both forms were measured before choosing.
|
||||
"""
|
||||
posted, r = _run_classify(
|
||||
tmp_path, _emitting("ErsatzTV/Program.cs"),
|
||||
status_mode="existing:success", status_creator="timothy",
|
||||
status_desc="Review-verdict: MERGEABLE @ a9e3e23 (base: probe/scratch) (base: main)")
|
||||
assert posted is not None, (
|
||||
"an appended '(base: main)' overrode the real recorded base, so a verdict formed elsewhere was "
|
||||
f"inherited. Log:\n{r.stdout[-600:]}")
|
||||
assert posted["state"] == "pending"
|
||||
|
||||
|
||||
def test_an_EMPTY_recorded_base_is_treated_as_a_mismatch(tmp_path):
|
||||
"""`(base: )` is not 'absent' — it is present and not equal to the PR's base, so it fails closed
|
||||
rather than being waved through by the legacy-verdict allowance."""
|
||||
posted, _ = _run_classify(
|
||||
tmp_path, _emitting("ErsatzTV/Program.cs"),
|
||||
status_mode="existing:success", status_creator="timothy",
|
||||
status_desc="Review-verdict: MERGEABLE @ a9e3e23 (base: )")
|
||||
assert posted is not None and posted["state"] == "pending"
|
||||
|
||||
Reference in New Issue
Block a user