Skip to content

Add immutable-ref CI guard for images and actions - #5

Merged
Miyamura80 merged 6 commits into
mainfrom
claude/festive-cori-e6o9o8
Oct 30, 2026
Merged

Miyamura80 merged 6 commits into
mainfrom
claude/festive-cori-e6o9o8

Conversation

@Miyamura80

Copy link
Copy Markdown
Contributor

Summary

Adds a CI guard (scripts/check_immutable_refs.py + a Pinned refs workflow) that fails on tag-only or :latest Dockerfile images and on any GitHub Action not pinned by full commit sha. The repo has no Dockerfiles or external actions today, so there is nothing to pin yet; the guard keeps future additions immutable.

Changes

  • scripts/check_immutable_refs.py: requires any future Dockerfile image to be pinned by digest and any GitHub Action by full commit sha (tags are mutable, which is how tag-rewrite supply-chain attacks land).
  • New "Pinned refs" workflow runs the guard.

Testing

  • python3 scripts/check_immutable_refs.py exits 0
  • make ci (not applicable: there is no Makefile)

Generated by Claude Code

Add scripts/check_immutable_refs.py and a "Pinned refs" workflow so any
future Dockerfile image must be pinned by digest and any GitHub Action by
full commit sha (tags are mutable, which is how tag-rewrite supply-chain
attacks land). The repo has no Dockerfiles or external actions today, so
there is nothing to pin yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wtx3dU8PQvgyubf6ZpNaG3
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread .github/workflows/pinned-refs.yml Resolved
Comment thread scripts/check_immutable_refs.py Resolved
Comment thread scripts/check_immutable_refs.py Resolved
Comment thread scripts/check_immutable_refs.py Resolved
Comment thread scripts/check_immutable_refs.py Resolved
Comment thread scripts/check_immutable_refs.py Resolved
Comment thread scripts/check_immutable_refs.py Resolved
Comment thread scripts/check_immutable_refs.py Resolved
Comment thread scripts/check_immutable_refs.py Resolved
Comment thread scripts/check_immutable_refs.py Resolved
- Guard v5: a blank line clears a pin-exempt marker, blank lines inside a
  continuation are skipped, continuations join like Docker, "# escape="
  is honoured, action.yml runs.image is exempt only for a Dockerfile path,
  flow-style and "uses :" YAML keys are parsed, every ref on a line is
  checked, and uses: must be owner/repo[/path]@<40-hex>.
- Pinned refs workflow runs the base branch copy of the checker on pull
  requests; the workflow file itself needs CODEOWNERS or a ruleset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wtx3dU8PQvgyubf6ZpNaG3
…blowup

- An anchor or tag before a block key (`- &step uses: x`, `- !!str uses: x`,
  `{ &k uses: x }`) no longer hides the key from the check.
- Verbatim tags with commas (`!<tag:yaml.org,2002:seq> [...]`) now open a
  flow collection.
- Each node property must end at whitespace or a bracket, so a run like
  `&&&&x` has one split instead of exponentially many (the old pattern hung
  on 30 characters).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wtx3dU8PQvgyubf6ZpNaG3
`!<[^>]*>` ran to the end of the line from every comma when the tag was
never closed, so a flow line of repeated `,!<` was quadratic (32k repeats
took 8s). YAML verbatim tags hold URI characters only, so the tag now
stops at whitespace or another `<`; the same line takes 0.04s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wtx3dU8PQvgyubf6ZpNaG3
`bun-version: &v latest` (and `&v` with `latest` on the next line) slipped
past the `latest` check because the value was taken to be `&v`, and
`uses: &pin owner/repo@<sha>` was wrongly rejected for the same reason.
Node properties after the colon are now skipped before the value is read,
on the key's own line and on the line below it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wtx3dU8PQvgyubf6ZpNaG3
`container: &c` followed by `{ image: <pinned> }` on the next line was
read as a scalar image and rejected. A continuation that opens a `{` or
`[` collection is now left to the per-line flow scanner, which already
checks the keys inside it, so a mutable image there is still flagged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wtx3dU8PQvgyubf6ZpNaG3
@Miyamura80
Miyamura80 merged commit 9e4e07a into main Oct 30, 2026
3 checks passed
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.

2 participants