From 43afe901043dc22d3c1d65d813ba6a3ee55760c0 Mon Sep 17 00:00:00 2001 From: Brian Caswell Date: Thu, 18 Mar 2021 11:49:11 -0400 Subject: [PATCH] enable generic-analysis as an optional component of libfuzzer local tasks --- .../src/local/generic_analysis.rs | 30 ++++++++++++------- .../onefuzz-agent/src/local/libfuzzer.rs | 3 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/agent/onefuzz-agent/src/local/generic_analysis.rs b/src/agent/onefuzz-agent/src/local/generic_analysis.rs index f7ff604baa..6cd1976dbc 100644 --- a/src/agent/onefuzz-agent/src/local/generic_analysis.rs +++ b/src/agent/onefuzz-agent/src/local/generic_analysis.rs @@ -60,7 +60,7 @@ pub async fn run(args: &clap::ArgMatches<'_>) -> Result<()> { run_analysis(config).await } -pub fn build_shared_args() -> Vec> { +pub fn build_shared_args(required_task: bool) -> Vec> { vec![ Arg::with_name(TARGET_EXE) .long(TARGET_EXE) @@ -68,37 +68,47 @@ pub fn build_shared_args() -> Vec> { .required(true), Arg::with_name(TARGET_ENV) .long(TARGET_ENV) + .requires(TARGET_EXE) .takes_value(true) .multiple(true), Arg::with_name(TARGET_OPTIONS) - .default_value("{input}") .long(TARGET_OPTIONS) .takes_value(true) + .default_value("{input}") .value_delimiter(" ") .help("Use a quoted string with space separation to denote multiple arguments"), Arg::with_name(CRASHES_DIR) .long(CRASHES_DIR) - .takes_value(true) - .required(true), - Arg::with_name(ANALYZER_EXE) - .takes_value(true) - .required(true), + .takes_value(true), Arg::with_name(ANALYZER_OPTIONS) + .long(ANALYZER_OPTIONS) + .requires(ANALYZER_EXE) .takes_value(true) .value_delimiter(" ") .help("Use a quoted string with space separation to denote multiple arguments"), Arg::with_name(ANALYZER_ENV) + .long(ANALYZER_ENV) + .requires(ANALYZER_EXE) .takes_value(true) .multiple(true), + Arg::with_name(TOOLS_DIR).long(TOOLS_DIR).takes_value(true), + Arg::with_name(ANALYZER_EXE) + .long(ANALYZER_EXE) + .takes_value(true) + .requires(ANALYSIS_DIR) + .requires(CRASHES_DIR) + .required(required_task), Arg::with_name(ANALYSIS_DIR) + .long(ANALYSIS_DIR) .takes_value(true) - .required(true), - Arg::with_name(TOOLS_DIR).takes_value(true).required(false), + .requires(ANALYZER_EXE) + .requires(CRASHES_DIR) + .required(required_task), ] } pub fn args(name: &'static str) -> App<'static, 'static> { SubCommand::with_name(name) .about("execute a local-only generic analysis") - .args(&build_shared_args()) + .args(&build_shared_args(true)) } diff --git a/src/agent/onefuzz-agent/src/local/libfuzzer.rs b/src/agent/onefuzz-agent/src/local/libfuzzer.rs index 5ea7c5881b..ae3596735c 100644 --- a/src/agent/onefuzz-agent/src/local/libfuzzer.rs +++ b/src/agent/onefuzz-agent/src/local/libfuzzer.rs @@ -7,7 +7,7 @@ use crate::{ build_common_config, wait_for_dir, DirectoryMonitorQueue, ANALYZER_EXE, COVERAGE_DIR, UNIQUE_REPORTS_DIR, }, - generic_analysis::build_analysis_config, + generic_analysis::{build_analysis_config, build_shared_args as build_analysis_args}, libfuzzer_coverage::{build_coverage_config, build_shared_args as build_coverage_args}, libfuzzer_crash_report::{build_report_config, build_shared_args as build_crash_args}, libfuzzer_fuzz::{build_fuzz_config, build_shared_args as build_fuzz_args}, @@ -109,6 +109,7 @@ pub fn args(name: &'static str) -> App<'static, 'static> { for args in &[ build_fuzz_args(), build_crash_args(), + build_analysis_args(false), build_coverage_args(true), ] { for arg in args {