Skip to content

Commit b6b9295

Browse files
committed
github: restrict workflow permissions
Removes all default permissions, and only adds needed permissions to the workflows that need it. - read contents: allows reading the repository, most workflows need this - write contents: allows to write to the repository. Needed to create releases - write pull-requests: allows to manipulate pull requests. Unfortunately this is needed to comment on PRs - read actions: allows reading the state of actions Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent 38d1595 commit b6b9295

File tree

9 files changed

+54
-5
lines changed

9 files changed

+54
-5
lines changed

.github/workflows/1.249-lcm.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
name: Build and test (1.249-lcm, scheduled)
22

3+
permissions: {}
4+
35
on:
46
schedule:
57
# run every Monday, this refreshes the cache
68
- cron: '13 2 * * 1'
79

810
jobs:
11+
permissions:
12+
contents: read
13+
914
python-test:
1015
name: Python tests
1116
runs-on: ubuntu-20.04

.github/workflows/docs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
name: Generate and upload docs
22

3+
permissions: {}
4+
35
on:
46
push:
57
branches: master
68

79
jobs:
10+
permissions:
11+
contents: read
12+
813
ocaml:
914
name: Docs
1015
runs-on: ubuntu-22.04

.github/workflows/format.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Check format
22

3+
permissions: {}
4+
35
on:
46
pull_request:
57
branches:
@@ -9,6 +11,9 @@ on:
911
merge_group:
1012

1113
jobs:
14+
permissions:
15+
contents: read
16+
1217
ocaml-format:
1318
name: Ocaml files
1419
runs-on: ubuntu-latest

.github/workflows/generate-and-build-sdks.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Generate and Build SDKs
22

3+
permissions: {}
4+
35
on:
46
workflow_call:
57
inputs:
@@ -8,6 +10,9 @@ on:
810
type: string
911

1012
jobs:
13+
permissions:
14+
contents: read
15+
1116
generate-sdk-sources:
1217
name: Generate SDK sources
1318
runs-on: ubuntu-22.04
@@ -25,7 +30,7 @@ jobs:
2530
run: opam exec -- make sdk
2631

2732
# sdk-ci runs some Go unit tests.
28-
# This setting ensures that SDK date time
33+
# This setting ensures that SDK date time
2934
# tests are run on a machine that
3035
# isn't using UTC
3136
- name: Set Timezone to Tokyo for datetime tests
@@ -120,9 +125,9 @@ jobs:
120125
distribution: 'temurin'
121126

122127
# Java Tests are run at compile time.
123-
# This setting ensures that SDK date time
128+
# This setting ensures that SDK date time
124129
# tests are run on a machine that
125-
# isn't using UTC
130+
# isn't using UTC
126131
- name: Set Timezone to Tokyo for datetime tests
127132
run: |
128133
sudo timedatectl set-timezone Asia/Tokyo
@@ -158,7 +163,7 @@ jobs:
158163
# All tests builds and pipelines should
159164
# work on other timezones. This setting ensures that
160165
# SDK date time tests are run on a machine that
161-
# isn't using UTC
166+
# isn't using UTC
162167
- name: Set Timezone to Tokyo for datetime tests
163168
shell: pwsh
164169
run: Set-TimeZone -Id "Tokyo Standard Time"

.github/workflows/hugo.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
name: Generate and upload Hugo docs
22

3+
permissions: {}
4+
35
on:
46
push:
57
branches: master
68

79
jobs:
10+
permissions:
11+
contents: read
12+
813
ocaml:
914
name: Docs
1015
runs-on: ubuntu-22.04

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Build and test
22

3+
permissions: {}
4+
35
on:
46
# When only Hugo docs change, this workflow is not required:
57
push:
@@ -17,6 +19,9 @@ concurrency: # On new push, cancel old workflows from the same PR, branch or tag
1719
cancel-in-progress: true
1820

1921
jobs:
22+
permissions:
23+
contents: read
24+
2025
ocaml-tests:
2126
name: Run OCaml tests
2227
runs-on: ubuntu-22.04

.github/workflows/other.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Build and test (other)
22

3+
permissions: {}
4+
35
on:
46
# When only Hugo docs change, this workflow is not required:
57
push:
@@ -17,6 +19,10 @@ concurrency: # On new push, cancel old workflows from the same PR, branch or tag
1719
cancel-in-progress: true
1820

1921
jobs:
22+
permissions:
23+
contents: read
24+
pull-requests: write # allow commenting on the PR
25+
2026
python-test:
2127
name: Python tests
2228
runs-on: ubuntu-22.04

.github/workflows/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
name: Create release from tag
22

3+
permissions: {}
4+
35
on:
46
push:
57
tags:
68
- "v*"
79

810
jobs:
11+
permissions:
12+
contents: read
13+
914
build-python:
1015
name: Build and upload Python artifacts
1116
runs-on: ubuntu-latest
@@ -40,6 +45,9 @@ jobs:
4045
xapi_version: ${{ github.ref_name }}
4146

4247
release:
48+
permissions:
49+
contents: write # allow creating a release
50+
4351
name: "Create and package release"
4452
runs-on: ubuntu-latest
4553
needs: [build-python, build-sdks]

.github/workflows/shellcheck.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: ShellCheck
22

3+
permissions: {}
4+
35
on:
46
pull_request:
57
merge_group:
@@ -16,8 +18,11 @@ jobs:
1618
runs-on: ubuntu-latest
1719

1820
permissions:
21+
actions: read
22+
contents: read
23+
pull-requests: write # allow commenting on the PR
1924
security-events: write
20-
25+
2126
steps:
2227
- name: Checkout code
2328
uses: actions/checkout@v4

0 commit comments

Comments
 (0)