Commit 9d5e2c2
[dev] [Marfuen] mariano/secure-rds-tls (#2762)
* chore(db): commit AWS RDS global CA bundle for verified TLS
* feat(db): strict TLS gating in shared prisma client
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(db): extract resolveSslConfig and use bun:test for consistency
Move SSL-resolution logic into a pure ssl-config.ts module so it can be
tested with bun:test (matching strip-ssl-mode.test.ts's pattern) without
importing the module-level Prisma client. Drop vitest devDependency.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(app): strict TLS gating in app prisma client
Extracts SSL config logic into apps/app/prisma/ssl-config.ts and
updates the Prisma client to throw at boot when connecting to a
non-local database without a verified CA bundle or explicit
PRISMA_ALLOW_INSECURE_TLS=1 opt-in.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(db): expose resolveSslConfig via subpath export; dedupe in apps/app
Add `./ssl-config` subpath export to @trycompai/db so apps/app (and
upcoming portal/framework-editor) can import the single source of truth
instead of maintaining their own copy. Widen the `env` parameter type
from `NodeJS.ProcessEnv` to `Partial<NodeJS.ProcessEnv>` (strictly more
permissive) to satisfy apps/app's strict TS config. Delete the duplicate
apps/app/prisma/ssl-config.ts and its redundant test file.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(portal): strict TLS gating in prisma client
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(framework-editor): strict TLS gating in prisma client
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(trigger): add caBundleExtension for verified-TLS Postgres
Ships the RDS CA bundle (packages/db/certs/rds-global-bundle.pem) into
Trigger.dev task images at /app/certs/rds-global-bundle.pem and sets
NODE_EXTRA_CA_CERTS via the deploy.env layer so Node TLS initialization
picks it up before any Prisma connection attempt.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(prisma): inline TLS gating in app clients to avoid published-package dependency
Drop `import { resolveSslConfig } from '@trycompai/db/ssl-config'` from
apps/app, apps/portal, and apps/framework-editor and inline the full
localhost/CA-bundle/PRISMA_ALLOW_INSECURE_TLS logic directly.
Trigger.dev pins @trycompai/db@^2.0.0 from npm which lacks the
./ssl-config subpath, causing indexer crashes at deploy time.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(prisma): skip hostname check when CA bundle is set (NLB compatibility)
AWS NLB → RDS Proxy connections fail TLS hostname verification because the
NLB hostname (*.elb.amazonaws.com) isn't in the RDS Proxy cert's SAN list.
Cert chain verification is preserved — an attacker still cannot present a
forged or wrong-CA cert. Only the hostname-string check is relaxed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(vercel): bundle RDS CA cert with Next.js apps for verified TLS
Add outputFileTracingIncludes to apps/app and apps/portal next.config.ts
so the rds-global-bundle.pem is included in Vercel's traced file output
for each deployed function.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* docs: deploy checklist for verified-TLS env vars
Documents the NODE_EXTRA_CA_CERTS values to set in Vercel (both candidate
paths), the Trigger.dev PRISMA_ALLOW_INSECURE_TLS removal commands, and
notes that API Docker needs no action.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(prisma): lazy-init client to prevent TLS throw during Next.js build
next build imports every route handler to analyze it, which previously
triggered our strict-TLS throw at module load even though no queries run.
Wrap the client in a Proxy that constructs the real PrismaClient on first
property access. The strict check still fires — just at first use, not at
import.
* fix(db): point ssl-config types at dist (src/ is not published)
cubic flagged: the subpath export's types entry pointed at ./src/ssl-config.ts,
but the published package's files array only includes dist/. Downstream npm
consumers would get broken type resolution. Workspace consumers were unaffected
because @trycompai/db resolves to source via workspace:*.
* chore: temporary debug endpoint to verify Vercel cert path
Hit /api/_debug-tls on the deployed preview. Reports process.cwd(),
NODE_EXTRA_CA_CERTS value, and existence/size for the env-var path plus
common candidate paths. Delete this commit once the path is confirmed.
---------
Co-authored-by: Mariano <marfuen98@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 2bde7ad commit 9d5e2c2
1 file changed
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments