Add minimal GITHUB_TOKEN permissions to workflows#416
Merged
Conversation
Fixes the missing-workflow-permissions code scanning alerts by adding explicit least-privilege permissions blocks. Most workflows only need contents: read (publishing uses dedicated secret tokens). The Java, Java7, and Rust release jobs additionally get job-level write scopes: contents: write for tag/release creation, plus pull-requests: write for release-plz. codeql.yml already sets job-level permissions, so it's unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
The build/test jobs for every language ( |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the repository’s GitHub Actions workflows by explicitly setting least-privilege GITHUB_TOKEN permissions, addressing actions/missing-workflow-permissions code-scanning alerts and reducing token blast radius.
Changes:
- Added top-level
permissions: contents: readto workflows that only need to check out and build/test/publish via external registry tokens. - Added job-level permission overrides for release jobs that need to create tags/releases or open PRs (
contents: write, pluspull-requests: writefor Rust). - Left existing CodeQL workflow permissions as-is (already explicitly set).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/rust.yml | Adds top-level read-only permissions; grants write permissions only to the publish job for release automation. |
| .github/workflows/ruby.yml | Adds top-level contents: read permissions. |
| .github/workflows/python.yml | Adds top-level contents: read permissions. |
| .github/workflows/php.yml | Adds top-level contents: read permissions. |
| .github/workflows/node.yml | Adds top-level contents: read permissions. |
| .github/workflows/java7.yml | Adds top-level contents: read; grants contents: write to the GitHub release job. |
| .github/workflows/java.yml | Adds top-level contents: read; grants contents: write to the GitHub release job. |
| .github/workflows/go.yml | Adds top-level contents: read permissions. |
| .github/workflows/csharp.yml | Adds top-level contents: read permissions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Explain why PRs that don't touch every language produce a neutral "configurations not found" code scanning result, and that the check shouldn't require a success conclusion in branch protection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lboynton
approved these changes
Jun 18, 2026
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
Adds explicit, least-privilege
permissionsblocks to the workflows that lacked one, fixing theactions/missing-workflow-permissionscode-scanning alerts. RestrictingGITHUB_TOKENto the minimum needed limits the blast radius if a step or dependency is compromised.Changes
Top-level
permissions: contents: read— read-only is sufficient (checkout only; publishing uses dedicated secret tokens, not GitHub write scopes):csharp.ymlNUGET_API_KEY)go.ymlnode.ymlNPM_TOKEN)php.ymldeploy_keypython.ymlPYPI_API_TOKEN)ruby.ymlGEM_HOST_API_KEY)Top-level
contents: read+ a job-level write grant — these have release jobs that genuinely need write access, so a blanketreadwould break them:java.yml/java7.yml— thecreate_github_releasejob getscontents: write(git tag viamathieudutour/github-tag-action+ release viasoftprops/action-gh-release).rust.yml— thepublishjob getscontents: write+pull-requests: write(release-plzopens release PRs and creates tags/releases).A job-level
permissionsblock fully overrides the top-level one, so each release job lists exactly the scopes it needs while every other job inherits the safecontents: read.Not changed:
codeql.ymlalready definespermissionson both of its jobs, so no alert fires there.🤖 Generated with Claude Code