security: add least-privilege permissions to release workflows#119
Merged
Conversation
Resolves CodeQL actions/missing-workflow-permissions MEDIUM alerts in
release.yml (jobs: release, bump-modules) and module-release.yml
(jobs: prepare-release, release-module).
Top-level `permissions: {}` added to both files to deny all scopes by
default. Each job is granted only the minimum scopes its steps require:
release.yml / release:
contents: write — gh release create, upload asset, git push branch (module-path PR)
pull-requests: write — gh pr create for v2+ module-path update
release.yml / bump-modules:
contents: write — callee (auto-bump-modules) commits, pushes, merges
pull-requests: write — callee creates and merges bump PR
actions: read — callee reads workflow run status (mirrors callee declaration)
checks: write — callee writes check results (mirrors callee declaration)
module-release.yml / prepare-release:
contents: read — checkout + git tag list + find modules (read-only)
module-release.yml / release-module:
contents: write — gh release create, git push origin "$TAG", git push branch
pull-requests: write — gh pr create for v2+ module-path update
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Fixes CodeQL
actions/missing-workflow-permissionsMEDIUM alerts in two release workflows by adding a top-levelpermissions: {}deny-all default and explicit least-privilegepermissions:blocks on each job.No workflow logic was changed — only
permissions:keys were added.Permissions added per job
release.ymlTop-level (new):
Denies all scopes by default; jobs below grant only what they need.
releasejob (was flagged ~line 46):Reasoning: the
Create releasestep runsgh release create … "$ARCHIVE"(uploads asset →contents: write). TheCreate PR for module path updatestep runsgit push origin "$BRANCH_NAME"andgh pr create→ both needcontents: write+pull-requests: write.bump-modulesjob (was flagged ~line 441):Reasoning:
bump-modulesis auses:delegation toauto-bump-modules.yml, which already declares these four scopes in its own top-levelpermissions:block. When a reusable workflow is called, the caller's GITHUB_TOKEN permissions bound what the callee receives — so the caller must carry at least the scopes the callee needs.module-release.ymlTop-level (new):
prepare-releasejob (read-only prep):Reasoning: this job only reads the repo (checkout,
git tag -l,find modules). No writes anywhere.release-modulejob (was flagged ~line 104):Reasoning: the
Create releasestep runsgh release createand thengit push origin "$TAG"(tag push →contents: write). TheCreate PR for module path updatestep runsgit push origin "$BRANCH_NAME"andgh pr create→contents: write+pull-requests: write.Test plan
python3 -c "import yaml; yaml.safe_load(open(f))"passes for both files — confirmed locally before push)Releaseworkflow (workflow_dispatch) on a patch bump and confirm thereleasejob andbump-modulesjob both complete successfullyModule Releaseworkflow and confirmprepare-release+release-moduleboth complete successfullyactions/missing-workflow-permissionsalerts are resolved after the next scan🤖 Generated with Claude Code