-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use caches to prevent repeated lookups
- Loading branch information
Showing
4 changed files
with
148 additions
and
54 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 |
---|---|---|
|
@@ -4,5 +4,5 @@ target | |
/data | ||
.trustify | ||
|
||
/flamegraph.svg | ||
/perf.data | ||
/flamegraph*.svg | ||
/perf.data* |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#![cfg(test)] | ||
|
||
use crate::graph::sbom::PackageCache; | ||
use crate::graph::Graph; | ||
use std::collections::HashMap; | ||
use std::convert::TryInto; | ||
use test_log::test; | ||
use trustify_common::db::{Database, Transactional}; | ||
|
@@ -198,6 +200,8 @@ async fn transitive_dependency_of() -> Result<(), anyhow::Error> { | |
let db = Database::for_test("transitive_dependency_of").await?; | ||
let system = Graph::new(db); | ||
|
||
let mut cache = PackageCache::new(1, &system, &Transactional::None); | ||
|
||
let sbom1 = system | ||
.ingest_sbom( | ||
"http://sbomsRus.gov/thing1.json", | ||
|
@@ -210,6 +214,7 @@ async fn transitive_dependency_of() -> Result<(), anyhow::Error> { | |
|
||
sbom1 | ||
.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|
@@ -219,6 +224,7 @@ async fn transitive_dependency_of() -> Result<(), anyhow::Error> { | |
|
||
sbom1 | ||
.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|
@@ -228,6 +234,7 @@ async fn transitive_dependency_of() -> Result<(), anyhow::Error> { | |
|
||
sbom1 | ||
.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|
@@ -237,6 +244,7 @@ async fn transitive_dependency_of() -> Result<(), anyhow::Error> { | |
|
||
sbom1 | ||
.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|
@@ -246,6 +254,7 @@ async fn transitive_dependency_of() -> Result<(), anyhow::Error> { | |
|
||
sbom1 | ||
.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|
@@ -269,6 +278,8 @@ async fn ingest_package_relates_to_package_dependency_of() -> Result<(), anyhow: | |
let db = Database::for_test("ingest_contains_packages").await?; | ||
let system = Graph::new(db); | ||
|
||
let mut cache = PackageCache::new(1, &system, &Transactional::None); | ||
|
||
let sbom1 = system | ||
.ingest_sbom( | ||
"http://sbomsRus.gov/thing1.json", | ||
|
@@ -281,6 +292,7 @@ async fn ingest_package_relates_to_package_dependency_of() -> Result<(), anyhow: | |
|
||
sbom1 | ||
.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|
@@ -300,6 +312,7 @@ async fn ingest_package_relates_to_package_dependency_of() -> Result<(), anyhow: | |
|
||
sbom2 | ||
.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|
@@ -345,6 +358,8 @@ async fn sbom_vulnerabilities() -> Result<(), anyhow::Error> { | |
let db = Database::for_test("sbom_vulnerabilities").await?; | ||
let system = Graph::new(db); | ||
|
||
let mut cache = PackageCache::new(1, &system, &Transactional::None); | ||
|
||
println!("{:?}", system); | ||
|
||
let sbom = system | ||
|
@@ -364,6 +379,7 @@ async fn sbom_vulnerabilities() -> Result<(), anyhow::Error> { | |
println!("-------------------- B"); | ||
|
||
sbom.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://oci/[email protected]".try_into()?, | ||
|
@@ -373,6 +389,7 @@ async fn sbom_vulnerabilities() -> Result<(), anyhow::Error> { | |
println!("-------------------- C"); | ||
|
||
sbom.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|
@@ -382,6 +399,7 @@ async fn sbom_vulnerabilities() -> Result<(), anyhow::Error> { | |
println!("-------------------- D"); | ||
|
||
sbom.ingest_package_relates_to_package( | ||
&mut cache, | ||
"pkg://maven/postgres/[email protected]".try_into()?, | ||
Relationship::DependencyOf, | ||
"pkg://maven/io.quarkus/[email protected]".try_into()?, | ||
|