Skip to content

Commit 812852a

Browse files
committed
fix(ci): pin GitHub Actions to commit SHAs and restrict GITHUB_TOKEN permissions
Resolve OpenSSF Scorecard alerts for TokenPermissions and PinnedDependencies by pinning all GitHub Actions to commit SHAs, hash-pinning pip install commands, and moving write permissions from workflow-level to job-level.
1 parent 07e262f commit 812852a

6 files changed

Lines changed: 34 additions & 31 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ on:
1919
schedule:
2020
- cron: '35 11 * * 6'
2121

22+
permissions: read-all
23+
2224
jobs:
2325
analyze:
2426
name: Analyze (${{ matrix.language }})
@@ -57,7 +59,7 @@ jobs:
5759
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
5860
steps:
5961
- name: Checkout repository
60-
uses: actions/checkout@v6
62+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6163

6264
# Add any setup steps before running the `github/codeql-action/init` action.
6365
# This includes steps like installing compilers or runtimes (`actions/setup-node`
@@ -67,7 +69,7 @@ jobs:
6769

6870
# Initializes the CodeQL tools for scanning.
6971
- name: Initialize CodeQL
70-
uses: github/codeql-action/init@v4
72+
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4
7173
with:
7274
languages: ${{ matrix.language }}
7375
build-mode: ${{ matrix.build-mode }}
@@ -95,6 +97,6 @@ jobs:
9597
exit 1
9698
9799
- name: Perform CodeQL Analysis
98-
uses: github/codeql-action/analyze@v4
100+
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4
99101
with:
100102
category: "/language:${{matrix.language}}"

.github/workflows/dependency-review.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
runs-on: 'ubuntu-latest'
1212
steps:
1313
- name: 'Harden Runner'
14-
uses: 'step-security/harden-runner@v2'
14+
uses: 'step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d' # v2.16.1
1515
with:
1616
egress-policy: 'audit'
1717

1818
- name: 'Checkout repository'
19-
uses: 'actions/checkout@v6'
19+
uses: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' # v6.0.2
2020

2121
- name: 'Dependency Review'
22-
uses: 'actions/dependency-review-action@v4'
22+
uses: 'actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48' # v4.9.0

.github/workflows/docs.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ jobs:
1919
runs-on: 'ubuntu-latest'
2020
steps:
2121
- name: 'Checkout repository'
22-
uses: 'actions/checkout@v6'
22+
uses: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' # v6.0.2
2323

2424
- name: 'Set up Python'
25-
uses: 'actions/setup-python@v6'
25+
uses: 'actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405' # v6.2.0
2626
with:
2727
python-version: '3.12'
2828

2929
- name: 'Install dependencies'
3030
run: |
3131
pip install --editable .
32-
pip install pdoc
32+
pip install --require-hashes --requirement /dev/stdin <<< "pdoc==16.0.0 --hash=sha256:070b51de2743b9b1a4e0ab193a06c9e6c12cf4151cf9137656eebb16e8556628"
3333
3434
- name: 'Build documentation'
3535
run: 'pdoc --output-directory docs lib'
@@ -38,7 +38,7 @@ jobs:
3838
run: 'touch docs/.nojekyll'
3939

4040
- name: 'Upload Pages artifact'
41-
uses: 'actions/upload-pages-artifact@v4'
41+
uses: 'actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b' # v4.0.0
4242
with:
4343
path: 'docs'
4444

@@ -51,4 +51,4 @@ jobs:
5151
steps:
5252
- name: 'Deploy to GitHub Pages'
5353
id: 'deployment'
54-
uses: 'actions/deploy-pages@v5'
54+
uses: 'actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128' # v5.0.0

.github/workflows/pre-commit-autoupdate.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,31 @@ on:
55
- cron: '0 8 * * 1'
66
workflow_dispatch: {}
77

8-
permissions:
9-
contents: 'write'
10-
pull-requests: 'write'
8+
permissions: read-all
119

1210
jobs:
1311
update:
1412
runs-on: 'ubuntu-latest'
13+
permissions:
14+
contents: 'write'
15+
pull-requests: 'write'
1516
steps:
1617
- name: 'Checkout repository'
17-
uses: 'actions/checkout@v6'
18+
uses: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' # v6.0.2
1819

