Skip to content

Commit

Permalink
Skip filtration for targeted scans #3243
Browse files Browse the repository at this point in the history
There is a scenario in which results filtration is known to cause problems, and this PR disables it in that scenario. (It should cause problems more generally, but lacking any concrete cases of that, I want to tread lightly.)
  • Loading branch information
rosecodym authored Aug 23, 2024
1 parent f39a525 commit 8f299ff
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,15 @@ func (e *Engine) verificationOverlapWorker(ctx context.Context) {
detectorKeysWithResults[detector.Key] = detector
}

results = e.filterResults(ctx, detector, results)
// If results filtration eliminates a rotated secret, then that rotation will never be reported. This
// problem can theoretically occur for any scan, but we've only actually seen it in practice during
// targeted scans. (The reason for this discrepancy is unclear.) The simplest fix is therefore to
// disable filtration for targeted scans, but if you're here because this problem surfaced for a
// non-targeted scan then we'll have to solve it correctly.
if chunk.chunk.SecretID == 0 {
results = e.filterResults(ctx, detector, results)
}

for _, res := range results {
var val []byte
if res.RawV2 != nil {
Expand Down Expand Up @@ -1043,7 +1051,14 @@ func (e *Engine) detectChunk(ctx context.Context, data detectableChunk) {
e.metrics.detectorAvgTime.Store(detectorName, avgTime)
}

results = e.filterResults(ctx, data.detector, results)
// If results filtration eliminates a rotated secret, then that rotation will never be reported. This problem
// can theoretically occur for any scan, but we've only actually seen it in practice during targeted scans. (The
// reason for this discrepancy is unclear.) The simplest fix is therefore to disable filtration for targeted
// scans, but if you're here because this problem surfaced for a non-targeted scan then we'll have to solve it
// correctly.
if data.chunk.SecretID == 0 {
results = e.filterResults(ctx, data.detector, results)
}

for _, res := range results {
e.processResult(ctx, data, res, isFalsePositive)
Expand Down

0 comments on commit 8f299ff

Please sign in to comment.