Skip to content

Commit

Permalink
fix logic for duplicate results in chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrav committed Jan 31, 2024
1 parent cb8dcb8 commit 1361e85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 2 additions & 11 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ func (e *Engine) reverifierWorker(ctx context.Context) {
detectorsWithResult := make(map[detectors.Detector]struct{}, avgSecretsPerDetector)
chunkSecrets := make(map[string]struct{}, avgSecretsPerDetector)

nextChunk:
for chunk := range e.reverifiableChunksChan {
for _, detector := range chunk.detectors {
// DO NOT VERIFY at this stage of the pipeline.
Expand Down Expand Up @@ -654,23 +653,15 @@ nextChunk:
if e.reverificationTracking != nil {
e.reverificationTracking.increment()
}
chunk.reverifyWgDoneFn()

e.processResult(ctx, detectableChunk{
chunk: chunk.chunk,
detector: detector,
decoder: chunk.decoder,
wgDoneFn: wgDetect.Done,
}, res)

// Empty the dupes and detectors slice.
for k := range chunkSecrets {
delete(chunkSecrets, k)
}
for k := range detectorsWithResult {
delete(detectorsWithResult, k)
}
continue nextChunk
// Remove the detector from the map as we have already processed the result.
delete(detectorsWithResult, detector)
}
chunkSecrets[string(val)] = struct{}{}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func TestEngine_DuplicatSecrets(t *testing.T) {
WithConcurrency(1),
WithDecoders(decoders.DefaultDecoders()...),
WithDetectors(DefaultDetectors()...),
WithVerify(true),
WithVerify(false),
WithPrinter(new(discardPrinter)),
)
assert.Nil(t, err)
Expand Down

0 comments on commit 1361e85

Please sign in to comment.