-
Notifications
You must be signed in to change notification settings - Fork 79
55 lines (52 loc) · 1.59 KB
/
Copy pathaudit.yml
File metadata and controls
55 lines (52 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Audit
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
node_matrix_audit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22, 24]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install Monorepo Deps
run: npm ci --ignore-scripts
- name: Run After Install Script
run: npm run afterinstall
- name: Run npm audit
run: |
npm audit --json | node -e '
const fs = require("fs");
const auditLevel = (process.argv[2] || "critical").toLowerCase();
const raw = fs.readFileSync(0).toString("utf-8");
let vulnerabilities = {};
try {
const parsed = JSON.parse(raw || "{}");
vulnerabilities = parsed.vulnerabilities || {};
} catch (e) {
console.error("Failed to parse npm audit output:", e.message || e);
process.exit(2);
}
const result = Object.values(vulnerabilities).filter((i) => i && i.severity && i.severity.toLowerCase() === auditLevel);
if (result.length) {
console.log(JSON.stringify(result, null, 2));
process.exit(1);
} else {
console.log('[]');
}
' high
npm_audit:
runs-on: ubuntu-latest
needs: node_matrix_audit
if: success()
steps:
- name: Final status
run: echo "✅ npm audit passed for Node.js 20, 22 and 24"