Repository navigation
feat: distro-aware CVE source (grype) for AMIs — vet#32 slice 2 - #34
Merged
Merged
Conversation
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Linuxquery reports a distro AMI (Amazon Linux) as clean even when it isn't — OSV'sLinuxecosystem 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 togrype sbom:<path> -o jsonover the SBOM document and parses severities. Fail-closed: missing SBOM path, absentgrypebinary, non-zero exit, or unparseable output all deny.cve.Sourcenow takesTarget{Packages, SBOMPath}— the second implementer revealed one input shape doesn't fit both: OSV queriesPackages; grype needs the full document (the lossy package list drops the distro metadata grype relies on).OSVSourcereadsTarget.Packages; behaviour unchanged.vet verify --cve-source auto|osv|grype(defaultauto): anami-…target routes to grype, everything else to OSV; explicit value overrides.resolveCVESourceunit-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.Targetsignature, green.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.