mirror of
https://github.com/securego/gosec.git
synced 2026-01-15 01:33:41 +08:00
feat: add concurrency option to parallelize package loading (#778)
* feat: add concurrency option to parallelize package loading * refactor: move wg.add inside the for loop * fix: gracefully stop the workers on error * test: add test for concurrent scan
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -114,6 +115,9 @@ var (
|
||||
// fail by confidence
|
||||
flagConfidence = flag.String("confidence", "low", "Filter out the issues with a lower confidence than the given value. Valid options are: low, medium, high")
|
||||
|
||||
// concurrency value
|
||||
flagConcurrency = flag.Int("concurrency", runtime.NumCPU(), "Concurrency value")
|
||||
|
||||
// do not fail
|
||||
flagNoFail = flag.Bool("no-fail", false, "Do not fail the scanning, even if issues were found")
|
||||
|
||||
@@ -371,7 +375,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Create the analyzer
|
||||
analyzer := gosec.NewAnalyzer(config, *flagScanTests, *flagExcludeGenerated, *flagTrackSuppressions, logger)
|
||||
analyzer := gosec.NewAnalyzer(config, *flagScanTests, *flagExcludeGenerated, *flagTrackSuppressions, *flagConcurrency, logger)
|
||||
analyzer.LoadRules(ruleList.RulesInfo())
|
||||
|
||||
excludedDirs := gosec.ExcludedDirsRegExp(flagDirsExclude)
|
||||
|
||||
Reference in New Issue
Block a user