Skip to content

Commit 96e5b01

Browse files
authored
feat: log why false positives are skipped (#3579)
1 parent 781157a commit 96e5b01

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/detectors/falsepositives.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func FilterKnownFalsePositives(ctx context.Context, detector Detector, results [
181181

182182
for _, result := range results {
183183
if len(result.Raw) == 0 {
184-
ctx.Logger().Error(fmt.Errorf("empty raw"), "invalid result; skipping")
184+
ctx.Logger().Error(fmt.Errorf("empty raw"), "Skipping result: invalid")
185185
continue
186186
}
187187

@@ -190,9 +190,11 @@ func FilterKnownFalsePositives(ctx context.Context, detector Detector, results [
190190
continue
191191
}
192192

193-
if isFp, _ := isFalsePositive(result); !isFp {
194-
filteredResults = append(filteredResults, result)
193+
if isFp, reason := isFalsePositive(result); isFp {
194+
ctx.Logger().V(4).Info("Skipping result: false positive", "result", result.Raw, "reason", reason)
195+
continue
195196
}
197+
filteredResults = append(filteredResults, result)
196198
}
197199

198200
return filteredResults

0 commit comments

Comments
 (0)