-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathadd_seeds.rs
More file actions
45 lines (40 loc) · 1.47 KB
/
add_seeds.rs
File metadata and controls
45 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate::*;
use anyhow::bail;
use std::{env, process};
impl AddSeeds {
pub fn add_seeds(&self) -> Result<(), anyhow::Error> {
eprintln!("Adding seeds to AFL");
let req = semver::VersionReq::parse(">=0.14.5").unwrap();
let cargo = env::var("CARGO").unwrap_or_else(|_| String::from("cargo"));
let afl_version = process::Command::new(&cargo)
.args(["afl", "--version"])
.output()
.context("could not run `cargo afl --version`")?;
if !std::str::from_utf8(afl_version.stdout.as_slice())
.unwrap_or_default()
.split_whitespace()
.nth(1)
.context("could not get afl version from stdout")
.map(semver::Version::parse)
.context("could not parse cargo-afl version")?
.map(|v| req.matches(&v))?
{
bail!("Outdated version of cargo-afl, ziggy needs >=0.14.5, please run `cargo install cargo-afl`");
}
let target = find_target(&self.target)?;
let input = self.input.display().to_string();
let cargo = env::var("CARGO").unwrap_or_else(|_| String::from("cargo"));
process::Command::new(&cargo)
.args([
"afl",
"addseeds",
"-o",
&format!("{}/{target}/afl", self.ziggy_output.display()),
"-i",
&input,
])
.spawn()?
.wait()?;
Ok(())
}
}