Skip to content

Commit

Permalink
feat: log why false positives are skipped (#3579)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgmz authored Nov 10, 2024
1 parent 781157a commit 96e5b01
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 96e5b01

Please sign in to comment.