Skip to content

Commit b4fa525

Browse files
committed
GH Actions: "pin" all action runners
Recently there has been more and more focus on securing GH Actions workflows - in part due to some incidents. The problem with "unpinned" action runners is as follows: * Tags are mutable, which means that a tag could point to a safe commit today, but to a malicious commit tomorrow. Note that GitHub is currently beta-testing a new "immutable releases" feature (= tags and release artifacts can not be changed anymore once the release is published), but whether that has much effect depends on the ecosystem of the packages using the feature. Aside from that, it will likely take years before all projects adopt _immutable releases_. * Action runners often don't even point to a tag, but to a branch, making the used action runner a moving target. _Note: this type of "floating major" for action runners used to be promoted as good practice when the ecosystem was "young". Insights have since changed._ While it is convenient to use "floating majors" of action runners, as this means you only need to update the workflows on a new major release of the action runner, the price is higher risk of malicious code being executed in workflows. Dependabot, by now, can automatically submit PRs to update pinned action runners too, as long as the commit-hash pinned runner is followed by a comment listing the released version the commit is pointing to. So, what with Dependabot being capable of updating workflows with pinned action runners, I believe it is time to update the workflows to the _current_ best practice of using commit-hash pinned action runners. The downside of this change is that there will be more frequent Dependabot PRs. If this would become a burden/irritating, the following mitigations can be implemented: 1. Updating the Dependabot config to group updates instead of sending individual PRs per action runner. 2. A workflow to automatically merge Dependabot PRs as long as CI passes. Ref: https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions
1 parent 5765dae commit b4fa525

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

.github/workflows/basic-qa.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626

2727
steps:
2828
- name: Checkout repository
29-
uses: actions/checkout@v5
29+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3030

3131
- name: Setup PHP
32-
uses: shivammathur/setup-php@v2
32+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
3333
with:
3434
php-version: 'latest'
3535
coverage: none
@@ -48,7 +48,7 @@ jobs:
4848
phpcsstandards/phpcsextra:"${{ env.EXTRA_DEV }}"
4949
5050
- name: Install Composer dependencies
51-
uses: ramsey/composer-install@v3
51+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
5252
with:
5353
# Bust the cache at least once a month - output format: YYYY-MM.
5454
custom-cache-suffix: $(date -u "+%Y-%m")
@@ -64,38 +64,38 @@ jobs:
6464
# Validate the Ruleset XML files.
6565
# @link http://xmlsoft.org/xmllint.html
6666
- name: Validate the WordPress rulesets
67-
uses: phpcsstandards/xmllint-validate@v1
67+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
6868
with:
6969
pattern: "./*/ruleset.xml"
7070
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
7171

7272
- name: Validate the sample ruleset
73-
uses: phpcsstandards/xmllint-validate@v1
73+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
7474
with:
7575
pattern: "phpcs.xml.dist.sample"
7676
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
7777

7878
# Validate the Documentation XML files.
7979
- name: Validate documentation against schema
80-
uses: phpcsstandards/xmllint-validate@v1
80+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
8181
with:
8282
pattern: "./WordPress/Docs/*/*Standard.xml"
8383
xsd-file: "vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd"
8484

8585
- name: Validate Project PHPCS ruleset against schema
86-
uses: phpcsstandards/xmllint-validate@v1
86+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
8787
with:
8888
pattern: ".phpcs.xml.dist"
8989
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
9090

9191
- name: "Validate PHPUnit config for use with PHPUnit 8"
92-
uses: phpcsstandards/xmllint-validate@v1
92+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
9393
with:
9494
pattern: "phpunit.xml.dist"
9595
xsd-file: "vendor/phpunit/phpunit/schema/8.5.xsd"
9696

9797
- name: "Validate PHPUnit config for use with PHPUnit 9"
98-
uses: phpcsstandards/xmllint-validate@v1
98+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
9999
with:
100100
pattern: "phpunit.xml.dist"
101101
xsd-file: "vendor/phpunit/phpunit/schema/9.2.xsd"
@@ -115,7 +115,7 @@ jobs:
115115

116116
steps:
117117
- name: Checkout code
118-
uses: actions/checkout@v5
118+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
119119

120120
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
121121
# This should not be blocking for this job, so ignore any errors from this step.
@@ -129,7 +129,7 @@ jobs:
129129

130130
# Show XML violations inline in the file diff.
131131
- name: Enable showing XML issues inline
132-
uses: korelstar/xmllint-problem-matcher@v1
132+
uses: korelstar/xmllint-problem-matcher@1bd292d642ddf3d369d02aaa8b262834d61198c0 # v1.2.0
133133

134134
- name: Check the code-style consistency of the xml files
135135
run: |
@@ -153,10 +153,10 @@ jobs:
153153

154154
steps:
155155
- name: Checkout repository
156-
uses: actions/checkout@v5
156+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
157157

