Skip to content

Commit 917daa6

Browse files
authored
ci: adopt zizmor for this repo's own workflows (#799)
Add the zizmor pre-commit hook and a .github/zizmor.yml (unpinned-uses relaxed to ref-pin, since actions are maintained via Dependabot), then make all workflows and the composite action zizmor-clean: - excessive-permissions: top-level permissions: {} with minimal per-job grants in ci.yml and cd.yml. - artipacked: persist-credentials: false on all checkouts. - template-injection: pass inputs through env vars in action.yml. - github-app: scope the bump bot's app token to contents + pull-requests. - dependabot-cooldown: add a 7-day cooldown for actions. - dangerous-triggers: documented ignore for the RTD preview pull_request_target (no untrusted checkout, gated on fork == false). Assisted-by: ClaudeCode:claude-opus-4.8
1 parent 2fb7908 commit 917daa6

12 files changed

Lines changed: 68 additions & 6 deletions

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "daily"
8+
cooldown:
9+
default-days: 7
810
groups:
911
actions:
1012
patterns:

.github/workflows/bump.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ jobs:
1818
with:
1919
app-id: ${{ secrets.APP_ID }}
2020
private-key: ${{ secrets.APP_PRIVATE_KEY }}
21+
# Scope the token to only what the PR creation needs
22+
permission-contents: write
23+
permission-pull-requests: write
2124
- uses: actions/checkout@v6
25+
with:
26+
persist-credentials: false
2227
- uses: astral-sh/setup-uv@v8.2.0
2328
- run: uvx nox -s pc_bump
2429
env:

.github/workflows/cd.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ on:
66
types:
77
- published
88

9+
permissions: {}
10+
911
jobs:
1012
dist:
1113
name: Distribution build
1214
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
1317

1418
steps:
1519
- uses: actions/checkout@v6
1620
with:
21+
persist-credentials: false
1722
fetch-depth: 0
1823

1924
- uses: hynek/build-and-inspect-python-package@v2

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,34 @@ concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}
1212
cancel-in-progress: true
1313

14+
permissions: {}
15+
1416
jobs:
1517
change-detection:
18+
permissions:
19+
contents: read
20+
pull-requests: read
1621
uses: ./.github/workflows/reusable-change-detection.yml
1722

1823
cookie:
1924
needs: change-detection
2025
if: fromJSON(needs.change-detection.outputs.run-cookie)
26+
permissions:
27+
contents: read
2128
uses: ./.github/workflows/reusable-cookie.yml
2229

2330
rr-tests:
2431
needs: change-detection
2532
if: fromJSON(needs.change-detection.outputs.run-rr)
33+
permissions:
34+
contents: read
2635
uses: ./.github/workflows/reusable-rr-tests.yml
2736

2837
docs:
2938
needs: change-detection
3039
if: fromJSON(needs.change-detection.outputs.run-docs)
40+
permissions:
41+
contents: read
3142
uses: ./.github/workflows/reusable-docs.yml
3243

3344
pass:

.github/workflows/docs-link.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Read the Docs PR preview
22

33
on:
4+
# zizmor: ignore[dangerous-triggers]
5+
# pull_request_target is required so the RTD preview can comment on PRs from
6+
# forks; no untrusted code is checked out, and it is gated on `fork == false`.
47
pull_request_target:
58
types:
69
- opened

.github/workflows/reusable-change-detection.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
2424
steps:
2525
- uses: actions/checkout@v6
26+
with:
27+
persist-credentials: false
2628

2729
- name: Changed cookie-related files
2830
if: github.event_name == 'pull_request'

.github/workflows/reusable-cookie.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v6
17+
with:
18+
persist-credentials: false
1719

1820
- name: Lint all
1921
run: pipx run nox -s 'lint'
@@ -33,6 +35,8 @@ jobs:
3335

3436
steps:
3537
- uses: actions/checkout@v6
38+
with:
39+
persist-credentials: false
3640

3741
- uses: actions/setup-python@v6
3842
with:
@@ -105,6 +109,8 @@ jobs:
105109

106110
steps:
107111
- uses: actions/checkout@v6
112+
with:
113+
persist-credentials: false
108114

109115
- uses: actions/setup-python@v6
110116
with:
@@ -172,6 +178,8 @@ jobs:
172178

173179
steps:
174180
- uses: actions/checkout@v6
181+
with:
182+
persist-credentials: false
175183

176184
- name: Build sdist and wheel
177185
run: pipx run nox -s dist

.github/workflows/reusable-docs.yml

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

1416
- uses: oven-sh/setup-bun@v2
1517

.github/workflows/reusable-rr-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v6
2323
with:
24+
persist-credentials: false
2425
fetch-depth: 0
2526

2627
- uses: actions/setup-python@v6
@@ -41,6 +42,7 @@ jobs:
4142
steps:
4243
- uses: actions/checkout@v6
4344
with:
45+
persist-credentials: false
4446
fetch-depth: 0
4547

4648
- name: Run sp-repo-review action
@@ -52,6 +54,7 @@ jobs:
5254
steps:
5355
- uses: actions/checkout@v6
5456
with:
57+
persist-credentials: false
5558
fetch-depth: 0
5659

5760
- uses: actions/setup-python@v6
@@ -71,6 +74,7 @@ jobs:
7174
steps:
7275
- uses: actions/checkout@v6
7376
with:
77+
persist-credentials: false
7478
fetch-depth: 0
7579

7680
- uses: actions/setup-python@v6

.github/zizmor.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Configuration for zizmor (https://docs.zizmor.sh)
2+
rules:
3+
unpinned-uses:
4+
config:
5+
# Actions are kept up to date with Dependabot, so a ref (tag) pin is
6+
# sufficient; hash pinning is not required.
7+
policies:
8+
"*": ref-pin

0 commit comments

Comments
 (0)