From 8c8b134bbcef6e143bc400067b3aa1ce2c123a72 Mon Sep 17 00:00:00 2001 From: Kasper Svendsen Date: Tue, 28 Oct 2025 10:32:34 +0100 Subject: [PATCH] Log numbered of PR diff-range filtered alerts --- lib/analyze-action.js | 3 +++ lib/init-action-post.js | 3 +++ lib/upload-lib.js | 3 +++ lib/upload-sarif-action.js | 3 +++ src/upload-lib.ts | 4 ++++ 5 files changed, 16 insertions(+) diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 158630ca5..b7bb5c8fb 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -96014,6 +96014,7 @@ function filterAlertsByDiffRange(logger, sarif) { } for (const run2 of sarif.runs) { if (run2.results) { + const preAlertCount = run2.results.length; run2.results = run2.results.filter((result) => { const locations = [ ...(result.locations || []).map((loc) => loc.physicalLocation), @@ -96030,6 +96031,8 @@ function filterAlertsByDiffRange(logger, sarif) { ); }); }); + const postAlertCount = run2.results.length; + logger.info(`Filtered ${preAlertCount - postAlertCount} alerts based on diff range.`); } } return sarif; diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 969811ee4..578cc1bbb 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -133526,6 +133526,7 @@ function filterAlertsByDiffRange(logger, sarif) { } for (const run2 of sarif.runs) { if (run2.results) { + const preAlertCount = run2.results.length; run2.results = run2.results.filter((result) => { const locations = [ ...(result.locations || []).map((loc) => loc.physicalLocation), @@ -133542,6 +133543,8 @@ function filterAlertsByDiffRange(logger, sarif) { ); }); }); + const postAlertCount = run2.results.length; + logger.info(`Filtered ${preAlertCount - postAlertCount} alerts based on diff range.`); } } return sarif; diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 319921e7b..e259be23c 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -92964,6 +92964,7 @@ function filterAlertsByDiffRange(logger, sarif) { } for (const run of sarif.runs) { if (run.results) { + const preAlertCount = run.results.length; run.results = run.results.filter((result) => { const locations = [ ...(result.locations || []).map((loc) => loc.physicalLocation), @@ -92980,6 +92981,8 @@ function filterAlertsByDiffRange(logger, sarif) { ); }); }); + const postAlertCount = run.results.length; + logger.info(`Filtered ${preAlertCount - postAlertCount} alerts based on diff range.`); } } return sarif; diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index f3d0f0727..e33ae8acf 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -93590,6 +93590,7 @@ function filterAlertsByDiffRange(logger, sarif) { } for (const run2 of sarif.runs) { if (run2.results) { + const preAlertCount = run2.results.length; run2.results = run2.results.filter((result) => { const locations = [ ...(result.locations || []).map((loc) => loc.physicalLocation), @@ -93606,6 +93607,8 @@ function filterAlertsByDiffRange(logger, sarif) { ); }); }); + const postAlertCount = run2.results.length; + logger.info(`Filtered ${preAlertCount - postAlertCount} alerts based on diff range.`); } } return sarif; diff --git a/src/upload-lib.ts b/src/upload-lib.ts index 416a86ab9..0e3d640d7 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -1142,6 +1142,7 @@ function filterAlertsByDiffRange(logger: Logger, sarif: SarifFile): SarifFile { for (const run of sarif.runs) { if (run.results) { + const preAlertCount = run.results.length; run.results = run.results.filter((result) => { const locations = [ ...(result.locations || []).map((loc) => loc.physicalLocation), @@ -1168,6 +1169,9 @@ function filterAlertsByDiffRange(logger: Logger, sarif: SarifFile): SarifFile { ); }); }); + + const postAlertCount = run.results.length; + logger.info(`Filtered ${preAlertCount - postAlertCount} alerts based on diff range.`); } }