Repository navigation
fix(ci-policy): harden push-filter parsing for anchors, aliases and block scalars (#9090) - #11351
Conversation
…olicy-yaml-parser
…olicy-yaml-parser
|
Warning Review limit reachedYou'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. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 👍 / 👎.
…olicy-yaml-parser
Harden the push-filter parser in
.github/scripts/check-ci-policy-agreement.shfor 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:workflow_dispatch: &m [main]followed bybranches: *morbranches-ignore: *mnow 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 falseno.branches: &m [main]followed bybranches-ignore: *mnow registers the anchored sequence. Previously this shape crashed awk withinvalid regexp: unbalanced [inglob_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:no, so a parser that stopped resolving aliases (returningnofor everything) passed the suite. Six mutations of the parser were used to confirm each new test fails when its fix is removed.*.yml) withnote-submission-pr.ymlexcluded 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:
This is not caused by this change and is not fixed here. It reproduces on a pristine
origin/mainarchive (f5cf9f58e7) with the unmodified script, andnote-submission-pr.ymlhas carried itspull_requesttrigger 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 -non both scripts — clean.origin/main.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.