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

Commit

Permalink
Capture required args and make it match cli (#3429)
Browse files Browse the repository at this point in the history
* Capture required args and make it match cli

* Match libfuzzer basic template
  • Loading branch information
tevoinea authored Aug 21, 2023
1 parent a551709 commit 8fc2f83
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,31 @@

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

required_args: &required_args
target_exe: "REPLACE_ME" # The path to your target
inputs: &inputs "REPLACE_ME" # A folder containining your inputs
crashes: &crashes "REPLACE_ME" # The folder where you want the crashing inputs to be output
crashdumps: "REPLACE_ME" # The folder where you want the crash dumps to be output
coverage: "REPLACE_ME" # The folder where you want the code coverage to be output
regression_reports: "REPLACE_ME" # The folder where you want the regression reports to be output

target_args: &target_args
<<: *required_args
target_env: {}
target_exe: "C:\\temp\\onefuzz\\integration\\windows-libfuzzer\\fuzz.exe"
target_options: []

inputs: &inputs "C:\\temp\\onefuzz\\integration\\windows-libfuzzer\\seeds"

tasks:
- type: LibFuzzer
<<: *target_args
inputs: *inputs
crashes: &crash "./crashes"
readonly_inputs: []
check_fuzzer_help: true

- type: "Report"
- type: LibfuzzerRegression
<<: *target_args
input_queue: *crash
crashes: *crash
reports: "./reports"
unique_reports: "./unique_reports"
no_repro: "./no_repro"

- type: "LibfuzzerCrashReport"
<<: *target_args
input_queue: *crashes
check_fuzzer_help: true

- type: "Coverage"
Expand All @@ -35,4 +38,11 @@ tasks:
- "{input}"
input_queue: *inputs
readonly_inputs: [*inputs]
coverage: "./coverage"

# The analysis task is optional in the libfuzzer_basic template
# - type: Analysis
# <<: *target_args
# analysis: "REPLACE_ME" # The folder where you want the analysis results to be output
# analyzer_exe: "REPLACE_ME"
# analyzer_options: []
# analyzer_env: {}
9 changes: 5 additions & 4 deletions src/agent/onefuzz-task/src/local/generic_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Analysis {
input_queue: Option<PathBuf>,
crashes: Option<PathBuf>,
analysis: PathBuf,
tools: PathBuf,
tools: Option<PathBuf>,
reports: Option<PathBuf>,
unique_reports: Option<PathBuf>,
no_repro: Option<PathBuf>,
Expand Down Expand Up @@ -49,9 +49,10 @@ impl Template for Analysis {
.and_then(|path| context.to_monitored_sync_dir("crashes", path).ok()),

analysis: context.to_monitored_sync_dir("analysis", self.analysis.clone())?,
tools: context
.to_monitored_sync_dir("tools", self.tools.clone())
.ok(),
tools: self
.tools
.as_ref()
.and_then(|path| context.to_monitored_sync_dir("tools", path).ok()),

reports: self
.reports
Expand Down
8 changes: 5 additions & 3 deletions src/agent/onefuzz-task/src/local/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
"analyzer_options",
"target_exe",
"target_options",
"tools",
"type"
],
"properties": {
Expand Down Expand Up @@ -182,7 +181,10 @@
}
},
"tools": {
"type": "string"
"type": [
"string",
"null"
]
},
"type": {
"type": "string",
Expand Down Expand Up @@ -893,4 +895,4 @@
]
}
}
}
}
12 changes: 5 additions & 7 deletions src/agent/onefuzz-task/src/local/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,10 @@ mod test {
.expect("Couldn't find checked-in schema.json")
.replace("\r\n", "\n");

println!("{}", schema_str);

assert_eq!(
schema_str.replace('\n', ""),
checked_in_schema.replace('\n', ""),
"The checked-in local fuzzing schema did not match the generated schema."
);
if schema_str.replace('\n', "") != checked_in_schema.replace('\n', "") {
std::fs::write("src/local/new.schema.json", schema_str)
.expect("The schemas did not match but failed to write new schema to file.");
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");
}
}
}

0 comments on commit 8fc2f83

Please sign in to comment.