wrolpi/modules/zim
Roland aeebe8d833
zim: address PR review — config race, YAML null, path traversal, pinned build
Triage of Greptile findings on the default-Zim / configurable-directory PR:

- Stale config on restart (P1): settings update() only queues an async
  background_save, and the restart switch has no ordering guarantee (the switch
  worker pops LIFO), so start_kiwix_serve.sh could read the old zims_destination.
  Save the config synchronously before activating the restart switch.
- YAML null (P1): read_config_value.sh now treats an unquoted null/~ as unset
  (returns the default), matching PyYAML/the Python config layer.  A quoted
  "null" remains the literal string.
- Path traversal (P1/security): the settings API now rejects a zims_destination
  containing "..", and start_kiwix_serve.sh defends in depth by falling back to
  `zims` for any absolute/traversal/empty value, so Kiwix can never scan or
  rewrite library.xml outside the media root.
- Reproducible build (P2): pin the zim-tools image to 3.7.0 instead of :latest.

Tests added for null handling, traversal rejection (API + script).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 19:10:09 -06:00
..
test zim: address PR review — config race, YAML null, path traversal, pinned build 2026-07-20 19:10:09 -06:00
__init__.py Zim/Kiwix (Wikipedia) feature 2023-07-10 21:30:40 -06:00
api.py Creating Zim search endpoint that searches all auto-search zim files. 2026-03-20 14:16:56 -06:00
conftest.py Using aria2c to download files. Removing custom file download functions. 2025-01-10 11:32:37 -07:00
downloader.py Migrating Kiwix downloaders. 2026-05-07 15:54:53 -06:00
errors.py Adding toggle to Channel page to stop downloading comments for certain channels. 2025-03-01 18:23:29 -07:00
kiwix.py Adding Khan Academy to zim subscriptions. Updating some kiwix catalog sizes. 2025-03-03 16:32:35 -07:00
lib.py Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
models.py Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
schema.py Adding feature which adds toggles to Zim files to enable/disable auto search. 2025-02-02 12:43:04 -07:00