Load rules on each code sample in order to reconfigure them

Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
Cosmin Cojocar 2019-06-25 11:14:27 +02:00
parent ed9934fa48
commit 78a49491a8
2 changed files with 2 additions and 1 deletions

View file

@ -334,4 +334,5 @@ func (gosec *Analyzer) Reset() {
gosec.context = &Context{} gosec.context = &Context{}
gosec.issues = make([]*Issue, 0, 16) gosec.issues = make([]*Issue, 0, 16)
gosec.stats = &Metrics{} gosec.stats = &Metrics{}
gosec.ruleset = NewRuleSet()
} }

View file

@ -28,10 +28,10 @@ var _ = Describe("gosec rules", func() {
config = gosec.NewConfig() config = gosec.NewConfig()
analyzer = gosec.NewAnalyzer(config, tests, logger) analyzer = gosec.NewAnalyzer(config, tests, logger)
runner = func(rule string, samples []testutils.CodeSample) { runner = func(rule string, samples []testutils.CodeSample) {
analyzer.LoadRules(rules.Generate(rules.NewRuleFilter(false, rule)).Builders())
for n, sample := range samples { for n, sample := range samples {
analyzer.Reset() analyzer.Reset()
analyzer.SetConfig(sample.Config) analyzer.SetConfig(sample.Config)
analyzer.LoadRules(rules.Generate(rules.NewRuleFilter(false, rule)).Builders())
pkg := testutils.NewTestPackage() pkg := testutils.NewTestPackage()
defer pkg.Close() defer pkg.Close()
for i, code := range sample.Code { for i, code := range sample.Code {