-
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.
- Loading branch information
1 parent
1994088
commit f5e1d08
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
libs/cti/src/breaches/application/find_one/breach_finder.rs
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,36 @@ | ||
use tracing::debug; | ||
|
||
use crate::{ | ||
breaches::domain::{entities::{breach::Breach, breach_product::BreachProduct, breach_product_version::BreachProductVersion, breach_vendor::BreachVendor}, repositories::breach_repository::BreachRepository}, cves::domain::entities::{cve::Cve, cve_id::CveId}, shared::domain::errors::DomainError | ||
}; | ||
use std::sync::Arc; | ||
|
||
pub struct BreachFinder<R: BreachRepository> { | ||
repository: Arc<R>, | ||
} | ||
|
||
impl<R: BreachRepository> BreachFinder<R> { | ||
pub fn new(repository: Arc<R>) -> BreachFinder<R> { | ||
BreachFinder { | ||
repository, | ||
} | ||
} | ||
|
||
pub async fn run( | ||
&self, | ||
vendor: BreachVendor, | ||
product: BreachProduct, | ||
product_version: BreachProductVersion, | ||
cve_id: CveId, | ||
) -> Result<Breach, DomainError> { | ||
debug!("Finding Breach with CVE: {} for Product: {}:{}:{}.", cve_id, vendor, product, product_version); | ||
let res = self.repository.find_one(&cve_id, &vendor, &product, &product_version).await; | ||
if res.is_err() { | ||
debug!("Error finding Breach with CVE: {} for Product: {}:{}:{}.", cve_id, vendor, product, product_version); | ||
return Err(res.err().unwrap()); | ||
} | ||
debug!("Breach with CVE: {} for Product: {}:{}:{}.", cve_id, vendor, product, product_version); | ||
|
||
res | ||
} | ||
} |
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 +1,2 @@ | ||
pub mod find_breach_query; | ||
pub mod breach_finder; |
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