Skip to content

Commit 24ed552

Browse files
Add explicit permissions to GitHub workflows (#1764)
Fix code scanning alert about unlimited permissions by applying the principle of least privilege to all workflow jobs. Each job now has only the permissions it actually needs (contents: read for checkout and build operations). The rules workflow gets empty permissions as it only runs shell scripts without needing repository access. Committed-By-Agent: claude
1 parent 38dd6ee commit 24ed552

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ on:
1818
- sdk-release/**
1919
- feature/**
2020

21+
permissions: {}
22+
2123
jobs:
2224
build:
2325
name: Build
2426
runs-on: ubuntu-22.04
27+
permissions:
28+
contents: read
2529

2630
steps:
2731
- uses: extractions/setup-just@v2
@@ -44,6 +48,8 @@ jobs:
4448
name: Test (${{ matrix.ruby-version }})
4549
# this version of jruby isn't available in the new latest (24.04) so we have to pin (or update jruby)
4650
runs-on: ubuntu-22.04
51+
permissions:
52+
contents: read
4753
strategy:
4854
matrix:
4955
# following https://docs.stripe.com/sdks/versioning?lang=ruby#stripe-sdk-language-version-support-policy
@@ -69,6 +75,8 @@ jobs:
6975
endsWith(github.actor, '-stripe')
7076
needs: [build, test]
7177
runs-on: ubuntu-22.04
78+
permissions:
79+
contents: read
7280
steps:
7381
- name: Download all workflow run artifacts
7482
uses: actions/download-artifact@v4

.github/workflows/rules.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
types:
88
- auto_merge_enabled
99

10+
permissions: {}
11+
1012
jobs:
1113
require_merge_commit_on_merge_script_pr:
1214
name: Merge script PRs must create merge commits

0 commit comments

Comments
 (0)