Skip to content

Commit 447ab7a

Browse files
eordanoclaude
andauthored
ci: give every Unity Cloud Build job a least-privilege permissions block
Audited every token-consuming operation per job: prebuild needs contents:read (checkout + version composite's git fetch), statuses:write (the four createCommitStatus calls) and pull-requests:read (changed-files REST fallback); build needs contents:read, actions:read (runs/{id}/jobs) and pull-requests:write (status-comment CRUD via build.py); build-gate touches no token at all. The two workflow_call callers' build jobs get the union block so the calls keep working if the repo default token ever tightens (a caller caps its callee). Fork PRs already run with a read-only token regardless of these blocks; status/comment writes there fail today and are unchanged by this. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 536e961 commit 447ab7a

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/build-profile-nightly.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ jobs:
7171
name: Build Unity Cloud
7272
needs: [check-commits, get-info]
7373
if: needs.check-commits.outputs.should_build == 'true'
74+
# Union of the called workflow's job-level grants — a caller caps its
75+
# callee, so this keeps the call working if the repo default tightens.
76+
permissions:
77+
contents: read
78+
statuses: write
79+
actions: read
80+
pull-requests: write
7481
uses: ./.github/workflows/build-unitycloud.yml
7582
with:
7683
profile: profile

.github/workflows/build-release-main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ jobs:
3838
build:
3939
name: Build Unity Cloud
4040
needs: get-info
41+
# Union of the called workflow's job-level grants — a caller caps its
42+
# callee, so this keeps the call working if the repo default tightens.
43+
permissions:
44+
contents: read
45+
statuses: write
46+
actions: read
47+
pull-requests: write
4148
strategy:
4249
matrix:
4350
install_source: ['launcher', 'epic']

.github/workflows/build-unitycloud.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ jobs:
209209
prebuild:
210210
name: Prebuild
211211
runs-on: ubuntu-latest
212+
# contents: read — checkout + the version composite's `git fetch origin main:main --tags`
213+
# over the checkout's persisted credentials.
214+
# statuses: write — "Skip build and test checks" posts 4 commit statuses via github-script.
215+
# pull-requests: read — step-security/changed-files' REST fallback (GET /pulls/{n}/files).
216+
permissions:
217+
contents: read
218+
statuses: write
219+
pull-requests: read
212220
timeout-minutes: 20
213221
# Skip when PR has 'perf_test' label (only performance tests should run)
214222
if: |
@@ -550,6 +558,14 @@ jobs:
550558
runs-on: ubuntu-latest
551559
needs: prebuild
552560
if: needs.prebuild.outputs.should_build == 'true'
561+
# contents: read — checkout + the size-budget step's GET /releases/latest.
562+
# actions: read — build.py resolves its own job URL via GET /actions/runs/{run_id}/jobs.
563+
# pull-requests: write — live CI status comment upsert (issue-comment POST/PATCH/DELETE
564+
# on the PR via .github/actions/ci-status-comment/upsert-ci-status.sh).
565+
permissions:
566+
contents: read
567+
actions: read
568+
pull-requests: write
553569
# Safety ceiling around the 450m retry budget + surrounding steps.
554570
timeout-minutes: 510
555571
strategy:
@@ -1018,6 +1034,8 @@ jobs:
10181034
build-gate:
10191035
name: Build Gate (Windows + macOS)
10201036
runs-on: ubuntu-latest
1037+
# Pure bash over needs.* context — no checkout, no token use.
1038+
permissions: {}
10211039
needs: [prebuild, build]
10221040
if: always() && github.event_name == 'pull_request'
10231041
steps:

0 commit comments

Comments
 (0)