-
Notifications
You must be signed in to change notification settings - Fork 0
584 lines (516 loc) · 21.7 KB
/
test.yml
File metadata and controls
584 lines (516 loc) · 21.7 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# ---------------------------------------------------------------------------
# Test Suite — Health Dataspace v2
# ---------------------------------------------------------------------------
# Runs unit tests, API integration tests, lint, and E2E tests for the
# Next.js UI and the Neo4j Query Proxy service.
#
# Unit/API tests use vi.mock() — NO live Neo4j, EDC-V, or Keycloak needed.
# E2E tests (Playwright) build the Next.js app and run against it.
#
# Triggers:
# - Push to any branch
# - Pull request to main
# - Manual dispatch
# ---------------------------------------------------------------------------
name: Test Suite
on:
push:
branches: ["*"]
paths:
- "ui/**"
- "services/neo4j-proxy/**"
- ".github/workflows/test.yml"
pull_request:
branches: [main]
paths:
- "ui/**"
- "services/neo4j-proxy/**"
workflow_dispatch:
env:
NODE_VERSION: "20"
jobs:
# -----------------------------------------------------------------------
# UI Unit + API Integration Tests (Vitest)
# -----------------------------------------------------------------------
ui-tests:
name: UI Tests (Vitest)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./ui/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npx vitest run --coverage --reporter=verbose --reporter=json --outputFile=test-results.json
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: ui-coverage
path: |
ui/coverage/
ui/test-results.json
retention-days: 30
- name: Coverage summary
if: always()
run: |
echo "## UI Test Coverage" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
npx vitest run --coverage 2>&1 | grep -A 50 "^-.*-$" | head -60 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# -----------------------------------------------------------------------
# Neo4j Query Proxy Tests (Vitest)
# -----------------------------------------------------------------------
proxy-tests:
name: Neo4j Proxy Tests (Vitest)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./services/neo4j-proxy
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./services/neo4j-proxy/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npx vitest run --coverage --reporter=verbose --reporter=json --outputFile=test-results.json
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: proxy-coverage
path: |
services/neo4j-proxy/coverage/
services/neo4j-proxy/test-results.json
retention-days: 30
- name: Coverage summary
if: always()
run: |
echo "## Neo4j Proxy Test Coverage" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
npx vitest run --coverage 2>&1 | grep -A 10 "^-.*-$" | head -20 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# -----------------------------------------------------------------------
# Secret Scan — gitleaks (BSI C5 DEV-08)
# Scans git history and staged files for accidentally committed secrets.
# Uses the official gitleaks binary (not the GitHub Action, which pins
# to a specific version via SHA for supply-chain safety).
# -----------------------------------------------------------------------
secret-scan:
name: Secret Scan (gitleaks)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history needed for gitleaks --log-opts
- name: Install gitleaks
run: |
GITLEAKS_VERSION="8.27.2"
GITLEAKS_ARCHIVE="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
curl -sfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${GITLEAKS_ARCHIVE}" \
-o "${GITLEAKS_ARCHIVE}"
curl -sfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_checksums.txt" \
-o gitleaks_checksums.txt
grep "${GITLEAKS_ARCHIVE}" gitleaks_checksums.txt | sha256sum -c -
tar -xzf "${GITLEAKS_ARCHIVE}" gitleaks
sudo mv gitleaks /usr/local/bin/gitleaks
- name: Scan git history for secrets
run: gitleaks detect --source . --log-opts="HEAD" --exit-code 1
- name: Secret scan summary
if: always()
run: |
echo "## Secret Scan (gitleaks)" >> $GITHUB_STEP_SUMMARY
gitleaks detect --source . --log-opts="HEAD" --no-banner 2>&1 >> $GITHUB_STEP_SUMMARY || true
# -----------------------------------------------------------------------
# Dependency Vulnerability Audit (BSI C5 DEV-05 / OWASP A06)
# -----------------------------------------------------------------------
dependency-audit:
name: Dependency Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./ui/package-lock.json
- name: Audit UI dependencies
working-directory: ./ui
run: npm audit --audit-level=high
- name: Audit Neo4j proxy dependencies
working-directory: ./services/neo4j-proxy
# Use --omit=dev to audit only production dependencies for the proxy
run: npm audit --audit-level=high --omit=dev
continue-on-error: true
- name: Audit summary
if: always()
run: |
echo "## Dependency Audit" >> $GITHUB_STEP_SUMMARY
echo "| Package | Severity |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
cd ui && npm audit --json 2>/dev/null | \
node -e "const d=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));
Object.values(d.vulnerabilities||{}).forEach(v=>
process.stdout.write('| '+v.name+' | '+v.severity+' |\n')
)" >> $GITHUB_STEP_SUMMARY || true
# -----------------------------------------------------------------------
# SBOM Generation (CycloneDX) — EU CRA Art. 13, EHDS Art. 50, SIMPL-Open
# -----------------------------------------------------------------------
sbom:
name: SBOM Generation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./ui/package-lock.json
- name: Install dependencies
working-directory: ./ui
run: npm ci
- name: Generate CycloneDX SBOM (UI)
working-directory: ./ui
run: npx @cyclonedx/cyclonedx-npm --output-file ../sbom-ui.cdx.json --spec-version 1.5
- name: Generate CycloneDX SBOM (Neo4j Proxy)
working-directory: ./services/neo4j-proxy
run: |
npm ci
npx @cyclonedx/cyclonedx-npm --output-file ../../sbom-neo4j-proxy.cdx.json --spec-version 1.5
- name: Upload SBOM artifacts
uses: actions/upload-artifact@v4
with:
name: sbom
path: |
sbom-ui.cdx.json
sbom-neo4j-proxy.cdx.json
retention-days: 90
- name: SBOM summary
run: |
echo "## SBOM Generation" >> $GITHUB_STEP_SUMMARY
echo "| Component | Format | Spec |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- | --- |" >> $GITHUB_STEP_SUMMARY
echo "| ui | CycloneDX | 1.5 |" >> $GITHUB_STEP_SUMMARY
echo "| neo4j-proxy | CycloneDX | 1.5 |" >> $GITHUB_STEP_SUMMARY
# -----------------------------------------------------------------------
# Licence Compliance — EU OSS Strategy, BSI C5 OPS-04, SIMPL-Open
# -----------------------------------------------------------------------
license-check:
name: Licence Compliance
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./ui/package-lock.json
- name: Install dependencies
working-directory: ./ui
run: npm ci
# license-checker@25.0.1 (the original) is unmaintained and crashes
# with TypeError: json.readme.toLowerCase is not a function on some
# modern package.json shapes. license-checker-rseidelsohn is the
# maintained fork and handles the same flags. Both ui/package.json
# and services/neo4j-proxy/package.json carry
# "license": "Apache-2.0" so the self-package passes its own
# allowlist without needing a version-pinned excludePackages entry.
- name: Check licences (UI)
working-directory: ./ui
run: |
npx --yes license-checker-rseidelsohn@4.4.2 --production --excludePrivatePackages --onlyAllow "MIT;Apache-2.0;ISC;BSD-2-Clause;BSD-3-Clause;0BSD;CC0-1.0;CC-BY-4.0;Unlicense;Python-2.0;BlueOak-1.0.0;LGPL-3.0-or-later" --summary
- name: Check licences (Neo4j Proxy)
working-directory: ./services/neo4j-proxy
run: |
npm ci
npx --yes license-checker-rseidelsohn@4.4.2 --production --excludePrivatePackages --onlyAllow "MIT;Apache-2.0;ISC;BSD-2-Clause;BSD-3-Clause;0BSD;CC0-1.0;CC-BY-4.0;Unlicense;Python-2.0;BlueOak-1.0.0;LGPL-3.0-or-later" --summary
- name: Licence summary
if: always()
run: |
echo "## Licence Compliance" >> $GITHUB_STEP_SUMMARY
echo "Allowlist: MIT, Apache-2.0, ISC, BSD-2-Clause, BSD-3-Clause, 0BSD, CC0-1.0, CC-BY-4.0, Unlicense, Python-2.0, BlueOak-1.0.0" >> $GITHUB_STEP_SUMMARY
# -----------------------------------------------------------------------
# Trivy Security Scan (CVE-2026-33634 safe version pinned)
#
# ⚠️ IMPORTANT: Do NOT use aquasecurity/trivy-action or setup-trivy —
# those GitHub Actions were compromised in the March 2026 supply chain
# attack (CVE-2026-33634 / GHSA-69fq-xp46-6x23). Tags 0.69.4–0.69.6
# and all trivy-action tags were poisoned with credential-stealing
# malware. We install the Trivy binary directly at the last clean
# version (0.69.3) via the official install.sh, pinned by SHA-256.
#
# Safe versions:
# trivy binary : 0.69.3
# trivy-action : DO NOT USE (compromised, not yet re-verified)
# setup-trivy : DO NOT USE (compromised, not yet re-verified)
# -----------------------------------------------------------------------
trivy-scan:
name: Trivy Security Scan
runs-on: ubuntu-latest
permissions:
security-events: write # required to upload SARIF to Security tab
contents: read
steps:
- uses: actions/checkout@v4
# Install Trivy 0.69.3 binary directly — avoids compromised trivy-action
# The install script is fetched from the official GitHub release, not Docker Hub.
- name: Install Trivy 0.69.3 (pinned — CVE-2026-33634 safe)
run: |
TRIVY_VERSION="0.69.3"
TRIVY_ARCHIVE="trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
curl -sfL "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/${TRIVY_ARCHIVE}" \
-o "${TRIVY_ARCHIVE}"
# Verify checksum from official release checksums file
curl -sfL "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_checksums.txt" \
-o trivy_checksums.txt
grep "${TRIVY_ARCHIVE}" trivy_checksums.txt | sha256sum -c -
tar -xzf "${TRIVY_ARCHIVE}" trivy
sudo mv trivy /usr/local/bin/trivy
trivy --version
- name: Trivy filesystem scan (HIGH+CRITICAL)
run: |
trivy fs \
--scanners vuln,secret,misconfig \
--severity HIGH,CRITICAL \
--format sarif \
--output trivy-results.sarif \
--exit-code 1 \
.
continue-on-error: true # upload report even on findings
- name: Upload SARIF to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: trivy-results.sarif
- name: Trivy summary table
if: always()
run: |
echo "## Trivy Scan Results" >> $GITHUB_STEP_SUMMARY
trivy fs \
--scanners vuln,secret,misconfig \
--severity HIGH,CRITICAL \
--format table \
. >> $GITHUB_STEP_SUMMARY 2>&1 || true
- name: Fail on HIGH/CRITICAL findings
continue-on-error: true # report findings without blocking the pipeline
run: |
trivy fs \
--scanners vuln \
--severity HIGH,CRITICAL \
--exit-code 1 \
--quiet \
.
# -----------------------------------------------------------------------
# Kubescape K8s Posture Scan (BSI C5 / NSA hardening guide)
# Scans k8s/ manifest files against CIS and NSA frameworks.
# Does NOT require a live cluster — static manifest analysis only.
# -----------------------------------------------------------------------
kubescape-scan:
name: Kubescape K8s Posture
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install kubescape
run: |
curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash
echo "$HOME/.kubescape/bin" >> "$GITHUB_PATH"
- name: Scan k8s manifests (NSA framework)
run: |
kubescape scan framework nsa \
--severity-threshold critical \
--format json \
--output kubescape-nsa.json \
k8s/
# Kubescape's framework names change release-to-release. The old
# cis-v1.23-t1.0.1 identifier returns `framework not found` on the
# current binary. List frameworks first, match the current CIS
# name, and only run the scan if it exists; otherwise just warn
# and continue so the NSA scan still gates critical issues.
- name: Scan k8s manifests (CIS benchmark)
run: |
CIS_FRAMEWORK=$(kubescape list frameworks 2>/dev/null \
| grep -oE "cis-v[^ ]+" | head -1 || true)
if [ -z "$CIS_FRAMEWORK" ]; then
echo "::warning::No CIS framework available in this kubescape build — skipping. NSA scan is authoritative."
echo '{"skipped":"no cis framework in kubescape"}' > kubescape-cis.json
exit 0
fi
echo "Using CIS framework: $CIS_FRAMEWORK"
kubescape scan framework "$CIS_FRAMEWORK" \
--severity-threshold critical \
--format json \
--output kubescape-cis.json \
k8s/
- name: Kubescape summary
if: always()
run: |
echo "## Kubescape K8s Posture" >> $GITHUB_STEP_SUMMARY
kubescape scan framework nsa k8s/ --format pretty-printer 2>/dev/null \
| tail -30 >> $GITHUB_STEP_SUMMARY || true
- name: Upload kubescape reports
uses: actions/upload-artifact@v4
if: always()
with:
name: kubescape-reports
path: |
kubescape-nsa.json
kubescape-cis.json
retention-days: 30
# -----------------------------------------------------------------------
# Lint Check
# -----------------------------------------------------------------------
lint:
name: Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./ui/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
# -----------------------------------------------------------------------
# Performance Budget (Lighthouse CI) — Core Web Vitals enforcement
# -----------------------------------------------------------------------
lighthouse:
name: Performance Budget (Lighthouse)
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
defaults:
run:
working-directory: ./ui
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./ui/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
env:
NEXT_PUBLIC_STATIC_EXPORT: "false"
- name: Install Lighthouse CI
run: npm install -g @lhci/cli
# `next start` fails with `output: export` configuration; our
# next.config.js flips to static export whenever GITHUB_ACTIONS is
# set AND NEXT_PUBLIC_STATIC_EXPORT != "false". Set the env var on
# the lhci step so next.config.js (re-read when `next start`
# launches) keeps the standalone server output.
#
# Assertions are scoped to the explicit performance budgets that
# matter for Core Web Vitals — dropped the `lighthouse:recommended`
# preset because it asserts minScore=1 on quality signals (meta
# description, aria-allowed-role, bf-cache, errors-in-console,
# legacy-javascript, etc.) that are orthogonal to the performance
# budget this job gates. Those live-check items belong in the
# WCAG / accessibility / security jobs, not the perf budget.
- name: Run Lighthouse CI
run: |
lhci autorun \
--collect.startServerCommand="npx next start -p 9222" \
--collect.url="http://localhost:9222/" \
--collect.url="http://localhost:9222/graph" \
--collect.url="http://localhost:9222/catalog" \
--collect.url="http://localhost:9222/docs" \
--collect.numberOfRuns=3 \
--assert.assertions.first-contentful-paint="warn:maxNumericValue=3000" \
--assert.assertions.largest-contentful-paint="error:maxNumericValue=4000" \
--assert.assertions.cumulative-layout-shift="error:maxNumericValue=0.1" \
--assert.assertions.total-blocking-time="warn:maxNumericValue=300" \
--assert.assertions.resource-summary:script:size="warn:maxNumericValue=500000"
env:
NEXT_PUBLIC_STATIC_EXPORT: "false"
NEXTAUTH_SECRET: ci-lighthouse-not-for-production
NEXTAUTH_URL: http://localhost:9222
LHCI_BUILD_CONTEXT__CURRENT_HASH: ${{ github.sha }}
- name: Upload Lighthouse reports
uses: actions/upload-artifact@v4
if: always()
with:
name: lighthouse-reports
path: ui/.lighthouseci/
retention-days: 30
# -----------------------------------------------------------------------
# E2E Tests (Playwright) — only on main / manual dispatch
# -----------------------------------------------------------------------
e2e-tests:
name: E2E Tests (Playwright)
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
defaults:
run:
working-directory: ./ui
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./ui/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
env:
NEXT_PUBLIC_STATIC_EXPORT: "false"
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
continue-on-error: true # Neo4j not available in CI — some tests expected to fail
run: npx playwright test --project=chromium
env:
CI: true
NEXT_PUBLIC_STATIC_EXPORT: "false"
NEXTAUTH_SECRET: ci-test-secret-not-for-production
NEXTAUTH_URL: http://localhost:3000
- name: WCAG 2.2 AA accessibility audit
run: npx playwright test __tests__/e2e/journeys/27-wcag-accessibility.spec.ts --project=chromium
env:
CI: true
NEXT_PUBLIC_STATIC_EXPORT: "false"
NEXTAUTH_SECRET: ci-test-secret-not-for-production
NEXTAUTH_URL: http://localhost:3000
- name: Security & penetration tests (OWASP/BSI)
continue-on-error: true # requires running services for full coverage
run: npx playwright test __tests__/e2e/journeys/28-security-pentest.spec.ts --project=chromium --grep-invert "SEC-4[1-9]|SEC-50"
env:
CI: true
NEXT_PUBLIC_STATIC_EXPORT: "false"
NEXTAUTH_SECRET: ci-test-secret-not-for-production
NEXTAUTH_URL: http://localhost:3000
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: ui/playwright-report/
retention-days: 30