Skip to content

Commit b385782

Browse files
ericproulxclaude
andauthored
Pin workflow actions to commits and grant their tokens only what they need (#3088)
Every action and reusable workflow was referenced by a tag or a branch its owner can move, and every job ran with the repository's default read/write token. Both Danger callers also passed `secrets: inherit`, handing every repository secret to another repository's workflow, though Danger uses only the token. Each reference now names the commit its tag or branch points to today, with the version as a comment, so what runs is unchanged. test and edge read only. The Danger callers grant what the called workflows ask for, and no secrets. Dependabot keeps the pins current, proposing a release once it is a week old. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f9a05c4 commit b385782

6 files changed

Lines changed: 41 additions & 14 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Keeps the actions and reusable workflows that .github/workflows pins to
2+
# commits up to date, with their version comments. A release is proposed once
3+
# it is a week old, so that a compromised one has time to be caught and pulled.
4+
version: 2
5+
updates:
6+
- package-ecosystem: github-actions
7+
directory: /
8+
schedule:
9+
interval: weekly
10+
cooldown:
11+
default-days: 7
12+
groups:
13+
github-actions:
14+
patterns: ['*']

‎.github/workflows/danger-comment.yml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@ on:
77

88
jobs:
99
comment:
10-
uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
11-
secrets: inherit
10+
uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@34fd37617a87c09a408c39646d871cd3b6135eb9 # v0.1.0
11+
# What the called workflow asks for. It needs no secret but the token.
12+
permissions:
13+
contents: read
14+
actions: read
15+
issues: write
16+
pull-requests: write

‎.github/workflows/danger.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ on:
66

77
jobs:
88
danger:
9-
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.2.0
10-
secrets: inherit
9+
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@6152b4436901a31e3ebbf09152ae182282487a75 # v0.2.0
10+
# What the called workflow asks for. It needs no secret but the token.
11+
permissions:
12+
contents: read
1113
with:
1214
ruby-version: '3.4'
1315
gemfile: gemfiles/danger.gemfile

‎.github/workflows/edge.yml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
name: edge
33
on: workflow_dispatch
4+
permissions:
5+
contents: read
46
jobs:
57
test:
68
strategy:
@@ -13,10 +15,10 @@ jobs:
1315
env:
1416
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
1517
steps:
16-
- uses: actions/checkout@v6
18+
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
1719

1820
- name: Set up Ruby
19-
uses: ruby/setup-ruby@v1
21+
uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0
2022
with:
2123
ruby-version: ${{ matrix.ruby }}
2224
bundler-cache: true
@@ -25,7 +27,7 @@ jobs:
2527
run: "RUBYOPT='--enable=frozen-string-literal' bundle exec rspec"
2628

2729
- name: Coveralls
28-
uses: coverallsapp/github-action@v2
30+
uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8
2931
with:
3032
github-token: ${{ secrets.GITHUB_TOKEN }}
3133
flag-name: run-${{ matrix.ruby }}-${{ matrix.gemfile }}
@@ -36,7 +38,7 @@ jobs:
3638
runs-on: ubuntu-latest
3739
steps:
3840
- name: Coveralls Finished
39-
uses: coverallsapp/github-action@v2
41+
uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8
4042
with:
4143
github-token: ${{ secrets.github_token }}
4244
parallel-finished: true

‎.github/workflows/test.yml‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ name: test
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
lint:
710
name: RuboCop
811
runs-on: ubuntu-latest
912
steps:
10-
- uses: actions/checkout@v6
13+
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
1114

1215
- name: Set up Ruby
13-
uses: ruby/setup-ruby@v1
16+
uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0
1417
with:
1518
ruby-version: 3.4
1619
bundler-cache: true
@@ -60,10 +63,10 @@ jobs:
6063
env:
6164
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
6265
steps:
63-
- uses: actions/checkout@v6
66+
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
6467

6568
- name: Set up Ruby
66-
uses: ruby/setup-ruby@v1
69+
uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0
6770
with:
6871
ruby-version: ${{ matrix.ruby }}
6972
bundler-cache: true
@@ -72,7 +75,7 @@ jobs:
7275
run: "RUBYOPT='--enable=frozen-string-literal' bundle exec rspec ${{ matrix.specs }}"
7376

7477
- name: Coveralls
75-
uses: coverallsapp/github-action@v2
78+
uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8
7679
with:
7780
github-token: ${{ secrets.GITHUB_TOKEN }}
7881
flag-name: run-${{ matrix.ruby }}-${{ matrix.gemfile }}
@@ -83,7 +86,7 @@ jobs:
8386
runs-on: ubuntu-latest
8487
steps:
8588
- name: Coveralls Finished
86-
uses: coverallsapp/github-action@v2
89+
uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8
8790
with:
8891
github-token: ${{ secrets.github_token }}
8992
parallel-finished: true

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [#3056](https://github.com/ruby-grape/grape/pull/3056): Drop support for Rails 7.2 and require ActiveSupport 8.0 - [@ericproulx](https://github.com/ericproulx).
1010
* [#3062](https://github.com/ruby-grape/grape/pull/3062): Use the reusable Danger workflow with a separate Gemfile - [@dblock](https://github.com/dblock).
1111
* [#3063](https://github.com/ruby-grape/grape/pull/3063): Drop support for Rack 2.2 and 3.0 and require Rack 3.1 - [@ericproulx](https://github.com/ericproulx).
12+
* [#3088](https://github.com/ruby-grape/grape/pull/3088): Pin workflow actions to commits and grant their tokens only what they need - [@ericproulx](https://github.com/ericproulx).
1213
* Your contribution here.
1314

1415
#### Fixes

0 commit comments

Comments
 (0)