Skip to content

v0.2: Add ReadOnlyQueryExecutor

Latest

Choose a tag to compare

@thorewi thorewi released this 17 Aug 15:24
· 1 commit to main since this release
Connects to the anonymized schema with the dedicated read-only account and runs
validated read-only queries. Extracted from a consuming project, where an LLM
writes the SQL - but it fits any untrusted or semi-trusted consumer, so it belongs
next to the views it queries.

- only SELECT/WITH/SHOW/DESCRIBE/EXPLAIN, no multi-statement, no qualified
  reference to the source database; checks run on a version of the query without
  string literals and comments so a keyword hidden in a value cannot slip through
- row cap and max_execution_time, plus streamQuery() for exports with a separate
  (higher) cap and a longer timeout
- getTables()/getTableColumns() expose the schema including the descriptions from
  the entity attributes, because generated views drop MySQL column comments
- refuses to run at all when no read-only user is configured, rather than quietly
  falling back to the application account

The validation is a second line of defence; the boundary remains the database
grant of that account.