From 90b6d6b8ebbd26723677e098017f688c65829311 Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Fri, 12 Sep 2025 15:16:11 +0100 Subject: [PATCH] feat: add sarif-tool-name input to configure SARIF file tool name rewriting --- action.yml | 3 +++ src/action.rs | 13 +++++++++++++ src/main.rs | 9 +++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 97b594f..92f4394 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,9 @@ inputs: default: latest working-directory: description: Working Directory + sarif-tool-name: + description: Re-write SARIF file tool name + default: 'true' attestation: description: Attestation default: 'false' diff --git a/src/action.rs b/src/action.rs index 5ac5fef..863fe7a 100644 --- a/src/action.rs +++ b/src/action.rs @@ -85,6 +85,14 @@ pub struct Action { )] working_directory: String, + /// Re-write SARIF file tool name + #[input( + description = "Re-write SARIF file tool name", + rename = "sarif-tool-name", + default = "true" + )] + sarif_tool_name: bool, + /// Attestation #[input(description = "Attestation", default = "false")] attestation: bool, @@ -360,6 +368,11 @@ impl Action { log::debug!("Allow empty database: {}", self.allow_empty_database); self.allow_empty_database } + + pub fn sarif_tool_name(&self) -> bool { + log::debug!("Re-write SARIF tool name: {}", self.sarif_tool_name); + self.sarif_tool_name + } } #[cfg(test)] diff --git a/src/main.rs b/src/main.rs index fcc2e9c..a62d8a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -269,8 +269,13 @@ async fn main() -> Result<()> { log::info!("Post-processing SARIF results"); - extractors::update_sarif(&sarif_path, extractor.display_name.clone()) - .context("Failed to update SARIF file with extractor information")?; + if action.sarif_tool_name() { + log::info!("Updating SARIF tool name with extractor information"); + extractors::update_sarif(&sarif_path, extractor.display_name.clone()) + .context("Failed to update SARIF file with extractor information")?; + } else { + log::info!("Skipping SARIF tool name update as per configuration"); + } // Reload the database to get analysis info database.reload()?;