Skip to content

Commit a29bc69

Browse files
authored
Scope GITHUB_TOKEN permissions (#4084)
## Description This PR does a few things related to scoping our tokens: * Add a `- uses: GitHubSecurityLab/actions-permissions/monitor@v1` to most of our actions so we can get ongoing summaries of the permissions each action is using. Some actions, like Windows tests and the TLS tests, are excluded because they are not supported or the proxy it uses breaks the test. * Add explicit `permissions` scoping to various jobs that need it. * Although not part of the PR I have changed our Workflow Permissions (in Settings > Actions > General > Workflow Permissions) from defaulting to Read/Write to Read Only. ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> * The CI for this PR ran successfully (except the Canary, but that appears to be an issue unrelated to this PR) * A dry-run release using the workflows from this branch succeeded https://github.com/smithy-lang/smithy-rs/actions/runs/14275005243 * Various other manually runnable actions tested against this branch: * Daily credentials verification: https://github.com/smithy-lang/smithy-rs/actions/runs/14288824835 * Update lockfiles: https://github.com/smithy-lang/smithy-rs/actions/runs/14288809742 * Invoke canary (failed but not for permissions reasons): https://github.com/smithy-lang/smithy-rs/actions/runs/14288631692 **Note:** I did not test the prod release workflow for obvious reasons. It might need permissions added next time it is invoked. I will cut a release as a follow up to this PR to see if anything needs updating ## Checklist ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 18e06e0 commit a29bc69

20 files changed

+113
-1
lines changed

.github/workflows/backport-pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
create-backport-pull-request:
2020
runs-on: ubuntu-latest
2121
steps:
22+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2223
- name: Checkout
2324
uses: actions/checkout@v4
2425
with:

.github/workflows/ci-main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ concurrency:
1818
env:
1919
ecr_repository: public.ecr.aws/w0m4q9l7/github-awslabs-smithy-rs-ci
2020

21+
permissions:
22+
actions: read
23+
contents: read
24+
id-token: write
25+
pull-requests: read
26+
2127
jobs:
2228
# Build and upload the Docker build image if necessary
2329
acquire-base-image:
@@ -30,6 +36,7 @@ jobs:
3036
id-token: write
3137
contents: read
3238
steps:
39+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
3340
- name: Checkout
3441
uses: actions/checkout@v4
3542
- name: Acquire credentials

.github/workflows/ci-merge-queue.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ concurrency:
1616
env:
1717
ecr_repository: public.ecr.aws/w0m4q9l7/github-awslabs-smithy-rs-ci
1818

19+
permissions:
20+
actions: read
21+
contents: read
22+
id-token: write
23+
pull-requests: read
24+
1925
jobs:
2026
# This job will, if possible, save a docker login password to the job outputs. The token will
2127
# be encrypted with the passphrase stored as a GitHub secret. The login password expires after 12h.
@@ -31,6 +37,7 @@ jobs:
3137
continue-on-error: true
3238
runs-on: ubuntu-latest
3339
steps:
40+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
3441
- name: Attempt to load a docker login password
3542
uses: aws-actions/configure-aws-credentials@v4
3643
with:
@@ -60,6 +67,7 @@ jobs:
6067
id-token: write
6168
contents: read
6269
steps:
70+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
6371
- uses: actions/checkout@v4
6472
with:
6573
path: smithy-rs

.github/workflows/ci-pr-forks.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,26 @@ concurrency:
1212
group: ci-forks-yaml-${{ github.ref }}
1313
cancel-in-progress: true
1414

15+
permissions:
16+
actions: read
17+
contents: read
18+
id-token: write
19+
pull-requests: read
20+
1521
jobs:
1622
# This job detects if the PR made changes to build tools. If it did, then it builds a new
1723
# build Docker image. Otherwise, it downloads a build image from Public ECR. In both cases,
1824
# it uploads the image as a build artifact for other jobs to download and use.
1925
acquire-base-image:
2026
name: Acquire Base Image
2127
if: ${{ github.event.pull_request.head.repo.full_name != 'smithy-lang/smithy-rs' }}
28+
permissions:
29+
id-token: write
30+
contents: read
2231
runs-on: ubuntu-latest
2332
timeout-minutes: 60
2433
steps:
34+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2535
- uses: actions/checkout@v4
2636
with:
2737
path: smithy-rs

.github/workflows/ci-pr.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ concurrency:
1515
env:
1616
ecr_repository: public.ecr.aws/w0m4q9l7/github-awslabs-smithy-rs-ci
1717

18+
permissions:
19+
actions: read
20+
contents: read
21+
id-token: write
22+
pull-requests: write
23+
1824
jobs:
1925
# This job will, if possible, save a docker login password to the job outputs. The token will
2026
# be encrypted with the passphrase stored as a GitHub secret. The login password expires after 12h.
@@ -31,6 +37,7 @@ jobs:
3137
continue-on-error: true
3238
runs-on: ubuntu-latest
3339
steps:
40+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
3441
- name: Attempt to load a docker login password
3542
uses: aws-actions/configure-aws-credentials@v4
3643
with:
@@ -45,7 +52,6 @@ jobs:
4552
)
4653
echo "docker-login-password=$ENCRYPTED_PAYLOAD" >> $GITHUB_OUTPUT
4754
48-
4955
# This job detects if the PR made changes to build tools. If it did, then it builds a new
5056
# build Docker image. Otherwise, it downloads a build image from Public ECR. In both cases,
5157
# it uploads the image as a build artifact for other jobs to download and use.
@@ -62,6 +68,7 @@ jobs:
6268
id-token: write
6369
contents: read
6470
steps:
71+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
6572
- uses: actions/checkout@v4
6673
with:
6774
path: smithy-rs
@@ -112,6 +119,8 @@ jobs:
112119

113120
semver-checks:
114121
name: Check PR semver compliance
122+
permissions:
123+
pull-requests: read
115124
runs-on: smithy_ubuntu-latest_8-core
116125
timeout-minutes: 20
117126
needs:
@@ -124,6 +133,7 @@ jobs:
124133
!contains(needs.*.result, 'failure') &&
125134
!contains(needs.*.result, 'cancelled')
126135
steps:
136+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
127137
- uses: actions/checkout@v4
128138
with:
129139
path: smithy-rs

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
- action: generate-aws-sdk-smoketest
5757
- action: generate-smithy-rs-release
5858
steps:
59+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
5960
- uses: actions/checkout@v4
6061
with:
6162
path: smithy-rs
@@ -127,6 +128,7 @@ jobs:
127128
- action: check-deterministic-codegen
128129
runner: smithy_ubuntu-latest_8-core
129130
steps:
131+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
130132
- uses: actions/checkout@v4
131133
with:
132134
path: smithy-rs
@@ -144,6 +146,7 @@ jobs:
144146
runs-on: smithy_ubuntu-latest_8-core
145147
timeout-minutes: 30
146148
steps:
149+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
147150
- uses: actions/checkout@v4
148151
with:
149152
path: smithy-rs
@@ -188,6 +191,7 @@ jobs:
188191
- action: check-aws-sdk-standalone-integration-tests
189192
runner: ubuntu-latest
190193
steps:
194+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
191195
- uses: actions/checkout@v4
192196
with:
193197
path: smithy-rs
@@ -266,6 +270,7 @@ jobs:
266270
test_aws_exclude: --exclude aws-inlineable
267271
test_smithy_rs_exclude: --exclude aws-smithy-http-server-python --exclude aws-smithy-http-server-typescript --exclude aws-smithy-experimental --exclude aws-smithy-http-client
268272
steps:
273+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
269274
- name: Checkout
270275
uses: actions/checkout@v4
271276
with:
@@ -343,7 +348,10 @@ jobs:
343348
permissions:
344349
id-token: write
345350
contents: read
351+
actions: read
352+
pull-requests: read
346353
steps:
354+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
347355
- uses: actions/checkout@v4
348356
with:
349357
path: smithy-rs
@@ -368,6 +376,7 @@ jobs:
368376
if: ${{ !inputs.run_canary }}
369377
runs-on: ubuntu-latest
370378
steps:
379+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
371380
- run: |
372381
echo "PR bot and canary cannot be invoked from a forked repository. Ask a maintainer to manually invoke them using your PR."
373382
exit 1
@@ -387,6 +396,7 @@ jobs:
387396
runs-on: ubuntu-latest
388397
name: Matrix Success
389398
steps:
399+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
390400
- name: Verify jobs succeeded
391401
# Pinned to commit hash of v1.2.2
392402
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe

.github/workflows/claim-crate-names.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
name: Check that workflow is running in main
2626
runs-on: ubuntu-latest
2727
steps:
28+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2829
- name: Main branch check
2930
if: ${{ github.ref_name != 'main' }}
3031
uses: actions/github-script@v7
@@ -35,10 +36,14 @@ jobs:
3536
# This job will be a no-op if an image was already built on main by another workflow.
3637
acquire-base-image:
3738
name: Acquire Base Image
39+
permissions:
40+
id-token: write
41+
contents: read
3842
needs:
3943
- main-branch-check
4044
runs-on: ubuntu-latest
4145
steps:
46+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
4247
- uses: actions/checkout@v4
4348
with:
4449
path: smithy-rs
@@ -60,6 +65,7 @@ jobs:
6065
- acquire-base-image
6166
runs-on: ubuntu-latest
6267
steps:
68+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
6369
- name: Install Rust
6470
uses: dtolnay/rust-toolchain@master
6571
with:

