Skip to content

CI: add zizmor security scanning for GitHub Actions workflows#31457

Open
Aniketsy wants to merge 11 commits into
numpy:mainfrom
Aniketsy:fix-zizmor
Open

CI: add zizmor security scanning for GitHub Actions workflows#31457
Aniketsy wants to merge 11 commits into
numpy:mainfrom
Aniketsy:fix-zizmor

Conversation

@Aniketsy
Copy link
Copy Markdown
Contributor

PR summary

  • In this PR we're adding zizmor in the github actions workflow, initial discussion was with @jorenham 😊 and then we had discussion in the numpy community meeting with other members.

First time committer introduction

No, i've contributed before in numpy

AI Disclosure

  • yes i've took help of llm to fix some errors which i faced during running zizmor locally and rest i've followed from my numtype pr to add zizmor

@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.

Comment thread .github/workflows/zizmor.yml
Comment thread .github/workflows/zizmor.yml
Comment on lines +19 to +21
permissions:
contents: read
pull-requests: write
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similar to how you added the top-level permissions: {} in .github/workflows/zizmor.yml, that would be useful in this file (and in all other files as well).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Eh, why? This isn't needed in any other files

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggested it for consistency with all files and hygiene reasons – just felt odd that one file has permissions: {} at the top level and others don't. Also, permissions: {} is stricter than contents: read, and it's helpful to have for those jobs that don't need to check out user code, such as the labeler, Mypy primer, etc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It shouldn't be consistent though, mypy_primer_comment and labeler are special. There's no need to add a lot more churn to change nothing in actual permissions in other yaml files.

Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
@Aniketsy
Copy link
Copy Markdown
Contributor Author

@agriyakhetarpal thanks for the review ❤️

Copy link
Copy Markdown
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

Thanks @Aniketsy. Adding zizmor in CI seems like a good idea now, I think it improved to the point where most of the UX issues and noise are gone, and it adds some security hardening that is useful.

Comment thread .github/workflows/zizmor.yml Outdated
permissions:
security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files.
contents: read # Only needed for private repos. Needed to clone the repo.
actions: read # Only needed for private repos. Needed for upload-sarif to read workflow run info.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These two lines can be removed it looks like, given that this is not a private repo.

Comment thread .github/workflows/zizmor.yml
Comment thread .github/workflows/zizmor.yml Outdated
uses: zizmorcore/zizmor-action@b1d7e1fb5de872772f31590499237e7cce841e8e # v0.5.3
with:
inputs: .github/
persona: pedantic
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please make this regular (or, equivalently, remove the line completely). pedantic isn't all that useful, and sometimes annoying - "pedantic" has a negative connotation for a reason.

Comment thread .github/zizmor.yml Outdated
@@ -0,0 +1,5 @@
rules:
dangerous-triggers:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest to remove this, in favor of a # zizmor: ignore[dangerous-triggers] comment in these two workflow files themselves, with a short justification ("safe: no PR-head checkout, no code execution, only pull-requests: write").

These workflows are currently safe, but there's not a single indication that there's a potential issue there, and future changes to those files can always happen, so a local warning is good.

Plus, it avoids having to update this separate config file in case the line number changes.

