Skip to content
Discussion options

You must be logged in to vote

In general I would advise using the access rights of your database to manage these sorts of restrictions.

That being said, it's a question of doing static analysis on the syntax tree.

Prevent all statements except select.

This is pretty trivial to achieve.

Prevent all from clauses with table/identifier named "users".

This is much harder. Especially if you want to avoid false positives. For example:

WITH users AS (SELECT * FROM products)
SELECT * FROM users;

That query doesn't touch the users table, but when you only look at the FROM clause, it will look like it does. Similarly you need to account for aliases. Also you need to consider schemas, like do you want to restrict access to pu…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by vbackeberg
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants