Files
hark/docker-entrypoint.sh
flan ada07544f3 0.3.1: hardening pass — fix recanonicalize corruption, deploy crash-loop, POST desync
A full audit before the TrueNAS deploy surfaced 15 issues, all fixed and
covered by regression tests:

- hark canon: label-only matches could clobber an unrelated topic's QID
  and merge distinct entities sharing a Wikidata display label; now only
  a QID match (or an unresolved same-label topic) merges, and genuine
  label collisions are disambiguated instead of crashing on the
  topics.label unique constraint.
- Web UI: a missing hark.db (fresh volume, no ingest yet) crashed every
  route with no HTTP response; now returns 503.
- Web UI: POST requests that redirected before reading the body left it
  undrained, desyncing the next HTTP/1.1 keep-alive request; body is now
  always consumed, and oversized bodies close the connection instead.
- Docker: non-root hark user couldn't write a freshly-created bind mount,
  crash-looping on first start; entrypoint now fixes ownership as root
  then drops to hark via gosu.
- hark load: per-record error isolation (one bad record no longer aborts
  the batch); re-loading already-extracted episodes reports as a skip,
  not a failure.
- Wikidata canonicalizer: Retry-After in HTTP-date form no longer crashes
  and gets silently swallowed as "no match"; transport errors (timeouts,
  connection resets) now retry like throttling responses do.
- Consolidated three near-duplicate topic-listing queries into one
  builder; deduped GENRES_FILTER against extract.GENRES.
2026-07-10 21:52:05 +00:00

10 lines
362 B
Bash
Executable File

#!/bin/sh
# Runs as root just long enough to fix ownership of the mounted /app/data
# (Docker creates bind mounts and anonymous volumes as root, which the
# unprivileged `hark` user can't write to), then execs into that user for
# everything else. No application code ever runs as root.
set -e
mkdir -p /app/data
chown -R hark:hark /app/data
exec gosu hark "$@"