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

Commit

Permalink
Match libfuzzer basic template
Browse files Browse the repository at this point in the history
  • Loading branch information
tevoinea committed Aug 18, 2023
1 parent 947d03a commit 558d555
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ required_args: &required_args
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
Expand All @@ -23,6 +24,9 @@ tasks:
readonly_inputs: []
check_fuzzer_help: true

- type: LibfuzzerRegression
<<: *target_args

- type: "LibfuzzerCrashReport"
<<: *target_args
input_queue: *crashes
Expand All @@ -34,3 +38,11 @@ tasks:
- "{input}"
input_queue: *inputs
readonly_inputs: [*inputs]

# 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 @@ -146,7 +146,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 @@ -175,9 +175,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 @@ -241,12 +241,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 558d555

Please sign in to comment.