use std::path::PathBuf;
use clap::Args;
#[derive(Args, Debug)]
pub struct BaseFuzzerOptions {
#[arg(
help = "The directory to read initial inputs from ('seeds')",
long = "in",
required = true
)]
pub in_dir: PathBuf,
#[arg(long = "out", default_value = "./out")]
pub find_corpus_dir: PathBuf,
#[arg(long = "crashes", default_value = "./crashes")]
pub find_crash_dir: PathBuf,
#[arg(long = "crash_inputs")]
pub executor_crash_dir: Option<PathBuf>,
#[arg(long = "token_file", default_value = "")]
pub token_file: String,
}
#[derive(Args, Debug)]
pub struct ReplayOptions {
#[arg(long = "replay-dir", action = clap::ArgAction::Append)]
pub replay_dirs: Option<Vec<String>>,
#[arg(long = "replay-file", action = clap::ArgAction::Append)]
pub replay_files: Option<Vec<String>>,
#[arg(long, default_value = "0")]
pub start: usize,
#[arg(long)]
pub end: Option<usize>,
#[arg(long, action = clap::ArgAction::SetTrue)]
pub debug: bool,
}
impl ReplayOptions {
pub fn get_replay_files(&self) -> Vec<PathBuf> {
let mut to_replay_files: Vec<PathBuf> = vec![];
if let Some(dirs) = &self.replay_dirs {
for dir_str in dirs {
let dir = PathBuf::from(dir_str);
if dir.is_dir() {
for entry in std::fs::read_dir(&dir).unwrap() {
let entry = entry.unwrap();
let path = entry.path();
if path.is_file() {
to_replay_files.push(path);
}
}
} else {
eprintln!("Warning: Skipping non-directory path: {:?}", dir);
}
}
}
if let Some(files) = &self.replay_files {
for file_str in files {
let file = PathBuf::from(file_str);
if file.is_file() {
to_replay_files.push(file);
} else {
eprintln!("Warning: Skipping non-file path: {:?}", file);
}
}
}
to_replay_files
}
pub fn get_end(&self) -> usize {
self.end.unwrap_or(usize::MAX)
}
}