-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code to move item and secret processing to separate functions
- Loading branch information
Baruch Odem
committed
Feb 14, 2024
1 parent
753c515
commit 3bc1589
Showing
2 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/checkmarx/2ms/secrets" | ||
) | ||
|
||
func processItems(detector *secrets.Secrets) { | ||
defer channels.WaitGroup.Done() | ||
|
||
wgItems := &sync.WaitGroup{} | ||
for item := range channels.Items { | ||
report.TotalItemsScanned++ | ||
wgItems.Add(1) | ||
go detector.Detect(item, secretsChan, wgItems, ignoreVar) | ||
} | ||
wgItems.Wait() | ||
close(secretsChan) | ||
} | ||
|
||
func processSecrets() { | ||
defer channels.WaitGroup.Done() | ||
|
||
for secret := range secretsChan { | ||
report.TotalSecretsFound++ | ||
if validateVar { | ||
validationChan <- secret | ||
} | ||
report.Results[secret.ID] = append(report.Results[secret.ID], secret) | ||
} | ||
close(validationChan) | ||
} | ||
|