158158
- name: Set up PHP
159-
uses: shivammathur/setup-php@v2
159+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
160160
with:
161161
php-version: ${{ matrix.php }}
162162
# Allow for PHP deprecation notices.
@@ -176,7 +176,7 @@ jobs:
176176
run: composer config --unset lock
177177

178178
- name: Install Composer dependencies
179-
uses: ramsey/composer-install@v3
179+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
180180
with:
181181
composer-options: --no-dev
182182
# Bust the cache at least once a month - output format: YYYY-MM.
@@ -234,10 +234,10 @@ jobs:
234234

235235
steps:
236236
- name: Checkout code
237-
uses: actions/checkout@v5
237+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
238238

239239
- name: Install PHP
240-
uses: shivammathur/setup-php@v2
240+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
241241
with:
242242
php-version: 'latest'
243243
coverage: none
@@ -247,7 +247,7 @@ jobs:
247247
# Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized.
248248
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
249249
- name: Install Composer dependencies
250-
uses: "ramsey/composer-install@v3"
250+
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
251251
with:
252252
# Bust the cache at least once a month - output format: YYYY-MM.
253253
custom-cache-suffix: $(date -u "+%Y-%m")
@@ -262,7 +262,7 @@ jobs:
262262

263263
steps:
264264
- name: "Checkout"
265-
uses: "actions/checkout@v5"
265+
uses: "actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8" # v5.0.0
266266

267267
- name: "Search for misspellings"
268-
uses: "crate-ci/typos@v1"
268+
uses: "crate-ci/typos@85f62a8a84f939ae994ab3763f01a0296d61a7ee" # v1.36.2

.github/workflows/manage-labels.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Clean up labels on PR merge
1818

1919
steps:
20-
- uses: mondeja/remove-labels-gh-action@v2
20+
- uses: mondeja/remove-labels-gh-action@b7118e4ba5dca74acf1059b3cb7660378ff9ab1a # v2.0.0
2121
with:
2222
token: ${{ secrets.GITHUB_TOKEN }}
2323
labels: |
@@ -31,7 +31,7 @@ jobs:
3131
name: Clean up labels on PR close
3232

3333
steps:
34-
- uses: mondeja/remove-labels-gh-action@v2
34+
- uses: mondeja/remove-labels-gh-action@b7118e4ba5dca74acf1059b3cb7660378ff9ab1a # v2.0.0
3535
with:
3636
token: ${{ secrets.GITHUB_TOKEN }}
3737
labels: |
@@ -46,7 +46,7 @@ jobs:
4646
name: Clean up labels on issue close
4747

4848
steps:
49-
- uses: mondeja/remove-labels-gh-action@v2
49+
- uses: mondeja/remove-labels-gh-action@b7118e4ba5dca74acf1059b3cb7660378ff9ab1a # v2.0.0
5050
with:
5151
token: ${{ secrets.GITHUB_TOKEN }}
5252
labels: |

.github/workflows/quicktest.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030

3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v5
33+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3434

3535
- name: Set up PHP
36-
uses: shivammathur/setup-php@v2
36+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
3737
with:
3838
php-version: ${{ matrix.php }}
3939
# With stable PHPCS dependencies, allow for PHP deprecation notices.
@@ -46,7 +46,7 @@ jobs:
4646
run: composer config --unset lock
4747

4848
- name: Install Composer dependencies
49-
uses: ramsey/composer-install@v3
49+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
5050
with:
5151
# Bust the cache at least once a month - output format: YYYY-MM.
5252
custom-cache-suffix: $(date -u "+%Y-%m")
@@ -73,7 +73,7 @@ jobs:
7373

7474
- name: Send coverage report to Codecov
7575
if: ${{ success() && github.repository_owner == 'WordPress' && github.ref_name == 'develop' }}
76-
uses: codecov/codecov-action@v5
76+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
7777
with:
7878
files: ./build/logs/clover.xml
7979
fail_ci_if_error: true

.github/workflows/unit-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474

7575
steps:
7676
- name: Checkout repository
77-
uses: actions/checkout@v5
77+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
7878

7979
# With stable PHPCS dependencies, allow for PHP deprecation notices.
8080
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
@@ -88,7 +88,7 @@ jobs:
8888
fi
8989
9090
- name: Set up PHP
91-
uses: shivammathur/setup-php@v2
91+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
9292
with:
9393
php-version: ${{ matrix.php }}
9494
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
@@ -108,7 +108,7 @@ jobs:
108108
run: composer config --unset lock
109109

110110
- name: Install Composer dependencies
111-
uses: ramsey/composer-install@v3
111+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
112112
with:
113113
# Bust the cache at least once a month - output format: YYYY-MM.
114114
custom-cache-suffix: $(date -u "+%Y-%m")
@@ -135,7 +135,7 @@ jobs:
135135

136136
- name: Send coverage report to Codecov
137137
if: ${{ success() && matrix.coverage == true && github.repository_owner == 'WordPress' }}
138-
uses: codecov/codecov-action@v5
138+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
139139
with:
140140
files: ./build/logs/clover.xml
141141
fail_ci_if_error: true

0 commit comments

Comments
 (0)