3.7 KiB
3.7 KiB
phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
| phase | plan | subsystem | tags | dependency_graph | tech_stack | key_files | decisions | metrics | |||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 16-ci-dependency-audit-and-security-checks | 01 | api-security |
|
|
|
|
|
|
Phase 16 Plan 01: Boot-time Dev-Bypass Guard Summary
One-liner: Boot-time refuse-to-boot guard (assertNotDevBypassInProduction) plus ENV NODE_ENV=production baked into the production Dockerfile stage, turning a silent auth-bypass misconfiguration into an immediate non-zero exit.
What Was Built
Task 1 — RED (test commit 8414e89)
Created apps/api/tests/lib/bootGuards.test.ts with 3 test cases:
NODE_ENV=production+DEV_AUTH_BYPASS=true→process.exit(1)is called (spy throws to make it observable)NODE_ENV=development+DEV_AUTH_BYPASS=true→ noprocess.exitNODE_ENV=production+DEV_AUTH_BYPASSunset → noprocess.exit
Suite failed with Cannot find module '../../src/lib/bootGuards.js' — RED state confirmed.
Task 2 — GREEN (feat commit c2ffd1c)
- Created
apps/api/src/lib/bootGuards.tsexportingassertNotDevBypassInProduction(): void - JSDoc documents D-08, call-time env evaluation, and required placement rule
- Added import to
apps/api/src/index.ts - Added call as the first statement in
isMainModule()block (before VAPID config, workers, serve()) - 3/3 unit tests pass,
pnpm typecheckgreen
Task 3 — Dockerfile ENV (chore commit 5b4f32a)
- Added
ENV NODE_ENV=productionto theproductionstage inapps/api/Dockerfile - Placed between
WORKDIR /app/apps/apiandCOPY --from=pwa-builder(exactly as specified) - Comment references D-07
- Exactly 1 occurrence; no other stage is affected
Deviations from Plan
None — plan executed exactly as written.
TDD Gate Compliance
- RED gate commit:
8414e89—test(16-01): add failing tests for boot-time dev-bypass guard - GREEN gate commit:
c2ffd1c—feat(16-01): add boot-time refuse-to-boot guard for dev-bypass in production - REFACTOR: not needed — implementation was clean on first pass
Threat Surface Scan
No new network endpoints, auth paths, file access patterns, or schema changes introduced. The boot guard adds a startup-time process.exit — no new externally-reachable surface.
Known Stubs
None.
Self-Check: PASSED
apps/api/src/lib/bootGuards.ts— FOUNDapps/api/tests/lib/bootGuards.test.ts— FOUNDapps/api/src/index.tsmodified — assertNotDevBypassInProduction() called at line 115apps/api/Dockerfile—ENV NODE_ENV=productionpresent in production stage
Commits:
8414e89— test(16-01): add failing tests for boot-time dev-bypass guardc2ffd1c— feat(16-01): add boot-time refuse-to-boot guard for dev-bypass in production5b4f32a— chore(16-01): bake ENV NODE_ENV=production into production Dockerfile stage