Skip to content

Commit fc0639a

Browse files
committed
build: harden workflow permissions
Signed-off-by: Alex <aleksandrosansan@gmail.com>
1 parent 35cd8f0 commit fc0639a

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.github/workflows/bors.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
- auto-libc
77
- try
88

9+
permissions: {}
910
jobs:
1011
docker_linux_tier1:
12+
permissions:
13+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
14+
contents: read # to fetch code (actions/checkout)
15+
1116
name: Docker Linux Tier1
1217
runs-on: ubuntu-22.04
1318
strategy:
@@ -28,6 +33,10 @@ jobs:
2833
run: LIBC_CI=1 sh ./ci/run-docker.sh ${{ matrix.target }}
2934

3035
macos:
36+
permissions:
37+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
38+
contents: read # to fetch code (actions/checkout)
39+
3140
name: macOS
3241
runs-on: macos-12
3342
strategy:
@@ -47,6 +56,10 @@ jobs:
4756
run: LIBC_CI=1 sh ./ci/run.sh ${{ matrix.target }}
4857

4958
windows:
59+
permissions:
60+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
61+
contents: read # to fetch code (actions/checkout)
62+
5063
name: Windows
5164
runs-on: windows-2022
5265
env:
@@ -83,6 +96,10 @@ jobs:
8396
shell: bash
8497

8598
style_check:
99+
permissions:
100+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
101+
contents: read # to fetch code (actions/checkout)
102+
86103
name: Style check
87104
runs-on: ubuntu-22.04
88105
steps:
@@ -96,6 +113,10 @@ jobs:
96113
run: sh ci/style.sh
97114

98115
docker_linux_tier2:
116+
permissions:
117+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
118+
contents: read # to fetch code (actions/checkout)
119+
99120
name: Docker Linux Tier2
100121
needs: [docker_linux_tier1, style_check]
101122
runs-on: ubuntu-22.04
@@ -154,6 +175,10 @@ jobs:
154175
# These targets are tier 3 or otherwise need to have CI build std via -Zbuild-std.
155176
# Because of this, only the nightly compiler can be used on these targets.
156177
docker_linux_build_std:
178+
permissions:
179+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
180+
contents: read # to fetch code (actions/checkout)
181+
157182
if: ${{ false }} # This is currently broken
158183
name: Docker Linux Build-Std Targets
159184
needs: [docker_linux_tier1, style_check]
@@ -177,6 +202,10 @@ jobs:
177202

178203
# devkitpro's pacman needs to be connected from Docker.
179204
docker_switch:
205+
permissions:
206+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
207+
contents: read # to fetch code (actions/checkout)
208+
180209
name: Docker Switch
181210
needs: [docker_linux_tier1, style_check]
182211
runs-on: ubuntu-22.04
@@ -191,6 +220,10 @@ jobs:
191220
run: LIBC_CI=1 sh ./ci/run-docker.sh switch
192221

193222
build_channels_linux:
223+
permissions:
224+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
225+
contents: read # to fetch code (actions/checkout)
226+
194227
name: Build Channels Linux
195228
needs: docker_linux_tier2
196229
runs-on: ubuntu-22.04
@@ -221,6 +254,10 @@ jobs:
221254
run: LIBC_CI=1 TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh
222255

223256
build_channels_macos:
257+
permissions:
258+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
259+
contents: read # to fetch code (actions/checkout)
260+
224261
name: Build Channels macOS
225262
needs: macos
226263
runs-on: macos-12
@@ -251,6 +288,9 @@ jobs:
251288
run: LIBC_CI=1 TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh
252289

253290
build_channels_windows:
291+
permissions:
292+
contents: read # to fetch code (actions/checkout)
293+
254294
name: Build Channels Windows
255295
runs-on: windows-2022
256296
env:
@@ -275,6 +315,9 @@ jobs:
275315
shell: bash
276316

277317
semver_linux:
318+
permissions:
319+
contents: read # to fetch code (actions/checkout)
320+
278321
if: ${{ false }} # This is currently broken
279322
name: Semver Linux
280323
runs-on: ubuntu-22.04
@@ -288,6 +331,9 @@ jobs:
288331
run: sh ci/semver.sh linux
289332

290333
semver_macos:
334+
permissions:
335+
contents: read # to fetch code (actions/checkout)
336+
291337
if: ${{ false }} # This is currently broken
292338
name: Semver macOS
293339
runs-on: macos-12
@@ -301,6 +347,10 @@ jobs:
301347
run: sh ci/semver.sh macos
302348

303349
docs:
350+
permissions:
351+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
352+
contents: read # to fetch code (actions/checkout)
353+
304354
name: Generate documentation
305355
runs-on: ubuntu-22.04
306356
needs: docker_linux_tier2

.github/workflows/docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ on:
55
branches:
66
- master
77

8+
permissions: {}
89
jobs:
910
upload_docs:
11+
permissions:
12+
contents: write # for git push
13+
1014
name: Upload documentation
1115
runs-on: ubuntu-22.04
1216
if: github.repository == 'rust-lang/libc'

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
branches:
88
- master
99

10+
permissions:
11+
contents: read # to fetch code (actions/checkout)
12+
1013
jobs:
1114
docker_linux_tier1:
1215
name: Docker Linux Tier1

0 commit comments

Comments
 (0)