diff --git a/docker-compose.yml b/docker-compose.yml index 0d193576..47ae50c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,9 @@ services: context: . args: JOERN_VERSION: ${JOERN_VERSION:-v4.0.625} + # The base is pinned by digest, the same pin CI builds from (plane/task-base.digest): a bare tag can move. + TASK_BASE_TAG: ${TASK_BASE_TAG:-base-b696c08} + TASK_BASE_DIGEST: ${TASK_BASE_DIGEST:-sha256:0f374138fcb49fef41609d323cc80b6c2324b1e798d3a2aee5c8038b8c7ac3aa} image: openultrasast:${OUSAST_VERSION:-dev} volumes: - ${TARGET:-.}:/target:ro # the repository under analysis, read-only @@ -26,6 +29,8 @@ services: # goes unasked. Passed through rather than baked in, so no key is ever in an image layer. DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY:-} OPENROUTER_API_KEY: ${OPENROUTER_API_KEY:-} + # A scan's run directory would otherwise land in the container's home and be lost when the container exits. + OPENULTRASAST_RUNS_DIR: /reports/runs TMPDIR: /work # A CPG build is memory-hungry, and two Joern JVMs at once is what triggered an out-of-memory kill on a # 7.7 GB machine during this project's measurements. diff --git a/tests/test_task_images.py b/tests/test_task_images.py index 5f1cb2f6..714bc138 100644 --- a/tests/test_task_images.py +++ b/tests/test_task_images.py @@ -47,6 +47,17 @@ def test_digest_required_and_code_last(name, variant): assert not any("venv /venv" in line for line in lines) +def test_compose_builds_from_the_pinned_base(): + """`docker compose build` takes no arguments, so the base it resolves is whatever these defaults say.""" + ref = json.loads(read("plane/task-base.digest"))["base"] + tag, digest = re.fullmatch(r"ghcr.io/norandom/ousast-task-base:(base-[a-z0-9-]+)@(sha256:[0-9a-f]{64})", ref).groups() + service = yaml.load(read("docker-compose.yml"), Loader=yaml.BaseLoader)["services"]["ousast"] + for name, default in (("TASK_BASE_TAG", tag), ("TASK_BASE_DIGEST", digest)): + default_ref = f"${{{name}:-{default}}}" + assert service["build"]["args"].get(name) == default_ref, f"{name} does not default to {default} (plane/task-base.digest)" + assert service["environment"]["OPENULTRASAST_RUNS_DIR"].startswith("/reports/") + + 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