Skip to content

Commit e8d4443

Browse files
authored
docs: add an example GHA workflow (#98)
1 parent dd96bde commit e8d4443

File tree

3 files changed

+57
-16
lines changed

3 files changed

+57
-16
lines changed

.github/workflows/zizmor.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# https://github.com/woodruffw/zizmor
2-
name: GitHub Actions Security Analysis with Zizmor
1+
name: GitHub Actions Security Analysis with zizmor 🌈
32

43
on:
54
push:
@@ -9,7 +8,7 @@ on:
98

109
jobs:
1110
zizmor:
12-
name: Zizmor latest via Cargo
11+
name: zizmor latest via Cargo
1312
runs-on: ubuntu-latest
1413
permissions:
1514
contents: read
@@ -23,13 +22,12 @@ jobs:
2322
uses: actions-rust-lang/setup-rust-toolchain@v1
2423
- name: Get zizmor
2524
run: cargo install zizmor
26-
- name: Run zizmor
25+
- name: Run zizmor 🌈
2726
run: zizmor --format sarif . > results.sarif
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2829
- name: Upload SARIF file
2930
uses: github/codeql-action/upload-sarif@v3
3031
with:
31-
# Path to SARIF file relative to the root of the repository
3232
sarif_file: results.sarif
33-
# Optional category for the results
34-
# Used to differentiate multiple results for one commit
3533
category: zizmor

docs/usage.md

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
4947
code 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

mkdocs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ theme:
2020
name: material
2121
palette:
2222
scheme: slate
23+
icon:
24+
annotation: material/arrow-right-circle
2325
features:
2426
- navigation.expand
2527
- navigation.sections
2628
- navigation.tracking
29+
- content.code.copy
30+
- content.code.annotate
2731

2832
markdown_extensions:
2933
# Makes sure we render `<https://...>`-style links correctly.
@@ -33,6 +37,7 @@ markdown_extensions:
3337
- pymdownx.details
3438
- pymdownx.superfences
3539
- md_in_html
40+
- attr_list
3641
- toc:
3742
permalink: 🔗
3843

0 commit comments

Comments
 (0)