Skip to content

Commit 2080e78

Browse files
oddvalueclaude
andauthored
Harden GitHub Actions workflows (#84)
Pin every third-party action `uses:` ref to a full-length commit SHA (tag retained as trailing comment) so a re-pointed tag cannot inject malicious code, per the 2025 tj-actions/changed-files incident. Add a default top-level `permissions: contents: read` block to every workflow that lacked one, and grant `contents: write` only on the specific jobs that need it (php-cs-fixer auto-commit, changelog auto-commit). The dependabot-auto-merge workflow keeps its existing explicit permissions. Group github-actions dependabot updates so weekly SHA bumps land as a single PR instead of one per action. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 60db4bc commit 2080e78

6 files changed

Lines changed: 35 additions & 13 deletions

File tree

.github/dependabot.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ updates:
99
schedule:
1010
interval: "weekly"
1111
labels:
12-
- "dependencies"
12+
- "dependencies"
13+
groups:
14+
actions:
15+
patterns:
16+
- "*"

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- name: Dependabot metadata
1515
id: metadata
16-
uses: dependabot/fetch-metadata@v3.1.0
16+
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
1717
with:
1818
github-token: "${{ secrets.GITHUB_TOKEN }}"
1919

.github/workflows/php-cs-fixer.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ name: Check & fix styling
22

33
on: [push]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
php-cs-fixer:
710
runs-on: ubuntu-latest
811

12+
permissions:
13+
contents: write
14+
915
steps:
1016
- name: Checkout code
11-
uses: actions/checkout@v6
17+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1218
with:
1319
ref: ${{ github.head_ref }}
1420

@@ -18,6 +24,6 @@ jobs:
1824
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
1925

2026
- name: Commit changes
21-
uses: stefanzweifel/git-auto-commit-action@v7
27+
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7
2228
with:
2329
commit_message: Fix styling

.github/workflows/phpstan.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@ on:
66
- '**.php'
77
- 'phpstan.neon.dist'
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
phpstan:
1114
name: phpstan
1215
runs-on: ubuntu-latest
1316
steps:
14-
- uses: actions/checkout@v6
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1518

1619
- name: Setup PHP
17-
uses: shivammathur/setup-php@v2
20+
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
1821
with:
1922
php-version: '8.3'
2023
coverage: none
2124

2225
- name: Install composer dependencies
23-
uses: ramsey/composer-install@v4
26+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4
2427

2528
- name: Run PHPStan
2629
run: ./vendor/bin/phpstan --error-format=github

.github/workflows/run-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
branches:
99
- main
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
test:
1316
runs-on: ${{ matrix.os }}
@@ -34,10 +37,10 @@ jobs:
3437

3538
steps:
3639
- name: Checkout code
37-
uses: actions/checkout@v6
40+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3841

3942
- name: Setup PHP
40-
uses: shivammathur/setup-php@v2
43+
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
4144
with:
4245
php-version: ${{ matrix.php }}
4346
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
@@ -57,7 +60,7 @@ jobs:
5760
run: vendor/bin/pest --coverage-cobertura coverage.xml
5861

5962
- name: Upload coverage
60-
uses: gaelgirodon/ci-badges-action@v1
63+
uses: gaelgirodon/ci-badges-action@07a65145ff9feb271f426865f940977a94578ad4 # v1
6164
if: github.ref == 'refs/heads/main'
6265
with:
6366
gist-id: 9dd8e508cb2433728d42a258193770eb

.github/workflows/update-changelog.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,30 @@ on:
44
release:
55
types: [released,prereleased]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
update:
912
runs-on: ubuntu-latest
1013

14+
permissions:
15+
contents: write
16+
1117
steps:
1218
- name: Checkout code
13-
uses: actions/checkout@v6
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1420
with:
1521
ref: main
1622

1723
- name: Update Changelog
18-
uses: stefanzweifel/changelog-updater-action@v1
24+
uses: stefanzweifel/changelog-updater-action@a938690fad7edf25368f37e43a1ed1b34303eb36 # v1
1925
with:
2026
latest-version: ${{ github.event.release.name }}
2127
release-notes: ${{ github.event.release.body }}
2228

2329
- name: Commit updated CHANGELOG
24-
uses: stefanzweifel/git-auto-commit-action@v7
30+
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7
2531
with:
2632
branch: main
2733
commit_message: Update CHANGELOG

0 commit comments

Comments
 (0)