@@ -42,22 +42,60 @@ See [Integration](#integration) for suggestions on when to use each format.
4242
4343### Use in GitHub Actions
4444
45- ` zizmor ` is trivial to use within GitHub Actions; you can run it just like
46- you would locally.
47-
45+ ` zizmor ` is designed to integrate with GitHub Actions. In particular,
4846` zizmor --format sarif ` specifies [ SARIF] as the output format, which GitHub's
4947code scanning feature also supports.
5048
51- See [ GitHub's documentation] for advice on how to integrate ` zizmor ` 's results
52- directly into a repository's scanning setup.
49+ You can integrate ` zizmor ` into your CI/CD however you please, but one
50+ easy way to do it is with a workflow that connects to
51+ [ GitHub's code scanning functionality] .
52+
53+ The following is an example of such a workflow:
54+
55+ ``` yaml title="zizmor.yml"
56+ name : GitHub Actions Security Analysis with zizmor 🌈
57+
58+ on :
59+ push :
60+ branches : ["main"]
61+ pull_request :
62+ branches : ["**"]
63+
64+ jobs :
65+ zizmor :
66+ name : zizmor latest via Cargo
67+ runs-on : ubuntu-latest
68+ permissions :
69+ contents : read
70+ security-events : write
71+ steps :
72+ - name : Checkout repository
73+ uses : actions/checkout@v4
74+ with :
75+ persist-credentials : false
76+ - name : Setup Rust
77+ uses : actions-rust-lang/setup-rust-toolchain@v1
78+ - name : Get zizmor
79+ run : cargo install zizmor
80+ - name : Run zizmor 🌈
81+ run : zizmor --format sarif . > results.sarif
82+ env :
83+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }} # (1)!
84+ - name : Upload SARIF file
85+ uses : github/codeql-action/upload-sarif@v3
86+ with :
87+ sarif_file : results.sarif
88+ category : zizmor
89+ ` ` `
90+
91+ 1. Optional: Remove the ` env:` block to only run `zizmor`'s offline audits.
5392
54- For a specific example, see ` zizmor ` 's own [ repository workflow scan] .
55- GitHub's example of [ running ESLint] as a security workflow provides additional
56- relevant links.
93+ For more inspiration, see `zizmor`'s own [repository workflow scan], as well
94+ as GitHub's example of [running ESLint] as a security workflow.
5795
5896[SARIF] : https://sarifweb.azurewebsites.net/
5997
60- [ GitHub's documentation ] : https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github
98+ [GitHub's code scanning functionality ] : https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github
6199
62100[repository workflow scan] : https://github.com/woodruffw/zizmor/blob/main/.github/workflows/zizmor.yml
63101
0 commit comments