Repository navigation
fix(rules): see quoted and flow-style uses: in KYAML workflows - #896
Merged
Merged
Conversation
pin_integrity's @uses_regex and research rules RE001/RE003/RE005 read
workflows as block-style text. On a KYAML workflow (YAML-POLICY Y-3, the
estate base form: `uses: "owner/repo@sha", # v1`, `{ uses: "..." },`,
step items opened by a bare `{`) they saw nothing: no pin sites, no jobs,
no steps. Planted tests confirmed it: 6 of the 10 KYAML cases were red on
main, and the PI001 mutant was missed.
- pin_integrity: the regex accepts an optional quote (matched by a
backreference), a leading `{`, and a trailing `}`/`,`. The key must
still open the line, so a `uses:` inside a `run:` string is not a site.
Substitution keeps the quote and comma intact.
- research_extensions: read_workflow/1 + flow_to_block/1 rewrite KYAML to
the equivalent block layout one line for one line, so finding line
numbers still point at the source. A file whose first significant
line is not a bare `{` passes through byte-identical. RE001, RE003 and
RE005 read through it.
Tests: test/kyaml_workflow_test.exs (positive, control and decoy per
rule) plus a KYAML PI001 mutant/repair case. Full suite: 1768 tests,
0 failures (242 :verisim_data excluded, as always).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W5CoaksP2Bg21HpDCgFgwS
hyperpolymath
enabled auto-merge (squash)
October 1, 2026 22:22
Contributor
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PinIntegrity(@uses_regex, pin_integrity.ex:56) and research rules RE001 / RE003 / RE005 read workflows as block-style text. On a KYAML workflow (YAML-POLICY Y-3, the estate base form, e.g.yq -o kyaml) they could not see anything:uses: "owner/repo@sha", # v1{ uses: "owner/repo@sha" },{anchor){actions/cacheThe blindness was measured before the fix: on
main, 6 of the 10 new KYAML cases fail, and the KYAML PI001 mutant passes unnoticed (4 red on the old regex).How
{and a trailing}/,. The key must still open the line (after indentation and an optional-/{), so auses:inside arun:string is not a site (decoy test).substitute_denylisted_pinskeeps rewriting the original bytes, and the quote and comma survive.read_workflow/1→flow_to_block/1rewrites KYAML to the equivalent block layout one line for one line: closers become blank lines,key: {drops its opener,-goes on a sequence item's first key, and trailing commas and plain quotes are removed. Finding line numbers therefore still point at the source. The rewrite applies only when the first significant line is a bare{, so block YAML (including its ownon: [push]andpermissions: {}) passes through byte-identical, and the existing suites confirm it. No new file is added underlib/rules/, so the module count stays at 33.Tests
test/kyaml_workflow_test.exs: per rule, a positive, a control and (for pin sites) arun:-string decoy; a single-quoted variant; the block-style control.test/rules/pin_integrity_test.exs: a KYAML PI001 mutant, caught at its physical line and then repaired in place.:verisim_datatests are excluded, as always (Known Gaps 3).mix format --check-formattedis clean.Not in scope (recorded, not fixed here)
RE002, RE004, RE006–RE010 and the composite-action
uses:scan (re006,~r/^\s*-?\s*uses:\s*(\S+)/m) still read raw text. They could adoptread_workflow/1in a follow-up, each with its own KYAML tests. RE003'suses: actions/cachematch is content-wide, so arun:body mentioning it counts. That is pre-existing for block YAML, and unquoting makes it reachable from KYAML too.🤖 Generated with Claude Code
https://claude.ai/code/session_01W5CoaksP2Bg21HpDCgFgwS