Skip to content

Commit bea5571

Browse files
ewelsclaude
andcommitted
ci: harden GitHub Actions workflows (zizmor) (#116)
* Update github actions * Bump docs npm packages * ci: harden GitHub Actions workflows (zizmor) Resolve all zizmor findings across the three workflows: - excessive-permissions: drop workflow-level write scopes to contents: read and grant packages:/contents: write only on the jobs that need them (docker push, tag/release creation). - template-injection: move all ${{ ... }} expansions out of run blocks into env vars referenced as shell variables. - artipacked: set persist-credentials: false on read-only checkouts; keep credentials only on create-tag-and-release (git push) with a documented zizmor ignore. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(ci): restore toolchain channel for dtolnay/rust-toolchain Pinning dtolnay/rust-toolchain to a SHA dropped the @stable channel from the action ref, so jobs without an explicit toolchain input failed with "'toolchain' is a required input". Add an explicit toolchain: stable input to the test, fmt, clippy and build-binaries jobs, which is robust against SHA pinning. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3f41801 commit bea5571

5 files changed

Lines changed: 1376 additions & 647 deletions

File tree

.github/workflows/build_docs.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ on:
88
# Allows you to run this workflow manually from the Actions tab
99
workflow_dispatch:
1010

11-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages.
12+
# Job-specific permissions are granted at the job level below.
1213
permissions:
1314
contents: read
14-
pages: write
15-
id-token: write
1615

1716
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
1817
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
@@ -30,7 +29,9 @@ jobs:
3029
runs-on: ubuntu-latest
3130
steps:
3231
- name: Checkout
33-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
32+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
33+
with:
34+
persist-credentials: false
3435
- name: Setup Node
3536
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # 6.4.0
3637
with:
@@ -44,10 +45,13 @@ jobs:
4445
run: npm ci
4546
working-directory: ${{ env.BUILD_PATH }}
4647
- name: Build with Astro
48+
env:
49+
PAGES_ORIGIN: ${{ steps.pages.outputs.origin }}
50+
PAGES_BASE_PATH: ${{ steps.pages.outputs.base_path }}
4751
run: |
4852
npx --no-install astro build \
49-
--site "${{ steps.pages.outputs.origin }}" \
50-
--base "${{ steps.pages.outputs.base_path }}/"
53+
--site "$PAGES_ORIGIN" \
54+
--base "$PAGES_BASE_PATH/"
5155
working-directory: ${{ env.BUILD_PATH }}
5256
- name: Upload artifact
5357
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
@@ -61,6 +65,9 @@ jobs:
6165
needs: build
6266
runs-on: ubuntu-latest
6367
name: Deploy
68+
permissions:
69+
pages: write
70+
id-token: write
6471
steps:
6572
- name: Deploy to GitHub Pages
6673
id: deployment

.github/workflows/ci.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ jobs:
2727
- name: macos-aarch64
2828
os: macos-latest
2929
steps:
30-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2
30+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
31+
with:
32+
persist-credentials: false
3133

3234
- name: Install Rust toolchain
33-
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@stable
35+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
36+
with:
37+
toolchain: stable
3438

3539
- name: Install Linux build deps
3640
if: runner.os == 'Linux'
@@ -67,21 +71,27 @@ jobs:
6771
name: Formatting
6872
runs-on: ubuntu-latest
6973
steps:
70-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2
71-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@stable
74+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
75+
with:
76+
persist-credentials: false
77+
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
7278
with:
79+
toolchain: stable
7380
components: rustfmt
7481
- run: cargo fmt --check
7582

7683
clippy:
7784
name: Clippy
7885
runs-on: ubuntu-latest
7986
steps:
80-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2
87+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
88+
with:
89+
persist-credentials: false
8190

8291
- name: Install Rust toolchain
83-
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@stable
92+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
8493
with:
94+
toolchain: stable
8595
components: clippy
8696

8797
- name: Install Linux build deps
@@ -98,10 +108,12 @@ jobs:
98108
name: MSRV check
99109
runs-on: ubuntu-latest
100110
steps:
101-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2
111+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
112+
with:
113+
persist-credentials: false
102114

103115
- name: Install Rust MSRV toolchain
104-
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@master
116+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
105117
with:
106118
toolchain: "1.87"
107119

@@ -120,7 +132,9 @@ jobs:
120132
name: Security audit
121133
runs-on: ubuntu-latest
122134
steps:
123-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2
135+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
136+
with:
137+
persist-credentials: false
124138
- name: Install cargo-audit
125139
run: cargo install cargo-audit
126140
- name: Run cargo audit

0 commit comments

Comments
 (0)