Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PaDarochek committed Dec 12, 2023
1 parent 514356f commit 74c731e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
23 changes: 5 additions & 18 deletions casr/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
};
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand All @@ -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"),
Expand Down Expand Up @@ -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]
Expand All @@ -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"),
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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);
}
8 changes: 6 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 74c731e

Please sign in to comment.