Skip to content

Commit 67297d3

Browse files
committed
fix: if there are no licenses, don't fail or generate empty results
We used to pick SBOMs which licenses. However, as RH's SBOMs no longer contains licenses, we can't use that for generating the scenario file.
1 parent 3ac1c4b commit 67297d3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/scenario/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ FROM
300300
sbom_package_purl_ref spr
301301
JOIN
302302
sbom_package sp ON spr.sbom_id = sp.sbom_id AND spr.node_id = sp.node_id
303-
JOIN
303+
LEFT JOIN
304304
sbom_package_license spl ON sp.sbom_id = spl.sbom_id AND sp.node_id = spl.node_id
305305
GROUP BY
306306
spr.qualified_purl_id
@@ -339,25 +339,22 @@ LIMIT 10;
339339
}
340340

341341
/// Get a pool of deletable SBOMs (up to 100)
342-
/// These SBOMs are selected based on having certain licenses that make them good candidates for deletion testing
342+
/// These SBOMs are selected based on having the most packages
343343
pub async fn deletable_sboms(&self) -> anyhow::Result<Vec<String>> {
344344
let mut db = crate::db::connect(&self.db).await?;
345345

346346
let rows = sqlx::query(
347347
r#"
348348
SELECT
349-
a.sbom_id::text as id
349+
a.sbom_id::text as id,
350+
count(b.*) as package_count
350351
FROM
351352
sbom a
352-
JOIN sbom_node b ON a.sbom_id = b.sbom_id
353-
JOIN sbom_package c ON b.sbom_id = c.sbom_id AND b.node_id = c.node_id
354-
JOIN sbom_package_license d ON c.sbom_id = d.sbom_id AND c.node_id = d.node_id
355-
JOIN license e ON d.license_id = e.id
356-
WHERE
357-
e.text IN ('GPLv3+ with exceptions', 'Apache-2.0', 'MIT', 'BSD-3-Clause')
353+
JOIN sbom_package b ON a.sbom_id = b.sbom_id
358354
GROUP BY
359355
a.sbom_id
360356
ORDER BY
357+
package_count DESC,
361358
a.sbom_id
362359
LIMIT 100
363360
"#,

0 commit comments

Comments
 (0)