Skip to content

cimas-master: add least-privilege permissions: to 6 caller templates - #339

Merged
opoudjis merged 1 commit into
mainfrom
fix/cimas-master-template-permissions
Jul 12, 2026
Merged

cimas-master: add least-privilege permissions: to 6 caller templates#339
opoudjis merged 1 commit into
mainfrom
fix/cimas-master-template-permissions

Conversation

@andrew2net

@andrew2net andrew2net commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Adds an explicit least-privilege top-level permissions: block to the six cimas master caller templates (cimas-config/gh-actions/master/) that previously had none. These templates sync to downstream standalone gem repos, so a missing permissions: meant each synced repo inherited the over-broad default GITHUB_TOKEN and got flagged by CodeQL actions/missing-workflow-permissions.

Each ceiling is sized to what the called reusable workflow actually needs (the caller's top-level permissions: caps the reusable's GITHUB_TOKEN):

Template Permissions Why
release.yml, release_wo_bundle_install.yml contents: write + id-token: write rubygems-release.yml release job: git tag push + OIDC Trusted Publishing
release_github_packages.yml contents: write + packages: write ghpkg-release.yml: tag push via GITHUB_TOKEN; gem push uses pat_token
notify.yml contents: read mn-processor-notify.yml: dispatch via pat_token only
rake-flavor.yml contents: read mn-processor-rake.yml already tops at contents: read
automerge.yml contents: write + pull-requests: write pascalgn/automerge-action merges PRs via GITHUB_TOKEN

master/rake.yml already carried contents: write and is unchanged. Also fixes a pre-existing missing-EOF-newline in release_github_packages.yml.

Context / scope note

This originated from a metanorma/pubid hand-off asking to fix the "source templates" behind pubid's generic-rake.yml / rubygems-release.yml. During investigation:

  • metanorma/ci's own reusable generic-rake.yml and rubygems-release.yml already carry least-privilege permissions — no change needed there.
  • pubid is not currently cimas-synced (cimas.yml lists it PENDING-READD, gated on cimas revival: design gaps and mandatory drift-audit before each sync #300 Gap 2), and its workflows are pubid-local + diverged — so no metanorma/ci change reaches pubid today.
  • The genuine upstream gap was these master caller templates, which this PR closes for every downstream standalone repo on its next sync.

pubid's own 5 alerts are addressed separately by hardening pubid's local workflows directly (safe while sync is paused) — tracked out-of-band, not part of this PR.

Validation

Repo CI is yamllint + actionlint + shellcheck (no rspec). Locally verified: all 6 files parse as valid YAML with the intended scopes; no trailing whitespace, lines ≤140, files end with a newline; only the 6 templates changed. yamllint/actionlint run in CI on push.

The cimas `master` caller templates that sync to downstream standalone gem
repos lacked a `permissions:` block, so every synced repo inherited the
over-broad default GITHUB_TOKEN and got flagged by CodeQL
`actions/missing-workflow-permissions`.

Add an explicit least-privilege top-level `permissions:` ceiling to each,
sized to what the called reusable workflow actually needs (the caller's
top-level permission caps the reusable's GITHUB_TOKEN):

- release.yml / release_wo_bundle_install.yml -> contents:write + id-token:write
  (rubygems-release.yml: git tag push + OIDC Trusted Publishing)
- release_github_packages.yml -> contents:write + packages:write
  (ghpkg-release.yml: tag push via GITHUB_TOKEN; gem push uses pat_token)
- notify.yml -> contents:read (mn-processor-notify.yml: dispatch via pat_token)
- rake-flavor.yml -> contents:read (mn-processor-rake.yml tops at read)
- automerge.yml -> contents:write + pull-requests:write (pascalgn/automerge-action)

master/rake.yml already carried contents:write and is unchanged. Also fixes a
pre-existing missing EOF newline in release_github_packages.yml.

Note: the originating hand-off (metanorma/pubid) assumed these clear pubid's
alerts on re-sync, but pubid is currently PENDING-READD (not cimas-synced,
gated on #300 Gap 2), so pubid's own alerts are addressed separately by
hardening its local workflows directly.
@andrew2net
andrew2net force-pushed the fix/cimas-master-template-permissions branch from 1e884f4 to eadff8b Compare July 3, 2026 02:47
@andrew2net
andrew2net requested a review from opoudjis July 3, 2026 02:51
@opoudjis

opoudjis commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Ack — this is well-scoped and reads cleanly. Deliberately keeping it out of the wave I'm firing tonight (which carries a release.yml template fix from Koonwa's lutaml#285 discovery, the rubocop template correction from 2026-07-07, and a broader-orphan cleanup) so it can carry Ronald's review on its own merits. Will fold into the next wave once merged.

🤖

@opoudjis

opoudjis commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@ronaldtse — flagging that this is now blocking the CodeQL missing-permissions: finding class from being retired across the fleet. Tonight's cimas sync wave opened 83 PRs, and CodeQL is re-surfacing the same "workflow does not contain permissions" finding on release.yml (and related) on each affected gem — e.g. coradoc#248 (review 4646568938) is the representative case.

Your approval on this PR unblocks the fix — the six template permissions: blocks fold into the next cimas sync wave and retire the finding fleet-wide. Review lives on this PR directly (Files changed tab has the six diffs with per-template ceilings and rationale).

🤖

@opoudjis
opoudjis requested a review from ronaldtse July 9, 2026 00:21
@opoudjis
opoudjis merged commit 32a3f61 into main Jul 12, 2026
68 checks passed
@opoudjis
opoudjis deleted the fix/cimas-master-template-permissions branch July 12, 2026 11:02
opoudjis added a commit to metanorma/cimas that referenced this pull request Jul 12, 2026
…ded on main

Wave PRs from 2026-07-08 taken to closure: 78 admin-merged (58 sync +
20 cleanup), 3 DIRTY closed (re-emit next wave), 1 wrong-org retried.
93 branches cleaned across origin + local checkouts via cleanup-merged-prs.

metanorma/ci#339 (Andrew's least-privilege permissions on 6 master
caller templates) and #348 (class F Ruby-floor drift audit) both
merged on main — distribute / activate on next cadence.

Mass-fail mn-templates-* PRs merged despite red CI: attributable to
the 2026-07-09 lutaml/xmi gem-yank fallout, not to wave content.
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.

3 participants