Skip to content

Commit 8209135

Browse files
committed
Build/Test Tools: Improve the security and correctness of the GitHub Actions workflows files.
This includes removing use of dangerous inline GitHub Actions expressions, preventing word splitting, further tightening permissions, and generally improving many aspects of the workflows. This also introduces a new workflow that runs Actionlint to detect incorrect and insecure code and configuration in workflow files. Props johnbillion, swissspidy, flixos90, desrosj. See #62221 git-svn-id: https://develop.svn.wordpress.org/trunk@59679 602fd350-edb4-49c9-b593-d223f7449a82
1 parent c7cd04c commit 8209135

32 files changed

+407
-175
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ jobs:
107107
workflow_id: 'failed-workflow.yml',
108108
ref: 'trunk',
109109
inputs: {
110-
run_id: '${{ github.run_id }}'
110+
run_id: context.runId,
111111
}
112112
});

.github/workflows/end-to-end-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ jobs:
9393
workflow_id: 'failed-workflow.yml',
9494
ref: 'trunk',
9595
inputs: {
96-
run_id: '${{ github.run_id }}'
96+
run_id: context.runId,
9797
}
9898
});

.github/workflows/failed-workflow.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
const workflow_run = await github.rest.actions.getWorkflowRun({
3939
owner: context.repo.owner,
4040
repo: context.repo.repo,
41-
run_id: ${{ inputs.run_id }},
41+
run_id: process.env.RUN_ID,
4242
});
4343
4444
// Only rerun after the first run attempt.
@@ -49,6 +49,8 @@ jobs:
4949
const rerun = await github.rest.actions.reRunWorkflowFailedJobs({
5050
owner: context.repo.owner,
5151
repo: context.repo.repo,
52-
run_id: ${{ inputs.run_id }},
52+
run_id: process.env.RUN_ID,
5353
enable_debug_logging: true
5454
});
55+
env:
56+
RUN_ID: ${{ inputs.run_id }}

.github/workflows/install-testing.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,20 @@ jobs:
119119
with:
120120
php-version: '${{ matrix.php }}'
121121
coverage: none
122-
tools: wp-cli${{ contains( fromJSON('["5.4", "5.5"]'), matrix.php ) && ':2.4.0' || '' }}
122+
tools: ${{ contains( fromJSON('["5.4", "5.5"]'), matrix.php ) && 'wp-cli:2.4.0' || 'wp-cli' }}
123123

124124
- name: Download WordPress
125-
run: wp core download ${{ inputs.wp-version && format( '--version={0}', inputs.wp-version ) || '--version=nightly' }}
125+
run: wp core download --version="${WP_VERSION}"
126+
env:
127+
WP_VERSION: ${{ inputs.wp-version || 'nightly' }}
126128

127129
- name: Create wp-config.php file
128-
run: wp config create --dbname=test_db --dbuser=root --dbpass=root --dbhost=127.0.0.1:${{ job.services.database.ports['3306'] }}
130+
run: wp config create --dbname=test_db --dbuser=root --dbpass=root --dbhost="127.0.0.1:${DB_PORT}"
131+
env:
132+
DB_PORT: ${{ job.services.database.ports['3306'] }}
129133

130134
- name: Install WordPress
131-
run: wp core ${{ matrix.multisite && 'multisite-' || '' }}install --url=http://localhost/ --title="Upgrade Test" --admin_user=admin --admin_password=password [email protected] --skip-email
135+
run: wp core ${{ matrix.multisite && 'multisite-install' || 'install' }} --url=http://localhost/ --title="Upgrade Test" --admin_user=admin --admin_password=password [email protected] --skip-email
132136

133137
slack-notifications:
134138
name: Slack Notifications
@@ -175,6 +179,6 @@ jobs:
175179
workflow_id: 'failed-workflow.yml',
176180
ref: 'trunk',
177181
inputs: {
178-
run_id: '${{ github.run_id }}'
182+
run_id: context.runId,
179183
}
180184
});

.github/workflows/javascript-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,6 @@ jobs:
9797
workflow_id: 'failed-workflow.yml',
9898
ref: 'trunk',
9999
inputs: {
100-
run_id: '${{ github.run_id }}'
100+
run_id: context.runId,
101101
}
102102
});

.github/workflows/local-docker-environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ jobs:
104104
db-type: 'mysql'
105105
db-version: ${{ matrix.db-version }}
106106
memcached: ${{ matrix.memcached }}
107-
tests-domain: ${{ matrix.tests-domain }}
108107

109108
slack-notifications:
110109
name: Slack Notifications
@@ -151,6 +150,6 @@ jobs:
151150
workflow_id: 'failed-workflow.yml',
152151
ref: 'trunk',
153152
inputs: {
154-
run_id: '${{ github.run_id }}'
153+
run_id: context.runId,
155154
}
156155
});

.github/workflows/performance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ jobs:
9393
workflow_id: 'failed-workflow.yml',
9494
ref: 'trunk',
9595
inputs: {
96-
run_id: '${{ github.run_id }}'
96+
run_id: context.runId,
9797
}
9898
});

.github/workflows/php-compatibility.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ jobs:
9494
workflow_id: 'failed-workflow.yml',
9595
ref: 'trunk',
9696
inputs: {
97-
run_id: '${{ github.run_id }}'
97+
run_id: context.runId,
9898
}
9999
});

.github/workflows/phpunit-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
multisite: ${{ matrix.multisite }}
145145
memcached: ${{ matrix.memcached }}
146146
phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
147-
report: ${{ matrix.report || false }}
147+
report: ${{ false }}
148148

149149
#
150150
# Creates PHPUnit test jobs to test MariaDB and MySQL innovation releases.
@@ -193,7 +193,7 @@ jobs:
193193
multisite: ${{ matrix.multisite }}
194194
memcached: ${{ matrix.memcached }}
195195
phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
196-
report: ${{ matrix.report || false }}
196+
report: ${{ false }}
197197

198198
#
199199
# Runs specific individual test groups.
@@ -263,6 +263,6 @@ jobs:
263263
workflow_id: 'failed-workflow.yml',
264264
ref: 'trunk',
265265
inputs: {
266-
run_id: '${{ github.run_id }}'
266+
run_id: context.runId,
267267
}
268268
});

.github/workflows/props-bot.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ jobs:
8585
github.rest.issues.removeLabel({
8686
owner: context.repo.owner,
8787
repo: context.repo.repo,
88-
issue_number: '${{ github.event.number }}',
88+
issue_number: process.env.ISSUE_NUMBER,
8989
name: 'props-bot'
9090
});
91+
env:
92+
ISSUE_NUMBER: ${{ github.event.number }}

0 commit comments

Comments
 (0)