Scope workflow GITHUB_TOKEN permissions per job#60
Merged
Conversation
Replace permissions: read-all with the minimal contents: read. The three jobs that inherit the top-level default (format, build-the-world, branding-guide-changelog) only need to read the repo; the two jobs that need more (compare-artifacts-build, compare-artifacts-comment) already declare their own permissions blocks. Clears a zizmor excessive-permissions finding.
Drop the workflow-wide contents: write in release-guide.yml (top-level
permissions: {}) and grant the minimum per job: release gets contents: write
for gh release create; the reusable-workflow callers grant the ceiling their
callees need -- check (contents: read), release-npm-package (id-token: write
for OIDC + contents: read), and deploy (contents/statuses/deployments: write
for the Netlify commit-comment, commit-status, and GitHub-deployment
integrations). Add the matching permissions block to netlify-deploy.yml so it
is explicit on both the release and manual paths.
Per GitHub's model a reusable workflow's token is set by the caller and can
only be reduced, so id-token: write must sit on the calling job. Clears the
remaining zizmor excessive-permissions findings.
Artifact comparison0 modified · 0 added · 0 deleted · 96 unchanged Download report — HTML file; open in a browser. Compared
|
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
Scopes the
GITHUB_TOKENpermissions across the workflows — the last of the zizmor findings.check.yml:read-all→contents: read(the two jobs needing more already declare their own blocks).release-guide.yml: top-levelcontents: write→{}, granted per job:release→contents: write(gh release create)check→contents: readrelease-npm-package→id-token: write+contents: read(npm OIDC)deploy→contents: write+statuses: write+deployments: write(Netlify commit-comment / commit-status / GitHub-deployment integrations)netlify-deploy.yml: explicitpermissionsblock matching those integrations, so it is scoped on both the release and manual (workflow_dispatch) paths.Why
The workflow-wide
contents: writeandread-allgave every job more access than it needs. A reusable workflow's token is set by the caller and can only be reduced, so each calling job now grants exactly its callee's need — notablyid-token: writefor the npm OIDC publish must sit on the calling job (reuse-workflows docs).The Netlify deploy keeps its three GitHub integrations (commit comment, commit status, and a
productiondeployment record — all pointing atbrand.nixos.org), so its job retainscontents/statuses/deployments: write, now scoped to that one job instead of the whole workflow.Verification
actionlint: cleanzizmor: 0 findings. This clears theexcessive-permissionsset; earlier PRs cleared unpinned-uses, template-injection, artipacked, and superfluous-actions.Not verified
Permissions only take effect at runtime on privileged events — an actual tag-push release and a manual Netlify deploy — which can't be exercised locally. On the next release, watch the npm OIDC publish (
id-token: writeon the calling job) and the Netlify integrations (contents/statuses/deployments: write).