-
Notifications
You must be signed in to change notification settings - Fork 35
Tc 3278 fix latest filtering #2185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideRefactors how latest SBOM graphs are resolved and ranked by moving the ranking logic from a SQL window function into Rust, adding recursive ancestor resolution, and extending tests/fixtures for latest filter behavior, while also tightening async trait bounds and wiring in new test data for TC-3278. Sequence diagram for the new latest SBOM graph retrieval flowsequenceDiagram
actor Client
participant AnalysisService
participant InnerService
participant Database
Client->>AnalysisService: retrieve_latest(query, options)
AnalysisService->>InnerService: load_latest_graphs_query(connection, GraphQuery)
rect rgb(230,230,250)
InnerService->>Database: query sbom_node to find matched_sbom_ids
Database-->>InnerService: matched_sbom_ids (sbom_id, node_id, name, published)
loop for each matched_sbom
InnerService->>Database: query package_relates_to_package for top_package_of_sbom
Database-->>InnerService: top_package_of_sbom
InnerService->>InnerService: resolve_all_ancestors(sbom_id, node_ref, visited)
activate InnerService
loop recursive ancestor resolution
InnerService->>Database: resolve_rh_external_sbom_ancestors
Database-->>InnerService: direct_ancestors
alt new_ancestor_not_visited
InnerService->>Database: query package_relates_to_package for ancestor packages
Database-->>InnerService: ancestor packages
InnerService->>InnerService: recursive resolve_all_ancestors(...)
else cycle_detected
InnerService-->>InnerService: stop recursion
end
end
deactivate InnerService
InnerService->>Database: query sbom_package_cpe_ref for CPEs of top_ancestor_sbom
Database-->>InnerService: cpe_list
InnerService->>InnerService: build RankedSbom entries
end
InnerService->>InnerService: apply_rank(matched_sboms)
InnerService-->>InnerService: ranked_sboms with rank
InnerService->>InnerService: filter rank == 1 and dedup to latest_ids
end
InnerService->>Database: load_graphs(connection, latest_ids)
Database-->>InnerService: graphs
InnerService-->>AnalysisService: Vec<(Uuid, Arc<PackageGraph>)>
AnalysisService-->>Client: response with latest graphs
Class diagram for InnerService latest graph loading and helpersclassDiagram
class InnerService {
+load_latest_graphs_query(connection, query) Result~Vec<(Uuid, Arc_PackageGraph)>~, Error
+load_graphs(connection, sbom_ids) Result~Vec<(Uuid, Arc_PackageGraph)>~, Error
}
class RankedSbom {
+Uuid matched_sbom_id
+String matched_name
+Uuid ancestor_sbom_id
+Uuid cpe_id
+DateTimeWithTimeZone sbom_date
+Option~usize~ rank
}
class resolve_all_ancestors_fn {
+resolve_all_ancestors(sbom_sbom_id, sbom_node_ref, connection, visited) async Vec~ResolvedSbom~
}
class apply_rank_fn {
+apply_rank(items Vec~RankedSbom~) Vec~RankedSbom~
}
class ResolvedSbom {
+Uuid sbom_id
+String node_id
}
InnerService --> RankedSbom : creates
InnerService --> resolve_all_ancestors_fn : calls
InnerService --> apply_rank_fn : calls
resolve_all_ancestors_fn --> ResolvedSbom : returns
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
60d9d8a to
67c0dc6
Compare
67c0dc6 to
8323440
Compare
041aa57 to
9e217b5
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2185 +/- ##
==========================================
+ Coverage 68.24% 68.51% +0.27%
==========================================
Files 376 378 +2
Lines 21208 21435 +227
Branches 21208 21435 +227
==========================================
+ Hits 14473 14687 +214
+ Misses 5868 5863 -5
- Partials 867 885 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR moves latest filter effectively from pure SQL to performing ranking in rust code (with some sql queries).
This is required mainly to find cpes (on top level externally linked sboms).
Summary by Sourcery
Improve selection of latest SBOM graphs by resolving ancestor SBOMs and ranking results in-memory for latest queries.
Bug Fixes:
Enhancements:
Build:
Tests: