Visitar URL original
Merge pull request #311 from wp-cli/composer-audit · wp-cli/.github@7bc2548 · GitHub
Skip to content

Commit 7bc2548

Browse files
authored
Merge pull request #311 from wp-cli/composer-audit
Audit committed composer.lock files for security advisories
2 parents 14d5615 + 5b7e817 commit 7bc2548

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

‎.github/workflows/reusable-code-quality.yml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,47 @@ jobs:
190190
if: steps.check_files.outputs.files_exists == 'true'
191191
uses: crate-ci/typos@7f9d0819ca1c008ade73f4b41fa9d258d48f605b # v1.51.1
192192

193+
composer-audit:
194+
name: Audit locked dependencies
195+
runs-on: ubuntu-latest
196+
timeout-minutes: 30
197+
steps:
198+
# Spreads the nightly runs of all repositories over 20 minutes, so they
199+
# don't all query Packagist at the same moment.
200+
- name: Wait a random delay
201+
if: github.event_name == 'schedule'
202+
run: sleep $(( RANDOM % 1200 ))
203+
204+
- name: Check out source code
205+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
206+
with:
207+
persist-credentials: false
208+
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
209+
210+
# Composer refuses versions with known security advisories when it
211+
# resolves dependencies, but not when it installs from a committed lock
212+
# file. This catches advisories published after a dependency was locked.
213+
# Repositories without a lock file resolve fresh on every run, so they are
214+
# covered by that blocking already.
215+
- name: Check existence of composer.lock file
216+
id: check_files
217+
run: echo "files_exists=$(test -f composer.lock && echo true || echo false)" >> "$GITHUB_OUTPUT"
218+
219+
- name: Set up PHP environment
220+
if: steps.check_files.outputs.files_exists == 'true'
221+
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
222+
with:
223+
php-version: 'latest'
224+
tools: composer
225+
coverage: none
226+
env:
227+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
228+
229+
# Abandoned packages are reported without failing the job.
230+
- name: Audit composer.lock
231+
if: steps.check_files.outputs.files_exists == 'true'
232+
run: composer audit --locked --abandoned=report --no-interaction
233+
193234
phpcs:
194235
name: PHPCS
195236
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)