Add explicit least-privilege permissions to read-only CI workflows#657
Add explicit least-privilege permissions to read-only CI workflows#657arpitjain099 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>
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.
| 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% 79.45% +0.75%
==========================================
Files 25 26 +1
Lines 5234 5500 +266
Branches 5234 5500 +266
==========================================
+ Hits 4119 4370 +251
- Misses 995 1001 +6
- Partials 120 129 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
45fcee0 to
bcb5fff
Compare
|
Hi @svasista-ms, gentle ping on this. PR has been open for 4 days without review. I noticed you've been on the recent-merger side of recent merges in this repo. When you have a moment, would you mind giving it a quick look? No urgency. Happy to address any feedback. |
|
Thanks for the PR @arpitjain099. We verified that the default A couple of small asks before we merge:
I have approved the workflows. Once these issues are addressed and workflows pass, this is GTG. Thanks again! |
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