Skip to content

Commit af330ad

Browse files
committed
Harden workflows security
Signed-off-by: Alex <aleksandrosansan@gmail.com>
1 parent 198beb0 commit af330ad

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.github/workflows/bors.yml

Lines changed: 43 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,9 @@ jobs:
221254
run: LIBC_CI=1 TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh
222255

223256
build_channels_macos:
257+
permissions:
258+
contents: read # to fetch code (actions/checkout)
259+
224260
name: Build Channels macOS
225261
needs: macos
226262
runs-on: macos-12
@@ -251,6 +287,9 @@ jobs:
251287
run: LIBC_CI=1 TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh
252288

253289
build_channels_windows:
290+
permissions:
291+
contents: read # to fetch code (actions/checkout)
292+
254293
name: Build Channels Windows
255294
runs-on: windows-2022
256295
env:
@@ -301,6 +340,10 @@ jobs:
301340
run: sh ci/semver.sh macos
302341

303342
docs:
343+
permissions:
344+
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
345+
contents: read # to fetch code (actions/checkout)
346+
304347
name: Generate documentation
305348
runs-on: ubuntu-22.04
306349
needs: docker_linux_tier2

.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)