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

Commit 8fc2f83

Browse files
authored
Capture required args and make it match cli (#3429)
* Capture required args and make it match cli * Match libfuzzer basic template
1 parent a551709 commit 8fc2f83

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

src/agent/onefuzz-task/src/local/example_templates/libfuzzer_basic.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,31 @@
55

66
# 2. Install llvm and export LLVM_SYMBOLIZER_PATH like we do in setup.sh
77

8+
required_args: &required_args
9+
target_exe: "REPLACE_ME" # The path to your target
10+
inputs: &inputs "REPLACE_ME" # A folder containining your inputs
11+
crashes: &crashes "REPLACE_ME" # The folder where you want the crashing inputs to be output
12+
crashdumps: "REPLACE_ME" # The folder where you want the crash dumps to be output
13+
coverage: "REPLACE_ME" # The folder where you want the code coverage to be output
14+
regression_reports: "REPLACE_ME" # The folder where you want the regression reports to be output
15+
816
target_args: &target_args
17+
<<: *required_args
918
target_env: {}
10-
target_exe: "C:\\temp\\onefuzz\\integration\\windows-libfuzzer\\fuzz.exe"
1119
target_options: []
1220

13-
inputs: &inputs "C:\\temp\\onefuzz\\integration\\windows-libfuzzer\\seeds"
14-
1521
tasks:
1622
- type: LibFuzzer
1723
<<: *target_args
18-
inputs: *inputs
19-
crashes: &crash "./crashes"
2024
readonly_inputs: []
2125
check_fuzzer_help: true
2226

23-
- type: "Report"
27+
- type: LibfuzzerRegression
2428
<<: *target_args
25-
input_queue: *crash
26-
crashes: *crash
27-
reports: "./reports"
28-
unique_reports: "./unique_reports"
29-
no_repro: "./no_repro"
29+
30+
- type: "LibfuzzerCrashReport"
31+
<<: *target_args
32+
input_queue: *crashes
3033
check_fuzzer_help: true
3134

3235
- type: "Coverage"
@@ -35,4 +38,11 @@ tasks:
3538
- "{input}"
3639
input_queue: *inputs
3740
readonly_inputs: [*inputs]
38-
coverage: "./coverage"
41+
42+
# The analysis task is optional in the libfuzzer_basic template
43+
# - type: Analysis
44+
# <<: *target_args
45+
# analysis: "REPLACE_ME" # The folder where you want the analysis results to be output
46+
# analyzer_exe: "REPLACE_ME"
47+
# analyzer_options: []
48+
# analyzer_env: {}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct Analysis {
2020
input_queue: Option<PathBuf>,
2121
crashes: Option<PathBuf>,
2222
analysis: PathBuf,
23-
tools: PathBuf,
23+
tools: Option<PathBuf>,
2424
reports: Option<PathBuf>,
2525
unique_reports: Option<PathBuf>,
2626
no_repro: Option<PathBuf>,
@@ -49,9 +49,10 @@ impl Template for Analysis {
4949
.and_then(|path| context.to_monitored_sync_dir("crashes", path).ok()),
5050

5151
analysis: context.to_monitored_sync_dir("analysis", self.analysis.clone())?,
52-
tools: context
53-
.to_monitored_sync_dir("tools", self.tools.clone())
54-
.ok(),
52+
tools: self
53+
.tools
54+
.as_ref()
55+
.and_then(|path| context.to_monitored_sync_dir("tools", path).ok()),
5556

5657
reports: self
5758
.reports

src/agent/onefuzz-task/src/local/schema.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@
126126
"analyzer_options",
127127
"target_exe",
128128
"target_options",
129-
"tools",
130129
"type"
131130
],
132131
"properties": {
@@ -182,7 +181,10 @@
182181
}
183182
},
184183
"tools": {
185-
"type": "string"
184+
"type": [
185+
"string",
186+
"null"
187+
]
186188
},
187189
"type": {
188190
"type": "string",
@@ -893,4 +895,4 @@
893895
]
894896
}
895897
}
896-
}
898+
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,10 @@ mod test {
242242
.expect("Couldn't find checked-in schema.json")
243243
.replace("\r\n", "\n");
244244

245-
println!("{}", schema_str);
246-
247-
assert_eq!(
248-
schema_str.replace('\n', ""),
249-
checked_in_schema.replace('\n', ""),
250-
"The checked-in local fuzzing schema did not match the generated schema."
251-
);
245+
if schema_str.replace('\n', "") != checked_in_schema.replace('\n', "") {
246+
std::fs::write("src/local/new.schema.json", schema_str)
247+
.expect("The schemas did not match but failed to write new schema to file.");
248+
panic!("The checked-in local fuzzing schema did not match the generated schema. The generated schema can be found at src/local/new.schema.json");
249+
}
252250
}
253251
}

0 commit comments

Comments
 (0)