X Tutup
The Wayback Machine - https://web.archive.org/web/20200906045149/https://github.com/brianc/node-postgres/pull/1788/
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

Include raw SQL statement and values in query errors #1788

Open
wants to merge 3 commits into
base: master
from

Conversation

@marshall007
Copy link

marshall007 commented Dec 12, 2018

Fixes #881

function handleQueryError (err, query) {
err.sql = {
text: query.text,
values: query.values

This comment has been minimized.

@joelmukuthu

joelmukuthu Dec 21, 2018

Including values introduces a security issue. This could lead to user data e.g. passwords being logged in production. Perhaps this should be configurable or removed altogether.

This comment has been minimized.

@marshall007

marshall007 Dec 21, 2018

Author

@joelmukuthu agreed, do you think we should just make the population of err.sql.values configurable, err.sql entirely, or have fine-grained options for both?

@marshall007
Copy link
Author

marshall007 commented Dec 21, 2018

I've addressed @joelmukuthu's concern in dd7352c. There is a new config option, sql_in_error (totally open to a better name there), which accepts the following values:

  • false: none (default, current behavior)
  • true: text and values from query
  • "text": only text from query
@mledom
Copy link

mledom commented Feb 11, 2019

This is great, I was actually trying to find a way to get that information.

@brianc
Copy link
Owner

brianc commented Feb 20, 2019

I'm not a fan of doing this - there's a security issue here in that we could be causing apps to accidentally log out sensitive information (e.g. a hashed password in the query params). It also is something that can/should be handled by a higher level library or your own application code if this kind of logging is required. Our responsibility as a database driver is to propagate the error back to the caller w/ the details included from the PostgreSQL backend.

@abenhamdine
Copy link
Contributor

abenhamdine commented Feb 27, 2019

there's a security issue here in that we could be causing apps to accidentally log out sensitive information

It would be indeed unacceptable in many businesses (including our) and uncompliant with European regulation on personal data protection (GDPR).
However, it would be useful for debugging purpose, could you allow to enable it only with an option ?

@marshall007
Copy link
Author

marshall007 commented Mar 4, 2019

... there's a security issue here in that we could be causing apps to accidentally log out sensitive information (e.g. a hashed password in the query params).

@brianc because the new behavior is strictly opt-in, I tend to disagree here. I'd be happy to add some logic that explicitly warns the user of your concern when NODE_ENV === 'production' and sql_in_error !== false. That would seem like a reasonable middle ground?

@brianc
Copy link
Owner

brianc commented Mar 6, 2019

I think the best approach here is to log your query text & sql out in your own application if you need to see it in your logs. I'm not comfortable putting code in that has the possible to leak secure information...even less so if it's non-compliant with regulation. I don't see a reason this has to be the responsibility of node-postgres.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.
X Tutup