Skip to content

Commit 83b6fd1

Browse files
peytondmurraygodlygeek
authored andcommitted
ci: Harden GitHub Actions workflows
Fix security-related issues in GitHub Actions flagged by zizmor. Signed-off-by: Peyton Murray <peynmurray@gmail.com>
1 parent bdb715b commit 83b6fd1

2 files changed

Lines changed: 35 additions & 16 deletions

File tree

.github/workflows/build.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Build
22

3+
permissions: {}
4+
35
on:
46
push:
57
pull_request:
@@ -19,17 +21,19 @@ jobs:
1921
name: Source and wheel distributions
2022
runs-on: ubuntu-latest
2123
steps:
22-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
25+
with:
26+
persist-credentials: false
2327

2428
- name: Build distributions
2529
run: pipx run build[virtualenv] --sdist --wheel
2630

27-
- uses: actions/upload-artifact@v4
31+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
2832
with:
2933
name: dist
3034
path: dist/*
3135

32-
- uses: actions/upload-artifact@v4
36+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
3337
with:
3438
name: test-deps
3539
path: |
@@ -47,14 +51,14 @@ jobs:
4751
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
4852
steps:
4953
- name: Set up Python
50-
uses: actions/setup-python@v4
54+
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
5155
with:
5256
python-version: ${{ matrix.python_version }}-dev
53-
- uses: actions/download-artifact@v4
57+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
5458
with:
5559
name: dist
5660
path: dist
57-
- uses: actions/download-artifact@v4
61+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
5862
with:
5963
name: test-deps
6064
path: .
@@ -78,9 +82,9 @@ jobs:
7882
permissions:
7983
id-token: write # Required to retrieve a Trusted Publishing token
8084
steps:
81-
- uses: actions/download-artifact@v4
85+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
8286
with:
8387
name: dist
8488
path: dist
8589

86-
- uses: pypa/gh-action-pypi-publish@v1.13.0
90+
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

.github/workflows/validate.yaml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
name: Validate
22

3+
permissions: {}
4+
35
on:
46
push:
5-
branches:
6-
- main
7+
branches: ["main"]
78
pull_request:
8-
branches:
9-
- main
10-
workflow_dispatch:
9+
branches: ["**"]
1110

1211
jobs:
1312
lint:
1413
name: 'Lint'
1514
runs-on: ubuntu-latest
1615
steps:
17-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
17+
with:
18+
persist-credentials: false
1819
- name: Set up Python
19-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
2021
with:
2122
python-version: '3.12-dev'
2223
- name: Install Python dependencies
@@ -27,4 +28,18 @@ jobs:
2728
python3 -m pip install -e .
2829
- name: Lint sources
2930
run: |
30-
make PYTHON=python${{matrix.python_version}} lint
31+
make lint
32+
33+
zizmor:
34+
name: Run zizmor 🌈
35+
runs-on: ubuntu-latest
36+
permissions:
37+
security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files.
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
41+
with:
42+
persist-credentials: false
43+
44+
- name: Run zizmor 🌈
45+
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6

0 commit comments

Comments
 (0)