Skip to content

Commit 3a4a3a6

Browse files
authored
build: apply least privilege to workflows (#263)
In this commit we add least privilege principle the workflow permissions. Signed-off-by: András Felleg <afelleg@gmail.com>
1 parent 15753e3 commit 3a4a3a6

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎.github/workflows/build.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ on:
1313
workflow_dispatch:
1414
# Allow workflow to be triggered manually.
1515

16+
permissions: {}
17+
1618
jobs:
1719
detect-secrets:
1820
if: "!contains(github.event.head_commit.message, '[skip ci]')"
1921
name: detect-secrets
2022
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
2125

2226
steps:
2327
- name: Checkout repository
@@ -41,6 +45,8 @@ jobs:
4145
name: build-test (java ${{matrix.java-version}})
4246
needs: detect-secrets
4347
runs-on: ubuntu-latest
48+
permissions:
49+
contents: read
4450
strategy:
4551
matrix:
4652
java-version: ['11', '25']
@@ -64,6 +70,7 @@ jobs:
6470
runs-on: ubuntu-latest
6571
name: Final Test Results
6672
needs: [build]
73+
permissions: {}
6774
steps:
6875
- run: |
6976
result="${{ needs.build.result }}"
@@ -78,6 +85,8 @@ jobs:
7885
needs: build
7986
if: "github.ref_name == 'main' && github.event_name != 'pull_request'"
8087
runs-on: ubuntu-latest
88+
permissions:
89+
contents: read
8190

8291
steps:
8392
- name: Checkout repository

‎.github/workflows/publish.yaml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ on:
1111
workflow_dispatch:
1212
# Allow this workflow to be triggered manually
1313

14+
permissions: {}
15+
1416
jobs:
1517
publish:
1618
name: publish-release
1719
runs-on: ubuntu-latest
18-
20+
permissions:
21+
contents: read
22+
1923
steps:
2024
- name: Checkout repository
2125
uses: actions/checkout@v4

0 commit comments

Comments
 (0)