Skip to content

Commit

Permalink
Fix casr-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
anfedotoff committed Aug 15, 2023
1 parent a618919 commit 90fe1bc
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions casr/src/bin/casr-cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SarifReport> {
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()
Expand All @@ -1048,13 +1048,20 @@ fn sarif(report_path: &Path, root: &str) -> Result<SarifReport> {
.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)
}

0 comments on commit 90fe1bc

Please sign in to comment.