-
Notifications
You must be signed in to change notification settings - Fork 18
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
Safe interpolation of column names #59
Comments
Found a related issue in psycopg2, quote psycopg/psycopg2#438 (comment):
|
Not a huge paint point in my life, but I'm open to this. |
It's not a huge pain point, but it would be nice to have, especially to avoid security debt. (I'm not planning to work on this right now, but I've just realized that I can't actually push to this repo since I'm no longer part of the Gratipay org.) |
Oops! Happy to add you back as a contributor on this repo if you like? |
Yes, that seems like a reasonable solution. |
Invite sent! :) |
Invite accepted. ;-) I think it's the 3rd time that I'm joining the Gratipay org. :D |
https://github.com/martijndeh/lego reminds me of this. |
AFAICT quoting an identifier is as simple as: def quote_identifier(s):
return '"%s"' % s.replace('"', '""') https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html
|
psycopg 2.7, which was released less than two months after this issue was opened, introduced a module for "safe" SQL query composition: psycopg2.sql – SQL string composition. |
Why don't we have this? It seems to me that a column name can be checked with a simple regexp, and a placeholder different than
%s
(e.g.%c
) could be used to insert a column name into a query.This is probably more of a psycopg2 issue, but let's discuss it here first, especially since we're considering porting to asyncpg (#58).
The text was updated successfully, but these errors were encountered: