Skip to content

Commit 0f61dc7

Browse files
jrhemstadwmaxey
authored andcommitted
Set finer-grain workflow permissions (#1163)
* Set workflow read permissions and per-job write permissions. * set pull-requests read at workflow level. * Set contents read at job level. * Explicitly set job-level read permissions. * Add permissions to verify-devcontainers.
1 parent a50c05f commit 0f61dc7

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

.github/workflows/build-and-test-linux.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ on:
1414
container_image: {type: string, required: false}
1515
run_tests: {type: boolean, required: false, default: true}
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
build:
1922
name: Build ${{inputs.test_name}}
23+
permissions:
24+
id-token: write
25+
contents: read
2026
uses: ./.github/workflows/run-as-coder.yml
2127
with:
2228
name: Build ${{inputs.test_name}}
@@ -27,6 +33,9 @@ jobs:
2733
2834
test:
2935
needs: build
36+
permissions:
37+
id-token: write
38+
contents: read
3039
if: ${{ !cancelled() && ( needs.build.result == 'success' || needs.build.result == 'skipped' ) && inputs.run_tests}}
3140
name: Test ${{inputs.test_name}}
3241
uses: ./.github/workflows/run-as-coder.yml

.github/workflows/dispatch-build-and-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ on:
88
devcontainer_version: {type: string, required: true}
99
is_windows: {type: boolean, required: true}
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
# Using a matrix to dispatch to the build-and-test reusable workflow for each build configuration
1316
# ensures that the build/test steps can overlap across different configurations. For example,
1417
# the build step for CUDA 12.1 + gcc 9.3 can run at the same time as the test step for CUDA 11.0 + clang 11.
1518
build_and_test_linux:
1619
name: build and test linux
20+
permissions:
21+
id-token: write
22+
contents: read
1723
if: ${{ !inputs.is_windows }}
1824
uses: ./.github/workflows/build-and-test-linux.yml
1925
strategy:
@@ -30,6 +36,9 @@ jobs:
3036

3137
build_and_test_windows:
3238
name: build and test windows
39+
permissions:
40+
id-token: write
41+
contents: read
3342
if: ${{ inputs.is_windows }}
3443
uses: ./.github/workflows/build-and-test-windows.yml
3544
strategy:

.github/workflows/pr.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ concurrency:
3030
group: ${{ github.workflow }}-on-${{ github.event_name }}-from-${{ github.ref_name }}
3131
cancel-in-progress: true
3232

33+
permissions:
34+
contents: read
35+
pull-requests: read
36+
3337
jobs:
3438
compute-matrix:
3539
name: Compute matrix
@@ -53,6 +57,9 @@ jobs:
5357
5458
nvrtc:
5559
name: NVRTC CUDA${{matrix.cuda}} C++${{matrix.std}}
60+
permissions:
61+
id-token: write
62+
contents: read
5663
needs: compute-matrix
5764
if: ${{ !contains(github.event.head_commit.message, 'skip-tests') }}
5865
uses: ./.github/workflows/run-as-coder.yml
@@ -69,6 +76,9 @@ jobs:
6976
7077
thrust:
7178
name: Thrust CUDA${{ matrix.cuda_version }} ${{ matrix.compiler }}
79+
permissions:
80+
id-token: write
81+
contents: read
7282
needs: compute-matrix
7383
uses: ./.github/workflows/dispatch-build-and-test.yml
7484
strategy:
@@ -84,6 +94,9 @@ jobs:
8494

8595
cub:
8696
name: CUB CUDA${{ matrix.cuda_version }} ${{ matrix.compiler }}
97+
permissions:
98+
id-token: write
99+
contents: read
87100
needs: compute-matrix
88101
uses: ./.github/workflows/dispatch-build-and-test.yml
89102
strategy:
@@ -99,6 +112,9 @@ jobs:
99112

100113
libcudacxx:
101114
name: libcudacxx CUDA${{ matrix.cuda_version }} ${{ matrix.compiler }}
115+
permissions:
116+
id-token: write
117+
contents: read
102118
needs: compute-matrix
103119
uses: ./.github/workflows/dispatch-build-and-test.yml
104120
strategy:
@@ -114,6 +130,9 @@ jobs:
114130

115131
clang-cuda:
116132
name: ${{matrix.lib}} ${{matrix.cpu}}/CTK${{matrix.cuda}}/clang-cuda
133+
permissions:
134+
id-token: write
135+
contents: read
117136
needs: compute-matrix
118137
strategy:
119138
fail-fast: false
@@ -129,6 +148,9 @@ jobs:
129148
130149
cccl-infra:
131150
name: CCCL Infrastructure
151+
permissions:
152+
id-token: write
153+
contents: read
132154
needs: compute-matrix
133155
if: ${{ !contains(github.event.head_commit.message, 'skip-tests') }}
134156
strategy:
@@ -146,6 +168,9 @@ jobs:
146168
147169
verify-devcontainers:
148170
name: Verify Dev Containers
171+
permissions:
172+
id-token: write
173+
contents: read
149174
uses: ./.github/workflows/verify-devcontainers.yml
150175

151176
# This job is the final job that runs after all other jobs and is used for branch protection status checks.
@@ -154,7 +179,7 @@ jobs:
154179
ci:
155180
runs-on: ubuntu-latest
156181
name: CI
157-
if: ${{ always() }} # need to use always() instead of !cancelled() because skipped jobs count as success
182+
if: ${{ always() }} # need to use always() instead of !cancelled() because skipped jobs count as success
158183
needs:
159184
- clang-cuda
160185
- cub

.github/workflows/run-as-coder.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ on:
1414
command: {type: string, required: true}
1515
env: { type: string, required: false, default: "" }
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
run-as-coder:
1922
name: ${{inputs.name}}
23+
permissions:
24+
id-token: write
25+
contents: read
2026
runs-on: ${{inputs.runner}}
2127
container:
2228
options: -u root
2329
image: ${{inputs.image}}
2430
env:
2531
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
26-
permissions:
27-
id-token: write
2832
steps:
2933
- name: Checkout repo
3034
uses: actions/checkout@v3

.github/workflows/verify-devcontainers.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ defaults:
77
run:
88
shell: bash -euo pipefail {0}
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
verify-make-devcontainers:
1215
name: Verify devcontainer files are up-to-date

0 commit comments

Comments
 (0)