From 5ad9e7781d4f1668c6d5bf23cf8c7c94b8b38883 Mon Sep 17 00:00:00 2001 From: Marius Ciepluch <11855163+norandom@users.noreply.github.com> Date: Thu, 26 Nov 2026 17:44:46 +0100 Subject: [PATCH] fix(contributor-scan): compose refuses a target that does not exist (item 5a) A mistyped TARGET read as a clean scan. The `/target` mount was in the short syntax, so Docker created a path that does not exist as an empty directory owned by 0:0, and the scan ended with exit 0 and no findings (the eighth session, 2026-11-26: file_targets=0, findings=0, exit=0). The mount is now in the long syntax with `create_host_path: false`, as `/reports` is since 9d53c32. The source is still `${TARGET:-.}` and the mount is still read-only. A path that does not exist is refused by the daemon before the container starts ("bind source path does not exist"), and nothing is created. Measured on 2026-11-26 with the new file alone in a scratch directory, Docker 29.8.1 and Compose v5.5.1, image openultrasast:dev (3f959b31f2f2), both API keys unset: a TARGET that does not exist gives exit 1 in one second and no directory; the documented command with `--mode quick` on a copy of libpng's contrib/examples gives file_targets=4, findings=4, exit 0; `touch /target/x` ends with "Read-only file system", exit 1; with TARGET unset the default source mounts (exit 0). Tests: the new `tests/test_task_images.py::test_compose_refuses_a_target_that_does_not_exist` fails on the short syntax (1 failed, 22 deselected) and passes after; with `tests/test_search_image.py`, 24 passed. 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; its remarks on two wordings are applied. Left as they are: `docs/detection-techniques.md` cites `docker-compose.yml` by line numbers that were already off before this change; that is the next docs commit of item 5a. An empty directory that exists still scans clean, natively and in the image; the menu did not choose to fail that. --- docker-compose.yml | 9 ++++++++- tests/test_task_images.py | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e5381ae5..d593c668 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,14 @@ services: TASK_BASE_DIGEST: ${TASK_BASE_DIGEST:-sha256:0f374138fcb49fef41609d323cc80b6c2324b1e798d3a2aee5c8038b8c7ac3aa} image: openultrasast:${OUSAST_VERSION:-dev} volumes: - - ${TARGET:-.}:/target:ro # the repository under analysis, read-only + # The repository under analysis, read-only. In the long syntax, like /reports below: in the short syntax Docker + # creates a TARGET that does not exist, as an empty directory, and an empty target scans clean. + - type: bind + source: ${TARGET:-.} + target: /target + read_only: true + bind: + create_host_path: false # 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 diff --git a/tests/test_task_images.py b/tests/test_task_images.py index 539c47dc..ccc48921 100644 --- a/tests/test_task_images.py +++ b/tests/test_task_images.py @@ -67,6 +67,16 @@ def test_compose_leaves_the_reports_directory_to_the_user(): assert mounts["/reports"].get("bind", {}).get("create_host_path") is False +def test_compose_refuses_a_target_that_does_not_exist(): + """Docker creates a missing bind source as an empty directory, and an empty target scans clean: a typo reads as clean.""" + service = yaml.safe_load(read("docker-compose.yml"))["services"]["ousast"] + mounts = {v["target"]: v for v in service["volumes"] if isinstance(v, dict)} + assert "/target" in mounts, "the /target volume is short syntax, so Docker creates a missing source as an empty directory" + assert mounts["/target"]["source"] == "${TARGET:-.}" + assert mounts["/target"]["read_only"] is True + assert mounts["/target"].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