Skip to content

Commit fa92407

Browse files
patrickrbclaude
andauthored
fix(security): bump Docker base image to node:22-alpine + wire Snyk (#186)
The 89 issues Snyk reported (4C/26H/17M/42L) were almost entirely from node:18-alpine (Node 18 EOL'd 2025-04). Both Dockerfiles bumped to node:22-alpine drops per-image vuln count from 58 to 3. - Dockerfile / Dockerfile.dev: node:18-alpine -> node:22-alpine - CI: setup-node 20 -> 22; new `security` job runs Snyk SCA + container test on PR/push, gracefully skips when SNYK_TOKEN is unset - @types/node ^20 -> ^22 to match runtime - Add snyk as devDependency with snyk:test/snyk:test:json/snyk:monitor scripts - New .snyk policy ignores SNYK-JS-LEAFLET-16427276 (XSS, no upstream patch as of 2026-05-10) with 90-day expiry Verified: npm run lint (0 errors), npm run build (success), npm run snyk:test (0 vulnerable paths). The original plan to override transitive npm deps was scrapped after discovering the SCA scan itself only finds the leaflet XSS - the dashboard count came from container scans of the EOL Node 18 base image. Follow-up: add SNYK_TOKEN to repo secrets to activate CI enforcement. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 311e528 commit fa92407

7 files changed

Lines changed: 318 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
- uses: actions/setup-node@v4
1818
with:
19-
node-version: '20'
19+
node-version: '22'
2020
cache: 'npm'
2121

2222
- name: Install dependencies
@@ -43,6 +43,39 @@ jobs:
4343
path: playwright-report/
4444
retention-days: 30
4545

46+
security:
47+
runs-on: ubuntu-latest
48+
env:
49+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: '22'
55+
cache: 'npm'
56+
- name: Install dependencies
57+
run: npm ci
58+
- name: Check Snyk token
59+
id: snyk_token
60+
run: |
61+
if [ -n "$SNYK_TOKEN" ]; then
62+
echo "present=true" >> "$GITHUB_OUTPUT"
63+
else
64+
echo "present=false" >> "$GITHUB_OUTPUT"
65+
echo "::warning::SNYK_TOKEN not set - skipping Snyk scan. Add it to repo secrets to enable enforcement."
66+
fi
67+
- name: Snyk SCA test
68+
if: steps.snyk_token.outputs.present == 'true'
69+
uses: snyk/actions/node@master
70+
with:
71+
args: --severity-threshold=high
72+
- name: Snyk container test (Dockerfile)
73+
if: steps.snyk_token.outputs.present == 'true'
74+
uses: snyk/actions/docker@master
75+
with:
76+
image: node:22-alpine
77+
args: --file=Dockerfile --severity-threshold=high
78+
4679
# This job will be required for merging PRs
4780
tests-required:
4881
runs-on: ubuntu-latest

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ yarn-error.log*
3636
# vercel
3737
.vercel
3838

39+
# snyk
40+
snyk-report.json
41+
container-report.json
42+
.dccache
43+
3944
#claude
4045
/.claude/
4146

.snyk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Snyk (https://snyk.io) policy file
2+
# Ignored vulnerabilities require a `reason` and an `expires` date so they
3+
# resurface for re-evaluation. Do not add permanent suppressions.
4+
version: v1.25.0
5+
ignore:
6+
SNYK-JS-LEAFLET-16427276:
7+
- '*':
8+
reason: >-
9+
leaflet 1.9.4 XSS — no upstream patch available as of 2026-05-10.
10+
Tracked at https://security.snyk.io/vuln/SNYK-JS-LEAFLET-16427276.
11+
Re-evaluate at expiry: bump if patched, otherwise consider replacing
12+
with maplibre-gl-js / openlayers.
13+
expires: 2026-08-10
14+
created: 2026-05-10
15+
patch: {}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-alpine AS base
1+
FROM node:22-alpine AS base
22

33
# Install dependencies only when needed
44
FROM base AS deps

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-alpine
1+
FROM node:22-alpine
22

33
# Install dependencies for development including PostgreSQL client
44
RUN apk add --no-cache libc6-compat postgresql-client bash

0 commit comments

Comments
 (0)