Skip to content

Commit 4d4350f

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 7856698 commit 4d4350f

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

.github/workflows/cs.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121

2222
steps:
2323
- name: Checkout code
24-
uses: actions/checkout@v5
24+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2525

2626
- name: Install PHP
27-
uses: shivammathur/setup-php@v2
27+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # master
2828
with:
2929
php-version: 'latest'
3030
coverage: none
@@ -46,56 +46,56 @@ jobs:
4646
# Install dependencies and handle caching in one go.
4747
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
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")
5353

5454
# Validate the XSD and XML files against schema.
5555
- name: Validate Docs XSD against schema
56-
uses: phpcsstandards/xmllint-validate@v1
56+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
5757
with:
5858
pattern: "DocsXsd/phpcsdocs.xsd"
5959
xsd-url: "https://www.w3.org/2012/04/XMLSchema.xsd"
6060

6161
- name: Validate PHPCSDebug ruleset against schema
62-
uses: phpcsstandards/xmllint-validate@v1
62+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
6363
with:
6464
pattern: "PHPCSDebug/ruleset.xml"
6565
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
6666

6767
- name: Validate docs against schema
68-
uses: phpcsstandards/xmllint-validate@v1
68+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
6969
with:
7070
pattern: "PHPCSDebug/Docs/*/*Standard.xml"
7171
xsd-file: "DocsXsd/phpcsdocs.xsd"
7272

7373
- name: Validate Project PHPCS ruleset against schema
74-
uses: phpcsstandards/xmllint-validate@v1
74+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
7575
with:
7676
pattern: "phpcs.xml.dist"
7777
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
7878

7979
- name: "Validate PHPUnit < 10 config for use with PHPUnit 8"
80-
uses: phpcsstandards/xmllint-validate@v1
80+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
8181
with:
8282
pattern: "phpunitlte9.xml.dist"
8383
xsd-file: "vendor/phpunit/phpunit/schema/8.5.xsd"
8484

8585
- name: "Validate PHPUnit < 10 config for use with PHPUnit 9"
86-
uses: phpcsstandards/xmllint-validate@v1
86+
uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1
8787
with:
8888
pattern: "phpunitlte9.xml.dist"
8989
xsd-file: "vendor/phpunit/phpunit/schema/9.5.xsd"
9090

9191
- name: "Validate PHPUnit 10+ config for use with PHPUnit 10"
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/10.5.xsd"
9696

9797
- name: "Validate PHPUnit 10+ config for use with PHPUnit 11"
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/phpunit.xsd"
@@ -118,7 +118,7 @@ jobs:
118118

119119
steps:
120120
- name: Checkout code
121-
uses: actions/checkout@v5
121+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
122122

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

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

137137
# Check code-style consistency of the XSD and XML files.
138138
- name: Check XSD code style

.github/workflows/label-merge-conflicts.yml

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

2323
steps:
2424
- name: Check PRs for merge conflicts
25-
uses: eps1lon/actions-label-merge-conflict@v3
25+
uses: eps1lon/actions-label-merge-conflict@1df065ebe6e3310545d4f4c4e862e43bdca146f0 # v3.0.3
2626
with:
2727
dirtyLabel: "Status: has merge conflict"
2828
repoToken: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/quicktest.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
steps:
2929
- name: Checkout code
30-
uses: actions/checkout@v5
30+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3131

3232
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
3333
# This should not be blocking for this job, so ignore any errors from this step.
@@ -40,7 +40,7 @@ jobs:
4040
run: sudo apt-get install --no-install-recommends -y libxml2-utils
4141

4242
- name: Install PHP
43-
uses: shivammathur/setup-php@v2
43+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # master
4444
with:
4545
php-version: ${{ matrix.php }}
4646
ini-values: error_reporting=-1, display_errors=On, display_startup_errors=On
@@ -49,7 +49,7 @@ jobs:
4949
# Install dependencies and handle caching in one go.
5050
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
5151
- name: Install Composer dependencies
52-
uses: "ramsey/composer-install@v3"
52+
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
5353
with:
5454
# Bust the cache at least once a month - output format: YYYY-MM.
5555
custom-cache-suffix: $(date -u "+%Y-%m")
@@ -120,7 +120,7 @@ jobs:
120120

