Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 02d9c0d

Browse files
chkeitatevoinea
andauthored
Local refactoring (#3117)
* WIP local mode refactoring * . * Adding coverage * Updated schema and basic template to use anchors * Libfuzzer with template works * Coverage task works * fixup * bug fixes * format * format * update the basic yaml * update libfuzzer basic * remove schema.yml --------- Co-authored-by: Teo Voinea <58236992+tevoinea@users.noreply.github.com>
1 parent 8fc878f commit 02d9c0d

File tree

8 files changed

+884
-7
lines changed

8 files changed

+884
-7
lines changed

src/agent/Cargo.lock

Lines changed: 61 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/agent/onefuzz-task/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ reqwest = { version = "0.11", features = [
3636
], default-features = false }
3737
serde = "1.0"
3838
serde_json = "1.0"
39+
serde_yaml = "0.9.21"
3940
onefuzz = { path = "../onefuzz" }
4041
onefuzz-telemetry = { path = "../onefuzz-telemetry" }
4142
path-absolutize = "3.1"
@@ -71,6 +72,7 @@ azure_storage_blobs = { version = "0.13", default-features = false, features = [
7172
] }
7273

7374
flexi_logger = "0.25"
75+
schemars = {version = "0.8.12", features = ["uuid1"]}
7476

7577
[dev-dependencies]
7678
pretty_assertions = "1.4"

src/agent/onefuzz-task/src/local/cmd.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ use crate::local::{
1010
};
1111
use anyhow::{Context, Result};
1212
use clap::{Arg, ArgAction, Command};
13-
use std::str::FromStr;
1413
use std::time::Duration;
14+
use std::{path::PathBuf, str::FromStr};
1515
use strum::IntoEnumIterator;
1616
use strum_macros::{EnumIter, EnumString, IntoStaticStr};
1717
use tokio::{select, time::timeout};
1818

19+
use super::template;
20+
1921
#[derive(Debug, PartialEq, Eq, EnumString, IntoStaticStr, EnumIter)]
2022
#[strum(serialize_all = "kebab-case")]
2123
enum Commands {
@@ -32,6 +34,7 @@ enum Commands {
3234
Generator,
3335
Analysis,
3436
TestInput,
37+
Template,
3538
}
3639

3740
const TIMEOUT: &str = "timeout";
@@ -82,6 +85,13 @@ pub async fn run(args: clap::ArgMatches) -> Result<()> {
8285
Commands::Generator => generic_generator::run(&sub_args, event_sender).await,
8386
Commands::Analysis => generic_analysis::run(&sub_args, event_sender).await,
8487
Commands::TestInput => test_input::run(&sub_args, event_sender).await,
88+
Commands::Template => {
89+
let config = sub_args
90+
.get_one::<PathBuf>("config")
91+
.expect("is marked required");
92+
93+
template::launch(config, event_sender).await
94+
}
8595
}
8696
});
8797

@@ -126,6 +136,7 @@ pub fn args(name: &'static str) -> Command {
126136
);
127137

128138
for subcommand in Commands::iter() {
139+
let add_common = subcommand != Commands::Template;
129140
let app = match subcommand {
130141
#[cfg(any(target_os = "linux", target_os = "windows"))]
131142
Commands::Coverage => coverage::args(subcommand.into()),
@@ -140,8 +151,18 @@ pub fn args(name: &'static str) -> Command {
140151
Commands::Generator => generic_generator::args(subcommand.into()),
141152
Commands::Analysis => generic_analysis::args(subcommand.into()),
142153
Commands::TestInput => test_input::args(subcommand.into()),
154+
Commands::Template => Command::new("template")
155+
.about("uses the template to generate a run")
156+
.args(vec![Arg::new("config")
157+
.value_parser(value_parser!(std::path::PathBuf))
158+
.required(true)]),
143159
};
144-
cmd = cmd.subcommand(add_common_config(app));
160+
161+
cmd = if add_common {
162+
cmd.subcommand(add_common_config(app))
163+
} else {
164+
cmd.subcommand(app)
165+
}
145166
}
146167

147168
cmd
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# yaml-language-server: $schema=schema.json
2+
3+
# What I had to do to get this working:
4+
# 1. Update target_exe to point to the target exe
5+
6+
# 2. Install llvm and export LLVM_SYMBOLIZER_PATH like we do in setup.sh
7+
8+
target_args: &target_args
9+
target_env: {}
10+
target_exe: "C:\\temp\\onefuzz\\integration\\windows-libfuzzer\\fuzz.exe"
11+
target_options: []
12+
13+
inputs: &inputs "C:\\temp\\onefuzz\\integration\\windows-libfuzzer\\seeds"
14+
15+
tasks:
16+
- type: LibFuzzer
17+
<<: *target_args
18+
inputs: *inputs
19+
crashes: &crash "./crashes"
20+
readonly_inputs: []
21+
check_fuzzer_help: true
22+
23+
- type: "Report"
24+
<<: *target_args
25+
input_queue: *crash
26+
crashes: *crash
27+
reports: "./reports"
28+
unique_reports: "./unique_reports"
29+
no_repro: "./noe_repro"
30+
check_fuzzer_help: true
31+
32+
- type: "Coverage"
33+
<<: *target_args
34+
target_options:
35+
- "{input}"
36+
input_queue: *inputs
37+
readonly_inputs: [*inputs]
38+
coverage: "./coverage"
39+
40+
# - type: Analysis
41+
# <<: *target_args
42+
43+

src/agent/onefuzz-task/src/local/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ pub mod libfuzzer_merge;
1515
pub mod libfuzzer_regression;
1616
pub mod libfuzzer_test_input;
1717
pub mod radamsa;
18+
pub mod template;
1819
pub mod test_input;
1920
pub mod tui;

0 commit comments

Comments
 (0)