mirror of
https://github.com/securego/gosec.git
synced 2025-11-29 22:37:59 +02:00
Detect the unhandled errors even though they are explicitly ignored if the 'audit: enabled' setting is defined in the global configuration (#274)
* Define more explicit the global options in the configuration * Detect in audit mode the unhandled errors even thought they are explicitly ignored
This commit is contained in:
committed by
Grant Murphy
parent
14ed63d558
commit
f87af5fa72
@@ -81,23 +81,31 @@ var _ = Describe("Configuration", func() {
|
||||
It("should have a default global section", func() {
|
||||
settings, err := configuration.Get("global")
|
||||
Expect(err).Should(BeNil())
|
||||
expectedType := make(map[string]string)
|
||||
expectedType := make(map[gosec.GlobalOption]string)
|
||||
Expect(settings).Should(BeAssignableToTypeOf(expectedType))
|
||||
})
|
||||
|
||||
It("should save global settings to correct section", func() {
|
||||
configuration.SetGlobal("nosec", "enabled")
|
||||
configuration.SetGlobal(gosec.Nosec, "enabled")
|
||||
settings, err := configuration.Get("global")
|
||||
Expect(err).Should(BeNil())
|
||||
if globals, ok := settings.(map[string]string); ok {
|
||||
if globals, ok := settings.(map[gosec.GlobalOption]string); ok {
|
||||
Expect(globals["nosec"]).Should(MatchRegexp("enabled"))
|
||||
} else {
|
||||
Fail("globals are not defined as map")
|
||||
}
|
||||
|
||||
setValue, err := configuration.GetGlobal("nosec")
|
||||
setValue, err := configuration.GetGlobal(gosec.Nosec)
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(setValue).Should(MatchRegexp("enabled"))
|
||||
})
|
||||
|
||||
It("should find global settings which are enabled", func() {
|
||||
configuration.SetGlobal(gosec.Nosec, "enabled")
|
||||
enabled, err := configuration.IsGlobalEnabled(gosec.Nosec)
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(enabled).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user