feat(ci): rotate the vulnerability engine per row and hand its databases over

Each CI deploy row now draws one vulnerability engine (trivy, grype or osv)
as a fifth rotation axis, shown in the job name next to distro and
filesystem (🔬 axis, 🔺 trivy, 🍇 grype, 🐙 osv). The deploy-time scan of
sys-ctl-hlth-runtime runs that engine behind Syft and the Grype runtime pass.

- A vulnerability-db job keeps one Actions cache per database and day and
  downloads only the missing ones. Every deploy job restores Grype plus its
  drawn engine, fails on a cache miss and never downloads a database itself.
- Local stacks share one host directory, INFINITO_VULNERABILITY_DB_HOST_PATH,
  mounted read-only at INFINITO_VULNERABILITY_DB_DIR in compose.yml and in
  every swarm node. A local deploy without a pinned engine draws one and
  refreshes only the databases it reads, at most once a day, under a lock.
- A pinned engine whose database is missing stops the deploy before it
  starts.

Part of #1324

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-11-01 02:44:58 +01:00
1 parent 6b36c8579a
commit 043e001669
25 files changed
+724 -10

No files matched your search

@@ -3,11 +3,15 @@ from __future__ import annotations
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
from unittest.mock import MagicMock, patch
from cli.administration.deploy.development.compose import Compose
from cli.administration.deploy.development.compose import (
Compose,
prepare_vulnerability_db,
)
class TestComposeUpRetries(unittest.TestCase):
@@ -209,6 +213,7 @@ class TestComposeUpRetries(unittest.TestCase):
def test_up_builds_when_build_flag_is_enabled(self) -> None:
compose = self._compose()
compose._render_coredns_corefile = MagicMock()
compose._prepare_vulnerability_db = MagicMock()
compose._compose_up_with_retries = MagicMock()
compose.wait_for_healthy = MagicMock()
@@ -237,6 +242,7 @@ class TestComposeUpRetries(unittest.TestCase):
def test_up_skips_build_when_build_flag_is_disabled(self) -> None:
compose = self._compose()
compose._render_coredns_corefile = MagicMock()
compose._prepare_vulnerability_db = MagicMock()
compose._compose_up_with_retries = MagicMock()
compose.wait_for_healthy = MagicMock()
@@ -274,6 +280,7 @@ class TestComposeUpRetries(unittest.TestCase):
def test_up_includes_cache_services_when_local(self) -> None:
compose = self._compose()
compose._render_coredns_corefile = MagicMock()
compose._prepare_vulnerability_db = MagicMock()
compose._compose_up_with_retries = MagicMock()
compose.wait_for_healthy = MagicMock()
compose._bootstrap_package_cache = MagicMock()
@@ -301,5 +308,29 @@ class TestComposeUpRetries(unittest.TestCase):
compose._install_package_frontend_ca_in_runner.assert_called_once()
class TestPrepareVulnerabilityDb(unittest.TestCase):
def test_the_shared_directory_is_created_as_the_calling_user(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
path = Path(tmp) / "cache" / "vulnerability-db"
prepare_vulnerability_db(path)
self.assertTrue(path.is_dir())
def test_a_directory_the_user_may_not_create_is_left_to_docker(self) -> None:
path = MagicMock()
path.mkdir.side_effect = PermissionError("read-only")
prepare_vulnerability_db(path)
path.mkdir.assert_called_once_with(parents=True, exist_ok=True)
def test_up_prepares_the_configured_directory(self) -> None:
compose = Compose(repo_root=Path("/tmp/infinito-nexus"), distro="arch")
with patch(
"cli.administration.deploy.development.compose.prepare_vulnerability_db"
) as prepare:
compose._prepare_vulnerability_db(
{"INFINITO_VULNERABILITY_DB_HOST_PATH": "/srv/db"}
)
prepare.assert_called_once_with(Path("/srv/db"))
if __name__ == "__main__": # pragma: no cover
unittest.main()