Skip to content

feat: distro-aware CVE source (grype) for AMIs — vet#32 slice 2 - #34

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/cve-grype-source
Jun 25, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/cve-grype-source

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Second slice of vet#32. Adds the distro-aware CVE source that fixes the false-clean gap the live both-source test found, and routes AMI targets to it. Still no AWS — fully fake-tested.

Why

The live test showed a naive OSV Linux query reports a distro AMI (Amazon Linux) as clean even when it isn't — OSV's Linux ecosystem is upstream-kernel-scoped, not ALAS-aware. grype is distro-advisory aware (it matches AL/RHEL/Debian packages against their feeds, incl. Amazon ALAS), so it's the right matcher for an AMI.

What

  • cve.GrypeSource — shells to grype sbom:<path> -o json over the SBOM document and parses severities. Fail-closed: missing SBOM path, absent grype binary, non-zero exit, or unparseable output all deny.
  • cve.Source now takes Target{Packages, SBOMPath} — the second implementer revealed one input shape doesn't fit both: OSV queries Packages; grype needs the full document (the lossy package list drops the distro metadata grype relies on). OSVSource reads Target.Packages; behaviour unchanged.
  • vet verify --cve-source auto|osv|grype (default auto): an ami-… target routes to grype, everything else to OSV; explicit value overrides. resolveCVESource unit-tested.
  • VerifyResult.CVECheckRan — the CLI no longer prints "✓ No critical/high CVEs found" when the check actually failed to run (e.g. grype absent); it shows only the fail-closed violation. (Caught in a CLI smoke test.)

Tests

  • internal/cve/grype_test.go: critical / high / clean / no-SBOM-path / missing-binary / scan-error / bad-JSON — all fail-closed paths covered.
  • cmd/vet/cve_source_test.go: the auto/explicit/unknown routing matrix.
  • Existing OSV + verify tests updated to the Target signature, green.
  • Smoke-tested the CLI: AMI verify auto-selects grype and fails closed with an install hint when grype is absent.

Next slice

The live AWS wiring — vet verify ami-… snapshots the AMI's EBS volume, syfts the mounted filesystem to produce the SBOM, then this grype source scans it. That slice creates real resources, so it'll follow the suite's injectable-interface + manual-live-wiring pattern.

Note: gofmt flags internal/sign/sign.go on the current toolchain — pre-existing drift, untouched here.

Second cve.Source. Fixes the false-clean gap the live both-source test found:
a naive OSV "Linux" query reports a distro AMI (Amazon Linux/RHEL) as clean
because OSV's Linux ecosystem is upstream-kernel-scoped, not ALAS-aware.

- cve.GrypeSource shells to grype over the SBOM *document* (grype is distro-
  advisory aware; it matches AL/RHEL/Debian packages against their feeds, e.g.
  Amazon ALAS). Fail-closed: missing SBOM path, absent binary, non-zero exit,
  or unparseable output all deny.
- cve.Source now takes Target{Packages, SBOMPath} — the second implementer
  showed one input shape doesn't fit both: OSV queries Packages, grype needs the
  full document (the lossy package list drops the distro metadata). OSVSource
  updated to read Target.Packages; behaviour unchanged.
- vet verify --cve-source auto|osv|grype (default auto): ami-… routes to grype,
  else OSV; explicit value overrides. resolveCVESource unit-tested.
- Added VerifyResult.CVECheckRan so the CLI stops printing "✓ No critical/high
  CVEs found" when the check actually failed to run (grype absent) — it now
  shows only the fail-closed policy violation.

Live AWS wiring (EBS-snapshot → syft) is the next slice. This slice is fully
fake-tested: internal/cve/grype_test.go (critical/high/clean/no-path/missing-
binary/scan-error/bad-json) + cmd/vet routing test. make-equivalent green.
@scttfrdmn
scttfrdmn merged commit cb59f88 into main Jun 25, 2026
2 checks passed
@scttfrdmn
scttfrdmn deleted the feat/cve-grype-source branch June 25, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant