ci: add explicit permissions to GitHub Actions workflows#42
Merged
Conversation
Resolve CodeQL 'Workflow does not contain permissions' alerts by adding a restrictive top-level `permissions: contents: read` default to each workflow, following the principle of least privilege. Jobs requiring more than read access get explicit job-level grants: - build-and-test.yml: test job needs packages: read to pull the image - helm.yml: security-scan needs security-events: write to upload SARIF Existing job-level permissions (packages: write, contents: write) are left unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7v75WdVmg6AFyTWCpWjX1
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 7 open CodeQL "Workflow does not contain permissions" (Medium) code scanning alerts across all four GitHub Actions workflows.
Each workflow now declares a restrictive top-level
permissions: contents: readdefault, following the principle of least privilege. TheGITHUB_TOKENin jobs that don't need write access is now scoped to read-only, rather than inheriting the repository/organization default (which is often read-write).Changes
build-and-test.ymlcontents: read;testjob grantedpackages: read(needs todocker pullthe image from ghcr.io)test.ymlcontents: read(coverstest-env-variablesandtest-builds)helm.ymlcontents: read;security-scanjob grantedsecurity-events: write(needs to upload the Checkov SARIF results)release.ymlcontents: read(coversbuild-images-for-version-detectionandget-postgres-versions)Jobs that already declared their own
permissionsblocks (e.g.packages: write,contents: writefor pushing images, tags, and releases) are left unchanged — a top-level default only applies to jobs that don't specify their own.Verification
yaml.safe_load.🤖 Generated with Claude Code
https://claude.ai/code/session_01G7v75WdVmg6AFyTWCpWjX1
Generated by Claude Code