-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(pg-connection-string): warn if non-standard ssl options are used #3473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hjr3
wants to merge
1
commit into
master
Choose a base branch
from
push-qkwyoukwlmvl
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
'use strict' | ||
|
||
const { emitWarning } = require('node:process') | ||
|
||
//Parse method copied from https://github.com/brianc/node-postgres | ||
//Copyright (c) 2010-2014 Brian Carlson ([email protected]) | ||
//MIT License | ||
|
@@ -133,6 +135,9 @@ function parse(str, options = {}) { | |
case 'require': | ||
case 'verify-ca': | ||
case 'verify-full': { | ||
if (config.sslmode !== 'verify-full') { | ||
deprecatedSslModeWarning(config.sslmode) | ||
} | ||
break | ||
} | ||
case 'no-verify': { | ||
|
@@ -201,6 +206,20 @@ function parseIntoClientConfig(str) { | |
return toClientConfig(parse(str)) | ||
} | ||
|
||
function deprecatedSslModeWarning(sslmode) { | ||
if (!deprecatedSslModeWarning.warned) { | ||
deprecatedSslModeWarning.warned = true | ||
emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'. | ||
In the next major version (v3.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees. | ||
|
||
To prepare for this change: | ||
- If you want the current behavior, explicitly use 'sslmode=verify-full' | ||
- If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${sslmode}' | ||
|
||
See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`) | ||
} | ||
} | ||
|
||
module.exports = parse | ||
|
||
parse.parse = parse | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this would probably be considered a breaking change to
pg
itself so might want to call out we'd be bumping pg semver to 9.x at this point as well?