forked from trustification/trustify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a way to find related SBOMs by CPE
Also, get rid of the central analysis graph instance.
- Loading branch information
Showing
49 changed files
with
1,861 additions
and
1,677 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Analysis Graph | ||
|
||
## Get a component | ||
|
||
```bash | ||
http localhost:8080/api/v2/analysis/root-component/B | ||
``` |
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 |
---|---|---|
|
@@ -65,7 +65,7 @@ pub async fn search_component_root_components( | |
) -> actix_web::Result<impl Responder> { | ||
Ok(HttpResponse::Ok().json( | ||
service | ||
.retrieve_root_components(search, paginated, db.as_ref()) | ||
.retrieve_root_components(&search, paginated, db.as_ref()) | ||
.await?, | ||
)) | ||
} | ||
|
@@ -92,13 +92,13 @@ pub async fn get_component_root_components( | |
let purl: Purl = Purl::from_str(&key).map_err(Error::Purl)?; | ||
Ok(HttpResponse::Ok().json( | ||
service | ||
.retrieve_root_components_by_purl(purl, paginated, db.as_ref()) | ||
.retrieve_root_components(&purl, paginated, db.as_ref()) | ||
.await?, | ||
)) | ||
} else { | ||
Ok(HttpResponse::Ok().json( | ||
service | ||
.retrieve_root_components_by_name(key.to_string(), paginated, db.as_ref()) | ||
.retrieve_root_components(&key.to_string(), paginated, db.as_ref()) | ||
.await?, | ||
)) | ||
} | ||
|
@@ -125,7 +125,7 @@ pub async fn search_component_deps( | |
) -> actix_web::Result<impl Responder> { | ||
Ok(HttpResponse::Ok().json( | ||
service | ||
.retrieve_deps(search, paginated, db.as_ref()) | ||
.retrieve_deps(&search, paginated, db.as_ref()) | ||
.await?, | ||
)) | ||
} | ||
|
@@ -150,15 +150,11 @@ pub async fn get_component_deps( | |
) -> actix_web::Result<impl Responder> { | ||
if key.starts_with("pkg:") { | ||
let purl: Purl = Purl::from_str(&key).map_err(Error::Purl)?; | ||
Ok(HttpResponse::Ok().json( | ||
service | ||
.retrieve_deps_by_purl(purl, paginated, db.as_ref()) | ||
.await?, | ||
)) | ||
Ok(HttpResponse::Ok().json(service.retrieve_deps(&purl, paginated, db.as_ref()).await?)) | ||
} else { | ||
Ok(HttpResponse::Ok().json( | ||
service | ||
.retrieve_deps_by_name(key.to_string(), paginated, db.as_ref()) | ||
.retrieve_deps(&key.to_string(), paginated, db.as_ref()) | ||
.await?, | ||
)) | ||
} | ||
|
@@ -187,8 +183,14 @@ mod test { | |
let request: Request = TestRequest::get().uri(uri).to_request(); | ||
let response: Value = app.call_and_read_body_json(request).await; | ||
|
||
if response["items"][0]["purl"] == "pkg:rpm/redhat/[email protected]" | ||
|| response["items"][1]["purl"] == "pkg:rpm/redhat/[email protected]" | ||
if response["items"][0]["purl"] | ||
.as_array() | ||
.unwrap() | ||
.contains(&Value::from("pkg:rpm/redhat/[email protected]")) | ||
|| response["items"][1]["purl"] | ||
.as_array() | ||
.unwrap() | ||
.contains(&Value::from("pkg:rpm/redhat/[email protected]")) | ||
{ | ||
assert_eq!(&response["total"], 2); | ||
} else { | ||
|
@@ -200,10 +202,13 @@ mod test { | |
let uri = "/api/v2/analysis/root-component?q=BB"; | ||
let request: Request = TestRequest::get().uri(uri).to_request(); | ||
let response: Value = app.call_and_read_body_json(request).await; | ||
assert_eq!(response["items"][0]["purl"], "pkg:rpm/redhat/[email protected]"); | ||
assert_eq!( | ||
response["items"][0]["purl"], | ||
Value::from(["pkg:rpm/redhat/[email protected]"]) | ||
); | ||
assert_eq!( | ||
response["items"][0]["ancestors"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]?arch=src" | ||
Value::from(["pkg:rpm/redhat/[email protected]?arch=src"]) | ||
); | ||
|
||
assert_eq!(&response["total"], 1); | ||
|
@@ -224,10 +229,13 @@ mod test { | |
|
||
let response: Value = app.call_and_read_body_json(request).await; | ||
|
||
assert_eq!(response["items"][0]["purl"], "pkg:rpm/redhat/[email protected]"); | ||
assert_eq!( | ||
response["items"][0]["purl"], | ||
Value::from(["pkg:rpm/redhat/[email protected]"]) | ||
); | ||
assert_eq!( | ||
response["items"][0]["ancestors"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]?arch=src" | ||
Value::from(["pkg:rpm/redhat/[email protected]?arch=src"]) | ||
); | ||
assert_eq!(&response["total"], 1); | ||
Ok(()) | ||
|
@@ -247,10 +255,13 @@ mod test { | |
|
||
let response: Value = app.call_and_read_body_json(request).await; | ||
|
||
assert_eq!(response["items"][0]["purl"], "pkg:rpm/redhat/[email protected]"); | ||
assert_eq!( | ||
response["items"][0]["purl"], | ||
Value::from(["pkg:rpm/redhat/[email protected]"]) | ||
); | ||
assert_eq!( | ||
response["items"][0]["ancestors"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]?arch=src" | ||
Value::from(["pkg:rpm/redhat/[email protected]?arch=src"]) | ||
); | ||
assert_eq!(&response["total"], 1); | ||
Ok(()) | ||
|
@@ -276,15 +287,15 @@ mod test { | |
|
||
assert_eq!( | ||
response["items"][0]["purl"], | ||
"pkg:maven/net.spy/[email protected]?type=jar" | ||
Value::from(["pkg:maven/net.spy/[email protected]?type=jar"]) | ||
); | ||
assert_eq!( | ||
response["items"][0]["document_id"], | ||
"https://access.redhat.com/security/data/sbom/spdx/quarkus-bom-3.2.11.Final-redhat-00001" | ||
); | ||
assert_eq!( | ||
response["items"][0]["ancestors"][0]["purl"], | ||
"pkg:maven/com.redhat.quarkus.platform/[email protected]?type=pom&repository_url=https%3a%2f%2fmaven.repository.redhat.com%2fga%2f" | ||
Value::from(["pkg:maven/com.redhat.quarkus.platform/[email protected]?repository_url=https%3A%2F%2Fmaven%2Erepository%2Eredhat%2Ecom%2Fga%2F&type=pom"]) | ||
); | ||
|
||
assert_eq!(&response["total"], 2); | ||
|
@@ -334,20 +345,22 @@ mod test { | |
let request: Request = TestRequest::get().uri(uri).to_request(); | ||
let response: Value = app.call_and_read_body_json(request).await; | ||
|
||
println!("Result: {response:#?}"); | ||
|
||
assert_eq!( | ||
response["items"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]?arch=src" | ||
Value::from(["pkg:rpm/redhat/[email protected]?arch=src"]), | ||
); | ||
assert_eq!( | ||
response["items"][0]["deps"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]?arch=src" | ||
Value::from(["pkg:rpm/redhat/[email protected]?arch=src"]), | ||
); | ||
assert_eq!( | ||
response["items"][0]["deps"][1]["purl"], | ||
"pkg:rpm/redhat/[email protected]" | ||
Value::from(["pkg:rpm/redhat/[email protected]"]), | ||
); | ||
|
||
assert_eq!(&response["total"], 3); | ||
assert_eq!(&response["total"], 2); | ||
Ok(()) | ||
} | ||
|
||
|
@@ -364,15 +377,15 @@ mod test { | |
|
||
assert_eq!( | ||
response["items"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]?arch=src" | ||
Value::from(["pkg:rpm/redhat/[email protected]?arch=src"]), | ||
); | ||
assert_eq!( | ||
response["items"][0]["deps"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]?arch=src" | ||
Value::from(["pkg:rpm/redhat/[email protected]?arch=src"]), | ||
); | ||
assert_eq!( | ||
response["items"][0]["deps"][1]["purl"], | ||
"pkg:rpm/redhat/[email protected]" | ||
Value::from(["pkg:rpm/redhat/[email protected]"]), | ||
); | ||
|
||
assert_eq!(&response["total"], 1); | ||
|
@@ -392,11 +405,11 @@ mod test { | |
|
||
assert_eq!( | ||
response["items"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]?arch=src" | ||
Value::from(["pkg:rpm/redhat/[email protected]?arch=src"]), | ||
); | ||
assert_eq!( | ||
response["items"][0]["deps"][0]["purl"], | ||
"pkg:rpm/redhat/[email protected]" | ||
Value::from(["pkg:rpm/redhat/[email protected]"]), | ||
); | ||
assert_eq!(&response["total"], 1); | ||
Ok(()) | ||
|
@@ -420,7 +433,7 @@ mod test { | |
|
||
assert_eq!( | ||
response["items"][0]["purl"], | ||
"pkg:maven/net.spy/[email protected]?type=jar" | ||
Value::from(["pkg:maven/net.spy/[email protected]?type=jar"]), | ||
); | ||
assert_eq!(&response["total"], 2); | ||
Ok(()) | ||
|
Oops, something went wrong.