ci: set least-privilege GITHUB_TOKEN permissions in workflow#28
Merged
Conversation
Add a top-level `permissions: contents: read` block so GITHUB_TOKEN is scoped to read-only instead of the repo/org default. Both jobs only read the repo (checkout, install, lint, typecheck, test, audit), so no job needs write access. Resolves the two open code-scanning alerts (actions/missing-workflow-permissions). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
.github/workflows/ci.ymldeclared nopermissions:block, soGITHUB_TOKENran with the repository/organization default scopes on every job. GitHub code scanning flagged this as two openactions/missing-workflow-permissionsalerts (one per job, atci.yml:16andci.yml:50). An over-privileged token is a needless supply-chain risk: a compromised or malicious action step could use it to write to the repo.Solution
Set a single top-level least-privilege block:
Declaring it once at the workflow level (rather than per-job) is the smallest change that satisfies the scanner and covers both jobs, since neither needs more:
build-and-testandauditonly checkout, install, lint, typecheck, test, and runnpm audit— all read-only operations. Any future job that genuinely needs to write (e.g. publishing, commenting) can opt into a wider scope with its own job-levelpermissions:without loosening the default for everything else. A code comment records that reasoning inline.No behavior change to the build/test pipeline — CI runs identically, just with a tighter token.
Fixes #24
Refs #27
🤖 Generated with Claude Code