Skip to content

Commit ee1e6c2

Browse files
committed
chore(ci): add Composer audit gate and composer-normalize
Add a dedicated Composer security workflow that runs `composer audit` on push, PR, and a weekly schedule, so advisories and malware in the dependency tree fail CI independently of the build. Pins Composer to 2.10 and the GitHub Actions to commit SHAs; the job uses a read-only token and resolves dependencies with `composer update` since the package ships no lockfile. Add a `config.policy` block (block on malware and advisories, report abandoned packages) and wire in `ergebnis/composer-normalize` with a `post-autoload-dump` hook so composer.json stays normalized, matching the rest of the packages.
1 parent 54f2ea8 commit ee1e6c2

2 files changed

Lines changed: 70 additions & 17 deletions

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: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
{
22
"name": "lemaur/markdown",
33
"description": "Another Markdown parsers but with super powers",
4+
"license": "MIT",
45
"keywords": [
56
"lemaur",
67
"laravel",
78
"markdown"
89
],
9-
"homepage": "https://github.com/lemaur/markdown",
10-
"license": "MIT",
1110
"authors": [
1211
{
1312
"name": "Maurizio",
1413
"email": "hello@lemaur.me",
1514
"role": "Developer"
1615
}
1716
],
17+
"homepage": "https://github.com/lemaur/markdown",
1818
"require": {
1919
"php": "^8.2",
20-
"spatie/laravel-package-tools": "^1.4.3",
21-
"illuminate/contracts": "^11.0|^12.0|^13.0",
22-
"league/commonmark": "^2.0"
20+
"illuminate/contracts": "^11.0 || ^12.0 || ^13.0",
21+
"league/commonmark": "^2.0",
22+
"spatie/laravel-package-tools": "^1.4.3"
2323
},
2424
"require-dev": {
25+
"ergebnis/composer-normalize": "^2.42",
2526
"laravel/pint": "^1.0",
26-
"orchestra/testbench": "^9.0|^10.0|^11.0",
27-
"phpstan/phpstan-deprecation-rules": "^1.1.1|^2.0",
28-
"phpstan/phpstan-phpunit": "^1.3.3|^2.0",
29-
"phpunit/phpunit": "^11.0|^12.0",
27+
"orchestra/testbench": "^9.0 || ^10.0 || ^11.0",
28+
"phpstan/phpstan-deprecation-rules": "^1.1.1 || ^2.0",
29+
"phpstan/phpstan-phpunit": "^1.3.3 || ^2.0",
30+
"phpunit/phpunit": "^11.0 || ^12.0",
3031
"spatie/phpunit-snapshot-assertions": "^5.0"
3132
},
33+
"minimum-stability": "dev",
34+
"prefer-stable": true,
3235
"autoload": {
3336
"psr-4": {
3437
"Lemaur\\Markdown\\": "src"
@@ -39,13 +42,22 @@
3942
"Lemaur\\Markdown\\Tests\\": "tests"
4043
}
4144
},
42-
"scripts": {
43-
"analyse": "vendor/bin/phpstan analyse",
44-
"test": "vendor/bin/phpunit",
45-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
46-
"format": "vendor/bin/pint"
47-
},
4845
"config": {
46+
"allow-plugins": {
47+
"ergebnis/composer-normalize": true
48+
},
49+
"policy": {
50+
"advisories": {
51+
"block": true
52+
},
53+
"malware": {
54+
"block": true,
55+
"block-scope": "all"
56+
},
57+
"abandoned": {
58+
"audit": "report"
59+
}
60+
},
4961
"sort-packages": true
5062
},
5163
"extra": {
@@ -55,6 +67,11 @@
5567
]
5668
}
5769
},
58-
"minimum-stability": "dev",
59-
"prefer-stable": true
70+
"scripts": {
71+
"post-autoload-dump": "composer normalize",
72+
"analyse": "vendor/bin/phpstan analyse",
73+
"format": "vendor/bin/pint",
74+
"test": "vendor/bin/phpunit",
75+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
76+
}
6077
}

0 commit comments

Comments
 (0)