Add explicit least-privilege permissions to read-only CI workflows#657
Open
arpitjain099 wants to merge 1 commit into
Open
Add explicit least-privilege permissions to read-only CI workflows#657arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
Seven workflows currently declare no permissions block at all, which leaves GITHUB_TOKEN scope dependent on the repository default. Adding an explicit workflow-level contents: read documents the minimum scope needed and matches GitHub's defense-in-depth guidance. Workflows touched (all are pure CI - build, lint, docs, tests, spell check, version consistency check). None push commits, create releases, or call write APIs: - build.yaml - code-formatting-check.yaml - docs.yaml - local-development-makefile.yaml - test.yaml - typos.yaml - version-checks.yaml Existing workflows that need elevated scopes (cargo-audit, codeql, github-dependency-review, lint) already declare per-job permissions; this PR does not modify those. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens GitHub Actions security by explicitly setting least-privilege GITHUB_TOKEN permissions (contents: read) for CI workflows that previously relied on the repository default token permissions.
Changes:
- Add workflow-level
permissions: contents: readto 7 CI workflows to make read-only intent explicit. - Align these workflows with the repo’s existing pattern of explicitly declaring permissions (especially for workflows that need elevated scopes).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/build.yaml | Adds explicit workflow-level contents: read token permissions. |
| .github/workflows/code-formatting-check.yaml | Adds explicit workflow-level contents: read token permissions. |
| .github/workflows/docs.yaml | Adds explicit workflow-level contents: read token permissions. |
| .github/workflows/local-development-makefile.yaml | Adds explicit workflow-level contents: read token permissions. |
| .github/workflows/test.yaml | Adds explicit workflow-level contents: read token permissions. |
| .github/workflows/typos.yaml | Adds explicit workflow-level contents: read token permissions. |
| .github/workflows/version-checks.yaml | Adds explicit workflow-level contents: read token permissions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
+14
| permissions: | ||
| contents: read | ||
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #657 +/- ##
=======================================
Coverage 78.69% 78.69%
=======================================
Files 25 25
Lines 5234 5234
Branches 5234 5234
=======================================
Hits 4119 4119
Misses 995 995
Partials 120 120 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
45fcee0 to
bcb5fff
Compare
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
Adds a workflow-level
permissions: contents: readblock to seven workflows that currently declare no permissions at all:build.yamlcode-formatting-check.yamldocs.yamllocal-development-makefile.yamltest.yamltypos.yamlversion-checks.yamlWhy
All seven are pure CI workflows — build, format check, docs build, makefile compile, tests,
typosspell check, and version consistency check. None push commits, create releases, comment on PRs, or call any GitHub API endpoint that needs write scopes. TheGITHUB_TOKENfor these workflows only needs read access for the checkout step, so declaringcontents: readat the workflow level documents the minimum scope and removes reliance on the repository default token permissions.This matches the existing project pattern: workflows that need elevated scopes (
cargo-audit.yaml,codeql.yaml,github-dependency-review.yaml,lint.yaml) already declare them at the job level. This PR fills the gap for the read-only workflows that were leaving scope implicit.Verification
python3 -c "import yaml; yaml.safe_load(open(...))"passes on each of the seven files.permissions:block is added.Reference