fix(sbom): version-filter product_status on the advisory and severity paths (TC-5641) - #2600
fix(sbom): version-filter product_status on the advisory and severity paths (TC-5641)#2600mrrajan wants to merge 1 commit into
Conversation
… paths product_advisory_info_sql and batch_severity_counts_sql matched product_status by package name only, reporting RPMs already past the fix as affected. Add version_matches via product_version_range -> version_range, mirroring the sibling purl_status/cpe_status CTEs. Implements TC-5641 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Assisted-by: Claude Code
Reviewer's GuideThe PR fixes inconsistent SBOM advisory reporting by applying Red Hat product_status version-range matching to both advisory details and batch severity counts, then validates that past-fix packages are excluded, in-range packages remain affected, and both response paths stay count-consistent. Sequence diagram for version-filtered SBOM advisory reportingsequenceDiagram
participant Client
participant AdvisoryAPI
participant SQL
participant Database
Client->>AdvisoryAPI: GET /sbom/{id}/advisory
AdvisoryAPI->>SQL: product_advisory_info_sql()
SQL->>Database: Join product_status to product_version_range and version_range
Database-->>SQL: version_matches(sp.version, vr.*)
SQL-->>AdvisoryAPI: In-range product_status matches
AdvisoryAPI-->>Client: Advisory details excluding past-fix RPMs
Sequence diagram for count-consistent SBOM severity reportingsequenceDiagram
participant Client
participant SeverityAPI
participant SQL
participant Database
Client->>SeverityAPI: Request severity summary
SeverityAPI->>SQL: batch_severity_counts_sql()
SQL->>Database: Match product_status by package and version
Database-->>SQL: version_matches(sp.version, vr.*)
SQL-->>SeverityAPI: In-range affected packages only
SeverityAPI-->>Client: Severity counts matching advisory details
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. An incorrect version-range match could suppress a real vulnerability finding or report a package as affected when it is not, causing downstream users to make security decisions from incorrect SBOM results. Reverting restores the prior matching behavior, but any missed or acted-on advisory before the revert is not undone.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| #[test_context(TrustifyContext)] | ||
| #[test(tokio::test)] | ||
| #[instrument] | ||
| async fn sbom_details_product_status_version_filtering( |
There was a problem hiding this comment.
This looks like it should be a parametrized test.
|
/scale-tests |
|
/perf-test |
1 similar comment
|
/perf-test |
|
🛠️ Perf test has started! Follow the progress here: Workflow Run |
Perf Test Report (Locust)
📄 Full Report (Go to "Artifacts" and download report) |
|
The CI failure reveals the real concern of this fix. TC-5751 producing false-negatives. The root cause is a semantic mismatch in the version filter I added. |
What this fixes
GET /sbom/{id}/advisoryand the severity summary matched Red Hatproduct_statusrows by package name only — reporting RPMs already past the fix as affected.purl_status/cpe_statusand the/purl+/analyzeendpoints already version-match; these two SBOM paths were missed.Change
In
modules/fundamental/src/sbom/model/raw_sql.rs, addversion_matchesto theproduct_statusCTEs inproduct_advisory_info_sqlandbatch_severity_counts_sql— joiningproduct_status → product_version_range → version_range, mirroring the siblingpurl_version_matchesCTE (and addingvp.versiontosbom_purls).product_version_range_idis NOT NULL and bareknown_affectedcreates noproduct_statusrow, so the inner join drops nothing that would otherwise match.Tests
New
sbom_details_product_status_version_filtering(tests/sbom/details.rs, fixtures inetc/test-data/cyclonedx/TC-5751/): a past-fix RPM is filtered, an in-range RPM is kept, and detail count == severity-summary count.sbom::detailssuite green;cargo xtask precommitclean.Implements TC-5641
🤖 Generated with Claude Code
Summary by Sourcery
Apply version-range filtering to product-status matches in SBOM advisory details and severity summaries.
Bug Fixes:
Tests: