Skip to content

Commit e74de71

Browse files
Harden GitHub Actions workflows with zizmor (#76)
* Bump click from 8.2.1 to 8.3.1 Bumps [click](https://github.com/pallets/click) from 8.2.1 to 8.3.1. - [Release notes](https://github.com/pallets/click/releases) - [Changelog](https://github.com/pallets/click/blob/main/CHANGES.rst) - [Commits](pallets/click@8.2.1...8.3.1) --- updated-dependencies: - dependency-name: click dependency-version: 8.3.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump pytask from 0.5.5 to 0.5.8 Bumps [pytask](https://github.com/pytask-dev/pytask) from 0.5.5 to 0.5.8. - [Release notes](https://github.com/pytask-dev/pytask/releases) - [Changelog](https://github.com/pytask-dev/pytask/blob/main/CHANGELOG.md) - [Commits](pytask-dev/pytask@v0.5.5...v0.5.8) --- updated-dependencies: - dependency-name: pytask dependency-version: 0.5.8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Harden GitHub Actions workflows with zizmor --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 0a559f7 commit e74de71

4 files changed

Lines changed: 90 additions & 20 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "weekly"
8+
cooldown:
9+
default-days: 7
810
groups:
911
github-actions:
1012
patterns:
@@ -13,3 +15,5 @@ updates:
1315
directory: "/"
1416
schedule:
1517
interval: "weekly"
18+
cooldown:
19+
default-days: 7

.github/workflows/main.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,34 @@ on:
1414
- '*'
1515
merge_group:
1616

17+
permissions: {}
18+
1719
jobs:
1820

1921
run-type-checking:
2022

2123
name: Run tests for type-checking
2224
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
2327

2428
steps:
25-
- uses: actions/checkout@v6
26-
- uses: astral-sh/setup-uv@v7
29+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
30+
with:
31+
persist-credentials: false
32+
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
2733
with:
2834
enable-cache: true
2935
- name: Install just
30-
uses: extractions/setup-just@v3
36+
uses: extractions/setup-just@f8a3cce218d9f83db3a2ecd90e41ac3de6cdfd9b # v3
3137
- run: just typing
3238

3339
run-tests:
3440

3541
name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }}
3642
runs-on: ${{ matrix.os }}
43+
permissions:
44+
contents: read
3745

3846
strategy:
3947
fail-fast: false
@@ -42,20 +50,22 @@ jobs:
4250
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
4351

4452
steps:
45-
- uses: actions/checkout@v6
46-
- uses: astral-sh/setup-uv@v7
53+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
54+
with:
55+
persist-credentials: false
56+
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
4757
with:
4858
enable-cache: true
4959
python-version: ${{ matrix.python-version }}
5060
- name: Install just
51-
uses: extractions/setup-just@v3
61+
uses: extractions/setup-just@f8a3cce218d9f83db3a2ecd90e41ac3de6cdfd9b # v3
5262

5363
- name: Run tests
5464
shell: bash -l {0}
5565
run: just test
5666

5767
- name: Upload test coverage reports to Codecov with GitHub Action
58-
uses: codecov/codecov-action@v5
68+
uses: codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5
5969

6070
- name: Run tests with lowest resolution
6171
if: matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest'

.github/workflows/publish-to-pypi.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ name: Publish Python 🐍 distribution 📦 to PyPI
22

33
on: push
44

5+
permissions: {}
6+
57
jobs:
68
build:
79
name: Build distribution 📦
810
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
913

1014
steps:
11-
- uses: actions/checkout@v6
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
16+
with:
17+
persist-credentials: false
1218
- name: Set up Python
13-
uses: actions/setup-python@v6
19+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
1420
with:
1521
python-version: "3.x"
1622
- name: Install pypa/build
@@ -22,7 +28,7 @@ jobs:
2228
- name: Build a binary wheel and a source tarball
2329
run: python3 -m build
2430
- name: Store the distribution packages
25-
uses: actions/upload-artifact@v7
31+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
2632
with:
2733
name: python-package-distributions
2834
path: dist/
@@ -41,12 +47,12 @@ jobs:
4147

4248
steps:
4349
- name: Download all the dists
44-
uses: actions/download-artifact@v8
50+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
4551
with:
4652
name: python-package-distributions
4753
path: dist/
4854
- name: Publish distribution 📦 to PyPI
49-
uses: pypa/gh-action-pypi-publish@release/v1
55+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
5056

5157
github-release:
5258
name: >-
@@ -62,30 +68,32 @@ jobs:
6268

6369
steps:
6470
- name: Download all the dists
65-
uses: actions/download-artifact@v8
71+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
6672
with:
6773
name: python-package-distributions
6874
path: dist/
6975
- name: Sign the dists with Sigstore
70-
uses: sigstore/gh-action-sigstore-python@v3.2.0
76+
uses: sigstore/gh-action-sigstore-python@a5caf349bc536fbef3668a10ed7f5cd309a4b53d # v3.2.0
7177
with:
7278
inputs: >-
7379
./dist/*.tar.gz
7480
./dist/*.whl
7581
- name: Create GitHub Release
7682
env:
7783
GITHUB_TOKEN: ${{ github.token }}
84+
RELEASE_TAG: ${{ github.ref_name }}
85+
REPOSITORY: ${{ github.repository }}
7886
run: >-
7987
gh release create
80-
'${{ github.ref_name }}'
81-
--repo '${{ github.repository }}'
88+
"$RELEASE_TAG"
89+
--repo "$REPOSITORY"
8290
--notes ""
8391
- name: Upload artifact signatures to GitHub Release
8492
env:
8593
GITHUB_TOKEN: ${{ github.token }}
86-
# Upload to GitHub Release using the `gh` CLI. `dist/` contains the built
87-
# packages, and the sigstore-produced signatures and certificates.
94+
RELEASE_TAG: ${{ github.ref_name }}
95+
REPOSITORY: ${{ github.repository }}
8896
run: >-
8997
gh release upload
90-
'${{ github.ref_name }}' dist/**
91-
--repo '${{ github.repository }}'
98+
"$RELEASE_TAG" dist/**
99+
--repo "$REPOSITORY"

.github/workflows/zizmor.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: zizmor
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- '*'
10+
schedule:
11+
- cron: '0 7 * * 1'
12+
workflow_dispatch:
13+
14+
permissions: {}
15+
16+
jobs:
17+
zizmor:
18+
name: Scan GitHub Actions
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
security-events: write
23+
24+
steps:
25+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
26+
with:
27+
persist-credentials: false
28+
29+
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
30+
with:
31+
enable-cache: true
32+
python-version: '3.13'
33+
34+
- name: Run zizmor
35+
run: uvx --from zizmor zizmor --format=github .
36+
37+
- name: Generate SARIF report
38+
if: always()
39+
run: uvx --from zizmor zizmor --format=sarif --no-exit-codes . > zizmor.sarif
40+
41+
- name: Upload SARIF report
42+
if: >
43+
always() &&
44+
(github.event_name != 'pull_request' ||
45+
github.event.pull_request.head.repo.full_name == github.repository)
46+
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4
47+
with:
48+
sarif_file: zizmor.sarif

0 commit comments

Comments
 (0)