Skip to content

fix(ci-policy): harden push-filter parsing for anchors, aliases and block scalars (#9090) - #11351

Merged
dezren39 merged 5 commits into
mainfrom
queue/20291-9090-ci-policy-yaml-parser
Nov 17, 2026
Merged

dezren39 merged 5 commits into
mainfrom
queue/20291-9090-ci-policy-yaml-parser

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Harden the push-filter parser in .github/scripts/check-ci-policy-agreement.sh for the seven YAML constructs dispositioned out of PR #8513 (issue #9090).

Closes #9090

What changed

check-ci-policy-agreement.sh — parser fixes, on top of the WIP already on this branch:

  • Construct 3, sequence alias declared on a non-push event. workflow_dispatch: &m [main] followed by branches: *m or branches-ignore: *m now records the anchored tokens, so the alias resolves before pattern matching. Previously the alias was glob-parsed as a literal and the verdict was a false no.
  • Construct 3, anchor declared on the filter key itself. branches: &m [main] followed by branches-ignore: *m now registers the anchored sequence. Previously this shape crashed awk with invalid regexp: unbalanced [ in glob_regex(), because &m [main] reached the matcher as a pattern.

The remaining constructs were fixed in the branch's earlier WIP and are now covered by discriminating tests: 1 (quoted-scalar tokenisation), 2 (whole-trigger alias), 4 (inline alias values), 5 (multiline anchored flow mappings), 6 (apostrophes in plain scalars), 7 (block and folded scalar filter entries).

check-ci-policy-agreement.test.sh — oracle changes:

  • Every construct is asserted in both directions: the fixture that must not be certified plus a positive control that must be. The previous fixtures only asserted no, so a parser that stopped resolving aliases (returning no for everything) passed the suite. Six mutations of the parser were used to confirm each new test fails when its fix is removed.
  • The fixture tree is the whole workflow set again (*.yml) with note-submission-pr.yml excluded by name, instead of a 10-file allowlist. The allowlist silently dropped 60 workflows from the registry-wide assertion. The exclusion is tied to issue ci(workflow-lint): ci-policy checker fails on the real tree — note-submission-pr.yml carries a forbidden pull_request trigger #11295 with a comment saying to delete it when that issue lands; nothing is waived.

The pre-existing real-tree failure

The checker still fails against the real tree:

::error::PR-derived trigger forbidden: .github/workflows/note-submission-pr.yml

This is not caused by this change and is not fixed here. It reproduces on a pristine origin/main archive (f5cf9f58e7) with the unmodified script, and note-submission-pr.yml has carried its pull_request trigger since PR #10991 merged it. It is tracked as issue #11295. The waiver set is unchanged and no workflow file is modified, per this task's acceptance criteria.

Verification

  • bash .github/scripts/check-ci-policy-agreement.test.sh — PASS (includes all seven constructs, both directions).
  • bash -n on both scripts — clean.
  • Real-tree run: unchanged failure, identical to origin/main.
  • Six parser mutations each produce a failing test, confirming the suite discriminates.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 21:25
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff1a1295-c44b-431c-886e-1ac3dd497f41
Commits

Reviewing files that changed from the base of the PR and between d0be5d0 and d694330.

Files selected for processing: 2

  • .github/scripts/check-ci-policy-agreement.sh
  • .github/scripts/check-ci-policy-agreement.test.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T21:37:43.138007Z d694330 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b649ed60d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# (`workflow_dispatch: &m [main]`) is referenced later as
# `branches: *m` or `{branches: *m}` (#9090 construct 3/4):
# record its tokens so the alias resolves before matching.
sequence_anchor[anchor_here] = add_tokens(rest)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve token boundaries when resolving sequence anchors

For an anchor such as workflow_dispatch: &m ['release,main'] followed by branches: *m under push, this stores the already-tokenized string release,main. After alias resolution, the branches handler calls add_tokens() again, splitting the literal comma into separate release and main patterns. Consequently, push_targets_main() returns yes even though the only actual pattern is release,main; previously this unresolved alias returned no. Preserve the raw sequence until its final tokenization pass, or avoid re-tokenizing decoded alias tokens. The outer canonical-syntax guard still rejects this fixture, so this affects the parser verdict rather than bypassing the entire checker.

Useful? React with 👍 / 👎.

if (block_scalar_key == "branches") {
seen_branches = 1
seen_branch_filter = 1
branches_list = branches_list " " value

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep each block scalar as a single filter pattern

When a branches sequence contains a |- scalar whose content is release main, this appends the content directly to the whitespace-delimited pattern list. branches_allow_main() subsequently splits it into release and main, incorrectly returning yes for a scalar that does not match main; the previous parser returned no. The quoted-token path now protects embedded whitespace with a sentinel, but the new block-scalar path bypasses that protection. Preserve the decoded block scalar as one pattern before appending it, and cover whitespace-containing block scalars in the parser fixtures.

Useful? React with 👍 / 👎.

@dezren39
dezren39 merged commit 4b8f283 into main Nov 17, 2026
@dezren39
dezren39 deleted the queue/20291-9090-ci-policy-yaml-parser branch November 17, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci(ci-policy checker): harden push-filter parsing beyond #7950 — anchors/aliases, block scalars, quoted-scalar tokenisation

2 participants