121121
steps:
122122
- name: Checkout code
123-
uses: actions/checkout@v5
123+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
124124

125125
# On stable PHPCS versions, allow for PHP deprecation notices.
126126
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
@@ -134,7 +134,7 @@ jobs:
134134
fi
135135
136136
- name: Install PHP
137-
uses: shivammathur/setup-php@v2
137+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # master
138138
with:
139139
php-version: ${{ matrix.php }}
140140
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
@@ -150,7 +150,7 @@ jobs:
150150
# Install dependencies and handle caching in one go.
151151
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
152152
- name: Install Composer dependencies
153-
uses: "ramsey/composer-install@v3"
153+
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
154154
with:
155155
# Bust the cache at least once a month - output format: YYYY-MM.
156156
custom-cache-suffix: $(date -u "+%Y-%m")

.github/workflows/test.yml

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

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

3535
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
3636
# This should not be blocking for this job, so ignore any errors from this step.
@@ -43,7 +43,7 @@ jobs:
4343
run: sudo apt-get install --no-install-recommends -y libxml2-utils
4444

4545
- name: Install PHP
46-
uses: shivammathur/setup-php@v2
46+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # master
4747
with:
4848
php-version: ${{ matrix.php }}
4949
ini-values: error_reporting=-1, display_errors=On, display_startup_errors=On
@@ -53,7 +53,7 @@ jobs:
5353
# Install dependencies and handle caching in one go.
5454
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
5555
- name: Install Composer dependencies
56-
uses: "ramsey/composer-install@v3"
56+
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
5757
with:
5858
composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }}
5959
# Bust the cache at least once a month - output format: YYYY-MM.
@@ -174,7 +174,7 @@ jobs:
174174

175175
steps:
176176
- name: Checkout code
177-
uses: actions/checkout@v5
177+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
178178

179179
- name: Setup ini config
180180
id: set_ini
@@ -188,7 +188,7 @@ jobs:
188188
fi
189189
190190
- name: Install PHP
191-
uses: shivammathur/setup-php@v2
191+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # master
192192
with:
193193
php-version: ${{ matrix.php }}
194194
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
@@ -204,7 +204,7 @@ jobs:
204204
# Install dependencies and handle caching in one go.
205205
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
206206
- name: Install Composer dependencies
207-
uses: "ramsey/composer-install@v3"
207+
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
208208
with:
209209
composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }}
210210
# Bust the cache at least once a month - output format: YYYY-MM.

.github/workflows/update-website.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ jobs:
4848
fi
4949
5050
- name: Checkout code
51-
uses: actions/checkout@v5
51+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
5252
with:
5353
ref: ${{ steps.base_branch.outputs.BRANCH }}
5454

5555
- name: Install PHP
56-
uses: shivammathur/setup-php@v2
56+
uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # master
5757
with:
5858
php-version: 'latest'
5959
ini-values: error_reporting=-1, display_errors=On, display_startup_errors=On, log_errors_max_len=0
@@ -83,13 +83,13 @@ jobs:
8383
fi
8484
8585
- name: Check GitHub Pages status
86-
uses: crazy-max/ghaction-github-status@v4
86+
uses: crazy-max/ghaction-github-status@fa6ac37620bc5d44b93e15caed498629665e9ff5 # v4.2.0
8787
with:
8888
pages_threshold: major_outage
8989

9090
- name: Deploy the website
9191
if: success()
92-
uses: crazy-max/ghaction-github-pages@v4
92+
uses: crazy-max/ghaction-github-pages@df5cc2bfa78282ded844b354faee141f06b41865 # v4.2.0
9393
with:
9494
build_dir: 'deploy'
9595
target_branch: 'gh-pages'

0 commit comments

Comments
 (0)