-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: /api/v2/purl/{purl} now honors qualifiers, or lack thereof
Fixes #1158 Signed-off-by: Jim Crossley <[email protected]>
- Loading branch information
1 parent
e3783b2
commit a4b12cd
Showing
4 changed files
with
33 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,7 +234,7 @@ mod tests { | |
"pkg:rpm/redhat/[email protected]?arch=s390x", | ||
r#" | ||
{ | ||
"identifier": "pkg:rpm/redhat/[email protected]?arch=ppc64le", | ||
"identifier": "pkg:rpm/redhat/[email protected]?arch=s390x", | ||
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"name": "libsepol", | ||
"version": "3.5-1.el9", | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -816,25 +816,33 @@ async fn ingest_some_log4j_data(ctx: &TrustifyContext) -> Result<(), anyhow::Err | |
&ctx.db, | ||
) | ||
.await?; | ||
|
||
log4j_123 | ||
.ingest_qualified_package( | ||
&Purl::from_str("pkg:maven/org.apache/[email protected]")?, | ||
&ctx.db, | ||
) | ||
.await?; | ||
Ok(()) | ||
} | ||
|
||
#[test_context(TrustifyContext)] | ||
#[test(actix_web::test)] | ||
async fn purl_by_purl(ctx: &TrustifyContext) -> Result<(), anyhow::Error> { | ||
async fn unqualified_purl_by_purl(ctx: &TrustifyContext) -> Result<(), anyhow::Error> { | ||
let service = PurlService::new(); | ||
|
||
ingest_some_log4j_data(ctx).await?; | ||
|
||
let purl = "pkg:maven/org.apache/[email protected]"; | ||
|
||
let results = service | ||
.purl_by_purl( | ||
&Purl::from_str("pkg:maven/org.apache/[email protected]")?, | ||
Default::default(), | ||
&ctx.db, | ||
) | ||
.await?; | ||
.purl_by_purl(&Purl::from_str(purl)?, Default::default(), &ctx.db) | ||
.await? | ||
.unwrap(); | ||
|
||
assert_eq!(results.unwrap().version.version, "1.2.3"); | ||
log::debug!("{results:#?}"); | ||
assert_eq!(results.head.purl.to_string(), purl); | ||
assert_eq!(results.version.version, "1.2.3"); | ||
|
||
Ok(()) | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,7 +299,7 @@ async fn product_statuses(ctx: &TrustifyContext) -> Result<(), anyhow::Error> { | |
// Ensure that purl->vuln mapping is good | ||
let purl = purl_service | ||
.purl_by_purl( | ||
&Purl::try_from("pkg:maven/io.quarkus/[email protected]")?, | ||
&Purl::try_from("pkg:maven/io.quarkus/[email protected]?repository_url=https://maven.repository.redhat.com/ga/&type=jar")?, | ||
Default::default(), | ||
&ctx.db, | ||
) | ||
|