diff --git a/analyzers/analyzerslist.go b/analyzers/analyzerslist.go index f215744..8d22238 100644 --- a/analyzers/analyzerslist.go +++ b/analyzers/analyzerslist.go @@ -51,7 +51,7 @@ func (al *AnalyzerList) AnalyzersInfo() (map[string]AnalyzerDefinition, map[stri type AnalyzerFilter func(string) bool // NewAnalyzerFilter is a closure that will include/exclude the analyzer ID's based on -// the supplied boolean value. +// the supplied boolean value (false means don't remove, true means exclude). func NewAnalyzerFilter(action bool, analyzerIDs ...string) AnalyzerFilter { analyzerlist := make(map[string]bool) for _, analyzer := range analyzerIDs { diff --git a/cmd/gosec/main.go b/cmd/gosec/main.go index efc7f5d..5a3121e 100644 --- a/cmd/gosec/main.go +++ b/cmd/gosec/main.go @@ -224,11 +224,11 @@ func loadConfig(configFile string) (gosec.Config, error) { if *flagEnableAudit { config.SetGlobal(gosec.Audit, "true") } - // set global option IncludeRules ,when flag set or global option IncludeRules is nil + // set global option IncludeRules, when flag set or global option IncludeRules is nil if v, _ := config.GetGlobal(gosec.IncludeRules); *flagRulesInclude != "" || v == "" { config.SetGlobal(gosec.IncludeRules, *flagRulesInclude) } - // set global option ExcludeRules ,when flag set or global option IncludeRules is nil + // set global option ExcludeRules, when flag set or global option ExcludeRules is nil if v, _ := config.GetGlobal(gosec.ExcludeRules); flagRulesExclude.String() != "" || v == "" { config.SetGlobal(gosec.ExcludeRules, flagRulesExclude.String()) } @@ -438,12 +438,13 @@ func main() { } ruleList := loadRules(includeRules, excludeRules) - if len(ruleList.Rules) == 0 { - logger.Fatal("No rules are configured") - } analyzerList := loadAnalyzers(includeRules, excludeRules) + if len(ruleList.Rules) == 0 && len(analyzerList.Analyzers) == 0 { + logger.Fatal("No rules/analyzers are configured") + } + // Create the analyzer analyzer := gosec.NewAnalyzer(config, *flagScanTests, *flagExcludeGenerated, *flagTrackSuppressions, *flagConcurrency, logger) analyzer.LoadRules(ruleList.RulesInfo())