mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-21 13:51:19 +00:00
Change prepare_test_result to take reference (#297)
Originally used move to avoid copying, but the copy is cheap in the normal case (no exceptions) and is more usable this way.
This commit is contained in:
@ -42,6 +42,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct DebuggerResult {
|
pub struct DebuggerResult {
|
||||||
pub exceptions: Vec<Exception>,
|
pub exceptions: Vec<Exception>,
|
||||||
pub exit_status: ExitStatus,
|
pub exit_status: ExitStatus,
|
||||||
|
@ -21,7 +21,7 @@ use winapi::{
|
|||||||
/// An error detected by ASAN.
|
/// An error detected by ASAN.
|
||||||
///
|
///
|
||||||
/// These kinds are based on strings output by the lldb ASAN plugin, unrecognized errors should use `UnknownAsanError`.
|
/// These kinds are based on strings output by the lldb ASAN plugin, unrecognized errors should use `UnknownAsanError`.
|
||||||
#[derive(Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum AsanError {
|
pub enum AsanError {
|
||||||
UnknownAsanError,
|
UnknownAsanError,
|
||||||
HeapUseAfterFree,
|
HeapUseAfterFree,
|
||||||
|
@ -97,6 +97,7 @@ fn generic_exception(exception_record: &EXCEPTION_RECORD) -> Option<ExceptionCod
|
|||||||
|
|
||||||
/// A friendly description of the exception based on the exception code and other
|
/// A friendly description of the exception based on the exception code and other
|
||||||
/// parameters available to the debugger when the exception was raised.
|
/// parameters available to the debugger when the exception was raised.
|
||||||
|
#[derive(Clone)]
|
||||||
pub enum ExceptionDescription {
|
pub enum ExceptionDescription {
|
||||||
/// A generic exception with no additional details.
|
/// A generic exception with no additional details.
|
||||||
GenericException(ExceptionCode),
|
GenericException(ExceptionCode),
|
||||||
@ -196,12 +197,14 @@ pub fn new_test_result(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The file and line number for frame in the calls stack.
|
/// The file and line number for frame in the calls stack.
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct FileInfo {
|
pub struct FileInfo {
|
||||||
pub file: String,
|
pub file: String,
|
||||||
pub line: u32,
|
pub line: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The location within a function for a call stack entry.
|
/// The location within a function for a call stack entry.
|
||||||
|
#[derive(Clone)]
|
||||||
pub enum DebugFunctionLocation {
|
pub enum DebugFunctionLocation {
|
||||||
/// If symbol information is available, we use the file/line numbers for stability across builds.
|
/// If symbol information is available, we use the file/line numbers for stability across builds.
|
||||||
FileInfo(FileInfo),
|
FileInfo(FileInfo),
|
||||||
@ -238,6 +241,7 @@ impl<'a> From<&'a stack::DebugFunctionLocation> for DebugFunctionLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A stack frame for reporting where an exception or other bug occurs.
|
/// A stack frame for reporting where an exception or other bug occurs.
|
||||||
|
#[derive(Clone)]
|
||||||
pub enum DebugStackFrame {
|
pub enum DebugStackFrame {
|
||||||
Frame {
|
Frame {
|
||||||
/// The name of the function (if available via symbols or exports) or possibly something else like a
|
/// The name of the function (if available via symbols or exports) or possibly something else like a
|
||||||
@ -281,6 +285,7 @@ impl<'a> From<&'a stack::DebugStackFrame> for DebugStackFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The details of an exception observed by the execution engine.
|
/// The details of an exception observed by the execution engine.
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct Exception {
|
pub struct Exception {
|
||||||
/// The win32 exception code.
|
/// The win32 exception code.
|
||||||
pub exception_code: u32,
|
pub exception_code: u32,
|
||||||
@ -316,7 +321,7 @@ impl fmt::Display for Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// How did the program exit - normally (so we have a proper exit code) or was it terminated?
|
/// How did the program exit - normally (so we have a proper exit code) or was it terminated?
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
pub enum ExitStatus {
|
pub enum ExitStatus {
|
||||||
/// The exit code returned from the process.
|
/// The exit code returned from the process.
|
||||||
Code(i32),
|
Code(i32),
|
||||||
@ -363,6 +368,7 @@ impl fmt::Display for ExitStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A fuzzer or execution engine sends this message to a back end to report the bugs found for a single input.
|
/// A fuzzer or execution engine sends this message to a back end to report the bugs found for a single input.
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct TestResult {
|
pub struct TestResult {
|
||||||
/// The input filename that results in the bugs_found.
|
/// The input filename that results in the bugs_found.
|
||||||
pub input_file: String,
|
pub input_file: String,
|
||||||
@ -401,7 +407,7 @@ impl TestResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// This is a non-exhaustive list of exceptions that might be raised in a program.
|
/// This is a non-exhaustive list of exceptions that might be raised in a program.
|
||||||
#[derive(Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum ExceptionCode {
|
pub enum ExceptionCode {
|
||||||
UnknownExceptionCode,
|
UnknownExceptionCode,
|
||||||
UnknownApplicationVerifierStop,
|
UnknownApplicationVerifierStop,
|
||||||
|
@ -18,7 +18,7 @@ use winapi::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Errors reported via the VC++ /RTC compiler flag, as defined in vctruntime\inc\rtcapi.h
|
/// Errors reported via the VC++ /RTC compiler flag, as defined in vctruntime\inc\rtcapi.h
|
||||||
#[derive(Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum VcppRtcError {
|
pub enum VcppRtcError {
|
||||||
UnknownRtcError,
|
UnknownRtcError,
|
||||||
/// _RTC_CORRUPT_STACK (stack memory corrupted)
|
/// _RTC_CORRUPT_STACK (stack memory corrupted)
|
||||||
|
@ -114,7 +114,7 @@ fn exception_stop_from_u32(code: u32) -> ExceptionStop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A bug detected by enabling `handles` in application verifier.
|
/// A bug detected by enabling `handles` in application verifier.
|
||||||
#[derive(Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum HandlesStop {
|
pub enum HandlesStop {
|
||||||
InvalidHandleStop,
|
InvalidHandleStop,
|
||||||
InvalidTlsValue,
|
InvalidTlsValue,
|
||||||
@ -125,7 +125,7 @@ pub enum HandlesStop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A bug detected by enabling `heaps` in application verifier.
|
/// A bug detected by enabling `heaps` in application verifier.
|
||||||
#[derive(Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum HeapStop {
|
pub enum HeapStop {
|
||||||
UnknownError,
|
UnknownError,
|
||||||
AccessViolation,
|
AccessViolation,
|
||||||
@ -150,7 +150,7 @@ pub enum HeapStop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A bug detected by enabling `leak` in application verifier.
|
/// A bug detected by enabling `leak` in application verifier.
|
||||||
#[derive(Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum LeakStop {
|
pub enum LeakStop {
|
||||||
Allocation,
|
Allocation,
|
||||||
Handle,
|
Handle,
|
||||||
@ -165,7 +165,7 @@ pub enum LeakStop {
|
|||||||
///
|
///
|
||||||
/// We don't enable this option normally because it only detects first chance exceptions which are already
|
/// We don't enable this option normally because it only detects first chance exceptions which are already
|
||||||
/// reported and this option ends up reporting the same issue a second time with a different stack.
|
/// reported and this option ends up reporting the same issue a second time with a different stack.
|
||||||
#[derive(Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum ExceptionStop {
|
pub enum ExceptionStop {
|
||||||
FirstChanceAccessViolationCode,
|
FirstChanceAccessViolationCode,
|
||||||
}
|
}
|
||||||
@ -174,6 +174,7 @@ pub enum ExceptionStop {
|
|||||||
/// information in understanding the type of bug detected.
|
/// information in understanding the type of bug detected.
|
||||||
///
|
///
|
||||||
/// This message encapsulates the most important kinds of bugs detected by application verifier when fuzzing.
|
/// This message encapsulates the most important kinds of bugs detected by application verifier when fuzzing.
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum VerifierStop {
|
pub enum VerifierStop {
|
||||||
/// A bug detected by enabling `heaps` in application verifier.
|
/// A bug detected by enabling `heaps` in application verifier.
|
||||||
Heap(HeapStop),
|
Heap(HeapStop),
|
||||||
|
@ -206,7 +206,7 @@ impl Tester {
|
|||||||
// and return a collection of results to possibly be reported.
|
// and return a collection of results to possibly be reported.
|
||||||
let mut test_results = vec![];
|
let mut test_results = vec![];
|
||||||
for result in results {
|
for result in results {
|
||||||
match self.prepare_test_result(result) {
|
match self.prepare_test_result(&result) {
|
||||||
Ok(Some(result)) => test_results.push(result),
|
Ok(Some(result)) => test_results.push(result),
|
||||||
Ok(None) => {}
|
Ok(None) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -228,7 +228,7 @@ impl Tester {
|
|||||||
let summary = Summary::from(&test_result.debugger_result);
|
let summary = Summary::from(&test_result.debugger_result);
|
||||||
|
|
||||||
let mut results = vec![];
|
let mut results = vec![];
|
||||||
if let Some(result) = self.prepare_test_result(test_result)? {
|
if let Some(result) = self.prepare_test_result(&test_result)? {
|
||||||
results.push(result);
|
results.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,10 +337,10 @@ impl Tester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prepare_test_result(&self, result: InputTestResult) -> Result<Option<TestResult>> {
|
pub fn prepare_test_result(&self, result: &InputTestResult) -> Result<Option<TestResult>> {
|
||||||
if !result.debugger_result.any_crashes_or_timed_out() {
|
if !result.debugger_result.any_crashes_or_timed_out() {
|
||||||
return Ok(Some(new_test_result(
|
return Ok(Some(new_test_result(
|
||||||
result.debugger_result,
|
result.debugger_result.clone(),
|
||||||
&result.input_path,
|
&result.input_path,
|
||||||
Path::new(""),
|
Path::new(""),
|
||||||
)));
|
)));
|
||||||
@ -396,7 +396,7 @@ impl Tester {
|
|||||||
));
|
));
|
||||||
self.create_test_failure_artifacts(&logs_dir, &result, &copied_file)?;
|
self.create_test_failure_artifacts(&logs_dir, &result, &copied_file)?;
|
||||||
Ok(Some(new_test_result(
|
Ok(Some(new_test_result(
|
||||||
result.debugger_result,
|
result.debugger_result.clone(),
|
||||||
&result.input_path,
|
&result.input_path,
|
||||||
&logs_dir,
|
&logs_dir,
|
||||||
)))
|
)))
|
||||||
|
Reference in New Issue
Block a user