Repository navigation
ci: declare least-privilege GITHUB_TOKEN permissions - #26
Merged
Merged
Conversation
Closes CodeQL alerts #2 (ci.yml) and #4 (deny.yml), both `actions/missing-workflow-permissions` (medium). Without an explicit permissions block, both workflows inherit the repository default GITHUB_TOKEN scope, which is broader than they need. Neither workflow writes to the repository: ci.yml runs fmt/clippy/ test/build, deny.yml runs cargo-deny check. `contents: read` is the minimum to allow `actions/checkout` and is sufficient for both. Matches the pattern already established in audit.yml, which scopes its broader `issues: write` permission alongside `contents: read` only because cargo-audit needs to file issues.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds explicit least-privilege permissions: contents: read blocks to ci.yml and deny.yml to resolve CodeQL actions/missing-workflow-permissions alerts. Matches the pattern already established in audit.yml.
Changes:
- Add workflow-level
permissions: contents: readto.github/workflows/ci.yml. - Add workflow-level
permissions: contents: readto.github/workflows/deny.yml.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| .github/workflows/ci.yml | Restricts GITHUB_TOKEN to read-only contents scope. |
| .github/workflows/deny.yml | Restricts GITHUB_TOKEN to read-only contents scope. |
💡 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.
Summary
Closes the two open CodeQL alerts about workflows that do not declare an explicit
permissions:block:.github/workflows/ci.yml:21(medium).github/workflows/deny.yml:14(medium)Both fired the same rule (
actions/missing-workflow-permissions). Without an explicit block, theGITHUB_TOKENused by these workflows inherits the repository's default scope, which is broader than the workflows actually need.Scope of the change
ci.ymlcontents: readdeny.ymlcargo-deny checkcontents: readcontents: readis the minimum scope required byactions/checkoutand is sufficient for both jobs.audit.ymlis unchanged: it already declarescontents: readplusissues: write(the latter only becausecargo-auditmay file issues). The new blocks here match that established pattern.Why this reappeared
The two CodeQL alerts on
deny.ymlfrom 2026-05-10 were markedfixedwhen CodeQL's earlier scan did not re-find them, but reappeared on a subsequent scan with no intervening change to the file. An explicitpermissions:block is the durable fix.Test plan
fixed.${{ github.event.* }}orhead_refinrun:blocks, so the change does not interact with workflow-injection risks called out in GitHub's guide.