-
Notifications
You must be signed in to change notification settings - Fork 48
fix(purl): filter purl_statuses by SBOM describing CPEs [Backport release/0.4.z] #2564
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: release/0.4.z
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,7 +94,7 @@ async fn ingest(ctx: TrustifyContext) -> anyhow::Result<()> { | |
| assert!(ubi_details.is_some()); | ||
| let ubi_details = ubi_details.unwrap(); | ||
| let ubi_advisories = ubi_details.advisories; | ||
| assert_eq!(ubi_advisories.len(), 1); | ||
| assert_eq!(ubi_advisories.len(), 3); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Strengthen this assertion to validate which advisories are present, not just the count. Simply increasing the expected advisory count to 3 keeps the test brittle and not very descriptive. Since the broader CPE matching is intentional, also assert on which advisories are returned (e.g., IDs, statuses, or a subset) rather than only their number. This will make future failures more informative and clearly document which advisories are expected for ubi8. Suggested implementation: let ubi_details = ubi_details.unwrap();
let ubi_advisories = ubi_details.advisories;
// Assert on the specific advisories we expect for ubi8, not just the count.
let advisory_ids: std::collections::HashSet<_> = ubi_advisories
.iter()
.map(|advisory| advisory.id.as_str())
.collect();
let expected_ids: std::collections::HashSet<&'static str> = [
"RHSA-YYYY:0001",
"RHSA-YYYY:0002",
"RHSA-YYYY:0003",
]
.into_iter()
.collect();
assert_eq!(
advisory_ids, expected_ids,
"unexpected advisories for ubi8: got {:?}, expected {:?}",
advisory_ids, expected_ids
);
assert!(
|
||
| assert!( | ||
| ubi_advisories | ||
| .iter() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider naming the JSON key to reflect that it carries an ID, not a full CPE object.
The value here is
purl_status.context_cpe_id, so the key name suggests a full CPE rather than an ID. Consider renaming the key (e.g. tocontext_cpe_id, or whatever matches existing API conventions) to avoid confusing downstream consumers about what this field contains.