Skip to content

Commit 66194f3

Browse files
jamesarichclaude
andauthored
ci: scope GITHUB_TOKEN to least privilege (#9)
Repo default is write (gh api repos/.../actions/permissions/workflow -> default_workflow_permissions: write), so every job here ran with a write-capable token even though this workflow now runs on every PR, including from forks, and only the release-asset upload step actually needs write access. Top-level contents: read, overridden to contents: write on the one job whose release step needs it. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 9f53e4f commit 66194f3

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

.github/workflows/githubci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ on:
88
types:
99
- created
1010

11+
# The repo's default is write (checked via `gh api .../actions/permissions/workflow`),
12+
# so every job here would otherwise get a write-capable GITHUB_TOKEN even
13+
# though only the release-asset upload needs one — and this workflow now
14+
# runs on every PR, including from forks. contents:write is scoped to the
15+
# one job that needs it (the release step, gated separately by
16+
# `if: github.event_name == 'release'`); everything else gets read-only.
17+
permissions:
18+
contents: read
19+
1120
concurrency:
1221
group: ${{ github.workflow }}-${{ github.ref }}
1322
cancel-in-progress: true
@@ -32,6 +41,10 @@ jobs:
3241
build:
3342
needs: set-matrix
3443
runs-on: ubuntu-latest
44+
# Only this job's release step needs write access (softprops/action-gh-release
45+
# creating/updating release assets); PR runs never reach that step.
46+
permissions:
47+
contents: write
3548
strategy:
3649
fail-fast: false
3750
matrix:

0 commit comments

Comments
 (0)