mirror of
https://github.com/securego/gosec.git
synced 2024-11-05 11:35:51 +00:00
Fix running single analyzer which isn't a rule bug (#1231)
* Fix running single analyzer which isn't a rule bug * remove uncessary diff (even if it's proper fmt)
This commit is contained in:
parent
a83689867d
commit
6741874d9b
2 changed files with 7 additions and 6 deletions
|
@ -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 {
|
||||
|
|
|
@ -228,7 +228,7 @@ func loadConfig(configFile string) (gosec.Config, error) {
|
|||
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())
|
||||
|
|
Loading…
Reference in a new issue