From 96e5b01ca189f4645c38723fe92335a5c134c604 Mon Sep 17 00:00:00 2001 From: Richard Gomez <32133502+rgmz@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:09:16 -0500 Subject: [PATCH] feat: log why false positives are skipped (#3579) --- pkg/detectors/falsepositives.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/detectors/falsepositives.go b/pkg/detectors/falsepositives.go index 7fb1a51d0f2b..7f2ecd668e0d 100644 --- a/pkg/detectors/falsepositives.go +++ b/pkg/detectors/falsepositives.go @@ -181,7 +181,7 @@ func FilterKnownFalsePositives(ctx context.Context, detector Detector, results [ for _, result := range results { if len(result.Raw) == 0 { - ctx.Logger().Error(fmt.Errorf("empty raw"), "invalid result; skipping") + ctx.Logger().Error(fmt.Errorf("empty raw"), "Skipping result: invalid") continue } @@ -190,9 +190,11 @@ func FilterKnownFalsePositives(ctx context.Context, detector Detector, results [ continue } - if isFp, _ := isFalsePositive(result); !isFp { - filteredResults = append(filteredResults, result) + if isFp, reason := isFalsePositive(result); isFp { + ctx.Logger().V(4).Info("Skipping result: false positive", "result", result.Raw, "reason", reason) + continue } + filteredResults = append(filteredResults, result) } return filteredResults