Skip to content

Commit 61fd80a

Browse files
authored
chore(ci): harden GitHub Actions workflow permissions (#2370)
1 parent 8c1f59b commit 61fd80a

File tree

9 files changed

+35
-30
lines changed

9 files changed

+35
-30
lines changed

.github/workflows/build-docs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ on:
2323
name: Build Latest Docs
2424
run-name: Build Latest Docs - ${{ inputs.version }}
2525

26+
permissions: {}
27+
2628
jobs:
2729
docs:
2830
runs-on: ubuntu-latest
2931
permissions:
30-
contents: read
31-
id-token: write
32+
contents: read # checkout repository
33+
id-token: write # OIDC for AWS credentials
3234
environment: Docs
3335
steps:
3436
- name: Checkout Repository

.github/workflows/check-pmd.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ on:
1818
name: PMD
1919
run-name: PMD - ${{ github.event_name }}
2020

21-
permissions:
22-
contents: read
21+
permissions: {}
2322

2423
jobs:
2524
pmd_analyse:
2625
runs-on: ubuntu-latest
2726
permissions:
28-
contents: write
29-
id-token: write
27+
contents: read # checkout repository
3028
steps:
3129
- name: Checkout Repository
3230
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -39,4 +37,4 @@ jobs:
3937
- uses: pmd/pmd-github-action@d9c1f3c5940cbf5923f1354e83fa858b4496ebaa # v2.0.0
4038
with:
4139
rulesets: '.github/pmd-ruleset.xml'
42-
token: ${{ secrets.GITHUB_TOKEN }}
40+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-drafter.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ on:
1414
name: Release Drafter
1515
run-name: Release Drafter
1616

17+
permissions: {}
18+
1719
jobs:
1820
update_release:
1921
runs-on: ubuntu-latest
2022
permissions:
21-
contents: write
22-
id-token: write
23+
contents: write # required for creating draft releases
2324
steps:
2425
- name: Relase Drafter
2526
uses: release-drafter/release-drafter@6db134d15f3909ccc9eefd369f02bd1e9cffdf97
2627
env:
27-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ on:
5555
name: Release
5656
run-name: Release – ${{ inputs.version }}
5757

58-
permissions:
59-
contents: read
58+
permissions: {}
6059

6160
env:
6261
RELEASE_COMMIT: ${{ github.sha }}
@@ -98,6 +97,8 @@ jobs:
9897
runs-on: ubuntu-latest
9998
needs:
10099
- setup
100+
permissions:
101+
contents: read # checkout repository
101102
outputs:
102103
source_hash: ${{ steps.upload_source.outputs.artifact-digest }}
103104
steps:
@@ -128,8 +129,7 @@ jobs:
128129
- version_seal
129130
if: ${{ inputs.skip_checks == false }}
130131
permissions:
131-
contents: write
132-
id-token: write
132+
contents: read # checkout and run tests
133133
steps:
134134
- id: download_source
135135
name: Download artifacts
@@ -162,6 +162,8 @@ jobs:
162162
- quality
163163
- version_seal
164164
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
165+
permissions:
166+
contents: read # download artifacts
165167
strategy:
166168
matrix:
167169
java: ${{ fromJson(needs.setup.outputs.build_matrix) }}
@@ -187,6 +189,8 @@ jobs:
187189
if: ${{ github.repository == 'aws-powertools/powertools-lambda-java' && inputs.skip_publish == false && always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
188190
needs:
189191
- build
192+
permissions:
193+
contents: read # download artifacts
190194
environment: Release
191195
steps:
192196
- id: download_source
@@ -219,8 +223,8 @@ jobs:
219223
- build
220224
- publish
221225
permissions:
222-
pull-requests: write
223-
contents: write
226+
contents: write # create tag and branch
227+
pull-requests: write # create PR
224228
steps:
225229
- id: checkout
226230
name: Checkout repository
@@ -266,8 +270,8 @@ jobs:
266270
needs:
267271
- create_pr
268272
permissions:
269-
contents: read
270-
id-token: write
273+
contents: read # checkout repository
274+
id-token: write # OIDC for AWS credentials
271275
environment: Docs
272276
steps:
273277
- id: checkout

.github/workflows/security-dependencies-check.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ on:
1313
name: Verify Dependencies
1414
run-name: Verify Dependencies – ${{ github.event_name }}
1515

16-
permissions:
17-
contents: read
16+
permissions: {}
1817

1918
jobs:
2019
verify:
2120
runs-on: ubuntu-latest
2221
permissions:
23-
contents: read
24-
pull-requests: write
22+
contents: read # checkout repository and read dependency snapshots
23+
pull-requests: write # post review comments
2524
steps:
2625
- name: Checkout Repository
2726
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.github/workflows/security-scorecard.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ on:
2323
name: OpenSSF Scorecard
2424
run-name: OpenSSF Scorecard
2525

26-
permissions: read-all
26+
permissions: {}
2727

2828
jobs:
2929
analysis:
3030
name: Scorecard analysis
3131
runs-on: ubuntu-latest
3232
environment: Security
3333
permissions:
34-
security-events: write
35-
id-token: write
34+
contents: read # checkout repository
35+
security-events: write # upload SARIF results
36+
id-token: write # OIDC authentication
3637
steps:
3738
- name: Checkout Repository
3839
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

examples/powertools-examples-kafka/src/main/java/org/demo/kafka/protobuf/ProtobufProduct.java

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/powertools-examples-kafka/src/main/java/org/demo/kafka/protobuf/ProtobufProductOrBuilder.java

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/powertools-examples-kafka/src/main/java/org/demo/kafka/protobuf/ProtobufProductOuterClass.java

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)