Commit Graph

106 Commits

Author SHA1 Message Date
6b7906dfb1 libfuzzer fuzzing task perf improvements (#941)
- resuse the regex to parse the output of libfuzzer
- added a cancellation notification to report_fuzzer_sys_info.
   ~~The code seems to be actively waiting this function and consuming some cpu time~~
   The notification allows us to reduce the time waiting for the fuzzing loop to terminate. 

## Summary of the Pull Request

_What is this about?_

## PR Checklist
* [ ] Applies to work item: #xxx
* [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/onefuzz) and sign the CLI.
* [ ] Tests added/passed
* [ ] Requires documentation to be updated
* [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

## Info on Pull Request

_What does this include?_

## Validation Steps Performed

_How does someone test & validate?_
2021-06-04 00:14:15 +00:00
2c72bd590f Add generic coverage task (#763)
**Todo:**
- [x] Finalize format for coverage file(s)
- [x] Add service support
- [x] Integration test
- [x] Merge #926 
- [x] Merge #929
2021-06-03 23:36:00 +00:00
e7669138c4 add an optional initial delay for heartbeats (#937)
One of the difficulties in crash repro as task is a race condition where we the client tries to connect before the cdb is running.

This makes it such that we can use the heartbeat to identify if the task has started before connecting in.

NOTE:  In this PR, it's always set to None.  See #830 for it's actual usage.  However, I split out the PR for easier review.
2021-06-01 20:08:53 +00:00
2b67c7b02f add setup_dir to generator task (#901)
fixes #848
2021-05-19 16:10:13 +00:00
ecec227c33 Remove transitive async-std dep (#892)
Now that we've updated our `tokio` version, we can easily remove this redundant async runtime dependency (and its transitive deps).
2021-05-15 18:06:41 +00:00
372c194f7a address clippy issues in latest rust release (#884) 2021-05-13 14:25:09 -04:00
54d49a973e cargo audit fix (#873) 2021-05-11 08:54:21 -04:00
85f606ab6a refactor SyncDir and blob container url (#809) 2021-04-19 17:38:58 +00:00
e413aec03d Upgrade to tokio 1.5.0 (#800)
Upgrade to tokio 1.5.0
replaced tokio::sync::mpsc:: with [flume ](https://crates.io/crates/flume) because try_recv was removed
2021-04-14 10:07:28 +00:00
3f52f34b6a Allow the local run to work without copying the synced dirs (#794)
Added an option to local run to not create a job directory
2021-04-13 23:53:37 +00:00
50ee2abf28 add basic context to every retried request (#798) 2021-04-13 17:36:46 -04:00
c570f55088 show task error details in logs (#802) 2021-04-13 17:34:15 -04:00
338a803a0d invert expect_crash_on_failure config option defaults (#792) 2021-04-12 14:08:36 -04:00
542129bd1f invert the TUI event filter (#787) 2021-04-09 19:37:17 -04:00
ef8e200438 embed coverage debugger scripts (#783) 2021-04-09 19:16:41 -04:00
a91b5aae89 don't remove inputs once processed (#788) 2021-04-09 17:41:44 -04:00
ba009cd30a combine execs/sec and iteration counts from multiple workers (#786) 2021-04-09 17:21:08 -04:00
030ab4b87f limit the amount of data recorded from libFuzzer's stderr (#785) 2021-04-09 15:44:57 -04:00
4f6432bdc3 don't refresh system stats when only reporting process stats (#784) 2021-04-09 14:12:13 -04:00
4086e7695e Wiring up the UI to the events (#776)
## Summary of the Pull Request
- The UI now receives the telemetry events
- A new section for the coverage has been added 
- All synced dir are now monitored by the UI
- Gracefully exit from the UI 


depends on #663
2021-04-09 17:05:48 +00:00
3e7b3df34f local run UI (#663)
## Summary of the Pull Request

This PR add a UI to the local run. 
- The UI currently monitors the logs and  some of the directory created (the rest will be wired in a coming PR)
- pressing 'q' will quit the PR
- By default, the job directory is deleted when the ui quits unless the parameter 'keep_job_dir' is specified
2021-04-06 21:44:37 +00:00
e21eafd135 clarify telemetry key names at the service level (#769) 2021-04-05 15:23:03 -04:00
eb7571e531 verify libfuzzer targets at the start of the task (#752) 2021-04-02 23:11:46 -04:00
f6adad3ed9 updates related to cargo clippy 1.51.0 (#730) 2021-04-01 13:08:21 -04:00
6aca32ed9c use usize for worker_id (#755) 2021-03-30 22:27:10 -04:00
5055bf6c38 add libfuzzer regression tasks to local fuzzing (#744) 2021-03-30 20:58:07 +00:00
e8ce384bd9 cleanup local job_id directory upon clean exit (#738) 2021-03-27 16:39:09 -04:00
19d19a1e0e add names for poller logging (#742) 2021-03-26 23:04:41 -04:00
b43a45187b optionally ignore dotfiles in syncdir monitors (#741) 2021-03-26 22:40:36 -04:00
fffaab2d25 change the scale of timeouts to seconds instead of minutes (#739) 2021-03-26 22:20:10 -04:00
dc9b6fa1b0 address telemetry log message locality (#736) 2021-03-26 18:45:36 -04:00
cf0d047a23 bubble out invalid messages on input queues (#731) 2021-03-26 15:50:48 +00:00
2a0365b9a2 Adding timeout to local run (#735) 2021-03-25 19:07:38 -04:00
c02ede76b3 fix local generic analysis (#729) 2021-03-24 22:03:34 -04:00
92d8299412 make asan_log optional in CrashReport (#714) 2021-03-23 02:36:20 -04:00
3113f887c4 remove generic- from the command prefixes (#710) 2021-03-22 20:39:32 -04:00
b4e0d89329 enable stack minimization for all crash dumps (#705)
This builds upon #591 to expand the stack minimization to crash reporting mechanisms.

Example (see #703 for an example without the new functionality):

```
$ onefuzz-agent local test-input /tmp/fuzz.exe /etc/passwd
{
  "crash_report": {
    "input_sha256": "a35b3ce1038750e9175a6dcd3f64c8d4e85720affb12cc11f5d0b6889274d06e",
    "executable": "/tmp/fuzz.exe",
    "crash_type": "SIGABRT",
    "crash_site": "0x7ffff7e0d18b in gsignal+0xcb (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x4618b)",
    "call_stack": [
      "#0 0x7ffff7e0d18b in gsignal+0xcb (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x4618b)",
      "#1 0x7ffff7dec859 in abort+0x12b (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x25859)",
      "#2 0x7ffff7e573ee in <unknown> (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x903ee)",
      "#3 0x7ffff7ef9b4a in __fortify_fail+0x2a (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x132b4a)",
      "#4 0x7ffff7ef83e6 in __chk_fail+0x16 (/usr/lib/x86_64-linux-gnu/libc-2.31.so+0x1313e6)",
      "#5 0x7ffff7ef7e09 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 0x7ffff7dee0b3 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": "99625a7c103136e02910b65c7b60f1bbd1a7612242d6838da52d968369039409",
    "minimized_stack": [
      "__fortify_fail",
      "__chk_fail",
      "from_file"
    ],
    "minimized_stack_sha256": "237f13bfa384c6c2bc06369099373efbb36995a9ad00fd5469d354b5fc672ba1",
    "minimized_stack_function_names": [
      "__fortify_fail",
      "__chk_fail",
      "from_file"
    ],
    "minimized_stack_function_names_sha256": "237f13bfa384c6c2bc06369099373efbb36995a9ad00fd5469d354b5fc672ba1",
    "asan_log": "",
    "task_id": "00000000-0000-0000-0000-000000000000",
    "job_id": "00000000-0000-0000-0000-000000000000"
  }
}
$
```
2021-03-23 00:13:28 +00:00
8250007294 Fix parsing of list of synced dir (#711) 2021-03-22 17:04:00 -04:00
7be4f3bbc1 add a single-shot crash report utility (#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"
  }
}
$
```
2021-03-22 17:46:33 +00:00
6e60a8cf10 add regression testing tasks (#664) 2021-03-18 15:37:19 -04:00
34b2a739cb provide parsed call stack details asan logs (#591)
For a given entry in a call stack, this parses out the following: line, function name, function offset, source file name, source file line, module path, and module offset.

Additionally, this provides a code-generated libclusterfuzz port of the regular expressions used for stack minimization.

For an example of the minimization, instead of:
```json
[
"#0 0x56512a9c1418 in __sanitizer_print_stack_trace /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/asan/asan_stack.cpp:86:3",
"#1 0x56512aaaa42d in fuzzer::PrintStackTrace() third_party/libFuzzer/src/FuzzerUtil.cpp:205:5",
"#2 0x56512aa6a85e in fuzzer::Fuzzer::CrashCallback() third_party/libFuzzer/src/FuzzerLoop.cpp:232:3",
"#3 0x56512aa6a7df in fuzzer::Fuzzer::StaticCrashSignalCallback() third_party/libFuzzer/src/FuzzerLoop.cpp:203:6",
"#4 0x56512aaab948 in fuzzer::CrashHandler(int, siginfo_t*, void*) third_party/libFuzzer/src/FuzzerUtilPosix.cpp:46:3",
"#5 0x7f1ee3f0188f  (/lib/x86_64-linux-gnu/libpthread.so.0+0x1288f)",
"#6 0x56512a9e5aa1 in Json::OurReader::parse(char const*, char const*, Json::Value&, bool) third_party/jsoncpp/source/src/lib_json/json_reader.cpp:1062:10",
"#7 0x56512a9eedb4 in Json::OurCharReader::parse(char const*, char const*, Json::Value*, std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char> >*) third_party/jsoncpp/source/src/lib_json/json_reader.cpp:1899:23",
"#8 0x56512a9e03a3 in LLVMFuzzerTestOneInput third_party/jsoncpp/fuzzers/json_fuzzer.cc:39:24",
"#9 0x56512aa6d0cf in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) third_party/libFuzzer/src/FuzzerLoop.cpp:556:15",
"#10 0x56512aa3b7da in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) third_party/libFuzzer/src/FuzzerDriver.cpp:292:6",
"#11 0x56512aa4108a in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) third_party/libFuzzer/src/FuzzerDriver.cpp:774:9","#12 0x56512aa821ac in main third_party/libFuzzer/src/FuzzerMain.cpp:19:10",
"#13 0x7f1ee3361b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310",
]
```

The minimized call stack is:
```json
[
"Json::OurReader::parse(char const*, char const*, Json::Value&, bool)", 
"Json::OurCharReader::parse(char const*, char const*, Json::Value*, std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char> >*)",
"json_fuzzer.cc"
]
```

This also provides a naïve function name list, which comes close to Clusterfuzz's function identification.

This would result in:
```json
[
    "Json::OurReader::parse",
    "Json::OurCharReader::parse",
    "json_fuzzer.cc"
]
```

Lastly, for our `stack hash` functionality used by the crash reporting task, those now provide the ability to specify the number of frames to include when building the hash.
2021-03-18 17:25:12 +00:00
1174162af9 enable generic-analysis as an optional component of libfuzzer local tasks (#688) 2021-03-18 12:24:12 -04:00
4b07fdc455 local_run refactoring (#508)
## Summary of the Pull Request

This is a refactoring of the local debugging.
- The input queue as been abstracted and can now be locally 
- The SyncDir can now sync a local directory
- Added the ability to monitor a local directory with a queue

## Reviewers Notes
The most import part of the PR are 
- The queue abstraction and implementations 
    - src/agent/storage-queue/src/azure_queue.rs
    - src/agent/storage-queue/src/local_queue.rs
    - src/agent/storage-queue/src/lib.rs
- Changes to support local files in 
    - src/agent/onefuzz/src/syncdir.rs
- Example of how those abstractions are used to link task together
    - src/agent/onefuzz-agent/src/local/libfuzzer_fuzz.rs
    - src/agent/onefuzz-agent/src/local/common.rs

## Validation Steps Performed

_How does someone test & validate?_
2021-03-17 19:32:45 +00:00
cd6621bb89 address latest clippy warnings (#679) 2021-03-17 15:13:43 +00:00
f0e5823c0a add retry to download_input (#676) 2021-03-16 12:17:28 -04:00
f26838452b remove stray ? (#652) 2021-03-09 11:57:58 -05:00
d2e4baa48d Updating Task Heartbeat Struct to actually include job_id (#646) 2021-03-09 10:24:04 -05:00
e43c1c875c simplify batch-processing log (#622)
Simplifies the logs from:

`Processing batch-downloaded input Ok(DirEntry(DirEntry("task_crashes_1/input-b4c3482194a6ebd275577ea52255fcea3358f3220c408d3c53b9f32b653e6586.txt")))`

to:

`Processing batch-downloaded input: task_crashes_1/input-b4c3482194a6ebd275577ea52255fcea3358f3220c408d3c53b9f32b653e6586.txt`
2021-03-02 17:32:07 +00:00
e3c73d7a10 Update command variable expansion (#561)
* Documents `crashes_account` and `crashes_container`
* Adds `reports_dir` and support for `unique_reports`, `reports`, and `no_repro` containers to the generic analysis task
* Adds `microsoft_telemetry_key` and `instance_telemetry_key` to generic supervisor, generator, and analysis tasks
2021-02-26 20:58:09 +00:00
06f45f338c Update Task Heartbeat to include Job_id (#594) 2021-02-26 13:36:10 -05:00