fix: use coreAnalyzer if there are no filters selected and no active_filters (#432)

Signed-off-by: Matthis Holleville <matthish29@gmail.com>
This commit is contained in:
Matthis
2023-05-17 10:36:47 +02:00
committed by GitHub
parent 940a50e851
commit f0d3f36f6d
2 changed files with 11 additions and 9 deletions

View File

@@ -128,7 +128,7 @@ func NewAnalysis(backend string, language string, filters []string, namespace st
func (a *Analysis) RunAnalysis() {
activeFilters := viper.GetStringSlice("active_filters")
analyzerMap := analyzer.GetAnalyzerMap()
coreAnalyzerMap, analyzerMap := analyzer.GetAnalyzerMap()
analyzerConfig := common.Analyzer{
Client: a.Client,
@@ -138,11 +138,11 @@ func (a *Analysis) RunAnalysis() {
}
semaphore := make(chan struct{}, a.MaxConcurrency)
// if there are no filters selected and no active_filters then run all of them
// if there are no filters selected and no active_filters then run coreAnalyzer
if len(a.Filters) == 0 && len(activeFilters) == 0 {
var wg sync.WaitGroup
var mutex sync.Mutex
for _, analyzer := range analyzerMap {
for _, analyzer := range coreAnalyzerMap {
wg.Add(1)
semaphore <- struct{}{}
go func(analyzer common.IAnalyzer, wg *sync.WaitGroup, semaphore chan struct{}) {

View File

@@ -78,18 +78,20 @@ func ListFilters() ([]string, []string, []string) {
return coreKeys, additionalKeys, integrationAnalyzers
}
func GetAnalyzerMap() map[string]common.IAnalyzer {
func GetAnalyzerMap() (map[string]common.IAnalyzer, map[string]common.IAnalyzer) {
mergedMap := make(map[string]common.IAnalyzer)
coreAnalyzer := make(map[string]common.IAnalyzer)
mergedAnalyzerMap := make(map[string]common.IAnalyzer)
// add core analyzer
for key, value := range coreAnalyzerMap {
mergedMap[key] = value
coreAnalyzer[key] = value
mergedAnalyzerMap[key] = value
}
// add additional analyzer
for key, value := range additionalAnalyzerMap {
mergedMap[key] = value
mergedAnalyzerMap[key] = value
}
integrationProvider := integration.NewIntegration()
@@ -106,9 +108,9 @@ func GetAnalyzerMap() map[string]common.IAnalyzer {
fmt.Println(color.RedString(err.Error()))
os.Exit(1)
}
in.AddAnalyzer(&mergedMap)
in.AddAnalyzer(&mergedAnalyzerMap)
}
}
return mergedMap
return coreAnalyzer, mergedAnalyzerMap
}