Skip to content

ci: add explicit permissions to GitHub Actions workflows#42

Merged
adityathebe merged 1 commit into
mainfrom
claude/pull-request-3p56u3
Jul 17, 2026
Merged

ci: add explicit permissions to GitHub Actions workflows#42
adityathebe merged 1 commit into
mainfrom
claude/pull-request-3p56u3

Conversation

@adityathebe

Copy link
Copy Markdown
Member

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: read default, following the principle of least privilege. The GITHUB_TOKEN in 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

Workflow Fix
build-and-test.yml Top-level contents: read; test job granted packages: read (needs to docker pull the image from ghcr.io)
test.yml Top-level contents: read (covers test-env-variables and test-builds)
helm.yml Top-level contents: read; security-scan job granted security-events: write (needs to upload the Checkov SARIF results)
release.yml Top-level contents: read (covers build-images-for-version-detection and get-postgres-versions)

Jobs that already declared their own permissions blocks (e.g. packages: write, contents: write for pushing images, tags, and releases) are left unchanged — a top-level default only applies to jobs that don't specify their own.

Verification

  • All four workflow files validated with yaml.safe_load.
  • Reviewed each job's steps to confirm the granted scopes match what the job actually does (checkout, pull/push images, upload SARIF, push tags/releases).

🤖 Generated with Claude Code

https://claude.ai/code/session_01G7v75WdVmg6AFyTWCpWjX1


Generated by Claude Code

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
@adityathebe
adityathebe merged commit 1e2a7a0 into main Jul 17, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants