diff --git a/casr/Cargo.toml b/casr/Cargo.toml index f12cf34d..1e350c1f 100644 --- a/casr/Cargo.toml +++ b/casr/Cargo.toml @@ -37,7 +37,6 @@ tokio = { version = "1", features = ["rt", "macros"], optional = true } toml = { version = "0.7", optional = true } wait-timeout = "0.2" which = "4.4" -copy_dir = "0.1.3" libcasr = { path = "../libcasr", version = "2.11.1", features = ["serde", "exploitable"] } @@ -54,3 +53,4 @@ required-features = ["dojo"] [dev-dependencies] lazy_static = "1.4" lsb_release = "0.1" +copy_dir = "0.1.3" diff --git a/casr/tests/tests.rs b/casr/tests/tests.rs index 4b64ff6b..b8bfcffa 100644 --- a/casr/tests/tests.rs +++ b/casr/tests/tests.rs @@ -1,13 +1,13 @@ +extern crate copy_dir; extern crate lazy_static; extern crate regex; extern crate serde_json; -extern crate copy_dir; +use copy_dir::copy_dir; use regex::Regex; use serde_json::Value; use std::env; use std::fs; -use copy_dir::copy_dir; use std::io::Write; use std::path::{Path, PathBuf}; @@ -3867,18 +3867,7 @@ fn test_casr_ubsan() { let test_dir = abs_path("tests/tmp_tests_casr/test_casr_ubsan"); let _ = fs::remove_dir_all(&test_dir); - - let output = Command::new("cp") - .args(["-r", &work_dir, &test_dir]) - .output() - .expect("failed to copy dir"); - - assert!( - output.status.success(), - "Stdout {}.\n Stderr: {}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); + let _ = copy_dir(work_dir, &test_dir); let paths = [ abs_path("tests/tmp_tests_casr/test_casr_ubsan/test_ubsan.cpp"), @@ -4390,17 +4379,7 @@ fn test_casr_san_python_df() { let work_dir = abs_path("tests/casr_tests/python"); let test_dir = abs_path("tests/tmp_tests_casr/test_casr_san_python_df"); - let output = Command::new("cp") - .args(["-r", &work_dir, &test_dir]) - .output() - .expect("failed to copy dir"); - - assert!( - output.status.success(), - "Stdout {}.\n Stderr: {}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); + let _ = copy_dir(work_dir, &test_dir); let paths = [ abs_path("tests/tmp_tests_casr/test_casr_san_python_df/cpp_module.cpp"), @@ -4501,17 +4480,7 @@ fn test_casr_san_atheris_df() { let work_dir = abs_path("tests/casr_tests/python"); let test_dir = abs_path("tests/tmp_tests_casr/test_casr_san_atheris_df"); - let output = Command::new("cp") - .args(["-r", &work_dir, &test_dir]) - .output() - .expect("failed to copy dir"); - - assert!( - output.status.success(), - "Stdout {}.\n Stderr: {}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); + let _ = copy_dir(work_dir, &test_dir); let paths = [ abs_path("tests/tmp_tests_casr/test_casr_san_atheris_df/cpp_module.cpp"), @@ -4616,17 +4585,7 @@ fn test_casr_python_call_san_df() { let work_dir = abs_path("tests/casr_tests/python"); let test_dir = abs_path("tests/tmp_tests_casr/test_casr_python_call_san_df"); - let output = Command::new("cp") - .args(["-r", &work_dir, &test_dir]) - .output() - .expect("failed to copy dir"); - - assert!( - output.status.success(), - "Stdout {}.\n Stderr: {}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); + let _ = copy_dir(work_dir, &test_dir); let paths = [ abs_path("tests/tmp_tests_casr/test_casr_python_call_san_df/cpp_module.cpp"), @@ -4988,19 +4947,9 @@ fn test_casr_js_native() { // Copy files to tmp dir let work_dir = abs_path("tests/casr_tests/js"); let test_dir = abs_path("tests/tmp_tests_casr/test_casr_js_native"); - let _ = std::fs::remove_dir_all(&test_dir); - let output = Command::new("cp") - .args(["-r", &work_dir, &test_dir]) - .output() - .expect("failed to copy dir"); - - assert!( - output.status.success(), - "Stdout {}.\n Stderr: {}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); + let _ = std::fs::remove_dir_all(&test_dir); + let _ = copy_dir(work_dir, &test_dir); let paths = [ abs_path("tests"), @@ -5127,19 +5076,9 @@ fn test_casr_js_native_jsfuzz() { // Copy files to tmp dir let work_dir = abs_path("tests/casr_tests/js"); let test_dir = abs_path("tests/tmp_tests_casr/test_casr_js_native_jsfuzz"); - let _ = std::fs::remove_dir_all(&test_dir); - - let output = Command::new("cp") - .args(["-r", &work_dir, &test_dir]) - .output() - .expect("failed to copy dir"); - assert!( - output.status.success(), - "Stdout {}.\n Stderr: {}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); + let _ = std::fs::remove_dir_all(&test_dir); + let _ = copy_dir(work_dir, &test_dir); let paths = [ abs_path("tests"), @@ -5266,19 +5205,9 @@ fn test_casr_js_native_jazzer() { // Copy files to tmp dir let work_dir = abs_path("tests/casr_tests/js"); let test_dir = abs_path("tests/tmp_tests_casr/test_casr_js_native_jazzer"); - let _ = std::fs::remove_dir_all(&test_dir); - - let output = Command::new("cp") - .args(["-r", &work_dir, &test_dir]) - .output() - .expect("failed to copy dir"); - assert!( - output.status.success(), - "Stdout {}.\n Stderr: {}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); + let _ = std::fs::remove_dir_all(&test_dir); + let _ = copy_dir(work_dir, &test_dir); let paths = [ abs_path("tests"), @@ -5955,7 +5884,7 @@ fn test_casr_afl_csharp_ignore_cmd() { &format!("{}/test_casr_afl_csharp.csproj", &paths[4]), ]) .output() - .expect("dotnet publish crashed"); + .expect("dotnet build crashed"); let bins = Path::new(*EXE_CASR_AFL.read().unwrap()).parent().unwrap(); let mut output = Command::new(*EXE_CASR_AFL.read().unwrap()); @@ -5979,7 +5908,6 @@ fn test_casr_afl_csharp_ignore_cmd() { format!("{}:{}", bins.display(), std::env::var("PATH").unwrap()), ); - print!("{:?}", output); let output = output.output().expect("casr-afl crashed"); assert!( diff --git a/docs/usage.md b/docs/usage.md index 3fece128..082b580b 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -436,7 +436,7 @@ Convert reports to SARIF report: ## casr-afl -Triage crashes found by AFL++ (Sharpfuzz) +Triage crashes found by AFL++/Sharpfuzz Usage: casr-afl [OPTIONS] --input --output [-- ...] @@ -455,7 +455,7 @@ Triage crashes found by AFL++ (Sharpfuzz) -i, --input AFL++ work directory -o, --output Output directory with triaged reports -f, --force-remove Remove output project directory if it exists - --ignore-cmdline Force usage to run target instead of searching for cmdline files + --ignore-cmdline Force usage to run target instead of searching for cmdline files in AFL fuzzing directory --no-cluster Do not cluster CASR reports -h, --help Print help