ci: lint workflows with zizmor #145

Closed
opened 2026-11-14 22:32:30 +00:00 by Claude · 5 comments
Owner

Spec: Threat model: what we defend against and what we accept, resolution comment, "zizmor".

What

  • Add zizmor as a pre-commit hook from zizmorcore/zizmor-pre-commit, hook id zizmor, pinned by commit SHA with a # frozen: vX.Y.Z comment like the other hooks.
  • Override files: to ^\.gitea/workflows/[^/]+\.ya?ml$. The hook's default only matches .github/workflows.
  • Run it at zizmor's default level, offline.
  • In image.yml, remove permissions: packages: write together with the job-token probe, keep one push-token probe that fails fast, and rewrite the header comment on credentials to match (scope from Does the stand-alone rule cover issue text and job logs). First check that the latest image build's log does not name the method job-token; if it does, stop and report. The digest scrape is unchanged.
  • Since this changes an image input, bump the ci image version (scripts/bump_image_versions.py).

Acceptance

  • The hook passes on all five workflows. A throwaway workflow with pull_request_target, or with ${{ github.event.pull_request.title }} in run:, fails it. Check this locally; do not commit the throwaway.
  • Image size: every layer of the ci image stays under 100 MB. If the hook's own Python environment does not fit, switch to zizmor in requirements-dev.txt/requirements-dev.lock and a language: system hook, like the repository's other tools.
  • Lint stays green. check_bot_pr_diff.py still accepts a Renovate bump of the new hook's rev: line.

Notes

Tested on 1.32.0 (MIT): it parses all five workflows when the files are passed explicitly, and finds nothing at the default level. Not tested: the hook run itself and a config file. The rule that only image.yml and renovate.yml may reference secrets is held by CODEOWNERS review, not by zizmor. More exactly: each secret is referenced by exactly one workflow (image.yml the push credential, renovate.yml the Renovate token, release.yml the release token).

