[bug-yhg8dqypwmar] fix(check-naming): reject hidden provenance #4

Merged
architect merged 12 commits from architect/bug-yhg8dqypwmar/reject-hidden-provenance into main 2026-08-27 17:53:56 +00:00
2 changed files with 36 additions and 2 deletions
Showing only changes of commit 14a8813a7b - Show all commits
+33 -2
View File
@@ -11,6 +11,37 @@ BODY="${PR_BODY:-}"
BASE="${BASE_SHA:-}"
HEAD="${HEAD_SHA:-}"
# Gitea renders HTML comments as hidden. Validate the visible body so required
# tracking and attribution cannot exist only in comment source.
VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk '
{
line=$0
while (line != "") {
if (in_comment) {
Outdated
Review

Blocker: this loop accepts four leading spaces, but CommonMark permits at most three before a fenced code block. With ```` followed by<!--, this sets in_fence` even though the backticks are indented code; the raw HTML comment is then printed unchanged, and hidden Tracking/Attribution headings satisfy the contract. Limit recognition to three leading spaces and add this exact regression.

Blocker: this loop accepts four leading spaces, but CommonMark permits at most three before a fenced code block. With ` ```` followed by `<!--`, this sets `in_fence` even though the backticks are indented code; the raw HTML comment is then printed unchanged, and hidden Tracking/Attribution headings satisfy the contract. Limit recognition to three leading spaces and add this exact regression.
end=index(line, "-->")
if (end == 0) {
line=""
break
}
line=substr(line, end + 3)
in_comment=0
Outdated
Review

Blocker: this gate rejects only HTML comment delimiters. Wrap canonical Tracking and Attribution sections in <script>...</script> and exact head returns check-naming: ok, while Gitea's authenticated /markdown sanitizes the entire raw HTML block to zero bytes. Reject raw HTML constructs that can hide content, or validate the required sections against rendered visible content, and add this exact regression.

Blocker: this gate rejects only HTML comment delimiters. Wrap canonical Tracking and Attribution sections in `<script>...</script>` and exact head returns `check-naming: ok`, while Gitea's authenticated `/markdown` sanitizes the entire raw HTML block to zero bytes. Reject raw HTML constructs that can hide content, or validate the required sections against rendered visible content, and add this exact regression.
}
Outdated
Review

Blocker: CommonMark closing code fences may only be followed by spaces or tabs, but this clears in_fence for any same-character run. With an actual opener, ```oops, a real closer, then an HTML comment containing canonical Tracking and Attribution, Gitea keeps ```oops inside the fence, closes on the next run, and hides the comment; this parser closes early, reopens on the real closer, and accepts the hidden sections. Require the closer remainder to contain only spaces or tabs before clearing in_fence, and add this exact regression.

Blocker: CommonMark closing code fences may only be followed by spaces or tabs, but this clears `in_fence` for any same-character run. With an actual opener, ` ```oops `, a real closer, then an HTML comment containing canonical Tracking and Attribution, Gitea keeps ` ```oops ` inside the fence, closes on the next run, and hides the comment; this parser closes early, reopens on the real closer, and accepts the hidden sections. Require the closer remainder to contain only spaces or tabs before clearing `in_fence`, and add this exact regression.
Outdated
Review

Blocker: you submit an opening three-backtick fence, then ```oops, then canonical Tracking and Attribution. This condition treats ```oops as the closer and returns check-naming: ok; CommonMark requires only spaces or tabs after a closing fence run, so Gitea keeps both labels inside code instead of rendering sections. The checked invalid-opener path has an unchecked invalid-closer twin, and it takes the same forged provenance. Require the remainder of a candidate closing line to contain only spaces or tabs, and add this exact regression.

Blocker: you submit an opening three-backtick fence, then ` ```oops `, then canonical Tracking and Attribution. This condition treats ` ```oops ` as the closer and returns `check-naming: ok`; CommonMark requires only spaces or tabs after a closing fence run, so Gitea keeps both labels inside code instead of rendering sections. The checked invalid-opener path has an unchecked invalid-closer twin, and it takes the same forged provenance. Require the remainder of a candidate closing line to contain only spaces or tabs, and add this exact regression.
start=index(line, "<!--")
architect marked this conversation as resolved Outdated
Outdated
Review

You can put the visible literal <!-- in a code span before valid Tracking and Attribution sections; this starts in_comment, erases the rest of the body, and reports both sections missing. Respect Markdown code spans/fences and cover this recovery case.

You can put the visible literal `<!--` in a code span before valid Tracking and Attribution sections; this starts `in_comment`, erases the rest of the body, and reports both sections missing. Respect Markdown code spans/fences and cover this recovery case.
if (start == 0) break
before=substr(line, 1, start - 1)
Outdated
Review

Blocker: this treats every backtick run of length 3+ as a fence opener, but CommonMark forbids a backtick in a backtick fence's info string. With a first line of three backticks followed by bad and one backtick, then <!--, canonical Tracking/Attribution, and -->, Gitea opens no fence and renders the whole comment hidden; this exact head enters in_fence and returns check-naming: ok. Reject backtick-fence candidates whose trailing info string contains a backtick, and cover this reproduction.

Blocker: this treats every backtick run of length 3+ as a fence opener, but CommonMark forbids a backtick in a backtick fence's info string. With a first line of three backticks followed by `bad` and one backtick, then `<!--`, canonical Tracking/Attribution, and `-->`, Gitea opens no fence and renders the whole comment hidden; this exact head enters `in_fence` and returns `check-naming: ok`. Reject backtick-fence candidates whose trailing info string contains a backtick, and cover this reproduction.
Outdated
Review

Blocker: you submit a body beginning with three backticks followed by html, a backtick, and oops, then put canonical Tracking and Attribution inside <!-- ... -->; Gitea opens no fence because a backtick-fence info string cannot contain a backtick, but this branch sets in_fence and returns check-naming: ok. The checked malformed-run paths have an unchecked invalid-info-string twin, and it takes the same hidden provenance. This isn't a harmless rendering difference: the action accepts sections Gitea hides, and the passing suite doesn't exercise this opener. Validate backtick-fence info strings before entering fence mode and add the exact regression.

Blocker: you submit a body beginning with three backticks followed by `html`, a backtick, and `oops`, then put canonical Tracking and Attribution inside `<!-- ... -->`; Gitea opens no fence because a backtick-fence info string cannot contain a backtick, but this branch sets `in_fence` and returns `check-naming: ok`. The checked malformed-run paths have an unchecked invalid-info-string twin, and it takes the same hidden provenance. This isn't a harmless rendering difference: the action accepts sections Gitea hides, and the passing suite doesn't exercise this opener. Validate backtick-fence info strings before entering fence mode and add the exact regression.
Outdated
Review

Blocker: this fence branch runs before the later in_comment handling. After <!--, a following three-backtick line sets in_fence and prints the rest of the hidden comment, so hidden Tracking and Attribution headings satisfy the check. Process an open comment before fence recognition and add this exact regression.

Blocker: this fence branch runs before the later `in_comment` handling. After `<!--`, a following three-backtick line sets `in_fence` and prints the rest of the hidden comment, so hidden Tracking and Attribution headings satisfy the check. Process an open comment before fence recognition and add this exact regression.
rest=substr(line, start + 4)
Outdated
Review

You paste a fenced log before valid visible Tracking and Attribution; this gate still fails the PR. The accepted cost covers HTML comments, and that existing delimiter gate already blocks the malformed-closer reproduction. Remove the fence-wide ban.

You paste a fenced log before valid visible Tracking and Attribution; this gate still fails the PR. The accepted cost covers HTML comments, and that existing delimiter gate already blocks the malformed-closer reproduction. Remove the fence-wide ban.
Outdated
Review

Blocker: You wrap canonical ## Tracking and ## Attribution sections in <details><summary>Release notes</summary>…</details>. Gitea renders them collapsed, while this exact-head checker exits 0. The checked fence path has an unchecked HTML-disclosure twin one handler over, and it takes the same raw headings. “Expandable” isn’t visible by default, and headings present only in source don’t satisfy the rendered contract. Reject raw HTML containers that can suppress or collapse Markdown, or validate the rendered structure, and cover this exact body.

Blocker: You wrap canonical `## Tracking` and `## Attribution` sections in `<details><summary>Release notes</summary>…</details>`. Gitea renders them collapsed, while this exact-head checker exits 0. The checked fence path has an unchecked HTML-disclosure twin one handler over, and it takes the same raw headings. “Expandable” isn’t visible by default, and headings present only in source don’t satisfy the rendered contract. Reject raw HTML containers that can suppress or collapse Markdown, or validate the rendered structure, and cover this exact body.
end=index(rest, "-->")
if (end == 0) {
Review

Blocker: curl has neither a connection nor total timeout. A renderer that accepts the socket and stops responding can hold this step until the configured 5-minute job timeout; the prior local parser had no remote wait. Add bounded connect and total timeouts, then cover a stalled-response reproduction.

Blocker: `curl` has neither a connection nor total timeout. A renderer that accepts the socket and stops responding can hold this step until the configured 5-minute job timeout; the prior local parser had no remote wait. Add bounded connect and total timeouts, then cover a stalled-response reproduction.
line=before
in_comment=1
break
}
line=before substr(rest, end + 3)
architect marked this conversation as resolved Outdated
Outdated
Review

before substr(...) joins text after a comment terminator into a new parsed line. CommonMark doesn't make <!-- -->## Tracking a heading, but this turns it into ## Tracking; both required sections can be forged. Preserve the physical boundary and add this regression.

`before substr(...)` joins text after a comment terminator into a new parsed line. CommonMark doesn't make `<!-- -->## Tracking` a heading, but this turns it into `## Tracking`; both required sections can be forged. Preserve the physical boundary and add this regression.
}
print line
Outdated
Review

You put an unrelated collapsible log before fully visible Tracking and Attribution; this gate still fails the PR. <details> is ordinary PR-description structure, and the README says collapsed copies of provenance don't satisfy—not that all details are forbidden. Reject required headings inside a details element without rejecting the element everywhere.

You put an unrelated collapsible log before fully visible Tracking and Attribution; this gate still fails the PR. `<details>` is ordinary PR-description structure, and the README says collapsed copies of provenance don't satisfy—not that all details are forbidden. Reject required headings inside a details element without rejecting the element everywhere.
}
')
# Break-glass: dfritz is exempt from all naming checks.
if [ "${AUTHOR}" = "dfritz" ]; then
echo "check-naming: dfritz break-glass — exempt"
8
@@ -53,7 +84,7 @@ if [ "${BRANCH_KIND}" = "role-bug" ]; then
FAILED=1
fi
tracking=$(printf '%s\n' "${BODY}" | awk '
tracking=$(printf '%s\n' "${VISIBLE_BODY}" | awk '
/^## Tracking[[:space:]]*$/ { in_section=1; next }
/^## / && in_section { exit }
in_section { print }
1
@@ -72,7 +103,7 @@ if [ "${BRANCH_KIND}" = "role-bug" ]; then
fi
fi
attribution=$(printf '%s\n' "${BODY}" | awk '
attribution=$(printf '%s\n' "${VISIBLE_BODY}" | awk '
/^## Attribution[[:space:]]*$/ { in_section=1; next }
/^## / && in_section { exit }
in_section { print }
+3
View File
@@ -104,6 +104,9 @@ check_contract "tracking rejects wrong Bug URL" \
check_contract "attribution must be in its own section" \
$'## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n- Authored-By: Codex (GPT-5) <noreply@openai.com>' \
"$BASE" "$GOOD_HEAD" "## Attribution must contain"
check_contract "hidden provenance does not satisfy the visible contract" \
$'<!--\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
git -C "${FIXTURES}" commit --allow-empty -q -m "unwatermarked change"
BAD_HEAD=$(git -C "${FIXTURES}" rev-parse HEAD)