1
0
mirror of https://github.com/securego/gosec.git synced 2025-11-25 22:22:17 +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:
Cosmin Cojocar
2019-01-14 12:37:40 +01:00
committed by Grant Murphy
parent 14ed63d558
commit f87af5fa72
8 changed files with 128 additions and 17 deletions

View File

@@ -41,7 +41,7 @@ type Context struct {
Pkg *types.Package
PkgFiles []*ast.File
Root *ast.File
Config map[string]interface{}
Config Config
Imports *ImportTracker
Ignores []map[string]bool
}
@@ -69,8 +69,8 @@ type Analyzer struct {
// NewAnalyzer builds a new analyzer.
func NewAnalyzer(conf Config, logger *log.Logger) *Analyzer {
ignoreNoSec := false
if setting, err := conf.GetGlobal("nosec"); err == nil {
ignoreNoSec = setting == "true" || setting == "enabled"
if enabled, err := conf.IsGlobalEnabled(Nosec); err == nil {
ignoreNoSec = enabled
}
if logger == nil {
logger = log.New(os.Stderr, "[gosec]", log.LstdFlags)