Skip to content

Harden and improve GitHub Actions workflows#702

Merged
wikkyk merged 6 commits intomainfrom
claude/review-github-workflows-2i3Hc
Apr 21, 2026
Merged

Harden and improve GitHub Actions workflows#702
wikkyk merged 6 commits intomainfrom
claude/review-github-workflows-2i3Hc

Conversation

@wikkyk
Copy link
Copy Markdown
Collaborator

@wikkyk wikkyk commented Apr 8, 2026

Description of changes:

A few simple tweaks to improve resilience and ergonomics of our actions.

Hardening:

  • Least-privilege permissions: Downgrade permissions add explicit permissions (resolves CodeQL alerts 34, 30, 19)
  • Expression injection hardening: Replace ${{ env.* }} interpolation with quoted shell variable expansion (interpolation happens before the expression is passed to shell, potentially allowing command injection)
  • Drop GITHUB_TOKEN from test: SonarQube doesn't need it

Ergonomics:

  • Run CI on all branches: Remove branch filters from PR triggers in test and e2e so CI runs on PRs targeting other PRs/branches; keep push limited to main.
  • Container image triggers: Only push images to GHCR on releases; PRs still build for validation
  • e2e concurrency control: Add job-level concurrency group so superseded runs for the same PR are cancelled after the new run is approved

Testing performed:

actionlint + CodeQL analyze actions
Tested triggers, e2e labels, concurrency

@wikkyk wikkyk marked this pull request as draft April 8, 2026 12:45
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from d12499c to 299c66c Compare April 8, 2026 15:27
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from 299c66c to 07a1a43 Compare April 8, 2026 20:38
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from 07a1a43 to 1c08ca0 Compare April 8, 2026 20:49
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from 1c08ca0 to 4ab569e Compare April 8, 2026 20:53
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from 4ab569e to e8d7851 Compare April 8, 2026 21:00
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from e8d7851 to a9fbcf0 Compare April 8, 2026 21:03
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from a9fbcf0 to 7215969 Compare April 8, 2026 21:05
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from 7215969 to 3ec4f33 Compare April 8, 2026 21:07
@wikkyk wikkyk marked this pull request as ready for review April 9, 2026 08:45
Copy link
Copy Markdown
Member

@mcbenjemaa mcbenjemaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,

If we don't need that GITHUB_TOKEN in the Sonar Action?

@wikkyk wikkyk marked this pull request as draft April 9, 2026 11:56
@wikkyk
Copy link
Copy Markdown
Collaborator Author

wikkyk commented Apr 9, 2026

I put it back into draft mode because I still need to test a few things (particularly dependabot and external contributor PRs). Plus, I need to fix SonarQube config.

@wikkyk wikkyk added the github_actions Pull requests that update GitHub Actions code label Apr 10, 2026
wikkyk and others added 6 commits April 17, 2026 12:41
Remove branch filters from pull_request/pull_request_target triggers
so that CI runs for PRs opened against any branch (e.g. WIP branches
like v1alpha3/wip). Restrict push triggers to main only to avoid
duplicate runs when pushing to branches with open PRs.

Co-authored-by: Claude <noreply@anthropic.com>
Rework triggers: push only fires on v* tags (no longer on branch
pushes), pull_request fires on all PRs with no branch filter.
Previously branch pushes to main/release-* would build and push
images to GHCR; now only tag releases do. PRs still build the
image for validation without pushing.

Co-authored-by: Claude <noreply@anthropic.com>
…issions

Add permissions: contents: read to test, e2e, and codespell workflows
which were missing explicit permissions blocks. Downgrade container-image
from contents: write to contents: read. Resolves CodeQL code scanning
alerts #34, #30, and #19.

Co-authored-by: Claude <noreply@anthropic.com>
Add a concurrency group keyed by PR number (or commit SHA for push
events) with cancel-in-progress. Placed at job level so the old run
continues until the new run passes its environment approval gate,
then gets cancelled.

Co-authored-by: Claude <noreply@anthropic.com>
Replace ${{ env.* }} expression interpolation with quoted shell
variable expansion to prevent potential command injection via
environment variables.

Co-authored-by: Claude <noreply@anthropic.com>
The sonarqube-scan-action only requires SONAR_TOKEN for authentication.
GITHUB_TOKEN is not used by the action.

Co-authored-by: Claude <noreply@anthropic.com>
@wikkyk wikkyk force-pushed the claude/review-github-workflows-2i3Hc branch from aa99b2e to ade227b Compare April 17, 2026 12:50
@sonarqubecloud
Copy link
Copy Markdown

@wikkyk wikkyk marked this pull request as ready for review April 17, 2026 12:56
Copilot AI review requested due to automatic review settings April 17, 2026 12:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens CAPMOX’s GitHub Actions workflows by reducing default token permissions, avoiding unsafe expression interpolation in shell commands, and improving CI ergonomics (trigger behavior, image publishing rules, and e2e run cancellation).

Changes:

  • Add explicit least-privilege permissions blocks across workflows and drop GITHUB_TOKEN from Sonar scan env.
  • Replace ${{ env.* }} interpolation in run: commands with quoted shell variable expansion.
  • Adjust CI behavior: broader PR triggering, tag-only image pushes, and job-level e2e concurrency cancellation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.github/workflows/test.yml Removes PR branch filter, adds minimal permissions, and removes GITHUB_TOKEN from Sonar steps.
.github/workflows/release.yml Hardens make invocation to use quoted shell variable expansion for RELEASE_VERSION.
.github/workflows/e2e.yml Removes PR-target branch filter, adds minimal permissions, adds concurrency cancellation, and hardens GINKGO_SKIP passing.
.github/workflows/container-image.yaml Removes branch filters from triggers and reduces contents permission to read while keeping GHCR publishing.
.github/workflows/codespell.yml Adds minimal contents: read permissions.

Comment thread .github/workflows/test.yml
Comment thread .github/workflows/e2e.yml
Copy link
Copy Markdown
Member

@mcbenjemaa mcbenjemaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wikkyk wikkyk merged commit c9797a4 into main Apr 21, 2026
17 checks passed
@wikkyk wikkyk deleted the claude/review-github-workflows-2i3Hc branch April 21, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants