Commit Graph
20 Commits
Author SHA1 Message Date
Donkie 404b03173b security: stop backup rotation from churning away the restore history
Rotating deletes the oldest restore point and shifts the rest down, so enough
calls in quick succession leave nothing but snapshots of whatever state the
database is in now. POST /backup takes no parameters, so a bodyless cross-origin
form post reached it; the audit destroyed a full six-deep history that way
(todo.md task 2).

The origin guard from the previous commit already refuses that request, but the
rotation itself should not be this easy to abuse, so two further changes:

Rotation is skipped when the database has not actually changed. Not by comparing
the live database file, which the audit suggested: under WAL the live file does
not yet contain recent commits, so comparing it would skip backups that were
genuinely needed. Instead the snapshot is written to a pending file first and
compared against the newest backup -- sqlite's backup API reads through the
connection, so it sees WAL content. Identical means the pending file is
discarded and the history is left alone. This is fail-safe: if the comparison
ever came out unequal for an unchanged database, the result is the old behaviour
of rotating, never a missed backup.

Rotation is also rate-limited to one per five minutes, returning the newest
existing backup instead. Never applied when there is no backup to fall back on.

BackupResponse gained a `created` field so a client can tell the difference.
Additive, so v1-compatible, but load-bearing: telling a user they have a fresh
restore point when they do not is exactly the wrong failure mode here.

Verified against a real server -- six rapid calls now leave exactly one backup
and never rotate.
2026-07-27 19:33:07 +02:00
Donkie b942d1f8a1 Replaced pdm with uv, updated backend deps, python 3.10 minimum, simplified install script 2026-01-07 22:01:02 +01:00
Paul Sinclair ea36a94327 🔨 Add pool_recycle for MySQL 2025-04-05 09:58:34 -04:00
Donkie 70ea7ad414 Update python dependencies and ruff/black versions 2025-03-16 21:34:02 +01:00
Donkie 535fa40ad2 Updated most python dependencies
Primarily FastAPI and Pydantic to v2. Also ruff to latest.

Updated some code to support Pydantic v2
2024-05-23 19:42:27 +02:00
Donkie 21d541a680 Added script to download files from external db 2024-05-12 10:48:33 +02:00
Dmitry Belousov 91d922d0b8 fixed version prometheus-client
added env variable SPOOLMAN_METRICS_ENABLED for enabled database collector

set metrics path as /metrics

checked Null values at vendors, init weight and price
removed some logs
2024-04-15 00:17:36 +03:00
Dmitry Belousov 2aa0a4f1b0 WA for FastApi session manager 2024-04-12 01:20:35 +03:00
Dmitry Belousov 28b2bfec50 Added prometheus client
Added scheduler for compute current spool metrics and info
2024-04-09 15:25:09 +03:00
Donkie 796523a860 Fixed db backups not using the fancy get_backups_dir function 2023-11-25 21:58:20 +01:00
Donkie d3a4dcfcf8 Added logging for when scheduled backup runs 2023-07-07 17:37:17 +02:00
Donkie f24b9610e8 Added automatic nightly SQLite backups
Resolves #22
2023-07-04 14:59:05 +02:00
Donkie d201f17e5e Improved manually specifying sqlite db 2023-07-04 12:10:14 +02:00
Donkie 94d8cbf227 SQLite dbs now handle concurrent reqs better
Closes #7
2023-06-30 22:28:01 +02:00
Donkie de1bf05922 Added Alembic for migrations 2023-05-27 23:14:06 +02:00
Donkie ba6fb62c7b Enabled pool_pre_ping to mitigate postgres drop 2023-05-21 23:38:21 +02:00
Donkie 1c59e0efd5 Added logging level env var 2023-05-09 21:44:25 +02:00
Donkie ed3e30ea75 Improved compatibility with postgres 2023-05-09 20:03:19 +02:00
Donkie 1a148c0991 Added proper support for all databases 2023-04-06 16:19:33 +02:00
Donkie 6fd9662c42 Renamed to Spoolman
Spoolson just didn't sound that good after all
2023-04-02 19:19:15 +02:00