Skip to content

Commit 94d46cd

Browse files
committed
build: add explicit workflow permissions and disable credential persistence
zizmor flagged two more findings once these files started being scanned: excessive-permissions (Medium, blocking) because none of the three workflows declared an explicit permissions: block and so ran with the default broad GITHUB_TOKEN scope, and artipacked (Low, informational) because checkout steps left credentials persisted in the git config, which get exposed to anything that later reads the workspace (e.g. artifact uploads). - build.yml: contents: read (checkout + build only, no writes) - lint.yml: contents: read, security-events: write (needed for github/codeql-action/upload-sarif) - generate-v3.yml: contents: read (the actual PR push uses its own SYNCED_GITHUB_TOKEN_REPO secret via peter-evans/create-pull-request, not the default token) - persist-credentials: false added to every actions/checkout step across all three files; none of them do a subsequent git push with the default token, so this is safe.
1 parent 60eb5ba commit 94d46cd

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ on:
2525
types: [ build ]
2626
workflow_dispatch:
2727

28+
permissions:
29+
contents: read
30+
2831
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2932
jobs:
3033
build-ApiDemos:
@@ -33,6 +36,8 @@ jobs:
3336

3437
steps:
3538
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
39+
with:
40+
persist-credentials: false
3641

3742
- name: set up Java 21
3843
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
@@ -56,6 +61,8 @@ jobs:
5661

5762
steps:
5863
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
64+
with:
65+
persist-credentials: false
5966

6067
- name: set up Java 21
6168
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
@@ -75,6 +82,8 @@ jobs:
7582

7683
steps:
7784
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
85+
with:
86+
persist-credentials: false
7887

7988
- name: set up Java 21
8089
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
@@ -94,6 +103,8 @@ jobs:
94103

95104
steps:
96105
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
106+
with:
107+
persist-credentials: false
97108

98109
- name: set up Java 21
99110
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
@@ -119,6 +130,8 @@ jobs:
119130

120131
steps:
121132
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
133+
with:
134+
persist-credentials: false
122135

123136
- name: set up Java 21
124137
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
@@ -144,6 +157,8 @@ jobs:
144157
- build-tutorials
145158
steps:
146159
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
160+
with:
161+
persist-credentials: false
147162
- name: set up Java 21
148163
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
149164
with:

.github/workflows/generate-v3.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ on:
1919
repository_dispatch:
2020
types: [ generate-v3 ]
2121

22+
permissions:
23+
contents: read
24+
2225
jobs:
2326
generate-v3:
2427
runs-on: ubuntu-latest
2528
timeout-minutes: 45
2629

2730
steps:
2831
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32+
with:
33+
persist-credentials: false
2934

3035
- name: set up JDK 17
3136
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0

.github/workflows/lint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ on:
1919
branches:
2020
- main
2121

22+
permissions:
23+
contents: read
24+
security-events: write
25+
2226
jobs:
2327
lint:
2428
runs-on: ubuntu-latest
2529

2630
steps:
2731
- name: Checkout code
2832
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
33+
with:
34+
persist-credentials: false
2935

3036
- name: Set up JDK 17
3137
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0

0 commit comments

Comments
 (0)