Skip to content

use zizmor to lint github action workflows#11269

Open
keewis wants to merge 29 commits intopydata:mainfrom
keewis:zizmor
Open

use zizmor to lint github action workflows#11269
keewis wants to merge 29 commits intopydata:mainfrom
keewis:zizmor

Conversation

@keewis
Copy link
Copy Markdown
Collaborator

@keewis keewis commented Mar 29, 2026

In times of AI-driven attacks on github actions (where the AI agent drastically reduces the effort needed to attack multiple repositories), it is a good idea to try as much as possible to avoid any of the foot guns that github actions provide.

zizmor is a github actions linter (with autocorrection functionality) that flags many potentially exploitable parts as possible.

For xarray, most of the changes were pinning the actions and limiting the permissions for the default GITHUB_TOKEN.

Note that while I've tried to figure out the needed permissions for each job, I'm not certain I found everything, so merging this may result in breaking CI on main.

I've also created new github environments for the codecov token and the nightly wheels token, which are now duplicated between the environment secrets and the repository secrets. After merging (and making sure the tokens are available as usual) it might be good to remove the repository secrets.

Edit: I've removed the codecov env and instead will ignore the zizmor warning, codecov is not a very sensible secret, and the "deployment" messages in PRs (see below) quickly become annoying.

@github-actions github-actions bot added the Automation Github bots, testing workflows, release automation label Mar 29, 2026
@keewis keewis added the run-slow-hypothesis Run slow hypothesis tests label Mar 29, 2026
@keewis
Copy link
Copy Markdown
Collaborator Author

keewis commented Mar 29, 2026

looks like the deployment messages for codecov may become annoying. This token is not a very sensible secret, so it may also be possible to remove the environment and instead ignore zizmor's warning (codecov is one of the kind of token the warning description explicitly shows how to ignore).

Edit: I've done just that

@dopplershift
Copy link
Copy Markdown
Contributor

You can now add deployment: false under the environment section to disable these annoying messages.

Copy link
Copy Markdown
Contributor

@VeckoTheGecko VeckoTheGecko left a comment

Choose a reason for hiding this comment

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

Looks good to me!

rev: v1.44.0
hooks:
- id: typos
- repo: https://github.com/zizmorcore/zizmor-pre-commit
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.

Awesome to have as a hook!

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.

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.

we can try that after merging this PR

Comment on lines +8 to +9
cooldown:
default-days: 7
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.

Related: We should also have this for Pixi when prefix-dev/pixi#5786 gets merged and released

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.

yep, we can do that, too. We'll have to be able to disable that for the nightly CI, though, otherwise the early warning system will be a week late.

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 was thinking 3 days would be good. I think its ok if our nightly env is a few days late?

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.

I guess so. The hope for using a cooldown is that if there is an attack, waiting for 7 days will allow others with more knowledge to detect and report the problem. Obviously, if everybody is doing this you won't gain anything.

However, my superficial knowledge on this topic is at its limit here, it might be worth raising this kind of question in the scientific-python discord: there are more security-aware folks and the authors of the scientific-python-nightly-wheels action.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(drive-by comment from the Discord thread on this): I'm of the opinion that the latest nightly can be used in a very sandboxed, very scoped down job, just to test compatibility but with no acces to anything else. The container where that job runs is deleted after the job runs, so it cannot poison future runs of same or other workflows. Static analysis of the package to detect vulns, exploits, is possible, if wanted

@VeckoTheGecko
Copy link
Copy Markdown
Contributor

VeckoTheGecko commented Mar 31, 2026

nit: maybe worth moving the zizmor (Rust based) tool further up the pre-commit chain since its quite quick compared to the others

Co-authored-by: Nick Hodgskin <36369090+VeckoTheGecko@users.noreply.github.com>
@VeckoTheGecko
Copy link
Copy Markdown
Contributor

VeckoTheGecko commented Mar 31, 2026

Once that pin is fixed I think its fine.

(so you can verify the pins yourself) uv run https://gist.github.com/VeckoTheGecko/734b10cc78742b354c01055660ddf625 - you may be rate limited by github though zizmor has built in tooling for this it turns out

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

Labels

Automation Github bots, testing workflows, release automation run-pyright Run pyright type checker run-slow-hypothesis Run slow hypothesis tests run-upstream Run upstream CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants