fix(ci): hand the vulnerability databases to the deploy jobs as run artifacts

Deploy jobs restored the day-keyed vulnerability-db caches with fail-on-cache-miss, but the repository cache was at 11.37 GB against the 10 GB limit: every PR run saves its own trivy, grype and OSV entries (about 2.9 GB a day), so GitHub evicted the least recently used vulnerability-db-osv-2026-11-12 of main while run 43288523728 still ran. Its last OSV hit was at 05:28, and 11 jobs (Matrix#1, NFS Server#0, Nextcloud#13 and 8 more) failed between 12:26 and 18:26 on the missing key, while grype, which every job restores, stayed.

The vulnerability-db job now uploads each engine database as the run artifact vulnerability-db-<chunk index>-<engine> (retention 3 days, overwrite for a full re-run) and the deploy jobs download it, so no job of a run depends on the evictable cache; the job keeps the day cache only to avoid a second download on the same day. The OSV cache key also carries the hash of roles/sys-ctl-hlth-runtime/meta/services.yml, so a change of the ecosystem list misses the stale database, and provided_databases checks every file of a pinned engine (each OSV ecosystem zip) instead of a non-empty directory.

Tests: TestDatabaseHandover in tests/lint/repository/test_deploy_vulnerability_databases.py (13 passed) and test_an_osv_database_without_one_ecosystem_fails in test_deploy.py (7 passed); negative control on main: 4 lint tests and the ecosystem test fail. ruff check and format clean.

Residuals: not yet exercised in a CI run; each chunk uploads about 2.9 GB of artifacts.

🎯 Fix: 90 %
💥 Break: 4 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-11-13 21:44:59 +00:00
1 parent 083096bc67
commit d76ad966ea
4 files changed
+119 -22

No files matched your search

@@ -3,12 +3,15 @@ from __future__ import annotations
import contextlib
import io
import random
import re
import tempfile
from pathlib import Path
from unittest import TestCase, main, mock
from utils.security import deploy
from utils.security.database import database_files
from utils.security.engine import ENGINE_ENV, ROLE, databases_for
from utils.security.pipeline import pipeline
class TestInventoryOverrides(TestCase):
@@ -66,19 +69,31 @@ class TestInventoryOverrides(TestCase):
with self.assertRaisesRegex(SystemExit, "no network"):
self._overrides("", errors=["grype database: no network"])
def _provide(self, name, skip=0):
files = database_files(pipeline(), self.root, name)
for path in files[: len(files) - skip]:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("x", encoding="utf-8")
return files
def test_a_pinned_engine_never_downloads(self):
for name in ("trivy", "grype"):
(self.root / name).mkdir()
(self.root / name / "db").write_text("x", encoding="utf-8")
self._provide(name)
self.assertEqual(
self._runtime(self._overrides("trivy"))["engines"], ["syft", "trivy"]
)
self.assertEqual(self.refreshed, [])
def test_a_pinned_engine_without_its_databases_fails(self):
(self.root / "grype").mkdir()
(self.root / "grype" / "db").write_text("x", encoding="utf-8")
with self.assertRaisesRegex(SystemExit, "no osv database"):
self._provide("grype")
first = database_files(pipeline(), self.root, "osv")[0]
with self.assertRaisesRegex(SystemExit, re.escape(str(first))):
self._overrides("osv")
def test_an_osv_database_without_one_ecosystem_fails(self):
self._provide("grype")
missing = self._provide("osv", skip=1)[-1]
with self.assertRaisesRegex(SystemExit, re.escape(str(missing))):
self._overrides("osv")