Skip to content

ci: Add Zizmor workflow (WIP)#383

Open
jmgate wants to merge 1 commit intomasterfrom
add-zizmor-github-action
Open

ci: Add Zizmor workflow (WIP)#383
jmgate wants to merge 1 commit intomasterfrom
add-zizmor-github-action

Conversation

@jmgate
Copy link
Copy Markdown
Collaborator

@jmgate jmgate commented Mar 31, 2026

Type: Task

Description

Related Issues/PRs

Closes #382.

Motivation

Implementation Details

Screenshots/Recordings

Testing

Documentation

Summary by Sourcery

CI:

  • Introduce a zizmor-based security analysis workflow that runs on pushes to main and all pull requests.

@jmgate jmgate self-assigned this Mar 31, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 31, 2026

Reviewer's Guide

Adds a new GitHub Actions workflow to run the zizmor security analysis on GitHub Actions configurations for pushes to main and all pull requests, using a hardened runner and pinned action SHAs.

Flow diagram for the Zizmor security analysis workflow execution

flowchart TD
    A[Push to main branch or any pull request] --> B[Trigger zizmor workflow]
    B --> C[Start job zizmor on ubuntu_latest]
    C --> D[Set job permissions<br>security_events write<br>contents read<br>actions read]
    D --> E[Run Harden_Runner using step_security_harden_runner]
    E --> F[Checkout repository using actions_checkout<br>persist_credentials false]
    F --> G[Run Zizmor security analysis using zizmorcore_zizmor_action]
    G --> H[Report security events to GitHub security_events]
Loading

File-Level Changes

Change Details Files
Introduce Zizmor-based GitHub Actions security scanning workflow.
  • Create a new GitHub Actions workflow triggered on pushes to main and all pull requests.
  • Configure minimal permissions at the workflow and job levels, granting write access only to security-events and read access to contents and actions where needed.
  • Add a hardening step for the runner using the step-security/harden-runner action with an audit egress policy.
  • Check out the repository with actions/checkout using a pinned commit SHA and without persisting credentials.
  • Run the zizmor security scan via zizmorcore/zizmor-action pinned to a specific release commit.
.github/workflows/zizmor.yml

Assessment against linked issues

Issue Objective Addressed Explanation
#382 Add a GitHub Actions workflow that runs the zizmor security analysis action (from zizmorcore/zizmor-action) to improve the security of the repository’s GitHub Actions.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.01%. Comparing base (d69ccc5) to head (1afd586).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #383   +/-   ##
=======================================
  Coverage   94.01%   94.01%           
=======================================
  Files           2        2           
  Lines         167      167           
  Branches       37       37           
=======================================
  Hits          157      157           
  Misses          4        4           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The Harden Runner step appears to have incorrect YAML indentation (uses and with should be aligned under the - name line), which will prevent this workflow from parsing correctly.
  • Consider whether pull_request needs the branches: ["**"] filter at all—removing it will make the workflow run on PRs targeting any branch by default and avoids an unusual pattern that may confuse readers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `Harden Runner` step appears to have incorrect YAML indentation (`uses` and `with` should be aligned under the `- name` line), which will prevent this workflow from parsing correctly.
- Consider whether `pull_request` needs the `branches: ["**"]` filter at all—removing it will make the workflow run on PRs targeting any branch by default and avoids an unusual pattern that may confuse readers.

## Individual Comments

### Comment 1
<location path=".github/workflows/zizmor.yml" line_range="19-22" />
<code_context>
+            contents: read # only needed for private or internal repos
+            actions: read # only needed for private or internal repos
+        steps:
+            - name: Harden Runner
+                uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
+                with:
+                egress-policy: audit
+
+            - name: Checkout repository
</code_context>
<issue_to_address>
**issue (bug_risk):** Fix step indentation so the workflow is valid YAML and GitHub Actions can parse the step correctly.

`uses:` and `with:` need to be indented to align under the `- name:` step, and `egress-policy` must be nested under `with:`, not aligned with it. For example:

```yaml
      - name: Harden Runner
        uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594
        with:
          egress-policy: audit
```

The current indentation will cause YAML parsing or runner interpretation problems.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jmgate jmgate force-pushed the add-zizmor-github-action branch from a109aa9 to 1afd586 Compare March 31, 2026 20:58
@github-advanced-security
Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

- name: Harden Runner
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this be changed to block now?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean change audit to block? I'm not sure. Audit was recommended by StepSecurity, but that was when I hardened these jobs years ago. Can you share any additional details I may be missing?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Audit will record what requests are made. Block prevents requests that aren't on a allowlist. Example.

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.

Add Zizmor GitHub Action

3 participants