Repository navigation
102 lines (89 loc) · 3.29 KB
/
Copy pathsecurity.yml
File metadata and controls
102 lines (89 loc) · 3.29 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Security
# Static analysis, dependency, filesystem, and secret scanning.
#
# Image scanning lives in docker.yml, not here: it already builds and Trivy
# scans every service image (this pipeline previously duplicated that for
# api-gateway only), so keeping it in one place avoids building the same
# images twice across workflows.
on:
pull_request:
push:
branches: [main, testing, dev]
schedule:
# Weekly CodeQL run so newly disclosed CVEs against unchanged code are
# still caught, independent of PR activity.
- cron: '17 4 * * 1'
workflow_dispatch: {}
concurrency:
group: security-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
codeql:
name: CodeQL (JavaScript/TypeScript)
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
security-events: write
actions: read
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
- uses: github/codeql-action/analyze@v3
with:
category: '/language:javascript-typescript'
dependency-audit:
name: Dependency audit (npm audit)
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
# A single root package-lock.json covers every workspace (shared +
# services/*), so one root `npm audit` already audits all of them --
# no need for a per-service matrix here.
- name: Install dependencies
run: npm ci
# Blocking gate: fail only on critical advisories. As of this writing,
# every high-severity finding in this dependency tree (js-yaml/lodash
# bundled by @nestjs/swagger, multer/body-parser bundled by
# @nestjs/platform-express, uuid bundled by @nestjs/typeorm) has no fix
# available inside the current NestJS 10/11 major line -- npm's own
# suggested remediation for every one of them is
# `npm audit fix --force`, which jumps @nestjs/core to v12 across all
# 12 services. That is a real, breaking, app-wide upgrade and out of
# scope for this pipeline to force silently. Blocking every unrelated
# PR on findings with no available non-breaking remediation isn't
# actionable, so this gate blocks on critical (none today) and reports
# high/moderate without failing the job.
- name: npm audit (critical, blocking)
run: npm audit --audit-level=critical
- name: npm audit (high/moderate, report only)
if: always()
continue-on-error: true
run: npm audit --audit-level=high
filesystem-scan:
name: Filesystem + secret scan (Trivy)
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Trivy filesystem scan (vulnerabilities + secrets)
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scan-ref: .
scanners: vuln,secret
severity: CRITICAL
ignore-unfixed: true
exit-code: 1