6 Commits
Author SHA1 Message Date
mvdbeek a86c3c6e0d Limit SQLite dataprovider query runtime
connect_read_only installs a progress handler that interrupts statements
still running a given number of seconds (10 by default) after the
connection is opened. The providers open the connection right before
running the query and consume all rows in the same request, so the
limit covers both preparing the query and fetching its rows.

The three SQLite providers now share SQLiteQueryDataProvider, which
opens the connection with its query_timeout class attribute, maps
SQLite errors raised while preparing the query or fetching rows to
RequestParameterInvalidException, and reports an interrupted query as a
timeout.
2026-11-07 15:27:49 +01:00
mvdbeek 6a2b2eb0e2 Enforce read-only SQLite dataprovider queries in SQLite itself
The sqlite, sqlite-table and sqlite-dict dataproviders run a
user-supplied query against the dataset file. They used to classify the
query with sqlparse (or a regex when sqlparse was missing) and then run
it on a read-write connection to the dataset file.

They now open the file with mode=ro&immutable=1 and install an
authorizer that only allows SELECT, table reads, function calls and
recursive CTEs, so SQLite refuses to prepare writes, ATTACH, VACUUM
INTO, PRAGMA and transaction statements. immutable=1 skips locking, so a
WAL-mode dataset can be read without creating -wal/-shm files next to
it, including in a read-only directory. Galaxy datasets do not change
once they are ready, which is what immutable requires.

A refused or failing query now raises RequestParameterInvalidException
(HTTP 400 with SQLite's message) instead of yielding a single empty
item.
2026-11-07 15:27:29 +01:00
Nicola Soranzo 0629908541 Fix new UP031 errors from ruff 0.4.2 2024-04-29 00:09:38 +01:00
mvdbeek c431c6f0fc Tighten pytest raises assertions 2023-01-21 12:54:05 +01:00
Nicola Soranzo 452aba9ee3 Fix remaining issues reported by bugbear; add it to flake8 reqs 2021-01-16 05:58:15 +00:00
John Chilton f529da1b30 Organize more unit tests into package tested bundles. 2020-07-06 18:49:04 -04:00