Skip to content

Commit

Permalink
Renamed option x2
Browse files Browse the repository at this point in the history
  • Loading branch information
hkctkuy committed Jun 12, 2024
1 parent ea477c0 commit 08336ac
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 43 deletions.
11 changes: 5 additions & 6 deletions casr/src/bin/casr-afl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ fn main() -> Result<()> {
.help("Output directory with triaged reports")
)
.arg(
Arg::new("base")
.short('b')
.long("base")
.env("CASR_BASE_DIR")
Arg::new("join")
.long("join")
.env("CASR_PREV_CLSUTERS_DIR")
.action(ArgAction::Set)
.value_parser(clap::value_parser!(PathBuf))
.value_name("BASE_DIR")
.help("Base directory with previously triaged reports")
.value_name("PREV_CLSUTERS_DIR")
.help("Use directory with previously triaged reports for new reports accumulation")
)
.arg(
Arg::new("force-remove")
Expand Down
11 changes: 5 additions & 6 deletions casr/src/bin/casr-libfuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ fn main() -> Result<()> {
.help("Output directory with triaged reports")
)
.arg(
Arg::new("base")
.short('b')
.long("base")
.env("CASR_BASE_DIR")
Arg::new("join")
.long("join")
.env("CASR_PREV_CLSUTERS_DIR")
.action(ArgAction::Set)
.value_parser(clap::value_parser!(PathBuf))
.value_name("BASE_DIR")
.help("Base directory with previously triaged reports")
.value_name("PREV_CLSUTERS_DIR")
.help("Use directory with previously triaged reports for new reports accumulation")
)
.arg(
Arg::new("force-remove")
Expand Down
6 changes: 3 additions & 3 deletions casr/src/triage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ pub fn fuzzing_crash_triage_pipeline(
bail!("No crashes found");
}

let base_mode = matches.contains_id("base");
let accum_mode = matches.contains_id("join");

let output_dir = initialize_dirs(matches)?;

let casrep_dir = if base_mode {
let casrep_dir = if accum_mode {
output_dir.join("casrep")
} else {
output_dir.to_path_buf()
Expand Down Expand Up @@ -238,7 +238,7 @@ pub fn fuzzing_crash_triage_pipeline(
}

if !matches.get_flag("no-cluster") {
if base_mode {
if accum_mode {
info!("Accumulating CASR reports...");
let casr_cluster_u = Command::new(&casr_cluster)
.arg("-u")
Expand Down
6 changes: 3 additions & 3 deletions casr/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ pub fn initialize_dirs(matches: &clap::ArgMatches) -> Result<&PathBuf> {
}
}

if let Some(base_dir) = matches.get_one::<PathBuf>("base") {
copy_dir(base_dir, output_dir)
.with_context(|| format!("Couldn't copy base directory {}", base_dir.display()))?;
if let Some(join_dir) = matches.get_one::<PathBuf>("join") {
copy_dir(join_dir, output_dir)
.with_context(|| format!("Couldn't copy join directory {}", join_dir.display()))?;
// Get casrep dir
let casrep_dir = output_dir.join("casrep");
if !casrep_dir.exists() && fs::create_dir_all(&casrep_dir).is_err() {
Expand Down
14 changes: 7 additions & 7 deletions casr/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3951,7 +3951,7 @@ fn test_casr_libfuzzer() {

let paths = [
abs_path("tests/casr_tests/casrep/libfuzzer_crashes_xlnt"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_base"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_join"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_out"),
abs_path("tests/casr_tests/bin/load_fuzzer"),
];
Expand Down Expand Up @@ -4039,19 +4039,19 @@ fn test_casr_libfuzzer() {

// Remove several clusters
let cluster_paths = [
abs_path("tests/tmp_tests_casr/casr_libfuzzer_base/cl2"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_base/cl20"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_base/cl21"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_base/cl22"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_base/cl23"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_join/cl2"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_join/cl20"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_join/cl21"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_join/cl22"),
abs_path("tests/tmp_tests_casr/casr_libfuzzer_join/cl23"),
];
for path in cluster_paths {
let _ = fs::remove_dir_all(path);
}

let mut cmd = Command::new(*EXE_CASR_LIBFUZZER.read().unwrap());
cmd.args([
"-i", &paths[0], "-b", &paths[1], "-o", &paths[2], "-f", "--", &paths[3],
"-i", &paths[0], "--join", &paths[1], "-o", &paths[2], "-f", "--", &paths[3],
])
.env(
"PATH",
Expand Down
37 changes: 19 additions & 18 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,22 +449,22 @@ Triage crashes found by AFL++/Sharpfuzz
triage C# crashes with additional options

Options:
-l, --log-level <log-level> Logging level [default: info] [possible values: info,
debug]
-j, --jobs <jobs> Number of parallel jobs for generating CASR reports
[default: half of cpu cores]
-t, --timeout <SECONDS> Timeout (in seconds) for target execution, 0 value means
that timeout is disabled [default: 0]
-i, --input <INPUT_DIR> AFL++ work directory
-o, --output <OUTPUT_DIR> Output directory with triaged reports
-s, --seed <SEED_DIR> Seed directory with previously triaged reports [env:
CASR_SEED_DIR=]
-f, --force-remove Remove output project directory if it exists
--ignore-cmdline Force <ARGS> 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
-V, --version Print version
-l, --log-level <log-level> Logging level [default: info] [possible values: info,
debug]
-j, --jobs <jobs> Number of parallel jobs for generating CASR reports
[default: half of cpu cores]
-t, --timeout <SECONDS> Timeout (in seconds) for target execution, 0 value means
that timeout is disabled [default: 0]
-i, --input <INPUT_DIR> AFL++ work directory
-o, --output <OUTPUT_DIR> Output directory with triaged reports
--join <PREV_CLSUTERS_DIR> Use directory with previously triaged reports for new
reports accumulation [env: CASR_PREV_CLSUTERS_DIR=]
-f, --force-remove Remove output project directory if it exists
--ignore-cmdline Force <ARGS> 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
-V, --version Print version

`casr-afl` provides a straightforward CASR integration with AFL++. While walking through afl
instances, `casr-afl` generates crash reports depending on target binary. For
Expand Down Expand Up @@ -592,8 +592,9 @@ Triage crashes found by libFuzzer based fuzzer
Directory containing crashes found by libFuzzer [default: .]
-o, --output <OUTPUT_DIR>
Output directory with triaged reports
-s, --seed <SEED_DIR>
Seed directory with previously triaged reports [env: CASR_SEED_DIR=]
--join <PREV_CLSUTERS_DIR>
Use directory with previously triaged reports for new reports accumulation [env:
CASR_PREV_CLSUTERS_DIR=]
-f, --force-remove
Remove output project directory if it exists
--no-cluster
Expand Down

0 comments on commit 08336ac

Please sign in to comment.