-
-
Notifications
You must be signed in to change notification settings - Fork 702
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
Allow-list pragma_table_info(tablename) and similar #761
Comments
I could allow-list some other useful SQLite calls these "pragma functions" - documented here: https://www.sqlite.org/pragma.html#pragfunc They sound safe:
|
The rationale for blocking
That second line is unsafe. I don't think it's possible to use the |
Maybe use a negative lookahead assertion? https://docs.python.org/3/library/re.html#index-20
|
For the moment I'll allow-list the following:
|
Interestingly https://latest.datasette.io/fixtures?sql=select+*+from+pragma_function_list() doesn't work, when it DOES work on my laptop.
https://www.sqlite.org/changes.html#version_3_30_0 says that as-of 3.30.0:
|
Enabled by simonw/datasette#761
Here's another demo I built using this feature: https://observablehq.com/@simonw/datasette-table-diagram Running on this query: select
sqlite_master.name as table_from,
fk_info.[from] as column_from,
fk_info.[table] as table_to,
fk_info.[to] as column_to
from
sqlite_master
join pragma_foreign_key_list(sqlite_master.name) as fk_info
order by
sqlite_master.name |
It would be great if
pragma_table_info(tablename)
was allowed to be used in queries. See also https://github.com/simonw/til/blob/master/sqlite/list-all-columns-in-a-database.mdOriginally posted by @simonw in #760 (comment)
The text was updated successfully, but these errors were encountered: