Skip to content

Commit 1db99b7

Browse files
authored
fix(ci): add explicit permissions to GitHub Actions workflows (#4)
Add permissions blocks to all jobs in CI and release workflows to follow security best practices. This limits GITHUB_TOKEN permissions to minimum required for each job: - contents: read - for jobs that only need to read repository - actions: write - for jobs that upload artifacts (coverage, build) - contents: write - for release job that creates GitHub releases This prevents potential privilege escalation and follows the principle of least privilege for GitHub Actions. Fixes 9 CodeQL security scanning alerts.
1 parent d755679 commit 1db99b7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
name: Check
2929
runs-on: ubuntu-latest
3030
timeout-minutes: 15
31+
permissions:
32+
contents: read
3133
steps:
3234
- uses: actions/checkout@v5
3335

@@ -63,6 +65,8 @@ jobs:
6365
name: Security Audit
6466
runs-on: ubuntu-latest
6567
timeout-minutes: 10
68+
permissions:
69+
contents: read
6670
steps:
6771
- uses: actions/checkout@v5
6872

@@ -92,6 +96,8 @@ jobs:
9296
needs: [check]
9397
runs-on: ${{ matrix.os }}
9498
timeout-minutes: 45
99+
permissions:
100+
contents: read
95101
strategy:
96102
fail-fast: false
97103
matrix:
@@ -149,6 +155,9 @@ jobs:
149155
needs: [check]
150156
runs-on: ubuntu-latest
151157
timeout-minutes: 30
158+
permissions:
159+
contents: read
160+
actions: write # For uploading artifacts
152161
steps:
153162
- uses: actions/checkout@v5
154163

@@ -199,6 +208,8 @@ jobs:
199208
needs: [check]
200209
runs-on: ubuntu-latest
201210
timeout-minutes: 20
211+
permissions:
212+
contents: read
202213
steps:
203214
- uses: actions/checkout@v5
204215

@@ -221,6 +232,8 @@ jobs:
221232
needs: [check]
222233
runs-on: ubuntu-latest
223234
timeout-minutes: 25
235+
permissions:
236+
contents: read
224237
steps:
225238
- uses: actions/checkout@v5
226239

@@ -252,6 +265,8 @@ jobs:
252265
needs: [test]
253266
runs-on: ubuntu-latest
254267
timeout-minutes: 25
268+
permissions:
269+
contents: read
255270
steps:
256271
- uses: actions/checkout@v5
257272

@@ -291,6 +306,8 @@ jobs:
291306
needs: [check, security, test, coverage, msrv, benchmark]
292307
runs-on: ubuntu-latest
293308
if: always()
309+
permissions:
310+
contents: read
294311
steps:
295312
- name: Check all jobs
296313
run: |

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
name: Build Release (${{ matrix.target }})
1414
runs-on: ${{ matrix.os }}
1515
timeout-minutes: 45
16+
permissions:
17+
contents: read
18+
actions: write # For uploading artifacts
1619
strategy:
1720
fail-fast: false
1821
matrix:

0 commit comments

Comments
 (0)