From 90fe1bc7a6bd736c8e22d5661ca897c4321ad689 Mon Sep 17 00:00:00 2001 From: fedotoff Date: Tue, 15 Aug 2023 19:29:50 +0300 Subject: [PATCH] Fix casr-cli --- casr/src/bin/casr-cli.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/casr/src/bin/casr-cli.rs b/casr/src/bin/casr-cli.rs index 7577dda2..99e8d688 100644 --- a/casr/src/bin/casr-cli.rs +++ b/casr/src/bin/casr-cli.rs @@ -1034,10 +1034,10 @@ fn process_report(report: &str, extension: &str) -> Option<(String, String, Stri /// Sarif report fn sarif(report_path: &Path, root: &str) -> Result { let mut sarif = SarifReport::new(); - let mut reports = Vec::new(); + let mut reports: Vec<(PathBuf, CrashReport)> = Vec::new(); if !report_path.is_dir() { let casr_report = report_from_file(report_path)?; - reports.push(casr_report); + reports.push((report_path.to_path_buf(), casr_report)); } else { for path in WalkDir::new(report_path) .sort_by_file_name() @@ -1048,13 +1048,20 @@ fn sarif(report_path: &Path, root: &str) -> Result { .filter(|file| file.to_str().unwrap().ends_with(".casrep")) { let casr_report = report_from_file(&path)?; - reports.push(casr_report); + reports.push((path.to_path_buf(), casr_report)); } } - reports - .iter() - .try_for_each(|r| sarif.add_casr_report(r, root))?; + for (path, report) in reports { + let result = sarif.add_casr_report(&report, root); + if result.is_err() { + println!( + "Error while converting {} to SARIF: {}", + path.display(), + result.err().unwrap() + ); + } + } Ok(sarif) }