Skip to content

Commit 7feaef4

Browse files
dsarnoclaude
andcommitted
ci(unity-tests): harden pull_request_target and gate artifact upload
Address CodeRabbit security review on #1103: - persist-credentials: false on the checkout step, so GITHUB_TOKEN is not written to disk and cannot be read by subsequent steps running PR-controlled code. - Explicit permissions: contents: read on the testAllModes job, scoping the workflow's token down from the default read/write set. - Skip upload-artifact when the main test step was skipped (e.g., because the preceding domain-reload step failed without continue-on-error). Avoids the noisy "No files were found" error on top of an already-failed run. The label-gated trigger plus these mitigations narrow the blast radius of the pull_request_target + checkout-PR-head pattern. The remaining trust boundary is the maintainer review before applying safe-to-test; documenting the review checklist (especially TestProjects/UnityMCPTests diffs) is a follow-up. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c641c8c commit 7feaef4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

.github/workflows/unity-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
testAllModes:
3232
name: Test in ${{ matrix.testMode }}
3333
runs-on: ubuntu-latest
34+
permissions:
35+
contents: read
3436
if: >
3537
github.event_name != 'pull_request_target' ||
3638
(github.event.pull_request.head.repo.full_name != github.repository &&
@@ -50,6 +52,7 @@ jobs:
5052
with:
5153
lfs: true
5254
ref: ${{ inputs.ref || github.event.pull_request.head.sha || github.ref }}
55+
persist-credentials: false
5356

5457
- name: Detect Unity license secrets
5558
id: detect
@@ -130,7 +133,7 @@ jobs:
130133
fi
131134
132135
- uses: actions/upload-artifact@v4
133-
if: always() && steps.detect.outputs.unity_ok == 'true'
136+
if: always() && steps.detect.outputs.unity_ok == 'true' && steps.tests.outcome != 'skipped'
134137
with:
135138
name: Test results for ${{ matrix.testMode }}
136139
path: ${{ steps.tests.outputs.artifactsPath }}

0 commit comments

Comments
 (0)