/// Run fuzzing on multiple target matching the filter option
Run fuzzing on multiple target matching the filter option
Run fuzzing on multiple target matching the filter option
fn run_continuously(
    filter: Option<String>,
    fuzzer: fuzzers::Fuzzer,
    config: fuzzers::FuzzerConfig,
    infinite: bool,
) -> Result<(), Error> {
    let run = |target: &str| -> Result<(), Error> {
        let target = match targets::Targets::iter().find(|x| x.name() == target) {
            None => bail!(
                "Don't know target `{}`. {}",
                target,
                if let Some(alt) = utils::did_you_mean(&target, &targets::get_targets()) {
                    format!("Did you mean `{}`?", alt)
                } else {
                    "".into()
                }
            ),
            Some(t) => t,
        };
        use fuzzers::Fuzzer::*;
        match fuzzer {
            Afl => {
                let hfuzz = rust_fuzzers::FuzzerAfl::new(config.clone())?;
                hfuzz.run(target)?;
            }
            Honggfuzz => {
                let hfuzz = rust_fuzzers::FuzzerHfuzz::new(config.clone())?;
                hfuzz.run(target)?;
            }
            Libfuzzer => {
                let hfuzz = rust_fuzzers::FuzzerLibfuzzer::new(config.clone())?;
                hfuzz.run(target)?;
            }
        }
        Ok(())
    };
    let targets = targets::get_targets();
    let targets = targets
        .iter()
        .filter(|x| filter.as_ref().map(|f| x.contains(f)).unwrap_or(true));
    'cycle: loop {
        'targets_pass: for target in targets.clone() {
            if let Err(e) = run(target) {
                match e.downcast::<fuzzers::FuzzerQuit>() {
                    Ok(_) => {
                        println!("Fuzzer failed so we'll continue with the next one");
                        continue 'targets_pass;
                    }
                    Err(other_error) => return Err(other_error),
                }
            }
        }
        if !infinite {
            break 'cycle;
        }
    }
    Ok(())
}
fn run_continuously ( filter : Option < String > , fuzzer : fuzzers :: Fuzzer , config : fuzzers :: FuzzerConfig , infinite : bool , ) -> Result < ( ) , Error > { let run = | target : & str | -> Result < ( ) , Error > { let target = match targets :: Targets :: iter ( ) . find ( | x | x . name ( ) == target ) { None => bail ! ( " " target if let Some ( alt ) utils did_you_mean ( target targets get_targets ( ) ) { format ( " " alt ) } else { " " into ( ) } ) , Some ( t ) => t , } ; use fuzzers :: Fuzzer :: * ; match fuzzer { Afl => { let hfuzz = rust_fuzzers :: FuzzerAfl :: new ( config . clone ( ) ) ? ; hfuzz . run ( target ) ? ; } Honggfuzz => { let hfuzz = rust_fuzzers :: FuzzerHfuzz :: new ( config . clone ( ) ) ? ; hfuzz . run ( target ) ? ; } Libfuzzer => { let hfuzz = rust_fuzzers :: FuzzerLibfuzzer :: new ( config . clone ( ) ) ? ; hfuzz . run ( target ) ? ; } } Ok ( ( ) ) } ; let targets = targets :: get_targets ( ) ; let targets = targets . iter ( ) . filter ( | x | filter . as_ref ( ) . map ( | f | x . contains ( f ) ) . unwrap_or ( true ) ) ; ' cycle : loop { ' targets_pass : for target in targets . clone ( ) { if let Err ( e ) = run ( target ) { match e . downcast :: < fuzzers :: FuzzerQuit > ( ) { Ok ( _ ) => { println ! ( " " ) ; continue ' targets_pass ; } Err ( other_error ) => return Err ( other_error ) , } } } if ! infinite { break ' cycle ; } } Ok ( ( ) ) }
Run fuzzing on multiple target matching the filter option
Run fuzzing on multiple target matching the filter option
filter
Option<String>
fuzzer
fuzzers::Fuzzer
config
fuzzers::FuzzerConfig
infinite
bool