From 9d53c320a589c3e47746591a036ff6532abd6318 Mon Sep 17 00:00:00 2001 From: Marius Ciepluch <11855163+norandom@users.noreply.github.com> Date: Thu, 26 Nov 2026 13:25:20 +0100 Subject: [PATCH] fix(contributor-scan): compose leaves the reports directory to the user (3.2, part 2) On a fresh checkout the documented command, `TARGET=/path/to/repo docker compose run --rm ousast scan /target`, died before scanning. The `/reports` mount was in the short syntax, so Docker created a missing `./reports` as root, and the image runs as uid 1000. On 2026-11-26, from a copy of the compose file at 8daca3d, Docker created the directory owned by 0:0 and the scan stopped after one second with exit 1 and `PermissionError: [Errno 13] Permission denied: '/reports/runs'`. The mount is now in the long syntax with `create_host_path: false`, so nothing is created. Without the directory the daemon refuses the container ("bind source path does not exist") and leaves nothing behind. After `mkdir -p reports` the same command completes with exit 0 and writes the run directory owned by the user (quick mode on four C files: file_targets=4, findings=4). The documented command in the compose header, in `README.md` and in `ops/README.md` creates the directory first. Both shell wrappers already did. Tests: the new `tests/test_task_images.py::test_compose_leaves_the_reports_directory_to_the_user` fails on the short syntax (1 failed, 16 deselected) and passes after; with `tests/test_search_image.py`, 18 passed. The eight test files that read `README.md` pass (183 tests). ruff format, ruff check, mypy, the three gates and compileall pass, and the gates print what they printed before the change. An independent reviewer approved the change in one round. Left as it was, an open item for the maintainer: the `/target` mount is still in the short syntax, so a `TARGET` that does not exist is created as an empty root-owned directory and the scan ends with exit 0 and no findings (measured on 2026-11-26). --- README.md | 3 ++- docker-compose.yml | 9 ++++++++- ops/README.md | 4 ++++ tests/test_task_images.py | 9 +++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a1b5cbe..b4267a30 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,8 @@ ousast-with-judge scan . --mode standard # network on, the model is a ``` `docker compose build` and `TARGET=/path/to/repo docker compose run --rm ousast scan /target` do -the same without the wrapper. +the same without the wrapper. Create `reports/` first (`mkdir -p reports`): compose does not create it, +because a directory Docker creates is root-owned and the image runs as an ordinary user. Findings land there. `deep` requests the REGRESS stage, which was retired on 2026-10-13: the scan records a `regress_retired` degradation and otherwise equals `standard`. Execution proof now comes from the search-with-proof arm. diff --git a/docker-compose.yml b/docker-compose.yml index 47ae50c7..e5381ae5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ # OpenUltraSAST as a contributor runs it: nothing installed on the host but Docker. # # docker compose build +# mkdir -p reports # TARGET=/path/to/repo docker compose run --rm ousast scan /target # # The target is mounted READ-ONLY. A tool that reads your source to tell you about it has no business being @@ -19,7 +20,13 @@ services: image: openultrasast:${OUSAST_VERSION:-dev} volumes: - ${TARGET:-.}:/target:ro # the repository under analysis, read-only - - ${OUSAST_REPORTS:-./reports}:/reports # where findings land, the one writable mount + # Where findings land, the one writable mount. Long syntax on purpose: the short syntax lets Docker create a + # missing source, as root, and the image runs as uid 1000. Create the directory first; the wrapper does. + - type: bind + source: ${OUSAST_REPORTS:-./reports} + target: /reports + bind: + create_host_path: false working_dir: /work tmpfs: # CPG construction is scratch-heavy and none of it should outlive the run or touch the host. diff --git a/ops/README.md b/ops/README.md index b9559b2b..af561053 100644 --- a/ops/README.md +++ b/ops/README.md @@ -42,6 +42,7 @@ translation: ```bash docker compose build +mkdir -p reports TARGET=/path/to/repo docker compose run --rm ousast scan /target ``` @@ -51,6 +52,9 @@ entails, and its residual and suspicion questions go unasked. `network_mode` def (`OUSAST_NETWORK=bridge`, which `ousast-with-judge` does) only when the model layer should reach the model endpoint. Compose passes `DEEPSEEK_API_KEY` and `OPENROUTER_API_KEY` through from the environment. +Findings land in `reports/`, which must already exist: the image runs as an ordinary user, and a directory +Docker has to create is root-owned. + **pyinfra (for a persistent host install).** Same engine, same pin, same checksum, but on the machine: ```bash diff --git a/tests/test_task_images.py b/tests/test_task_images.py index eb7191a2..91df2268 100644 --- a/tests/test_task_images.py +++ b/tests/test_task_images.py @@ -58,6 +58,15 @@ def test_compose_builds_from_the_pinned_base(): assert service["environment"]["OPENULTRASAST_RUNS_DIR"].startswith("/reports/") +def test_compose_leaves_the_reports_directory_to_the_user(): + """Docker creates a missing bind source as root, and the image runs as uid 1000: the run could not write.""" + service = yaml.safe_load(read("docker-compose.yml"))["services"]["ousast"] + mounts = {v["target"]: v for v in service["volumes"] if isinstance(v, dict)} + assert "/reports" in mounts, "the /reports volume is short syntax, so Docker creates a missing source as root" + assert mounts["/reports"]["source"] == "${OUSAST_REPORTS:-./reports}" + assert mounts["/reports"].get("bind", {}).get("create_host_path") is False + + def test_shared_ancestry_and_replay_exact_engine(): base = read("plane/Dockerfile.base") assert "FROM ghcr.io/norandom/ax-task-runner:v0.3.1 AS base" in base