forked from microsoft/onefuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a single-shot crash report utility (microsoft#703)
Adds `test-input` and `test-input-libfuzzer`, which print the CrashTestResult in json form. While many of the existing tasks make sense running in a managed loop, crash report generation is something that having a single one-off is useful. Example: ``` $ onefuzz-agent local test-input /tmp/fuzz.exe /tmp/crash.txt { "crash_report": { "input_sha256": "a35b3ce1038750e9175a6dcd3f64c8d4e85720affb12cc11f5d0b6889274d06e", "executable": "/tmp/fuzz.exe", "crash_type": "SIGABRT", "crash_site": "0x7f0d9d4ad18b in gsignal+0xcb (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x4618b)", "call_stack": [ "#0 0x7f0d9d4ad18b in gsignal+0xcb (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x4618b)", "#1 0x7f0d9d48c859 in abort+0x12b (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x25859)", "#2 0x7f0d9d4f73ee in <unknown> (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x903ee)", "#3 0x7f0d9d599b4a in __fortify_fail+0x2a (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x132b4a)", "#4 0x7f0d9d5983e6 in __chk_fail+0x16 (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x1313e6)", "#5 0x7f0d9d597e09 in __strncpy_chk+0x19 (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x130e09)", "#6 0x400a54 in from_file+0xa4 (/tmp/fuzz.exe+0xa54)", "#7 0x7f0d9d48e0b3 in __libc_start_main+0xf3 (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x270b3)", "#8 0x40077a in _start+0x2a (/tmp/fuzz.exe+0x77a)" ], "call_stack_sha256": "6906234fb235690cc2843a1a55f49ff68b424e54bec55f9b8258415d97b3e638", "task_id": "00000000-0000-0000-0000-000000000000", "job_id": "00000000-0000-0000-0000-000000000000" } } $ ```
- Loading branch information
Showing
15 changed files
with
207 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
use crate::{ | ||
local::common::{ | ||
build_common_config, get_cmd_arg, get_cmd_env, CmdType, CHECK_RETRY_COUNT, TARGET_ENV, | ||
TARGET_EXE, TARGET_OPTIONS, TARGET_TIMEOUT, | ||
}, | ||
tasks::report::libfuzzer_report::{test_input, TestInputArgs}, | ||
}; | ||
use anyhow::Result; | ||
use clap::{App, Arg, SubCommand}; | ||
use std::path::PathBuf; | ||
|
||
pub async fn run(args: &clap::ArgMatches<'_>) -> Result<()> { | ||
let common = build_common_config(args, true)?; | ||
|
||
let target_exe = value_t!(args, TARGET_EXE, PathBuf)?; | ||
let target_env = get_cmd_env(CmdType::Target, args)?; | ||
let target_options = get_cmd_arg(CmdType::Target, args); | ||
let input = value_t!(args, "input", PathBuf)?; | ||
let target_timeout = value_t!(args, TARGET_TIMEOUT, u64).ok(); | ||
let check_retry_count = value_t!(args, CHECK_RETRY_COUNT, u64)?; | ||
|
||
let config = TestInputArgs { | ||
target_exe: &target_exe.as_path(), | ||
target_env: &target_env, | ||
target_options: &target_options, | ||
input_url: None, | ||
input: input.as_path(), | ||
job_id: common.job_id, | ||
task_id: common.task_id, | ||
target_timeout, | ||
check_retry_count, | ||
setup_dir: &common.setup_dir, | ||
minimized_stack_depth: None, | ||
}; | ||
|
||
let result = test_input(config).await?; | ||
println!("{}", serde_json::to_string_pretty(&result)?); | ||
Ok(()) | ||
} | ||
|
||
pub fn build_shared_args() -> Vec<Arg<'static, 'static>> { | ||
vec![ | ||
Arg::with_name(TARGET_EXE).takes_value(true).required(true), | ||
Arg::with_name("input").takes_value(true).required(true), | ||
Arg::with_name(TARGET_ENV) | ||
.long(TARGET_ENV) | ||
.takes_value(true) | ||
.multiple(true), | ||
Arg::with_name(TARGET_OPTIONS) | ||
.default_value("{input}") | ||
.long(TARGET_OPTIONS) | ||
.takes_value(true) | ||
.value_delimiter(" ") | ||
.help("Use a quoted string with space separation to denote multiple arguments"), | ||
Arg::with_name(TARGET_TIMEOUT) | ||
.takes_value(true) | ||
.long(TARGET_TIMEOUT), | ||
Arg::with_name(CHECK_RETRY_COUNT) | ||
.takes_value(true) | ||
.long(CHECK_RETRY_COUNT) | ||
.default_value("0"), | ||
] | ||
} | ||
|
||
pub fn args(name: &'static str) -> App<'static, 'static> { | ||
SubCommand::with_name(name) | ||
.about("test a libfuzzer application with a specific input") | ||
.args(&build_shared_args()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
use crate::{ | ||
local::common::{ | ||
build_common_config, get_cmd_arg, get_cmd_env, CmdType, CHECK_ASAN_LOG, CHECK_RETRY_COUNT, | ||
DISABLE_CHECK_DEBUGGER, TARGET_ENV, TARGET_EXE, TARGET_OPTIONS, TARGET_TIMEOUT, | ||
}, | ||
tasks::report::generic::{test_input, TestInputArgs}, | ||
}; | ||
use anyhow::Result; | ||
use clap::{App, Arg, SubCommand}; | ||
use std::path::PathBuf; | ||
|
||
pub async fn run(args: &clap::ArgMatches<'_>) -> Result<()> { | ||
let common = build_common_config(args, false)?; | ||
|
||
let target_exe = value_t!(args, TARGET_EXE, PathBuf)?; | ||
let target_env = get_cmd_env(CmdType::Target, args)?; | ||
let target_options = get_cmd_arg(CmdType::Target, args); | ||
let input = value_t!(args, "input", PathBuf)?; | ||
let target_timeout = value_t!(args, TARGET_TIMEOUT, u64).ok(); | ||
let check_retry_count = value_t!(args, CHECK_RETRY_COUNT, u64)?; | ||
let check_asan_log = args.is_present(CHECK_ASAN_LOG); | ||
let check_debugger = !args.is_present(DISABLE_CHECK_DEBUGGER); | ||
|
||
let config = TestInputArgs { | ||
target_exe: &target_exe.as_path(), | ||
target_env: &target_env, | ||
target_options: &target_options, | ||
input_url: None, | ||
input: input.as_path(), | ||
job_id: common.job_id, | ||
task_id: common.task_id, | ||
target_timeout, | ||
check_retry_count, | ||
setup_dir: &common.setup_dir, | ||
minimized_stack_depth: None, | ||
check_asan_log, | ||
check_debugger, | ||
}; | ||
|
||
let result = test_input(config).await?; | ||
println!("{}", serde_json::to_string_pretty(&result)?); | ||
Ok(()) | ||
} | ||
|
||
pub fn build_shared_args() -> Vec<Arg<'static, 'static>> { | ||
vec![ | ||
Arg::with_name(TARGET_EXE).takes_value(true).required(true), | ||
Arg::with_name("input").takes_value(true).required(true), | ||
Arg::with_name(TARGET_ENV) | ||
.long(TARGET_ENV) | ||
.takes_value(true) | ||
.multiple(true), | ||
Arg::with_name(TARGET_OPTIONS) | ||
.default_value("{input}") | ||
.long(TARGET_OPTIONS) | ||
.takes_value(true) | ||
.value_delimiter(" ") | ||
.help("Use a quoted string with space separation to denote multiple arguments"), | ||
Arg::with_name(TARGET_TIMEOUT) | ||
.takes_value(true) | ||
.long(TARGET_TIMEOUT), | ||
Arg::with_name(CHECK_RETRY_COUNT) | ||
.takes_value(true) | ||
.long(CHECK_RETRY_COUNT) | ||
.default_value("0"), | ||
Arg::with_name(CHECK_ASAN_LOG) | ||
.takes_value(false) | ||
.long(CHECK_ASAN_LOG), | ||
Arg::with_name(DISABLE_CHECK_DEBUGGER) | ||
.takes_value(false) | ||
.long("disable_check_debugger"), | ||
] | ||
} | ||
|
||
pub fn args(name: &'static str) -> App<'static, 'static> { | ||
SubCommand::with_name(name) | ||
.about("test an application with a specific input") | ||
.args(&build_shared_args()) | ||
} |
Oops, something went wrong.