Skip to content

Commit

Permalink
Push main diff
Browse files Browse the repository at this point in the history
  • Loading branch information
jgcrosta committed Mar 25, 2024
1 parent d48bdf5 commit e3db9af
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
12 changes: 4 additions & 8 deletions apps/cargo-scout-audit/tests/integration_tests/detectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ fn test() {
vec![false; integration_tests_to_run.as_ref().map_or(0, |v| v.len())];

// Get the configuration
let detectors_config = Configuration::build().expect(&"Failed to get the configuration".red());
let detectors_config = Configuration::build()
.unwrap_or_else(|_| panic!("{}", "Failed to get the configuration".red().to_string()));

// Run all integration tests
for detector_config in detectors_config.detectors.iter() {
Expand All @@ -64,15 +65,10 @@ fn test() {
println!("\n{} {}", "Testing detector:".bright_cyan(), detector_name);
for example in detector_config.testcases.iter() {
if let Some(vulnerable_path) = &example.vulnerable_path {
execute_and_validate_testcase(&detector_name, lint_message, &vulnerable_path, true);
execute_and_validate_testcase(&detector_name, lint_message, vulnerable_path, true);
}
if let Some(remediated_path) = &example.remediated_path {
execute_and_validate_testcase(
&detector_name,
lint_message,
&remediated_path,
false,
);
execute_and_validate_testcase(&detector_name, lint_message, remediated_path, false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl Configuration {
.ok_or(anyhow!("Failed to find testcases path"))?
.join("test-cases");
let testcases_paths: Vec<PathBuf> = std::fs::read_dir(&testcases_root_path)?
.into_iter()
.filter_map(|r| r.ok().map(|f| f.path()))
.filter(|r| r.is_dir())
.collect();
Expand All @@ -47,7 +46,6 @@ impl Configuration {
let detector_name = detector.to_string();
let testcases_root_path = testcases_root_path.join(detector_name);
let testcases_paths: Vec<PathBuf> = std::fs::read_dir(testcases_root_path)?
.into_iter()
.filter_map(|r| r.ok().map(|f| f.path()))
.filter(|r| r.is_dir())
.collect();
Expand Down Expand Up @@ -101,7 +99,7 @@ impl Configuration {
.into_iter()
.sorted()
.zip(Detector::iter().map(|d| d.to_string()).sorted())
.filter(|(p, d)| p.file_name().unwrap().to_string_lossy() != d.to_string())
.filter(|(p, d)| p.file_name().unwrap().to_string_lossy() != *d)
.count();

if count > 0 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[package]
name = "unprotected-mapping-operation"
name = "unprotected-mapping-operation-remediated-1"
version = "0.1.0"
edition = "2021"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[package]
name = "unprotected-mapping-operation"
name = "unprotected-mapping-operation-vulnerable-1"
version = "0.1.0"
edition = "2021"

Expand Down

0 comments on commit e3db9af

Please sign in to comment.