Skip to content

Commit 9edcdfb

Browse files
committed
feat(ci): add dependency vulnerability scanning and audit policy
1 parent a209574 commit 9edcdfb

4 files changed

Lines changed: 95 additions & 1 deletion

File tree

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
groups:
9+
production-dependencies:
10+
dependency-type: production
11+
development-dependencies:
12+
dependency-type: development

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@ on:
77
- develop
88

99
jobs:
10+
security-audit:
11+
runs-on: ubuntu-latest
12+
name: Dependency Security Audit
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up pnpm
18+
uses: pnpm/action-setup@v4
19+
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
cache: 'pnpm'
25+
26+
- name: Install dependencies
27+
run: pnpm install --frozen-lockfile
28+
29+
- name: Generate audit report
30+
run: pnpm audit --json > audit-report.json || true
31+
32+
- name: Run security audit (block on high/critical)
33+
run: pnpm audit --audit-level=high
34+
35+
- name: Upload audit report
36+
if: always()
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: dependency-audit-report
40+
path: audit-report.json
41+
retention-days: 30
42+
1043
quality-checks:
1144
runs-on: ubuntu-latest
1245
name: Type Check, Lint & Validation

CONTRIBUTING.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Your PR will be blocked from merging unless it meets the following:
2020

2121
1. **CI must pass**
2222

23-
- Required checks: `type-check`, `lint`, `build`, `test` (GitHub Actions: **Frontend CI**)
23+
- Required checks: `type-check`, `lint`, `build`, `test`, `security-audit` (GitHub Actions: **Branch Protection**)
2424

2525
2. **Approvals required**
2626

@@ -44,6 +44,7 @@ Your PR will be blocked from merging unless it meets the following:
4444
- `pnpm run lint`
4545
- `pnpm run test`
4646
- `pnpm run build`
47+
- `pnpm audit --audit-level=high`
4748

4849
## Git hooks
4950

@@ -79,3 +80,47 @@ Use the PR template (auto-applied). Ensure it includes:
7980
## Security
8081

8182
Do not commit secrets. Use `.env.local` for local environment variables.
83+
84+
### Dependency vulnerability audit
85+
86+
CI runs a `security-audit` job on every pull request to `main` and `develop`. It executes:
87+
88+
```bash
89+
pnpm audit --audit-level=high
90+
```
91+
92+
**Policy:**
93+
94+
- **High** and **critical** severity vulnerabilities **fail** the pipeline and block merge.
95+
- **Low** and **moderate** findings are reported but do not block merge.
96+
- The full JSON audit report is uploaded as a CI artifact (`dependency-audit-report`) on every run.
97+
98+
Run the same check locally before pushing:
99+
100+
```bash
101+
pnpm audit --audit-level=high
102+
```
103+
104+
### Triaging and suppressing accepted risks
105+
106+
If a high or critical CVE cannot be fixed immediately (no patch available, breaking upgrade, or false positive), you may suppress it after maintainer review:
107+
108+
1. Confirm the risk is understood and document the rationale in the PR.
109+
2. Add the CVE or GHSA identifier to `pnpm.auditConfig` in `package.json`:
110+
111+
```json
112+
"pnpm": {
113+
"auditConfig": {
114+
"ignoreCves": ["CVE-YYYY-NNNNN"],
115+
"ignoreGhsas": ["GHSA-xxxx-xxxx-xxxx"]
116+
}
117+
}
118+
```
119+
120+
3. Open a follow-up issue to remove the suppression when a fix is available.
121+
122+
Suppressions require explicit PR approval — do not add ignored CVEs without maintainer sign-off.
123+
124+
### Automated dependency updates
125+
126+
[Dependabot](https://docs.github.com/en/code-security/dependabot) (`.github/dependabot.yml`) opens weekly PRs for npm dependency updates. Review and merge these promptly to keep the dependency tree current.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
"vitest": "^2.1.9"
139139
},
140140
"pnpm": {
141+
"auditConfig": {
142+
"ignoreCves": [],
143+
"ignoreGhsas": []
144+
},
141145
"overrides": {
142146
"react": "^18.3.1",
143147
"react-dom": "^18.3.1",

0 commit comments

Comments
 (0)