wrolpi/wrolpi/test
lrnselfreliance f27720683d
Read-only SQL query endpoint for advanced users (#820)
* Read-only SQL query endpoint for advanced users

POST /api/db/query runs one read-only statement; GET /api/db/schema describes
the tables.  Both are refused unless `allow_database_query: true` is set in
wrolpi.yaml (there is no UI for it).  The connection is opened with mode=ro and
an authorizer that allows only reads; queries are interrupted after 10 seconds,
rows are capped, and long values are truncated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Database queries cannot be enabled through the API, and use bounded memory

The config update API refuses to change `allow_database_query`; only an edit of
wrolpi.yaml on the WROLPi can enable queries.  Query connections refuse values
over 32 MB and rows over 100 columns, rows are read one at a time, and the
response stops at 5 million characters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* The database query setting can be changed like any other config

WROLPi is meant to be as secure as a bookshelf in your home; a LAN user who can
reach the API is trusted, so gating one key in the config API adds nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Database queries can search FTS5 tables on SQLite 3.46

FTS5 reads `PRAGMA data_version` through the authorizer when it opens a table
on SQLite 3.46 (Debian 13), so every MATCH and the schema endpoint failed with
"vtable constructor failed".  A denied VACUUM INTO also explains itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* A config status test attaches the shared context it reads

It passed only when an earlier test in the same worker had attached it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 17:34:00 -06:00
..
fixtures/configs Add Docs module for searching and organizing PDFs and EPUBs 2026-03-20 14:17:06 -06:00
__init__.py A new start 2021-11-01 16:43:09 -06:00
common.py Rename skip_circleci to skip_ci (#797) 2026-10-08 17:28:13 -06:00
test_api_fixtures.py db: request-path library functions use the request's connection (#774) 2026-10-04 11:05:20 -06:00
test_api_utils.py api: run the perpetual loops in one Sanic-managed process (#718) 2026-09-23 07:53:53 -06:00
test_bookmarks.py Add a Repos module that mirrors git repositories (#783) 2026-10-07 15:16:58 -06:00
test_captions.py videos: center YouTube auto-captions at download time 2026-07-16 18:51:36 -06:00
test_cmd.py Single file deno (#478) 2026-06-12 17:07:28 -06:00
test_common.py Rename skip_circleci to skip_ci (#797) 2026-10-08 17:28:13 -06:00
test_config_api.py Changing archive special directory default to include domain tag. 2025-12-25 15:42:35 -07:00
test_config_backup_import.py Read-only SQL query endpoint for advanced users (#820) 2026-10-11 17:34:00 -06:00
test_config_partial_import.py Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
test_contexts.py Reformatting code. 2025-12-06 15:11:37 -07:00
test_cross_config_disaster_recovery.py Track how far the user is through a file, kept in recently_viewed.yaml (#787) 2026-10-08 16:15:25 -06:00
test_dates.py Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
test_db.py Request sessions keep objects after commit; guard dict() serializers (#811) 2026-10-10 19:15:33 -06:00
test_db_bootstrap.py Track how far the user is through a file, kept in recently_viewed.yaml (#787) 2026-10-08 16:15:25 -06:00
test_db_query.py Read-only SQL query endpoint for advanced users (#820) 2026-10-11 17:34:00 -06:00
test_downloader.py db: request-path library functions use the request's connection (#774) 2026-10-04 11:05:20 -06:00
test_downloads_config.py tests: fix the midnight and event-loop timing flakes (#779) 2026-10-04 18:43:00 -06:00
test_events.py Rename skip_circleci to skip_ci (#797) 2026-10-08 17:28:13 -06:00
test_extensions.py Creating browser extension to facilitate starting downloads. Chrome/Brave and Firefox supported. 2026-05-03 11:48:50 -06:00
test_flags.py Displaying warning when no drive is mounted. 2026-05-14 16:16:18 -06:00
test_fts.py Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
test_jobs.py Jobs queue, video Edit dropdown: transcode/remux, edit title & description (#711) 2026-09-16 19:25:23 -06:00
test_json_encoder.py API JSON: encode paths without a lookup per path (#810) 2026-10-09 19:45:43 -06:00
test_model_repr.py Model reprs read only loaded state (#819) 2026-10-11 16:47:32 -06:00
test_perpetual.py api: forked workers die on SIGTERM before Sanic installs their handlers (#743) 2026-10-02 15:49:06 -06:00
test_request_db.py db: request-path library functions use the request's connection (#774) 2026-10-04 11:05:20 -06:00
test_root_api.py Download forms: allow a frequency of "Once" (#804) 2026-10-09 15:00:24 -06:00
test_rss.py Using stubs to simplify tests. 2026-05-07 20:07:46 -06:00
test_serializers.py db: serializers read only loaded data (#777) 2026-10-04 18:28:08 -06:00
test_speedtest.py Speed Test calculator: ping, download, and upload against the API (#708) 2026-09-13 18:47:18 -06:00
test_switches.py Fix API stalls: non-blocking switch worker, threaded searches, indexed Videos page (#678) 2026-08-29 16:17:53 -06:00
test_tags.py db: serializers read only loaded data (#777) 2026-10-04 18:28:08 -06:00
test_upgrade.py api: run the perpetual loops in one Sanic-managed process (#718) 2026-09-23 07:53:53 -06:00