ci: add least-privilege permissions to GitHub workflows - #36
Merged
Conversation
Address CodeQL 'Workflow does not contain permissions' alerts by declaring explicit GITHUB_TOKEN permissions. - Add a top-level 'contents: read' default to both workflows so all jobs run read-only unless they opt into more. - semantic-release: contents/issues/pull-requests write for release creation and PR/issue comments. - binary: contents write to upload release assets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012piXvDqsCcLoVenm2oVCUy
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
Resolves the CodeQL "Workflow does not contain permissions" alerts (#1, #3, #8, #9, #11) on
main. Both workflows previously relied on the repository's defaultGITHUB_TOKENscope, which is broader than needed. This PR declares explicit, least-privilegepermissionsfor every job.Changes
.github/workflows/test.yamlpermissions: contents: read(thetestjob only checks out code)..github/workflows/release.yamlpermissions: contents: readas the default; read-only jobs (docker-merge,helm) inherit it.semantic-release→contents: write(create releases/tags) plusissues: write/pull-requests: write(semantic-release comments on released issues/PRs).binary→contents: write(uploads binaries to the release viaupload-release-action).dockeralready declaredcontents: read/packages: write— left unchanged.The
helmjob pushes to the external charts repo using theFLANKBOTPAT rather thanGITHUB_TOKEN, socontents: readis sufficient there.Verification
Both files parse as valid YAML and every job now has an explicit permission set (either its own override or the inherited top-level default).
🤖 Generated with Claude Code
https://claude.ai/code/session_012piXvDqsCcLoVenm2oVCUy
Generated by Claude Code