Repository navigation
[Susan (Grok Bot)] chore: explicit pg sslmode=verify-full and channel binding - #13
Merged
Merged
Conversation
Rewrite Neon sslmode aliases for node-postgres, enable channel binding, and append sslaccept=strict for prisma db push. Authored-by: Susan (Grok Bot) Co-authored-by: Grant Lindsay <glindsay65@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Authored by Susan (Grok Bot), not Grant.
Why
Vercel function logs show the node-postgres warning that
sslmodevaluesprefer,require, andverify-caare aliases ofverify-full, and that pg 9 / pg-connection-string 3 will switch those aliases to weaker libpq semantics. The Neon Vercel integration ownsDATABASE_URL,DATABASE_URL_UNPOOLED, andPOSTGRES_URL_NON_POOLING. Those URLs end in?channel_binding=require&sslmode=require, so the fix has to live in code.pg 8.21.0 / pg-connection-string 2.13.0 copies
channel_bindingonto the parsed config and never reads it.Client.enableChannelBinding(pg/lib/client.js) stays false unless that constructor option is set.@types/pg8.20.0 does not declare the option; the runtime does.What changed
src/lib/pg-config.ts—pgPoolConfig()rewrites onlysslmode=require|prefer|verify-catoverify-full.disable,allow,verify-full, and a missing sslmode stay as they are, and sslmode is never added, sopostgresql://localhost:5432/fdc_websiteis unchanged.channel_binding=requiresetsenableChannelBinding: true. The query param stays in the URL: constructing a client with it left in place emits no warning. Empty or invalid input is returned as aconnectionStringconfig.prismaDbPushUrl()appendssslaccept=strictwhen the URL hassslmode=requireand nosslaccept, using&when a query string is already present and?otherwise.sslmode=requirestays in place for the schema engine.src/lib/prisma.ts,scripts/sync-resume.ts,prisma/seed.ts— pools are created withpgPoolConfig(...). Scripts import the helper by relative path, the same way they already importsrc/lib.scripts/print-prisma-db-push-url.ts,scripts/vercel-build.sh—prisma db pushreceives the strict URL for that command only. Seed still reads the original URL (DATABASE_URL_UNPOOLEDorDATABASE_URL) and the pg helper rewritessslmodetoverify-fullitself.src/lib/pg-config.test.ts— vitest coverage for the sslmode rewrites, preserved params, channel binding, unset/empty input, and the db push URL.scripts/dev.shis unchanged (local Postgres, no sslmode).Behavior
sslmode=requireasverify-full(ssl: {}, certificate check left at the Node default). The rewrite makes that explicit so the warning stops and pg 9 keeps the same verification.new pg.Client(pgPoolConfig('postgresql://u:p@host/db?channel_binding=require&sslmode=require'))hasenableChannelBinding: true, ssl enabled, and emits noSECURITY WARNING. The same constructor with the rawsslmode=requireURL still warns, andenableChannelBindingstays false.prisma db pushnow verifies certificates viasslaccept=strict. Quaint in engines 7.8.0 only understands sslmodedisable/prefer/requireand would treatverify-fullasprefer, so the push URL keepssslmode=require.Preview test plan
/api/syncand the sitemap respond.SECURITY WARNINGfrom pg.prisma db pushsucceeding (and seed, whenSEED_DATABASEis set).Verification
npm ci,npx tsc --noEmit, andnpm run test:run(7 files, 61 tests) passed.npx next buildcompiled and the TypeScript step finished. Static generation then failed withCan't reach database server at 127.0.0.1:1because this environment has no Postgres.npm run lintstill reports existing issues inHeaderNav.tsx,SiteFooter.tsx,SiteHeader.tsx, andTestimonialSection.tsx. Those files are outside this diff. The files changed here are lint-clean.SCRAM-SHA-256-PLUSwhenenableChannelBindingis true, the connection is TLS, and the server offers that mechanism; otherwise it usesSCRAM-SHA-256(pg/lib/crypto/sasl.js). Neon documents SCRAM-SHA-256-PLUS on direct and pooled connections. A pooler that omits the PLUS mechanism would still authenticate with SCRAM-SHA-256.