feat: add zizmor static action checks#351
feat: add zizmor static action checks#351gforsyth wants to merge 5 commits intorapidsai:branch-25.08from
Conversation
|
Moving from |
|
Good points @msarahan - I think |
fix up build-in-devcontainer chore: add more ignores to various expected unpinned images fix(project-set): stop inheriting blanket secrets fix(wheels): address zizmor concerns in wheel files feat: add zizmor pre-commit hook fix: commit zizmor config file
You might find the links and other info at https://github.com/rapidsai/build-infra/issues/204 useful (private issue because security, sorry). I also could not find docs on how to do that with dependabot, but there are some examples there of folks who are doing it. |
|
Thanks, @jameslamb ! From what I've seen, I think |
|
Cool, cool, that makes sense.
For this point, I believe so e.g. if you have: - uses: actions/checkout@abc123 # v4.2.1It'll propose an update like: - uses: actions/checkout@def456 # v4.2.2That'll help with readability, I think. |
This is an experiment in using `zizmor` (https://docs.zizmor.sh/) to run static analysis on all of the shared workflow files. This seems like a nice tool to add, especially in this repository. Some of the classes of errors/warnings that are fixed here (and any associated configuration): ### unpinned-uses https://docs.zizmor.sh/audits/#unpinned-uses Any `uses:` mapping should pin to an exact hash to avoid things getting swapped out underneath. Since we deliberately make use of some of the `uses:` to reference our own `shared-workflows` and `nv-gha-runners` -- these are allowed to point at refs. Those patterns are configured in `.github/zizmor.yml` ### artipacked https://docs.zizmor.sh/audits/#artipacked We should always explicitly set `persist-credentials`, either to `true` or `false`. Everywhere that the `checkout` action has implicitly set it to `true`, I have made it an explicit `true`. I suspect some of these need to be true, but probably not all of them. I'll have to do some testing downstream to see which actions break when those secrets are disabled. ### overprovisioned-secrets https://docs.zizmor.sh/audits/#overprovisioned-secrets Looking up secrets like `secrets[some_key]` injects the entire secrets context into the runner, but I don't see a way around that for our current secret lookup patterns. I've just ignored these instances individually. ### unpinned-images https://docs.zizmor.sh/audits/#unpinned-images The only unpinned images belong to us and those have been individually allowlisted. ### template-injection https://docs.zizmor.sh/audits/#template-injection Generally speaking lines like `run: ${{ inputs.script }}` are susceptible to template injection. Also, that's the entire point of these lines, so they are individually allowlisted. For other potentially injectable lines, like `run: rapids-wheels-anaconda "${{ inputs.package-name }}" "${{ inputs.package-type }}" `, I've unpacked the inputs in to the environment and passed through those env-vars instead. In #351, @msarahan and @jameslamb and I determined that we can use full SHAs to specify the image to use for a given step, but leave a trailing same-line comment that points to the corresponding tag. That let's us use the more secure exact pin for the images that we don't control, but still keeps it human-readable and compatible with dependabot, e.g. ``` - uses: actions/checkout@def456 # v4.2.2 ```
This is an experiment in using
zizmor(https://docs.zizmor.sh/) to run static analysis on all of the shared workflow files. This seems like a nice tool to add, especially in this repository.Some of the classes of errors/warnings that are fixed here (and any associated configuration):
unpinned-uses
https://docs.zizmor.sh/audits/#unpinned-uses
Any
uses:mapping should pin to an exact hash to avoid things getting swapped out underneath.Since we deliberately make use of some of the
uses:to reference our ownshared-workflowsandnv-gha-runners-- these are allowed to point at refs. Those patterns are configured in.github/zizmor.ymlartipacked
https://docs.zizmor.sh/audits/#artipacked
We should always explicitly set
persist-credentials, either totrueorfalse. Everywhere that thecheckoutaction has implicitly set it totrue, I have made it an explicittrue.I suspect some of these need to be true, but probably not all of them. I'll have to do some testing downstream to see which actions break when those secrets are disabled.
overprovisioned-secrets
https://docs.zizmor.sh/audits/#overprovisioned-secrets
Looking up secrets like
secrets[some_key]injects the entire secrets context into the runner, but I don't see a way around that for our current secret lookup patterns. I've just ignored these instances individually.unpinned-images
https://docs.zizmor.sh/audits/#unpinned-images
The only unpinned images belong to us and those have been individually allowlisted.
template-injection
https://docs.zizmor.sh/audits/#template-injection
Generally speaking lines like
run: ${{ inputs.script }}are susceptible to template injection. Also, that's the entire point of these lines, so they are individually allowlisted.For other potentially injectable lines, like
run: rapids-wheels-anaconda "${{ inputs.package-name }}" "${{ inputs.package-type }}", I've unpacked the inputs in to the environment and passed through those env-vars instead.