save the fuzzer and triger input that enables to reproduce this incident
(
fuzzer_dir: &Path,
incident_dir: &Path,
artifact: &[u8],
err_msg: Option<String>,
)
| 530 | |
| 531 | // save the fuzzer and triger input that enables to reproduce this incident |
| 532 | fn save_the_incident( |
| 533 | fuzzer_dir: &Path, |
| 534 | incident_dir: &Path, |
| 535 | artifact: &[u8], |
| 536 | err_msg: Option<String>, |
| 537 | ) -> Result<()> { |
| 538 | if incident_dir.exists() { |
| 539 | return Ok(()); |
| 540 | } |
| 541 | log::info!("The incident is saved in {incident_dir:?}"); |
| 542 | crate::deopt::utils::create_dir_if_nonexist(incident_dir)?; |
| 543 | |
| 544 | let fuzz_binary = get_fuzzer_path(fuzzer_dir); |
| 545 | let save_binary = get_fuzzer_path(incident_dir); |
| 546 | std::fs::copy(fuzz_binary, save_binary)?; |
| 547 | |
| 548 | let save_log = get_fuzzer_log(incident_dir); |
| 549 | if let Some(err_msg) = err_msg { |
| 550 | std::fs::write(save_log, err_msg)?; |
| 551 | } else { |
| 552 | let fuzz_log = get_fuzzer_log(fuzzer_dir); |
| 553 | std::fs::copy(fuzz_log, save_log)?; |
| 554 | } |
| 555 | |
| 556 | let trigger_input: PathBuf = [incident_dir.to_path_buf(), "triger_input".into()] |
| 557 | .iter() |
| 558 | .collect(); |
| 559 | std::fs::write(trigger_input, artifact)?; |
| 560 | Ok(()) |
| 561 | } |
| 562 | |
| 563 | pub fn is_incident_reproducible(incident_dir: &Path, deopt: &Deopt) -> Result<bool> { |
| 564 | let fuzzer_binary = get_fuzzer_path(incident_dir); |
no test coverage detected