check libfuzzer -help=1 prior to starting the heartbeat (#528)

This commit is contained in:
bmc-msft
2021-02-09 21:20:36 -05:00
committed by GitHub
parent af447898d8
commit 4900b5a920
4 changed files with 28 additions and 6 deletions

View File

@ -21,6 +21,7 @@ use tokio::task::spawn;
pub async fn run(args: &clap::ArgMatches<'_>) -> Result<()> {
let fuzz_config = build_fuzz_config(args)?;
let fuzzer = LibFuzzerFuzzTask::new(fuzz_config)?;
fuzzer.check_libfuzzer().await?;
let fuzz_task = spawn(async move { fuzzer.run().await });
let report_config = build_report_config(args)?;

View File

@ -162,7 +162,7 @@ impl Config {
match self {
Config::LibFuzzerFuzz(config) => {
fuzz::libfuzzer_fuzz::LibFuzzerFuzzTask::new(config)?
.run()
.managed_run()
.await
}
Config::LibFuzzerReport(config) => {

View File

@ -106,19 +106,22 @@ impl CoverageTask {
Ok(())
}
pub async fn managed_run(&mut self) -> Result<()> {
info!("starting libFuzzer coverage task");
async fn check_libfuzzer(&self) -> Result<()> {
if self.config.check_fuzzer_help {
let target = LibFuzzer::new(
let fuzzer = LibFuzzer::new(
&self.config.target_exe,
&self.config.target_options,
&self.config.target_env,
&self.config.common.setup_dir,
);
target.check_help().await?;
fuzzer.check_help().await?;
}
Ok(())
}
pub async fn managed_run(&mut self) -> Result<()> {
info!("starting libFuzzer coverage task");
self.check_libfuzzer().await?;
self.config.coverage.init_pull().await?;
self.process().await
}

View File

@ -80,6 +80,11 @@ impl LibFuzzerFuzzTask {
}
}
pub async fn managed_run(&self) -> Result<()> {
self.check_libfuzzer().await?;
self.run().await
}
pub async fn run(&self) -> Result<()> {
self.init_directories().await?;
@ -98,6 +103,19 @@ impl LibFuzzerFuzzTask {
Ok(())
}
pub async fn check_libfuzzer(&self) -> Result<()> {
if self.config.check_fuzzer_help {
let fuzzer = LibFuzzer::new(
&self.config.target_exe,
&self.config.target_options,
&self.config.target_env,
&self.config.common.setup_dir,
);
fuzzer.check_help().await?;
}
Ok(())
}
pub async fn run_fuzzers(&self, stats_sender: Option<&StatsSender>) -> Result<()> {
let fuzzers: Vec<_> = (0..self.workers())
.map(|id| self.start_fuzzer_monitor(id, stats_sender))