1920
- name: 'Set up Python'
20-
uses: 'actions/setup-python@v6'
21+
uses: 'actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405' # v6.2.0
2122
with:
2223
python-version: '3.12'
2324

2425
- name: 'Install pre-commit'
25-
run: 'pip install pre-commit'
26+
run: 'pip install --require-hashes --requirement /dev/stdin <<< "pre-commit==4.5.1 --hash=sha256:3b3afd891e97337708c1674210f8eba659b52a38ea5f822ff142d10786221f77"'
2627

2728
- name: 'Run pre-commit autoupdate'
2829
run: 'pre-commit autoupdate'
2930

3031
- name: 'Create Pull Request'
31-
uses: 'peter-evans/create-pull-request@v8'
32+
uses: 'peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0' # v8.1.0
3233
with:
3334
commit-message: 'chore: update pre-commit hooks'
3435
title: 'chore: update pre-commit hooks'

.github/workflows/release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ jobs:
1414
runs-on: 'ubuntu-latest'
1515
steps:
1616
- name: 'Checkout repository'
17-
uses: 'actions/checkout@v6'
17+
uses: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' # v6.0.2
1818

1919
- name: 'Set up Python'
20-
uses: 'actions/setup-python@v6'
20+
uses: 'actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405' # v6.2.0
2121
with:
2222
python-version: '3.12'
2323

2424
- name: 'Install build tools'
25-
run: 'pip install --upgrade build'
25+
run: 'pip install --require-hashes --requirement /dev/stdin <<< "build==1.4.2 --hash=sha256:7a4d8651ea877cb2a89458b1b198f2e69f536c95e89129dbf5d448045d60db88"'
2626

2727
- name: 'Build package'
2828
run: 'python -m build'
2929

3030
- name: 'Upload build artifacts'
31-
uses: 'actions/upload-artifact@v7'
31+
uses: 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f' # v7.0.0
3232
with:
3333
name: 'dist'
3434
path: 'dist/'
@@ -44,13 +44,13 @@ jobs:
4444
id-token: 'write'
4545
steps:
4646
- name: 'Download build artifacts'
47-
uses: 'actions/download-artifact@v8'
47+
uses: 'actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c' # v8.0.1
4848
with:
4949
name: 'dist'
5050
path: 'dist/'
5151

5252
- name: 'Publish to TestPyPI'
53-
uses: 'pypa/gh-action-pypi-publish@release/v1'
53+
uses: 'pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc' # v1.12.4
5454
with:
5555
repository-url: 'https://test.pypi.org/legacy/'
5656

@@ -65,10 +65,10 @@ jobs:
6565
id-token: 'write'
6666
steps:
6767
- name: 'Download build artifacts'
68-
uses: 'actions/download-artifact@v8'
68+
uses: 'actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c' # v8.0.1
6969
with:
7070
name: 'dist'
7171
path: 'dist/'
7272

7373
- name: 'Publish to PyPI'
74-
uses: 'pypa/gh-action-pypi-publish@release/v1'
74+
uses: 'pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc' # v1.12.4

.github/workflows/scorecard.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ jobs:
1717

1818
steps:
1919
- name: 'Harden Runner'
20-
uses: 'step-security/harden-runner@v2'
20+
uses: 'step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d' # v2.16.1
2121
with:
2222
egress-policy: 'audit'
2323

2424
- name: 'Checkout code'
25-
uses: 'actions/checkout@v6'
25+
uses: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd' # v6.0.2
2626
with:
2727
persist-credentials: false
2828

2929
- name: 'Run analysis'
30-
uses: 'ossf/scorecard-action@v2.4.3'
30+
uses: 'ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a' # v2.4.3
3131
with:
3232
results_file: 'results.sarif'
3333
results_format: 'sarif'
3434
publish_results: true
3535

3636
- name: 'Upload artifact'
37-
uses: 'actions/upload-artifact@v7'
37+
uses: 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f' # v7.0.0
3838
with:
3939
name: 'SARIF file'
4040
path: 'results.sarif'
4141
retention-days: 5
4242

4343
- name: 'Upload to code-scanning'
44-
uses: 'github/codeql-action/upload-sarif@v4'
44+
uses: 'github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13' # v4
4545
with:
4646
sarif_file: 'results.sarif'

0 commit comments

Comments
 (0)