Skip to content

Commit 7ca31bc

Browse files
authored
workflows: don't persist credentials on checkout (#39)
1 parent 4312765 commit 7ca31bc

6 files changed

Lines changed: 81 additions & 1 deletion

File tree

.github/workflows/zizmor.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: GitHub Actions Security Analysis with zizmor 🌈
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
zizmor:
11+
name: zizmor latest via PyPI
12+
runs-on: ubuntu-latest
13+
permissions:
14+
security-events: write
15+
# required for workflows in private repositories
16+
contents: read
17+
actions: read
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
24+
- name: Install the latest version of uv
25+
uses: astral-sh/setup-uv@v4
26+
27+
- name: Run zizmor 🌈
28+
# Run it for both this repo and the templated cookiecutter repo.
29+
run: uvx zizmor --format sarif . {{cookiecutter.project_slug}}/.github/workflows > results.sarif
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Upload SARIF file
34+
uses: github/codeql-action/upload-sarif@v3
35+
with:
36+
sarif_file: results.sarif
37+
category: zizmor

cookiecutter.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"_copy_without_render": [
3232
".github/workflows/docs.yml",
3333
".github/workflows/lint.yml",
34-
".github/workflows/tests.yml"
34+
".github/workflows/tests.yml",
35+
".github/workflows/zizmor.yml"
3536
],
3637
"__prompts__": {
3738
"project_name": "Human-readable project name (translated into module slug and import)",

{{cookiecutter.project_slug}}/.github/workflows/docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13+
with:
14+
persist-credentials: false
1315

1416
- name: Install uv
1517
uses: astral-sh/setup-uv@v3

{{cookiecutter.project_slug}}/.github/workflows/lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14+
with:
15+
persist-credentials: false
1416

1517
- name: Install uv
1618
uses: astral-sh/setup-uv@v3

{{cookiecutter.project_slug}}/.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
2123

2224
- name: Install uv
2325
uses: astral-sh/setup-uv@v3
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: GitHub Actions Security Analysis with zizmor 🌈
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
zizmor:
11+
name: zizmor latest via PyPI
12+
runs-on: ubuntu-latest
13+
permissions:
14+
security-events: write
15+
# required for workflows in private repositories
16+
contents: read
17+
actions: read
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
24+
- name: Install the latest version of uv
25+
uses: astral-sh/setup-uv@v4
26+
27+
- name: Run zizmor 🌈
28+
run: uvx zizmor --format sarif . > results.sarif
29+
env:
30+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Upload SARIF file
33+
uses: github/codeql-action/upload-sarif@v3
34+
with:
35+
sarif_file: results.sarif
36+
category: zizmor

0 commit comments

Comments
 (0)