chore(ci): declare explicit GITHUB_TOKEN permissions on unscoped jobs - #73
Merged
Merged
Conversation
Closes the three open `actions/missing-workflow-permissions` code scanning
alerts. The org and repo defaults are already read-only, so this is
defense-in-depth rather than a live over-grant — but it stops the workflows
depending on a setting that could be flipped later.
- test: contents: read. The job only checks out the repo, but `npm install`
executes arbitrary postinstall scripts, so pinning the scope explicitly is
the one that carries real weight.
- create-release: contents: write. CodeQL suggests `contents: read` here, but
the job pushes the version commit to main and creates the release branch;
read would break the `secrets.ACTIONS_TOKEN || github.token` fallback.
- create-summary: {}. Only writes to $GITHUB_STEP_SUMMARY.
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 three open
actions/missing-workflow-permissionscode scanning alerts by adding an explicitpermissionsblock to each job that lacked one.Worth being clear about the severity: the org and repo already set
default_workflow_permissions: read, so the token in these jobs is already read-only at runtime. CodeQL is flagging the absence of a declaration, not an actual over-grant. The value here is that the workflows stop depending on an org setting someone could flip later, and the intent becomes self-documenting.Changes
test.yml→testcontents: readcreate-release.yml→create-releasecontents: writemainand creates the release branchcreate-release.yml→create-summary{}$GITHUB_STEP_SUMMARYTwo things worth a reviewer's attention
CodeQL's suggested fix for
create-releaseis wrong. It recommendscontents: read, but that job pushes a version commit tomainand creates the release branch. It checks out with${{ secrets.ACTIONS_TOKEN || github.token }}—readwould break the fallback path.writeboth satisfies the alert and repairs a latent break, since that fallback is already dead today under the read-only default.The
testjob change is the one that carries real weight. It runsnpm install, which executes arbitrary postinstall scripts. Fork PRs already get a read-only token on a public repo, but pushes tomaindon't — so pinning that job explicitly is genuine defense-in-depth against a compromised transitive dependency.Verification
format:check,lint,test(22 passed).