Skip to content

Commit

Permalink
feat: log why false positives are skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
rgmz committed Nov 9, 2024
1 parent 781157a commit 97a943e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/detectors/falsepositives.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand Down

0 comments on commit 97a943e

Please sign in to comment.