Skip to content

ci: harden GitHub Actions workflows#396

Merged
flavorjones merged 7 commits intomainfrom
flavorjones/harden-github-actions
Mar 20, 2026
Merged

ci: harden GitHub Actions workflows#396
flavorjones merged 7 commits intomainfrom
flavorjones/harden-github-actions

Conversation

@flavorjones
Copy link
Member

@flavorjones flavorjones commented Mar 19, 2026

Summary

  • Pin all actions to SHA hashes with version comments via pinact
  • Fix zizmor findings: excessive-permissions, artipacked, template-injection, dependabot-cooldown
  • Move workflow-level permissions to per-job least-privilege grants with permissions: {} at workflow level
  • Add zizmor + actionlint CI job
  • Configure dependabot with weekly batching and cooldown on all ecosystems

Test plan

  • CI passes on this branch
  • Verify zizmor reports clean: zizmor .

Set permissions: {} at workflow level in publish-image.yml and move
permissions down to each individual job: build gets contents/packages,
manifest gets contents/packages/id-token for cosign keyless signing.
- Add persist-credentials: false to all checkout steps (artipacked)
- Add permissions: {} workflow-level and contents: read per-job in ci.yml (excessive-permissions)
- Add cooldown: default-days: 10 to both dependabot ecosystems (dependabot-cooldown)
Copilot AI review requested due to automatic review settings March 19, 2026 20:22
Copy link

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 the repository’s GitHub automation by tightening GitHub Actions security (pinning action refs, reducing default permissions, and adding workflow lint/audit jobs) and by adjusting Dependabot update behavior.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Pin GitHub Actions to commit SHAs and reduce default workflow permissions to permissions: {} with per-job grants.
  • Update the image publish workflow to reduce injection risk by avoiding direct ${{ ... }} interpolation inside shell scripts.
  • Add a CI job to run actionlint and zizmor, and expand Dependabot config (grouping + cooldown).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/publish-image.yml Pins actions, reduces default permissions, and hardens shell steps used in image publishing/signing.
.github/workflows/ci.yml Pins actions, reduces default permissions, and adds an actions audit job (actionlint + zizmor).
.github/dependabot.yml Adds grouping for GitHub Actions updates and introduces cooldown configuration.
Comments suppressed due to low confidence (1)

.github/workflows/publish-image.yml:57

  • build runs on pull_request, but the GHCR login step runs unconditionally. Since the image isn’t pushed on PRs (push: false), this login is unnecessary and can fail on fork PRs due to restricted token permissions. Consider gating the login step (and any other registry-auth-dependent steps) with if: github.event_name != 'pull_request' so PR builds don’t attempt to authenticate to GHCR.
      - name: Log in to GHCR
        uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -28,6 +24,9 @@ jobs:
name: Build and push image (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

The build job requests packages: write, but on pull_request runs it never pushes images (and can be configured to skip registry login). This is broader than necessary for PR builds, and undermines the least-privilege goal of the PR. To fully minimize privileges, consider splitting PR builds vs. publish builds into separate jobs/workflows so only the publish path gets packages: write.

Suggested change
timeout-minutes: 45
timeout-minutes: 45
if: github.event_name != 'pull_request'

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

The build job needs packages: write because it pushes images on non-PR events (tag pushes). The workflow uses a single job definition for both paths. Splitting by event trigger would add complexity without meaningful security benefit since the token is scoped to this repo's packages.

Replaces the generic default-days cooldown with semver-granular values so
low-risk patches flow faster while major bumps get more soak time. Also
corrects github-actions cooldown from 10 days to 7 days.
Copilot AI review requested due to automatic review settings March 20, 2026 15:20
@flavorjones flavorjones force-pushed the flavorjones/harden-github-actions branch from 8bd56eb to 7a56e02 Compare March 20, 2026 15:20
Copy link

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +15
cooldown:
semver-major-days: 7
semver-minor-days: 3
semver-patch-days: 2
default-days: 7
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

PR description says a 10-day Dependabot cooldown, but this bundler entry sets shorter values (e.g., default/major 7 days, minor 3, patch 2). Please align the configuration with the stated 10-day cooldown (or update the PR description if 7/3/2 is intended).

Copilot uses AI. Check for mistakes.
@flavorjones flavorjones merged commit 5aa5e68 into main Mar 20, 2026
11 checks passed
@flavorjones flavorjones deleted the flavorjones/harden-github-actions branch March 20, 2026 15:32
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