From 3531b95de0b7383a5d202af110930845368df540 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 1 Nov 2026 08:36:36 +0100 Subject: [PATCH] fix(sys-ctl-hlth-runtime): give the scanners a writable temp dir and keep the workspace databases outside the checkout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #1326 CI failed in two places: - The vulnerability-db job stopped on `unable to create listing temp file: open /tmp/grype-db-listing…: permission denied`. The repository runs the engines as `docker run --user :`, and the Grype and Syft images set no User and WorkingDir /tmp, which only root may write. The dry-run mirror scan failed the same way: 156 Syft errors and the Grype database. Every engine now gets TMPDIR pointing at its writable /work mount. - Every workspace job died in `make system-purge`: `git clean -fdX` could not remove build/vulnerability-db, because the job bound that directory as its own mount inside the mounted checkout. On GitHub the workspace job now keeps its databases under ${RUNNER_TEMP}, outside the checkout; act keeps the shared host directory. Part of #1324 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/call-test-workspace.yml | 2 +- roles/sys-ctl-hlth-runtime/files/python/script.py | 2 +- .../test_deploy_vulnerability_databases.py | 14 ++++++++++---- .../sys-ctl-hlth-runtime/files/test_script.py | 13 +++++++++++++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/call-test-workspace.yml b/.github/workflows/call-test-workspace.yml index e575af4d75..e69f470d56 100644 --- a/.github/workflows/call-test-workspace.yml +++ b/.github/workflows/call-test-workspace.yml @@ -120,7 +120,7 @@ jobs: if [[ "${ACT:-}" == "true" ]]; then db_host_path="${INFINITO_VULNERABILITY_DB_HOST_PATH:?scripts/tests/deploy/act/workflow.sh passes the shared host directory}" else - db_host_path="${HOST_WORKDIR}/build/vulnerability-db" + db_host_path="${RUNNER_TEMP:?GitHub sets RUNNER_TEMP for every job}/vulnerability-db" fi mkdir -p "${db_host_path}" diff --git a/roles/sys-ctl-hlth-runtime/files/python/script.py b/roles/sys-ctl-hlth-runtime/files/python/script.py index db5c5fa161..c0e261f881 100755 --- a/roles/sys-ctl-hlth-runtime/files/python/script.py +++ b/roles/sys-ctl-hlth-runtime/files/python/script.py @@ -848,7 +848,7 @@ def run_argv( mounts += ["-v", f"/:{HOST_ROOT}:ro"] if target is not None and target.kind == "container": mounts += ["-v", f"{DOCKER_SOCKET}:{DOCKER_SOCKET}:ro"] - environment = {**ENGINE_ENV[engine], **extra_env} + environment = {"TMPDIR": WORK, **ENGINE_ENV[engine], **extra_env} return (*layout.runtime, "--rm", *mounts, *_env(environment), image, *args) diff --git a/tests/lint/repository/test_deploy_vulnerability_databases.py b/tests/lint/repository/test_deploy_vulnerability_databases.py index 62bfe0d725..49b9900199 100644 --- a/tests/lint/repository/test_deploy_vulnerability_databases.py +++ b/tests/lint/repository/test_deploy_vulnerability_databases.py @@ -24,7 +24,7 @@ def bash(script: str, env: dict[str, str], cwd: str) -> subprocess.CompletedProc clean = { k: v for k, v in os.environ.items() - if k not in ("BASH_ENV", "ACT", DB_HOST_PATH) + if k not in ("BASH_ENV", "ACT", "RUNNER_TEMP", DB_HOST_PATH) } return subprocess.run( ["bash", "-c", script], @@ -106,9 +106,15 @@ class TestWorkspaceJob(unittest.TestCase): done, path = self._db_host_path({"ACT": "true", DB_HOST_PATH: "{tmp}/shared"}) self.assertEqual((done.returncode, path), (0, "{tmp}/shared")) - def test_a_github_run_reads_the_databases_of_its_checkout(self) -> None: - done, path = self._db_host_path({}) - self.assertEqual((done.returncode, path), (0, "{tmp}/build/vulnerability-db")) + def test_a_github_run_keeps_the_databases_outside_its_checkout(self) -> None: + done, path = self._db_host_path({"RUNNER_TEMP": "{tmp}/runner-temp"}) + self.assertEqual( + (done.returncode, path), (0, "{tmp}/runner-temp/vulnerability-db") + ) + + def test_a_github_run_without_runner_temp_fails(self) -> None: + done, _path = self._db_host_path({}) + self.assertNotEqual(done.returncode, 0) def test_an_act_run_without_the_wrapper_path_fails(self) -> None: done, _path = self._db_host_path({"ACT": "true"}) diff --git a/tests/unit/python/roles/sys-ctl-hlth-runtime/files/test_script.py b/tests/unit/python/roles/sys-ctl-hlth-runtime/files/test_script.py index 7d744dbef2..34e5606952 100644 --- a/tests/unit/python/roles/sys-ctl-hlth-runtime/files/test_script.py +++ b/tests/unit/python/roles/sys-ctl-hlth-runtime/files/test_script.py @@ -1049,6 +1049,19 @@ class TestCommands(TestCase): step = SCRIPT.trivy_step(self.layout, "trivy:1", self.host, _config()) self.assertIn("/:/host:ro", step.argv) + def test_every_engine_writes_its_temp_files_to_the_work_mount(self): + for engine in ("trivy", "grype", "osv", "syft"): + with self.subTest(engine=engine): + argv = SCRIPT.run_argv( + self.layout, engine, f"{engine}:1", [], target=None, extra_env={} + ) + self.assertIn("TMPDIR=/work", argv) + self.assertIn("/var/cache/v/run:/work", argv) + + def test_the_grype_database_update_writes_its_listing_to_the_work_mount(self): + (step,) = SCRIPT.db_steps("grype", self.layout, "grype:1") + self.assertIn("TMPDIR=/work", step.argv) + def test_a_container_scan_reads_the_docker_socket_read_only(self): step = SCRIPT.trivy_step(self.layout, "trivy:1", self.container, _config()) self.assertIn("/var/run/docker.sock:/var/run/docker.sock:ro", step.argv)