mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-27 21:38:01 +00:00
The runtime check judged PHP by its upstream version and failed every container on an end-of-life line. Distribution builds backport fixes without raising that number, so main run 41154895895 failed Checkmk#0 on `PHP 8.1.2-1ubuntu2.28 runs the end-of-life line 8.1`, a build Ubuntu lists as fixed for CVE-2026-109618 and CVE-2026-109619. - The role now runs Trivy, Grype and OSV-Scanner, with a Syft SBOM per target, against the host and the images of the running containers, in bounded parallel lanes. Targets, engines and the failing severities are lists in meta/services.yml; the default is every target and engine at CRITICAL and HIGH with a fix available. - Grype always scans the binary-classified packages of the SBOM, so a PHP built from source in an official php image (8.4.26) still fails on the CVEs fixed in 8.4.27, which Trivy and OSV do not see. - OSV reads an SBOM copy whose distro purls carry the source package name. - A CVE is suppressed only in the role owning the image, under services.<service>.security.suppressions with id, until and a `# nocheck: cve <reason>` marker; a lint rejects bare, malformed and expired entries. - The deploy-time run fails on its first finding: sys-service gains system_service_run_once and sys-service-terminator skips the retries only for those units. The timer runs daily at 00:00 UTC. - The PHP version floors are removed; the php_hardening check stays. - make test-security replaces make security-runtimes: Syft builds an SBOM of every pinned image straight from the GHCR mirror, cached by digest, and the three engines scan it with the role's threshold and suppressions. Part of #1324 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
2.3 KiB
Python
85 lines
2.3 KiB
Python
"""Which vulnerability engines a development or CI deploy runs.
|
|
|
|
Every such deploy runs Syft and one drawn engine, plus Grype over the
|
|
source-built runtimes. A CI deploy job pins the engine its matrix row drew in
|
|
``INFINITO_VULNERABILITY_ENGINE`` and provides the databases; a local deploy
|
|
draws one at random. Only production hosts run every engine of
|
|
``sys-ctl-hlth-runtime``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
import random
|
|
|
|
ROLE = "sys-ctl-hlth-runtime"
|
|
SCANNERS = ("trivy", "grype", "osv")
|
|
SBOM_BUILDER = "syft"
|
|
RUNTIME_ENGINE = "grype"
|
|
ENGINE_ENV = "INFINITO_VULNERABILITY_ENGINE"
|
|
|
|
|
|
def pinned_engine() -> str:
|
|
"""Return the engine the environment pins, ``""`` when none is pinned."""
|
|
return os.environ.get(ENGINE_ENV, "").strip()
|
|
|
|
|
|
def draw_engine(rng: random.Random) -> str:
|
|
"""Draw the engine of a local deploy."""
|
|
return rng.choice(SCANNERS)
|
|
|
|
|
|
def _known(engine: str) -> str:
|
|
if engine not in SCANNERS:
|
|
raise ValueError(
|
|
f"unknown vulnerability engine {engine!r}; expected {', '.join(SCANNERS)}"
|
|
)
|
|
return engine
|
|
|
|
|
|
def engines_for(engine: str) -> list[str]:
|
|
"""Return the engine list that runs *engine* behind a Syft SBOM.
|
|
|
|
Raises:
|
|
ValueError: *engine* is not one of :data:`SCANNERS`.
|
|
"""
|
|
return [SBOM_BUILDER, _known(engine)]
|
|
|
|
|
|
def databases_for(engine: str) -> list[str]:
|
|
"""Return the databases a deploy pinned to *engine* reads.
|
|
|
|
Grype also scans the source-built runtimes of every SBOM, so its
|
|
database is always among them.
|
|
|
|
Raises:
|
|
ValueError: *engine* is not one of :data:`SCANNERS`.
|
|
"""
|
|
return [name for name in SCANNERS if name in {_known(engine), RUNTIME_ENGINE}]
|
|
|
|
|
|
def deploy_overrides(engine: str, database_dir: str) -> dict:
|
|
"""Return the ``applications`` override that pins the scan to *engine*.
|
|
|
|
Args:
|
|
engine: the engine of the deploy.
|
|
database_dir: where the deploy target reads the databases.
|
|
|
|
Returns:
|
|
The override of ``sys-ctl-hlth-runtime``'s ``runtime`` service.
|
|
"""
|
|
return {
|
|
ROLE: {
|
|
"services": {
|
|
"runtime": {
|
|
"engines": engines_for(engine),
|
|
"database_dir": database_dir,
|
|
"db_update": False,
|
|
}
|
|
}
|
|
}
|
|
}
|