security(ocr): run OCR container as non-root user (CIS Docker §4.1) #611

Merged
marcel merged 12 commits from feat/issue-459-ocr-non-root into main 2026-05-17 19:06:47 +02:00
2 changed files with 10 additions and 1 deletions
Showing only changes of commit bead6f1811 - Show all commits

View File

@@ -24,7 +24,7 @@ log = logging.getLogger(__name__)
BLLA_MODEL_PATH = os.environ.get("BLLA_MODEL_PATH", "/app/models/blla.mlmodel")
# DOI for "General segmentation model for print and handwriting" — ketos 7 compatible.
BLLA_MODEL_DOI = "10.5281/zenodo.14602569"
HTRMOPO_DIR = os.environ.get("HTRMOPO_DIR", "/app/models/.htrmopo")
HTRMOPO_DIR = os.environ.get("HTRMOPO_DIR") or "/app/models/.htrmopo"
def _model_is_loadable(path: str) -> bool:

View File

@@ -29,6 +29,15 @@ def test_htrmopo_dir_default_is_fixed_path():
assert result == "/app/models/.htrmopo"
def test_htrmopo_dir_falls_back_to_default_when_set_to_empty_string():
"""HTRMOPO_DIR='' must not produce an empty path — get() returns '' for blank env vars."""
with patch.dict(os.environ, {"HTRMOPO_DIR": ""}):
importlib.reload(ensure_blla_model)
result = ensure_blla_model.HTRMOPO_DIR
importlib.reload(ensure_blla_model)
assert result != ""
# ─── Model already loadable ───────────────────────────────────────────────────