Skip to content

Commit c604d10

Browse files
committed
chore(ci): add Composer malware + advisory audit gate
Add a dedicated Composer Security workflow that runs `composer audit` (Composer >= 2.10 fails on known malware and security advisories) on a pinned toolchain, separate from the build/test pipeline. Runs on pushes touching dependencies, on pull requests, and weekly via cron to catch advisories newly published against an unchanged dependency set. Also add a `config.policy` block to composer.json so the audit blocks on malware and advisories while reporting (not failing) on abandoned packages. - actions pinned by commit SHA - Composer pinned to 2.10 - read-only token (contents: read)
1 parent eb18055 commit c604d10

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# managed-by: ComposerSecurityStamp (profile=oss) — edit the stamp, not this file
2+
name: Composer Security
3+
4+
permissions:
5+
contents: read
6+
7+
on:
8+
push:
9+
paths:
10+
- 'composer.json'
11+
- '.github/workflows/composer-security.yml'
12+
pull_request:
13+
schedule:
14+
- cron: '27 6 * * 1' # weekly — catches deps newly flagged in an unchanged lockfile
15+
16+
jobs:
17+
audit:
18+
name: Malware & advisory audit
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 5
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
24+
25+
- name: Setup PHP + pinned Composer
26+
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
27+
with:
28+
php-version: '8.4'
29+
tools: composer:2.10
30+
coverage: none
31+
32+
- name: Resolve dependencies (library ships no lock)
33+
run: composer update --prefer-dist --no-interaction --no-progress
34+
35+
- name: Audit (Composer >= 2.10 fails on malware + advisories)
36+
run: composer audit

composer.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,25 @@
4949
"pestphp/pest-plugin": true,
5050
"phpstan/extension-installer": true
5151
},
52+
"policy": {
53+
"advisories": {
54+
"block": true
55+
},
56+
"malware": {
57+
"block": true,
58+
"block-scope": "all"
59+
},
60+
"abandoned": {
61+
"audit": "report"
62+
}
63+
},
5264
"sort-packages": true
5365
},
5466
"scripts": {
5567
"post-autoload-dump": "composer normalize",
68+
"analyse": "vendor/bin/phpstan analyse",
5669
"format": "vendor/bin/pint",
5770
"refactor": "vendor/bin/rector process",
58-
"analyse": "vendor/bin/phpstan analyse",
5971
"test": "vendor/bin/pest",
6072
"test:coverage": "vendor/bin/pest --coverage",
6173
"test:type": "vendor/bin/pest --type-coverage --log-junit=build/type-coverage.xml"

0 commit comments

Comments
 (0)