Add explicit GITHUB_TOKEN permissions to workflows - #47
Merged
Conversation
Resolves the four open `actions/missing-workflow-permissions` CodeQL alerts. Each scope is the least privilege the job actually needs: - build.yml (#5): workflow-level `contents: read`. The single `build` job only checks out, restores an `actions/cache` entry, and runs `npm ci` / `npm run build:prod` / `npm test`. Neither setup-node nor actions/cache needs a token scope beyond reading the repo. - publish.yml (#1): workflow-level `contents: read`. Despite the name, this tag-triggered job does not publish anything — it runs `vsce package` and hands the .vsix to `actions/upload-artifact`. Uploading an artifact needs no extra scope, there is no `vsce publish`, no `gh release create`, and no `npm publish`, so no write scope is warranted. The Marketplace release is done off the artifact, not by this token. - stale.yml (#2): job-level `issues: write` + `pull-requests: write`. The shared-config stale workflow runs `actions/stale`, which comments on and closes both stale issues and stale PRs. A caller's permissions are the ceiling for the reusable workflow, so both scopes must be granted here or the nightly cron silently stops closing things. - triage.yml (#4): job-level `issues: write`. The shared-config triage workflow only runs `gh issue edit --add-label triage`. Callers use job-level blocks immediately above `uses:`, matching the accepted precedent in rubyatscale/query_packwerk. codeql.yml already declares its permissions and is left untouched.
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.
Resolves the four open
actions/missing-workflow-permissionsCodeQLalerts. Each scope is the least privilege the job actually needs:
contents: read. The singlebuildjob only checks out, restores an
actions/cacheentry, and runsnpm ci/npm run build:prod/npm test. Neither setup-node noractions/cache needs a token scope beyond reading the repo.
contents: read. Despite the name,this tag-triggered job does not publish anything — it runs
vsce packageand hands the .vsix toactions/upload-artifact.Uploading an artifact needs no extra scope, there is no
vsce publish, nogh release create, and nonpm publish, so nowrite scope is warranted. The Marketplace release is done off the
artifact, not by this token.
issues: write+pull-requests: write.The shared-config stale workflow runs
actions/stale, which commentson and closes both stale issues and stale PRs. A caller's permissions
are the ceiling for the reusable workflow, so both scopes must be
granted here or the nightly cron silently stops closing things.
issues: write. The shared-config triageworkflow only runs
gh issue edit --add-label triage.Callers use job-level blocks immediately above
uses:, matching theaccepted precedent in rubyatscale/query_packwerk. codeql.yml already
declares its permissions and is left untouched.
Alerts resolved
actions/missing-workflow-permissions(medium) —.github/workflows/build.yml:11actions/missing-workflow-permissions(medium) —.github/workflows/triage.yml:9actions/missing-workflow-permissions(medium) —.github/workflows/stale.yml:8actions/missing-workflow-permissions(medium) —.github/workflows/publish.yml:8Verification
permissions:block (cross-checked by parsing the YAML against the alert list).actionlintoutput is byte-identical tomain— no new findings introduced.codeql.ymluntouched.