From 0f22089305fd92e20a44a3ef9793bce390671c1f Mon Sep 17 00:00:00 2001 From: Flavio Castelli Date: Thu, 21 Nov 2024 08:35:54 +0100 Subject: [PATCH] refactor: remove `mod.rs` files Signed-off-by: Flavio Castelli --- src/errors.rs | 2 +- src/sarif.rs | 2 +- src/sarif/trivy.rs | 17 ++++++++--------- src/{sbombastic/mod.rs => sbombastic.rs} | 0 src/sbombastic/{storage/mod.rs => storage.rs} | 0 .../storage/{v1alpha1/mod.rs => v1alpha1.rs} | 0 6 files changed, 10 insertions(+), 11 deletions(-) rename src/{sbombastic/mod.rs => sbombastic.rs} (100%) rename src/sbombastic/{storage/mod.rs => storage.rs} (100%) rename src/sbombastic/storage/{v1alpha1/mod.rs => v1alpha1.rs} (100%) diff --git a/src/errors.rs b/src/errors.rs index 7da3214..d0f7910 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -87,5 +87,5 @@ pub enum ImageValidationError { MalformedImageName(String), #[error("Failed to parse the SARIF report: {0}")] - SarifParseError(String), + SarifParse(String), } diff --git a/src/sarif.rs b/src/sarif.rs index e2b66b6..4bce35f 100644 --- a/src/sarif.rs +++ b/src/sarif.rs @@ -52,7 +52,7 @@ impl Report { always_allowed: &HashSet, ) -> Result { if trivy_report.runs.len() != 1 { - return Err(ImageValidationError::SarifParseError(format!( + return Err(ImageValidationError::SarifParse(format!( "wrong number of 'run' items inside of trivy report, expected 1 got {}", trivy_report.runs.len() ))); diff --git a/src/sarif/trivy.rs b/src/sarif/trivy.rs index 0f39070..88a33ad 100644 --- a/src/sarif/trivy.rs +++ b/src/sarif/trivy.rs @@ -5,25 +5,24 @@ impl TryFrom for Report { type Error = ImageValidationError; fn try_from(sbombastic_vulnerability_report: VulnerabilityReport) -> Result { - let spec = - sbombastic_vulnerability_report - .spec - .ok_or(ImageValidationError::SarifParseError( - "missing VulnerabilityReportSpec".to_string(), - ))?; + let spec = sbombastic_vulnerability_report + .spec + .ok_or(ImageValidationError::SarifParse( + "missing VulnerabilityReportSpec".to_string(), + ))?; let report = serde_json::from_value::(spec.sarif) - .map_err(|e| ImageValidationError::SarifParseError(e.to_string()))?; + .map_err(|e| ImageValidationError::SarifParse(e.to_string()))?; if report.runs.len() != 1 { - return Err(ImageValidationError::SarifParseError(format!( + return Err(ImageValidationError::SarifParse(format!( "wrong number of 'run' items inside of trivy report, expected 1 got {}", report.runs.len() ))); } if report.runs[0].tool.driver.name != "Trivy" { - return Err(ImageValidationError::SarifParseError(format!( + return Err(ImageValidationError::SarifParse(format!( "wrong tool driver name inside of trivy report, expected 'Trivy' got '{}'", report.runs[0].tool.driver.name ))); diff --git a/src/sbombastic/mod.rs b/src/sbombastic.rs similarity index 100% rename from src/sbombastic/mod.rs rename to src/sbombastic.rs diff --git a/src/sbombastic/storage/mod.rs b/src/sbombastic/storage.rs similarity index 100% rename from src/sbombastic/storage/mod.rs rename to src/sbombastic/storage.rs diff --git a/src/sbombastic/storage/v1alpha1/mod.rs b/src/sbombastic/storage/v1alpha1.rs similarity index 100% rename from src/sbombastic/storage/v1alpha1/mod.rs rename to src/sbombastic/storage/v1alpha1.rs