.github/workflows/credentials-verification.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
if: github.repository == 'smithy-lang/smithy-rs'
1313
runs-on: ubuntu-latest
1414
steps:
15+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
1516
- name: Checkout smithy-rs
1617
uses: actions/checkout@v4
1718
- name: Verify Crates.io Token
@@ -38,6 +39,7 @@ jobs:
3839
if: github.repository == 'smithy-lang/smithy-rs'
3940
runs-on: ubuntu-latest
4041
steps:
42+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
4143
- name: Checkout smithy-rs
4244
# To test the validity of the personal access token, we only need to perform checkout with the specified token.
4345
uses: actions/checkout@v4

.github/workflows/dry-run-release-scheduled.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ on:
1111
# Runs 00:00 UTC every day
1212
- cron: 0 0 * * *
1313

14+
permissions:
15+
actions: read
16+
contents: read
17+
id-token: write
18+
pull-requests: read
19+
1420
jobs:
1521
smithy-rs-scheduled-dry-run-release:
1622
name: Scheduled dry-run release

.github/workflows/dry-run-release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ on:
2222
type: boolean
2323
default: true
2424

25+
permissions:
26+
actions: read
27+
contents: read
28+
id-token: write
29+
pull-requests: read
30+
2531
jobs:
2632
smithy-rs-manual-dry-run-release:
2733
name: Manual dry run release

.github/workflows/github-pages.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
if: github.repository == 'smithy-lang/smithy-rs'
2121
runs-on: ubuntu-latest
2222
steps:
23+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2324
- name: Checkout
2425
uses: actions/checkout@v4
2526
with:

.github/workflows/manual-canary.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
name: Get PR info
2525
runs-on: ubuntu-latest
2626
steps:
27+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2728
- name: Get PR info
2829
id: get-pr-info
2930
uses: actions/github-script@v7
@@ -47,10 +48,14 @@ jobs:
4748

4849
acquire-base-image:
4950
name: Acquire Base Image
51+
permissions:
52+
id-token: write
53+
contents: read
5054
needs:
5155
- get-pr-info
5256
runs-on: ubuntu-latest
5357
steps:
58+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
5459
- uses: actions/checkout@v4
5560
with:
5661
path: smithy-rs
@@ -75,6 +80,7 @@ jobs:
7580
- get-pr-info
7681
runs-on: smithy_ubuntu-latest_8-core
7782
steps:
83+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
7884
- uses: actions/checkout@v4
7985
with:
8086
path: smithy-rs
@@ -94,6 +100,7 @@ jobs:
94100
id-token: write
95101
contents: read
96102
steps:
103+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
97104
- uses: actions/checkout@v4
98105
with:
99106
path: smithy-rs

.github/workflows/manual-pull-request-bot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ on:
1313
required: true
1414
type: string
1515

16+
permissions:
17+
id-token: write
18+
pull-requests: write
19+
contents: read
20+
1621
jobs:
1722
get-pr-info:
1823
name: Get PR info
1924
runs-on: ubuntu-latest
2025
steps:
26+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2127
- name: Get PR info
2228
id: get-pr-info
2329
uses: actions/github-script@v7
@@ -45,10 +51,14 @@ jobs:
4551
# it uploads the image as a build artifact for other jobs to download and use.
4652
acquire-base-image:
4753
name: Acquire Base Image
54+
permissions:
55+
id-token: write
56+
contents: read
4857
needs:
4958
- get-pr-info
5059
runs-on: ubuntu-latest
5160
steps:
61+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
5262
- uses: actions/checkout@v4
5363
with:
5464
path: smithy-rs

.github/workflows/manual-update-lockfiles.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
type: boolean
1717
default: false
1818

19+
permissions:
20+
contents: read
21+
id-token: write
22+
1923
concurrency:
2024
group: ${{ github.workflow }}-${{ inputs.base_branch }}
2125
cancel-in-progress: true

.github/workflows/prod-release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ on:
1717
required: true
1818
type: string
1919

20+
permissions:
21+
actions: read
22+
contents: read
23+
id-token: write
24+
pull-requests: read
25+
2026
jobs:
2127
smithy-rs-prod-release:
2228
name: Prod release

.github/workflows/pull-request-bot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
outputs:
4747
bot-message: ${{ steps.generate-diff.outputs.bot-message }}
4848
steps:
49+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
4950
- uses: actions/checkout@v4
5051
with:
5152
path: smithy-rs
@@ -147,6 +148,7 @@ jobs:
147148
contents: read
148149
pull-requests: write
149150
steps:
151+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
150152
- uses: actions/checkout@v4
151153
with:
152154
path: smithy-rs

0 commit comments

Comments
 (0)