Skip to content

Commit d44073e

Browse files
authored
Merge pull request #6 from advanced-security/sarif-updates
feat: Update SARIF parsing and loading
2 parents c021cea + a6b3d93 commit d44073e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ ghastoolkit = { version = "^0.11", features = ["toolcache"] }
3030
# GitHub API
3131
octocrab = "^0.44"
3232
openssl = { version = "0.10", features = ["vendored"] }
33-
serde_json = "1.0.140"
33+
serde_json = "1.0"

src/main.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ async fn main() -> Result<()> {
188188
}
189189

190190
log::info!("Post-processing SARIF results");
191-
if let Ok(sarif_content) = std::fs::read_to_string(&sarif_path) {
192-
if let Ok(mut sarif) = serde_json::from_str::<Sarif>(&sarif_content) {
191+
192+
match Sarif::try_from(sarif_path.clone()) {
193+
Ok(mut sarif) => {
194+
log::info!("Updating SARIF tool name for language: {language}");
193195
sarif.runs.iter_mut().for_each(|run| {
194196
run.tool.driver.name = format!("CodeQL - {language}");
195197
});
@@ -201,12 +203,17 @@ async fn main() -> Result<()> {
201203
log::info!("SARIF file written successfully: {sarif_path:?}");
202204
}
203205
}
206+
Err(e) => {
207+
log::error!("Failed to read and parse SARIF file: {e}");
208+
}
204209
}
205210

206211
// Reload the database to get analysis info
207212
database.reload()?;
208213
log::info!("CodeQL Database LoC :: {}", database.lines_of_code());
209214

215+
log::info!("SARIF Output Path :: {sarif_path:?}");
216+
210217
log::info!("Analysis complete :: {database:?}");
211218
groupend!();
212219
}

0 commit comments

Comments
 (0)