feat: integrate RapidFort advisory matching for their curated images#3327
Open
vaibhav-rf wants to merge 4 commits intoanchore:mainfrom
Open
feat: integrate RapidFort advisory matching for their curated images#3327vaibhav-rf wants to merge 4 commits intoanchore:mainfrom
vaibhav-rf wants to merge 4 commits intoanchore:mainfrom
Conversation
- Add ApplySelectionPolicy to decide matchers from scan context - For RF-curated images: replace dpkg/apk with rapidfort matcher - For non-RF sources: keep default matchers unchanged - Remove RapidFort imports from root.go; pass pkgContext into getMatchers - Reuse a single rapidfort matcher instance for both dpkg and apk - Add tests for nil context, non-RF image, and RF image
- Register rapidfort-redhat distro and wire RapidFort matcher - Parse OS FixedIn Identifier; v6 transform: release-identifier refs with vendor advisory URL when present - Add rapidfort-redhat-9 transform fixture and matcher unit tests
Binary lookups were incorrectly labeled ExactIndirectMatch; pass match.Type explicitly so binary path reports ExactDirectMatch. Add TestIsRapidFortImage (nil, non-image, case-insensitive key/value, non-RF label) and Alpine case in TestRapidfortDistroVersion. Signed-off-by: Vaibhav Thatai <vaibhav@rapidfort.com>
Contributor
|
Hi @vaibhav-rf is there a publicly pullable test image I can try this out on? |
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.
Summary
Adds a dedicated RapidFort matcher that activates when the scanned image carries
a
maintainer=RapidFort*Docker label. RapidFort advisories are stored underrapidfort-{os}:{version}namespaces (e.g.rapidfort-ubuntu:20.04) — fullyisolated from standard distro scans so non-RF images are never affected.
Supported base distros: Ubuntu (dpkg), Alpine (apk), Red Hat (rpm).
Changes
New:
grype/matcher/rapidfort/matcher.golabel.goIsRapidFortImage— detects RF-curated images via maintainer labelmatcher_test.golabel_test.goIsRapidFortImageedge cases: nil source, non-image, case-insensitive key/valueModified: existing packages
grype/matcher/matchers.goApplySelectionPolicyreplaces dpkg/apk/rpm matchers withRapidFortMatcherfor RF images; Java/stock matchers are preservedgrype/matcher/matchers_test.gogrype/match/matcher_type.goRapidFortMatchertype (excluded fromAllMatcherTypes— it is a conditional override)grype/distro/type.goRapidFortUbuntu,RapidFortAlpine,RapidFortRedHatdistro types withIDMappingentriesgrype/db/internal/provider/unmarshal/os_vulnerability.goIdentifierfield toOSFixedInfor per-release RPM advisory routinggrype/db/v6/build/transformers/os/transform.gogetPackageTypemaps RF distros;getFixemitsrelease-identifieradvisory references fromIdentifierfieldTest fixtures
test-fixtures/rapidfort-ubuntu-20.04.jsontest-fixtures/rapidfort-redhat-9.jsonDesign notes
Namespace isolation — The RF matcher queries
rapidfort-{os}:{version}namespacesthat vunnel emits exclusively for RF advisories. Standard distro matchers (dpkg/apk/rpm)
never see these namespaces, so there is zero cross-contamination.
RPM release-identifier routing — Red Hat advisories carry per-release
Identifierfields (e.g.
el9,fc36). The matcher derives the installed release from the packageversion suffix (
.el9,.fc41,.rf) and filters to advisories with a matchingrelease-identifier:*advisory reference. Unknown release identifiers fall back tomatching
el*advisories.Matcher activation —
ApplySelectionPolicyinmatchers.gochecksIsRapidFortImageand, when true, replaces dpkg/apk/rpm matchers with a singleRapidFortMatcher. This avoids double-reporting and keeps RF advisory logicself-contained.
Test plan
go test ./grype/matcher/rapidfort/...— all matcher and label tests passgo test ./grype/matcher/...— selection policy tests passgo test ./grype/db/v6/build/transformers/os/...— transform tests pass for both RF fixturesgo test ./grype/distro/...— distro type registration passesrapidfort-matcherappears in match detailsrapidfort-matcheris absent from match details