Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zizmor is all the rage these days, probably worth adding it #3154

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

graingert
Copy link
Member

No description provided.

Copy link
Contributor

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

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

I was going to do this when I read woodruffw's blog post about ultralytics, but got distracted by updating action versions... oops...

Thanks for doing this!

.github/workflows/autodeps.yml Outdated Show resolved Hide resolved
- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v0.9.1
hooks:
- id: zizmor
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth adding it as a GitHub action because I think it can catch more issues if it is passed a GITHUB_TOKEN.

Copy link
Member

Choose a reason for hiding this comment

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

(source: https://woodruffw.github.io/zizmor/usage/#operating-modes if others are curious)

it's sort-of possible to pass ENV variables to pre-commit hooks (pre-commit/pre-commit#758 (comment)) though it's somewhat hacky. If we expect the hook to trigger somewhat frequently we can have it as a pre-commit hook that's disabled in CI (idk where that's documented, but https://github.com/python-trio/flake8-async/blob/f82074ad631e46daa63fa4a2b016e54dc6e762f0/.pre-commit-config.yaml#L7) and a github action - but perhaps we only need to bother with it as a github action.

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00000%. Comparing base (a670d60) to head (f6cc842).

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3154   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             124          124           
  Lines           18427        18427           
  Branches         1215         1215           
===============================================
  Hits            18427        18427           

Copy link
Member

Choose a reason for hiding this comment

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

Most changes in this file need to be dropped since there's less checkout invocations now.

.pre-commit-config.yaml Outdated Show resolved Hide resolved
@graingert
Copy link
Member Author

not sure what to do about this failure:

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check toml...............................................................Passed
check for merge conflicts................................................Passed
mixed line ending........................................................Passed
check for case conflicts.................................................Passed
sort simple yaml files...................................................Passed
black....................................................................Passed
ruff.....................................................................Passed
codespell................................................................Passed
Sphinx Lint..............................................................Passed
zizmor...................................................................Failed
- hook id: zizmor
- exit code: 11

2024-12-22T09:40:49.443244Z  WARN zizmor: skipping impostor-commit: can't run without a GitHub API token
2024-12-22T09:40:49.443272Z  WARN zizmor: skipping ref-confusion: can't run without a GitHub API token
2024-12-22T09:40:49.443275Z  WARN zizmor: skipping known-vulnerable-actions: can't run without a GitHub API token
2024-12-22T09:40:49.443458Z  INFO audit: zizmor: 🌈 completed /home/graingert/projects/trio/.github/workflows/autodeps.yml
2024-12-22T09:40:49.443528Z  INFO audit: zizmor: 🌈 completed /home/graingert/projects/trio/.github/workflows/check-newsfragment.yml
2024-12-22T09:40:49.444248Z  INFO audit: zizmor: 🌈 completed /home/graingert/projects/trio/.github/workflows/ci.yml
2024-12-22T09:40:49.444383Z  INFO audit: zizmor: 🌈 completed /home/graingert/projects/trio/.github/workflows/release.yml
info[template-injection]: code injection via template expansion
  --> /home/graingert/projects/trio/.github/workflows/ci.yml:65:9
   |
65 |         - name: Verify that the artifacts with expected names got created
   |           --------------------------------------------------------------- info: this step
66 | /         run: >-
67 | |           ls -1
68 | |           dist/${{ steps.artifact-name.outputs.sdist }}
69 | |           dist/${{ steps.artifact-name.outputs.wheel }}
   | |_______________________________________________________- info: steps.artifact-name.outputs.sdist may expand into attacker-controllable code
   |
   = note: audit confidence → Low

info[template-injection]: code injection via template expansion
  --> /home/graingert/projects/trio/.github/workflows/ci.yml:65:9
   |
65 |         - name: Verify that the artifacts with expected names got created
   |           --------------------------------------------------------------- info: this step
66 | /         run: >-
67 | |           ls -1
68 | |           dist/${{ steps.artifact-name.outputs.sdist }}
69 | |           dist/${{ steps.artifact-name.outputs.wheel }}
   | |_______________________________________________________- info: steps.artifact-name.outputs.wheel may expand into attacker-controllable code
   |
   = note: audit confidence → Low

32 findings (30 suppressed): 0 unknown, 2 informational, 0 low, 0 medium, 0 high

regenerate generated files...............................................Passed

@graingert graingert requested a review from webknjaz December 22, 2024 09:44
@webknjaz
Copy link
Member

@graingert can it be ignored? The values are constructed in the same job by our code. So this templating is safe in that regard. Though, the generic approach is to use step env vars as a trampoline..

@graingert
Copy link
Member Author

How do you do the step env trampoline?

@A5rocks
Copy link
Contributor

A5rocks commented Dec 22, 2024

How do you do the step env trampoline?

Just do env: VAR: value for the step; GitHub actions automatically escapes the value

@webknjaz
Copy link
Member

@graingert check out this https://woodruffw.github.io/zizmor/audits/#template-injection — if you scroll a little, there's a Remediation title. Under it, there's a concrete example with the Before and After tabs. Hope this helps!

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.

4 participants