-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (58 loc) · 1.87 KB
/
dependency-audit.yml
File metadata and controls
68 lines (58 loc) · 1.87 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
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Dependency Audit
on:
schedule:
- cron: "30 2 * * 1"
workflow_dispatch:
jobs:
audit:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
actions: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Run dependency audit
id: run-audit
continue-on-error: true
run: pnpm audit --prod --audit-level=low --json > dependency-audit.json
- name: Evaluate vulnerabilities
run: |
node - <<'NODE'
const fs = require("node:fs");
const report = JSON.parse(
fs.readFileSync("dependency-audit.json", "utf8"),
);
const vulns = report?.metadata?.vulnerabilities ?? {};
const critical = vulns.critical ?? 0;
const high = vulns.high ?? 0;
const moderate = vulns.moderate ?? 0;
const low = vulns.low ?? 0;
const info = vulns.info ?? 0;
const total = critical + high + moderate + low + info;
const summary = [
`Dependency audit completed with ${total} vulnerabilities found.`,
`critical: ${critical}`,
`high: ${high}`,
`moderate: ${moderate}`,
`low: ${low}`,
`info: ${info}`,
].join("\n");
console.log(summary);
if (process.env.GITHUB_STEP_SUMMARY) {
fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, `${summary}\n`);
}
if (critical > 0) {
console.error("Critical vulnerabilities found. Failing audit.");
process.exit(1);
}
NODE