Skip to content
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

Remove password from stringified outputs #2070

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions packages/pg-pool/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ class Pool extends EventEmitter {
constructor (options, Client) {
super()
this.options = Object.assign({}, options)
const password = this.options.password
// "hiding" the password so it doesn't show up in stack traces
// or if the client is console.logged
Object.defineProperty(this.options, 'password', {
configurable: true,
enumerable: false,
value: password,
writable: true
})

if (options != null && 'password' in options) {
// "hiding" the password so it doesn't show up in stack traces
// or if the client is console.logged
Object.defineProperty(this.options, 'password', {
configurable: true,
enumerable: false,
writable: true,
value: options.password
})
}

this.options.max = this.options.max || this.options.poolSize || 10
this.log = this.options.log || function () { }
this.Client = this.options.Client || Client || require('pg').Client
Expand Down
5 changes: 2 additions & 3 deletions packages/pg/lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ var Client = function (config) {

// "hiding" the password so it doesn't show up in stack traces
// or if the client is console.logged
const password = this.connectionParameters.password
Object.defineProperty(this, 'password', {
configurable: true,
charmander marked this conversation as resolved.
Show resolved Hide resolved
enumerable: false,
configurable: false,
writable: true,
value: password
value: this.connectionParameters.password
})

this.replication = this.connectionParameters.replication
Expand Down
7 changes: 3 additions & 4 deletions packages/pg/lib/connection-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ var ConnectionParameters = function (config) {

// "hiding" the password so it doesn't show up in stack traces
// or if the client is console.logged
const password = val('password', config)
Object.defineProperty(this, 'password', {
configurable: true,
enumerable: false,
configurable: false,
writable: false,
value: password
writable: true,
value: val('password', config)
})

this.binary = val('binary', config)
Expand Down