diff --git a/analyzer.go b/analyzer.go index 5828761..8043255 100644 --- a/analyzer.go +++ b/analyzer.go @@ -97,6 +97,11 @@ func (gosec *Analyzer) SetConfig(conf Config) { gosec.config = conf } +// Config returns the current configuration +func (gosec *Analyzer) Config() Config { + return gosec.config +} + // LoadRules instantiates all the rules to be used when analyzing source // packages func (gosec *Analyzer) LoadRules(ruleDefinitions map[string]RuleBuilder) { diff --git a/analyzer_test.go b/analyzer_test.go index 945c108..534bf01 100644 --- a/analyzer_test.go +++ b/analyzer_test.go @@ -416,6 +416,22 @@ var _ = Describe("Analyzer", func() { Expect(ferr[1].Err).Should(MatchRegexp(`error2`)) } }) + + It("should set the config", func() { + config := gosec.NewConfig() + config["test"] = "test" + analyzer.SetConfig(config) + found := analyzer.Config() + Expect(config).To(Equal(found)) + }) + + It("should reset the analyzer", func() { + analyzer.Reset() + issues, metrics, errors := analyzer.Report() + Expect(issues).To(BeEmpty()) + Expect(*metrics).To(Equal(gosec.Metrics{})) + Expect(errors).To(BeEmpty()) + }) }) Context("when appending errors", func() {