Spec: [Threat model: what we defend against and what we accept](https://git.rkdr.net/Mortis/Kamino/issues/99), resolution comment, "zizmor". ## What - Add zizmor as a pre-commit hook from `zizmorcore/zizmor-pre-commit`, hook id `zizmor`, pinned by commit SHA with a `# frozen: vX.Y.Z` comment like the other hooks. - Override `files:` to `^\.gitea/workflows/[^/]+\.ya?ml$`. The hook's default only matches `.github/workflows`. - Run it at zizmor's default level, offline. - In `image.yml`, remove `permissions: packages: write` together with the job-token probe, keep one push-token probe that fails fast, and rewrite the header comment on credentials to match (scope from [Does the stand-alone rule cover issue text and job logs](https://git.rkdr.net/Mortis/Kamino/issues/253)). First check that the latest image build's log does not name the method `job-token`; if it does, stop and report. The digest scrape is unchanged. - Since this changes an image input, bump the `ci` image version (`scripts/bump_image_versions.py`). ## Acceptance - The hook passes on all five workflows. A throwaway workflow with `pull_request_target`, or with `${{ github.event.pull_request.title }}` in `run:`, fails it. Check this locally; do not commit the throwaway. - **Image size:** every layer of the `ci` image stays under 100 MB. If the hook's own Python environment does not fit, switch to zizmor in `requirements-dev.txt`/`requirements-dev.lock` and a `language: system` hook, like the repository's other tools. - Lint stays green. `check_bot_pr_diff.py` still accepts a Renovate bump of the new hook's `rev:` line. ## Notes Tested on 1.32.0 (MIT): it parses all five workflows when the files are passed explicitly, and finds nothing at the default level. Not tested: the hook run itself and a config file. The rule that only `image.yml` and `renovate.yml` may reference secrets is held by CODEOWNERS review, not by zizmor. More exactly: each secret is referenced by exactly one workflow (`image.yml` the push credential, `renovate.yml` the Renovate token, `release.yml` the release token).
Claude added the
Status
Ready for Agent
label 2026-11-14 22:32:30 +00:00
Author
Owner

Correction to the Notes, from Enforcement map for each prose-only rule: the secrets rule is "each secret is referenced by exactly one workflow (image.yml the push credential, renovate.yml the Renovate token, release.yml the release token)". It is held by CODEOWNERS review, not by zizmor.

Correction to the Notes, from [Enforcement map for each prose-only rule](https://git.rkdr.net/Mortis/Kamino/issues/102): the secrets rule is "each secret is referenced by exactly one workflow (`image.yml` the push credential, `renovate.yml` the Renovate token, `release.yml` the release token)". It is held by CODEOWNERS review, not by zizmor.
Claude added this to the Open to contributors milestone 2026-11-15 22:21:19 +00:00
Author
Owner

ci(images): assign image versions in CI (#165) now blocks this; once it lands CI assigns the image version, so skip the bump_image_versions.py step. (From Order of the implementation backlog, #198.)

ci(images): assign image versions in CI (#165) now blocks this; once it lands CI assigns the image version, so skip the `bump_image_versions.py` step. (From Order of the implementation backlog, #198.)
Author
Owner

Review of the map (2026-11-17).

Review of the map (2026-11-17). - This issue lands after `.gitea/workflows/AGENTS.md` exists. In that file, change the held-by of the two rules zizmor now checks ("never `pull_request_target`"; "never interpolate `${{ github.* }}` into a `run:` block") from review to "control: the zizmor hook". Reason: a held-by line names a control only once it exists, and must name it once it does. - This issue is blocked by the image-version issue only because its body describes the manual image bump. Whether that edge stays is in [Which issues must land before the first friend: image versions in CI, the apm trim and the unfiled skills commit](https://git.rkdr.net/Mortis/Kamino/issues/259). - This issue moves `permissions: packages: write` to the job in `image.yml`. An older open issue calls that permission and the job-token probe dead weight; see [Does the stand-alone rule cover issue text and job logs](https://git.rkdr.net/Mortis/Kamino/issues/253), question 3.
Author
Owner

Scope added by Does the stand-alone rule cover issue text and job logs (2026-11-20): instead of moving permissions: packages: write to the job, remove it together with the job-token probe in image.yml, keeping one push-token probe that fails fast, and rewrite the header comment on credentials to match. First check that the latest image build's log does not name the method job-token; if it does, stop and report. The digest scrape is unchanged.

Scope added by [Does the stand-alone rule cover issue text and job logs](https://git.rkdr.net/Mortis/Kamino/issues/253) (2026-11-20): instead of moving `permissions: packages: write` to the job, remove it together with the job-token probe in `image.yml`, keeping one push-token probe that fails fast, and rewrite the header comment on credentials to match. First check that the latest image build's log does not name the method `job-token`; if it does, stop and report. The digest scrape is unchanged.
Author
Owner

Final validation round, second pass (2026-11-20): body edited.

  • "Move packages: write in image.yml from workflow level to the job" is replaced by the comment of 2026-11-20 (from the stand-alone-rule issue): remove it together with the job-token probe, keep one push-token probe that fails fast, rewrite the credentials header comment, and first check the latest build log does not name the method job-token.
  • The Notes carry the corrected secrets rule from the comment of 2026-11-15.
  • The comments above stay as history.
Final validation round, second pass (2026-11-20): body edited. - "Move `packages: write` in `image.yml` from workflow level to the job" is replaced by the comment of 2026-11-20 (from the stand-alone-rule issue): remove it together with the job-token probe, keep one push-token probe that fails fast, rewrite the credentials header comment, and first check the latest build log does not name the method `job-token`. - The Notes carry the corrected secrets rule from the comment of 2026-11-15. - The comments above stay as history.
Defame1297 was assigned by Claude 2026-11-21 18:44:44 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#145