ci: adopt zizmor and harden GitHub Actions workflows - #39
ci: adopt zizmor and harden GitHub Actions workflows#39hasansezertasan wants to merge 3 commits into
Conversation
Add zizmor (as a pre-commit hook, which runs in the existing validate
CI job) to statically analyze GitHub Actions, and resolve every
finding it reports:
- Pin all third-party and first-party actions to full commit SHAs
(unpinned-uses), with the version tag kept as a trailing comment.
- Set persist-credentials: false on every checkout (artipacked).
- Add top-level 'permissions: {}' with least-privilege per-job grants
(excessive-permissions).
- Disable uv caching on the release-triggered docs and publish
workflows (cache-poisoning).
- Replace the archived sonarsource/sonarcloud-github-action@master
with SonarSource/sonarqube-scan-action, pinned to v6 (v4-v5 are
vulnerable to argument injection, GHSA-5xq9-5g24-4g6f) and add
SONAR_HOST_URL for SonarQube Cloud.
- Bump github/codeql-action from the retired v2 to v3.
- Add a 7-day dependabot cooldown (dependabot-cooldown), mirroring the
uv exclude-newer policy.
Closes #22
Reviewer's GuideThis PR integrates zizmor as a pre-commit hook to statically analyze GitHub Actions and remediates all reported issues by pinning actions to SHAs, tightening permissions, disabling unsafe caches, migrating Sonar scanning, bumping CodeQL, and adding a Dependabot cooldown, without introducing new workflows. Sequence diagram for validate job running zizmor via pre-commitsequenceDiagram
actor Developer
participant GitHub
participant ci_validate_job
participant pre_commit
participant zizmor
Developer->>GitHub: push or open_pull_request
GitHub->>ci_validate_job: trigger ci.yaml validate
ci_validate_job->>pre_commit: pre-commit run --all-files
pre_commit->>zizmor: run zizmor
zizmor-->>ci_validate_job: findings for workflows and dependabot
ci_validate_job-->>GitHub: job status with zizmor as required check
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Add .github/workflows/zizmor.yml using zizmorcore/zizmor-action to upload zizmor findings as SARIF to the GitHub Security tab for stateful, incremental triage. Complements the blocking pre-commit hook, which provides the hard CI gate and local developer feedback. Refs #22
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Add a codecov job to the CI workflow that consumes the existing coverage-xml artifact and uploads it via codecov/codecov-action, plus a root codecov.yml (auto targets, patch coverage, PR comments) and a coverage badge in the README. Adapted from #16. Stacked on the zizmor hardening (#39): the codecov job uses SHA-pinned actions, persist-credentials: false, and a least-privilege permissions block so it passes the zizmor pre-commit gate. Closes #24
There was a problem hiding this comment.
Pull request overview
This PR hardens the repository’s GitHub Actions posture by introducing zizmor-based static analysis (both as a blocking pre-commit hook and as a SARIF-uploading workflow) and tightening workflow security across CI, release, docs, and CodeQL automation.
Changes:
- Add zizmor as a pre-commit hook and introduce a dedicated zizmor workflow that uploads SARIF to the Security tab.
- Harden workflows by setting default
permissions: {}, adding least-privilege per-job permissions, SHA-pinning actions, and disablingpersist-credentialsonactions/checkout. - Update automation configuration: migrate Sonar scan action, bump CodeQL action to v3, disable uv caching in release-triggered workflows, and add a Dependabot cooldown window.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| .pre-commit-config.yaml | Adds zizmor as a required pre-commit hook so workflow security checks run in existing CI validation. |
| .github/workflows/zizmor.yml | New zizmor workflow to produce/upload SARIF results with pinned actions and reduced permissions. |
| .github/workflows/test.yaml | Applies default-deny permissions and SHA-pins actions for the reusable test workflow. |
| .github/workflows/publish.yaml | Applies default-deny permissions, SHA-pins actions, disables uv cache, and pins PyPI publish action. |
| .github/workflows/docs.yaml | Applies default-deny permissions, SHA-pins actions, and disables uv cache for release-triggered docs deploy. |
| .github/workflows/codeql.yml | Applies default-deny permissions, SHA-pins checkout, and bumps CodeQL action to v3 with pinned SHAs. |
| .github/workflows/ci.yaml | Applies default-deny permissions, SHA-pins actions, tightens job permissions, and migrates Sonar action. |
| .github/dependabot.yaml | Adds a 7-day cooldown before proposing newly published GitHub Actions updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # .github/workflows/ci.yaml # .github/workflows/codeql.yml # .github/workflows/docs.yaml # .github/workflows/publish.yaml # .github/workflows/test.yaml
Description
Adopts zizmor to statically analyze our GitHub Actions, wired in as a pre-commit hook (
zizmorcore/zizmor-pre-commit). Because the existingvalidateCI job already runspre-commit run --all-files, this makes zizmor a required CI check with no new workflow and no extra action to pin.Per maintainer direction, this uses the strict policy (SHA-pin everything) and resolves every finding to zero.
Findings resolved (23 high + 13 medium → 0)
unpinned-uses(21)# vXcommentartipacked(7)persist-credentials: falseon everyactions/checkoutexcessive-permissions(5)permissions: {}on every workflow + least-privilege per-job grantscache-poisoning(2)enable-cache: falseon the release-triggereddocs/publishworkflowsarchived-uses(1)sonarsource/sonarcloud-github-action@masterreplaceddependabot-cooldown(1)Notable changes reviewers should sanity-check
sonarsource/sonarcloud-github-action@master(archived) →SonarSource/sonarqube-scan-action, pinned to v6. v4–v5 are vulnerable to argument injection (GHSA-5xq9-5g24-4g6f); v6.0.0 is the first patched release. AddedSONAR_HOST_URL: https://sonarcloud.ioas required by the new action. Worth a live check that the Sonar scan still reports.github/codeql-actionv2 → v3 — v2 is retired, so pinning a v2 SHA would be a dead pin.exclude-newer = "1 week"policy from build: pin uv resolver with exclude-newer #19.Verification
zizmor .github/workflows/→ No findings to report (16 suppressed by default persona).pre-commit run zizmor --all-files→ Passed (also audits.github/dependabot.yaml).Closes
Summary by Sourcery
Harden GitHub Actions workflows and CI configuration, including adopting zizmor in pre-commit and tightening security posture across workflows.
Enhancements:
CI:
Tests:
Chores:
Two layers of zizmor
Following the zizmor-action usage (modeled on Starlette's workflow):
zizmorpre-commit hook (runs in thevalidatejob + locally).github/workflows/zizmor.yml→zizmorcore/zizmor-action(SHA-pinnedv0.6.0)The new workflow is itself SHA-pinned and least-privilege, so it passes the zizmor audit it runs.