pub trait CommandConfigurator<EM, I: Input, S, Z>: Sized + Debug {
    fn spawn_child(
        &mut self,
        fuzzer: &mut Z,
        state: &mut S,
        mgr: &mut EM,
        input: &I
    ) -> Result<Child, Error>; fn into_executor<OT: Debug>(
        self,
        observers: OT
    ) -> CommandExecutor<EM, I, OT, S, Self, Z>
    where
        OT: ObserversTuple<I, S>
, { ... } }
Expand description

A CommandConfigurator takes care of creating and spawning a std::process::Command for the CommandExecutor.

Example

use std::{io::Write, process::{Stdio, Command, Child}};
use libafl::{Error, inputs::{Input, HasTargetBytes}, executors::{Executor, command::CommandConfigurator}};
#[derive(Debug)]
struct MyExecutor;

impl<EM, I: Input + HasTargetBytes, S, Z> CommandConfigurator<EM, I, S, Z> for MyExecutor {
    fn spawn_child(
       &mut self,
       fuzzer: &mut Z,
       state: &mut S,
       mgr: &mut EM,
       input: &I,
    ) -> Result<Child, Error> {
        let mut command = Command::new("../if");
        command
            .stdin(Stdio::piped())
            .stdout(Stdio::null())
            .stderr(Stdio::null());

        let child = command.spawn().expect("failed to start process");
        let mut stdin = child.stdin.as_ref().unwrap();
        stdin.write_all(input.target_bytes().as_slice())?;
        Ok(child)
    }
}

fn make_executor<EM, I: Input + HasTargetBytes, S, Z>() -> impl Executor<EM, I, S, Z> {
    MyExecutor.into_executor(())
}

Required methods

Spawns a new process with the given configuration.

Provided methods

Create an Executor from this CommandConfigurator.

Implementors