chore(ci): declare least-privilege permissions for GITHUB_TOKEN#557
Open
einarwar wants to merge 1 commit into
Open
chore(ci): declare least-privilege permissions for GITHUB_TOKEN#557einarwar wants to merge 1 commit into
einarwar wants to merge 1 commit into
Conversation
Explicitly set the GITHUB_TOKEN permissions on every workflow rather
than relying on the repository default. Each workflow now requests only
the scopes it actually needs:
- publish-image: contents:read, packages:write (push to ghcr.io)
- publish-docs: contents:write (force-push to gh-pages branch)
- tests: contents:read, packages:read (pull ghcr images)
- linting-and-checks: contents:read
- release-please: contents:read (uses an App token for writes)
- on-pull-request /
on-push-main-branch: contents:read at workflow level, with per-job
elevation where reusable workflows need more
than the caller (publish jobs, docs job, tests
job)
deploy-to-radix and rollback already declared explicit permissions and
are unchanged.
There was a problem hiding this comment.
Pull request overview
This PR explicitly declares least-privilege permissions: for the GITHUB_TOKEN across the repository’s GitHub Actions workflows, avoiding reliance on repository-default token scopes and ensuring reusable workflows are not implicitly over-privileged.
Changes:
- Added workflow-level
permissions:blocks to reusable workflows (tests,linting-and-checks,publish-image,publish-docs,release-please) matching their actual token needs. - Added workflow-level
contents: readto the caller workflows (on-pull-request,on-push-main-branch) and elevated permissions per-job where required by called reusable workflows (packages read/write, contents write). - Kept the existing pattern where caller-job permissions can be higher when a reusable workflow requires it (due to GitHub’s caller/callee permission constraints).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/tests.yaml | Declares contents: read + packages: read for pulling GHCR images and checkout. |
| .github/workflows/release-please.yaml | Declares contents: read for minimal repo read access. |
| .github/workflows/publish-image.yaml | Declares contents: read + packages: write for building and pushing images to GHCR. |
| .github/workflows/publish-docs.yaml | Declares contents: write to enable force-pushing to gh-pages. |
| .github/workflows/on-push-main-branch.yaml | Adds workflow-level contents: read and per-job permission elevation for reusable workflow calls. |
| .github/workflows/on-pull-request.yaml | Adds workflow-level contents: read and per-job packages: read for tests. |
| .github/workflows/linting-and-checks.yaml | Declares contents: read for checkout-based linting/checks steps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Explicitly set
permissions:on every workflow rather than relying on the repository defaultGITHUB_TOKENscopes. Each workflow now requests only what it actually needs.publish-imagecontents: read,packages: write(push to ghcr.io)publish-docscontents: write(force-push togh-pages)testscontents: read,packages: read(pull ghcr images)linting-and-checkscontents: readrelease-pleasecontents: read(uses a GitHub App token for writes)on-pull-request/on-push-main-branchcontents: readat workflow level, with per-job elevation where reusable workflows need more than the callerdeploy-to-radixandrollbackalready declared explicit permissions and are unchanged.Why per-job permissions on the callers?
GitHub will not let a called reusable workflow exceed the caller job's permissions, so the publish/docs/tests jobs in
on-push-main-branch.yaml(and the tests job inon-pull-request.yaml) explicitly elevate theirpackages/contentsscopes.