From 74c731ef9c79a7a9e918c2a21b0daf49c1a2e47a Mon Sep 17 00:00:00 2001 From: Darya Parygina Date: Tue, 12 Dec 2023 12:34:12 +0300 Subject: [PATCH] Fixes --- README.md | 8 ++++++-- casr/tests/tests.rs | 23 +++++------------------ docs/usage.md | 8 ++++++-- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 52a0833b..46ac6e6b 100644 --- a/README.md +++ b/README.md @@ -186,9 +186,13 @@ Triage Atheris crashes with casr-libfuzzer: $ unzip casr/tests/casr_tests/python/ruamel.zip $ casr-libfuzzer -i casr/tests/casr_tests/casrep/atheris_crashes_ruamel_yaml -o casr/tests/tmp_tests_casr/casr_libfuzzer_atheris_out -- casr/tests/casr_tests/python/yaml_fuzzer.py -Triage Jazzer.js crashes with casr-libfuzzer: +Triage Jazzer.js crashes with casr-libfuzzer (Jazzer.js installation [guide](https://github.com/CodeIntelligenceTesting/jazzer.js#quickstart)): + $ unzip casr/tests/casr_tests/js/xml2js.zip -d xml2js - $ casr-libfuzzer -i ./xml2js -o casr/tests/tmp_tests_casr/casr_libfuzzer_jazzer_js_xml2js_out -- npx jazzer casr/tests/casr_tests/js/test_casr_libfuzzer_jazzer_js_xml2js.js + $ mkdir -p casr/tests/tmp_tests_casr/xml2js_fuzzer_out + $ cp casr/tests/casr_tests/js/test_casr_libfuzzer_jazzer_js_xml2js.js casr/tests/tmp_tests_casr/xml2js_fuzzer_out/xml2js_fuzzer.js + $ sudo npm install xml2js + $ casr-libfuzzer -i ./xml2js -o casr/tests/tmp_tests_casr/xml2js_fuzzer_out/out -- npx jazzer casr/tests/tmp_tests_casr/xml2js_fuzzer_out/xml2js_fuzzer.js Upload new and unique CASR reports to [DefectDojo](https://github.com/DefectDojo/django-DefectDojo): diff --git a/casr/tests/tests.rs b/casr/tests/tests.rs index 511f1886..27826792 100644 --- a/casr/tests/tests.rs +++ b/casr/tests/tests.rs @@ -4570,7 +4570,7 @@ fn test_casr_cluster_d_python() { fn test_casr_js() { let test_dir = abs_path("tests/tmp_tests_casr/test_casr_js"); let test_path = abs_path("tests/casr_tests/js/test_casr_js.js"); - let _ = std::fs::remove_dir_all(&test_dir); + let _ = std::fs::remove_dir_all(test_dir); let Ok(node_path) = which::which("node") else { panic!("No node is found."); }; @@ -4605,14 +4605,13 @@ fn test_casr_js() { } else { panic!("Couldn't parse json report file."); } - let _ = std::fs::remove_dir_all(test_dir); } #[test] #[cfg(target_arch = "x86_64")] fn test_casr_js_jsfuzz() { let test_dir = abs_path("tests/tmp_tests_casr/test_casr_js_jsfuzz"); - let _ = std::fs::remove_dir_all(&test_dir); + let _ = std::fs::remove_dir_all(test_dir); let paths = [ "tests/casr_tests/js/test_casr_js_jsfuzz.js".to_string(), "tests/tmp_tests_casr/test_casr_js_jsfuzz/corpus".to_string(), @@ -4674,14 +4673,13 @@ fn test_casr_js_jsfuzz() { } else { panic!("Couldn't parse json report file."); } - let _ = std::fs::remove_dir_all(test_dir); } #[test] #[cfg(target_arch = "x86_64")] fn test_casr_js_jazzer() { let test_dir = abs_path("tests/tmp_tests_casr/test_casr_js_jazzer"); - let _ = std::fs::remove_dir_all(&test_dir); + let _ = std::fs::remove_dir_all(test_dir); let paths = [ abs_path("tests/casr_tests/js/test_casr_js_jazzer.js"), abs_path("tests/tmp_tests_casr/test_casr_js_jazzer/corpus"), @@ -4744,7 +4742,6 @@ fn test_casr_js_jazzer() { } else { panic!("Couldn't parse json report file."); } - let _ = std::fs::remove_dir_all(test_dir); } #[test] @@ -4880,8 +4877,6 @@ fn test_casr_js_native() { } else { panic!("Couldn't parse json report file."); } - - let _ = std::fs::remove_dir_all(&test_dir); } #[test] @@ -5017,8 +5012,6 @@ fn test_casr_js_native_jsfuzz() { } else { panic!("Couldn't parse json report file."); } - - let _ = std::fs::remove_dir_all(&test_dir); } #[test] @@ -5160,8 +5153,6 @@ fn test_casr_js_native_jazzer() { } else { panic!("Couldn't parse json report file."); } - - let _ = std::fs::remove_dir_all(&test_dir); } // Jsfuzz is available only in very old version and it behaves very strangely. @@ -5173,7 +5164,7 @@ fn test_casr_js_native_jazzer() { #[cfg(target_arch = "x86_64")] fn test_casr_libfuzzer_jsfuzz() { let test_dir = abs_path("tests/tmp_tests_casr/test_casr_libfuzzer_jsfuzz"); - let _ = std::fs::remove_dir_all(&test_dir); + let _ = std::fs::remove_dir_all(test_dir); let paths = [ "tests/casr_tests/js/test_casr_libfuzzer_jsfuzz.js".to_string(), abs_path("tests/tmp_tests_casr/test_casr_libfuzzer_jsfuzz/crashes"), @@ -5250,8 +5241,6 @@ fn test_casr_libfuzzer_jsfuzz() { .unwrap(); assert_eq!(unique_cnt, 1, "Invalid number of deduplicated reports"); - - let _ = std::fs::remove_dir_all(test_dir); } #[test] @@ -5260,7 +5249,7 @@ fn test_casr_libfuzzer_jazzer_js() { use std::collections::HashMap; let test_dir = abs_path("tests/tmp_tests_casr/test_casr_libfuzzer_jazzer_js"); - let _ = std::fs::remove_dir_all(&test_dir); + let _ = std::fs::remove_dir_all(test_dir); let paths = [ abs_path("tests/casr_tests/js/test_casr_libfuzzer_jazzer_js.js"), abs_path("tests/tmp_tests_casr/test_casr_libfuzzer_jazzer_js/crashes"), @@ -5376,7 +5365,6 @@ fn test_casr_libfuzzer_jazzer_js() { } assert!(storage.values().all(|x| *x > 1)); - let _ = std::fs::remove_dir_all(test_dir); } #[test] @@ -5536,5 +5524,4 @@ fn test_casr_libfuzzer_jazzer_js_xml2js() { } assert!(storage.values().all(|x| *x > 1)); - let _ = std::fs::remove_dir_all(test_dir); } diff --git a/docs/usage.md b/docs/usage.md index b4d93dd6..4f866a52 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -545,9 +545,13 @@ Atheris example: $ unzip casr/tests/casr_tests/python/ruamel.zip $ casr-libfuzzer -i casr/tests/casr_tests/casrep/atheris_crashes_ruamel_yaml -o casr/tests/tmp_tests_casr/casr_libfuzzer_atheris_out -- casr/tests/casr_tests/python/yaml_fuzzer.py -Jazzer.js example: +Jazzer.js example (Jazzer.js installation [guide](https://github.com/CodeIntelligenceTesting/jazzer.js#quickstart)): + $ unzip casr/tests/casr_tests/js/xml2js.zip -d xml2js - $ casr-libfuzzer -i ./xml2js -o casr/tests/tmp_tests_casr/casr_libfuzzer_jazzer_js_xml2js_out -- npx jazzer casr/tests/casr_tests/js/test_casr_libfuzzer_jazzer_js_xml2js.js + $ mkdir -p casr/tests/tmp_tests_casr/xml2js_fuzzer_out + $ cp casr/tests/casr_tests/js/test_casr_libfuzzer_jazzer_js_xml2js.js casr/tests/tmp_tests_casr/xml2js_fuzzer_out/xml2js_fuzzer.js + $ sudo npm install xml2js + $ casr-libfuzzer -i ./xml2js -o casr/tests/tmp_tests_casr/xml2js_fuzzer_out/out -- npx jazzer casr/tests/tmp_tests_casr/xml2js_fuzzer_out/xml2js_fuzzer.js You can set environment variable `RUST_BACKTRACE=(1|full)` for `casr-libfuzzer`. This variable may be used by [casr-san](#casr-san).