| 658 | use super::*; |
| 659 | |
| 660 | pub fn sanitize_crash(fuzzer_dir: &Path, deopt: &Deopt) -> Result<()> { |
| 661 | log::info!("Sanitize the crashes found by libfuzzer! fuzzer_dir: {fuzzer_dir:?}"); |
| 662 | let executor = Executor::new(deopt)?; |
| 663 | for fuzz_entry in crate::deopt::utils::read_sort_dir(fuzzer_dir)? { |
| 664 | if !fuzz_entry.is_dir() { |
| 665 | continue; |
| 666 | } |
| 667 | let mut crashes = Vec::new(); |
| 668 | sanitize_asan_artcraft_file(&fuzz_entry, &executor)?; |
| 669 | |
| 670 | for entry in crate::deopt::utils::read_sort_dir(&fuzz_entry)? { |
| 671 | if entry |
| 672 | .file_name() |
| 673 | .unwrap() |
| 674 | .to_string_lossy() |
| 675 | .starts_with("error_") |
| 676 | { |
| 677 | crashes.push(entry); |
| 678 | } |
| 679 | } |
| 680 | let crashes = sanitize_false_alarm_crashes(crashes, deopt)?; |
| 681 | let unique_crashes = sanitize_crash_by_call_stack(crashes)?; |
| 682 | let ubsan_crashes: Vec<String> = sanitize_ubsan_report(&fuzz_entry, &executor)?; |
| 683 | log::info!("the unique ASAN crashes: {unique_crashes:#?}"); |
| 684 | log::info!("the unique UBSAN crashes: {ubsan_crashes:?}"); |
| 685 | } |
| 686 | log::info!("Sanitizer automatically removed most of the duplicated crashes."); |
| 687 | Ok(()) |
| 688 | } |
| 689 | |
| 690 | fn sanitize_false_alarm_crashes(crashes: Vec<PathBuf>, deopt: &Deopt) -> Result<Vec<PathBuf>> { |
| 691 | let mut retained = Vec::new(); |