Comment thread .github/workflows/zizmor.yml Outdated
push:
branches: [main]
pull_request:
branches: ["**"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The usual pattern is:

    branches:
      - main
      - maintenance/**

Comment thread .github/workflows/labeler.yml Outdated
permissions:
pull-requests: write # to add labels
contents: read # to read .github/pr-prefix-labeler.yml
issues: write # to add labels
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't what this action does, it only labels PRs. So I don't think this can be right - please remove this last line.

steps:
- name: Extract warnings
shell: bash
env:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't mind these changes, but for clarity: there was no issue here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

please let me know , if we should revert these changes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no, fine to keep this change

@Aniketsy
Copy link
Copy Markdown
Contributor Author

@rgommers thanks for the review 😊 , and sharing pointers, i'll look into the ci- failures shortly.

@stefanv
Copy link
Copy Markdown
Contributor

stefanv commented May 20, 2026

Still need to make Zizmor pass:

 INFO audit: zizmor: 🌈 completed .github/workflows/zizmor.yml
Error: labeler.yml:3: use of fundamentally insecure workflow trigger: pull_request_target is almost always used insecurely
Error: linux.yml:441: unpinned image references: container image is unpinned
Error: mypy_primer_comment.yml:4: use of fundamentally insecure workflow trigger: workflow_run is almost always used insecurely
Warning: scorecards.yml:28: action's hash pin has mismatched or missing version comment: points to commit 93ea575cb5d8
Warning: scorecards.yml:53: action's hash pin has mismatched or missing version comment: points to commit 807578363a78
Warning: wheels.yml:59: action's hash pin has mismatched or missing version comment: points to commit 06ea2833eef6
Warning: windows.yml:100: action's hash pin has mismatched or missing version comment: points to commit 06ea2833eef6

Approved, since everything seems to be in place, other than those fixes.

@Aniketsy
Copy link
Copy Markdown
Contributor Author

i've fixed the errors we were getting , do we need to worry about warning?

Warning: scorecards.yml:28: action's hash pin has mismatched or missing version comment: points to commit 93ea575cb5d8
Warning: scorecards.yml:53: action's hash pin has mismatched or missing version comment: points to commit 807578363a78
Warning: wheels.yml:59: action's hash pin has mismatched or missing version comment: points to commit 06ea2833eef6
Warning: windows.yml:100: action's hash pin has mismatched or missing version comment: points to commit 06ea2833eef6

@jorenham
Copy link
Copy Markdown
Member

do we need to worry about warning?

The warnings look legitimate, so I'd say so.

@Aniketsy
Copy link
Copy Markdown
Contributor Author

@jorenham I'm not able to see ci-fail log, do you have any idea for this .

@agriyakhetarpal
Copy link
Copy Markdown
Contributor

Yes, Zizmor is passing now: https://github.com/numpy/numpy/actions/runs/26234123656/job/77202376754?pr=31457. Thanks!

Assuming that the macOS x86-64 conda py3.12 job is what you meant, apparently it just froze while running the test suite; probably a case of GitHub acting up...

- name: Setup MSVC (32-bit)
if: ${{ matrix.buildplat[1] == 'win32' }}
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
uses: bus1/cabuild/action/msdevshell@06ea2833eef61e9b0d0ce0d728416e617e4fb1fe # v1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you manually review all code changes between these SHAs? If not, you shouldn't bump the pin, that defeats part of the purpose of pinning.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Did you manually review all code changes between these SHAs?

no, should i look into this, or revert back changes, i updated as we were getting warning of mismatch sha commit

# There are few options for i686 images at https://quay.io/organization/pypa,
# use the glibc2.28 one
image: quay.io/pypa/manylinux_2_28_i686
image: quay.io/pypa/manylinux_2_28_i686@sha256:817099eabdaf534fd802079ed185b62b97f1fc5e7027db9a14fd7540931819b9
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pinning Docker images is something we haven't done before. It's a tradeoff; there are benefits too, but unless Dependabot bumps these similarly to other pins, it'll probably go out of date. Did you check if those bumps will happen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

but unless Dependabot bumps these similarly to other pins, it'll probably go out of date.

yes, i agree

Did you check if those bumps will happen?

i'll look into this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Aniketsy just a gentle ping, would be nice to resolve this and get this in!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@seberg yes, sorry for the delay 😿 , i'll update today , i need to verify and review the code between sha as per review point.

@Aniketsy
Copy link
Copy Markdown
Contributor Author

Aniketsy commented Jun 3, 2026

i have resolved conflict of this file .github/workflows/scorecards.yml by accepting incoming changes from main ...we're getting Warning: scorecards.yml:53: action's hash pin has mismatched or missing version comment: points to commit 807578363a78

any thoughts on this ?

@Aniketsy
Copy link
Copy Markdown
Contributor Author

Aniketsy commented Jun 4, 2026

(numpy-dev) C:\Users\Aniket.DESKTOP-074O80J\numpy\numpy>zizmor .github/workflows
 INFO zizmor: 🌈 zizmor v1.24.1
 INFO audit: zizmor: 🌈 completed .github/workflows\circleci.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\codeql.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\compiler_sanitizers.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\cygwin.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\dependency-review.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\emscripten.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\labeler.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\linux-ibm.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\linux.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\linux_blas.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\linux_qemu.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\linux_riscv64.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\linux_simd.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\macos.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\mypy_primer.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\mypy_primer_comment.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\pixi-packages.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\scorecards.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\stubtest.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\typecheck.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\wheels.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\windows.yml
 INFO audit: zizmor: 🌈 completed .github/workflows\zizmor.yml
No findings to report. Good job! (2 ignored, 72 suppressed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants