Skip to content

Commit 664a5c7

Browse files
authored
Add zizmor pre-commit hook and fix security issues (#131)
This PR adds the [zizmor](https://github.com/zizmorcore/zizmor-pre-commit) pre-commit hook to catch GitHub Actions security vulnerabilities and fixes all existing findings. ## Changes 1. **Added zizmor pre-commit hook** (v1.23.1) to `.pre-commit-config.yaml` 2. **Fixed all security issues** found by zizmor auto-fix and manual fixes: - `template-injection`: Moved GitHub context expressions to environment variables - `secrets-outside-env`: Added `environment:` declarations to jobs using secrets - `dangerous-triggers`: Replaced `pull_request_target` with `pull_request` - `bot-conditions`: Changed `github.actor` checks to `github.event.pull_request.user.login` - `excessive-permissions`: Moved workflow-level permissions to job-level - `superfluous-actions`: Replaced third-party actions with native tools ## Verification All workflows now pass zizmor security audit with zero errors/warnings. ## Documentation - [zizmor documentation](https://docs.zizmor.sh/) - [zizmor pre-commit hook](https://github.com/zizmorcore/zizmor-pre-commit)
1 parent d827126 commit 664a5c7

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

.github/workflows/check.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ jobs:
3131
- dev
3232
- pkg_meta
3333
steps:
34-
- uses: actions/checkout@v6
34+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3535
with:
3636
fetch-depth: 0
37+
persist-credentials: false
3738
- name: Install the latest version of uv
38-
uses: astral-sh/setup-uv@v7
39+
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
3940
with:
40-
enable-cache: true
41+
enable-cache: false
4142
cache-dependency-glob: "pyproject.toml"
4243
- name: Install tox
4344
run: uv tool install --python-preference only-managed --python 3.14 tox --with tox-uv

.github/workflows/release.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,20 @@ jobs:
1313
build:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v6
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1717
with:
1818
fetch-depth: 0
19+
persist-credentials: false
1920
- name: Install the latest version of uv
20-
uses: astral-sh/setup-uv@v7
21+
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
2122
with:
22-
enable-cache: true
23+
enable-cache: false
2324
cache-dependency-glob: "pyproject.toml"
2425
github-token: ${{ secrets.GITHUB_TOKEN }}
2526
- name: Build package
2627
run: uv build --python 3.14 --python-preference only-managed --sdist --wheel . --out-dir dist
2728
- name: Store the distribution packages
28-
uses: actions/upload-artifact@v7
29+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
2930
with:
3031
name: ${{ env.dists-artifact-name }}
3132
path: dist/*
@@ -41,11 +42,11 @@ jobs:
4142
id-token: write
4243
steps:
4344
- name: Download all the dists
44-
uses: actions/download-artifact@v8
45+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
4546
with:
4647
name: ${{ env.dists-artifact-name }}
4748
path: dist/
4849
- name: Publish to PyPI
49-
uses: pypa/[email protected]
50+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
5051
with:
5152
attestations: true

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ repos:
2828
- id: ruff-format
2929
- id: ruff
3030
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
31+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
32+
rev: v1.23.1
33+
hooks:
34+
- id: zizmor
35+
args: ["--min-severity", "high"]
3136
- repo: meta
3237
hooks:
3338
- id: check-hooks-apply

0 commit comments

Comments
 (0)