diff --git a/analyzer.go b/analyzer.go index 430a947604..07498ce808 100644 --- a/analyzer.go +++ b/analyzer.go @@ -390,7 +390,6 @@ func (gosec *Analyzer) CheckRules(pkg *packages.Package) { gosec.context.PkgFiles = pkg.Syntax gosec.context.Imports = NewImportTracker() gosec.context.PassedValues = make(map[string]interface{}) - gosec.context.Ignores = newIgnores() gosec.updateIgnores() ast.Walk(gosec, file) gosec.stats.NumFiles++ diff --git a/testutils/g115_samples.go b/testutils/g115_samples.go index 4e075c67bd..12c557492e 100644 --- a/testutils/g115_samples.go +++ b/testutils/g115_samples.go @@ -115,4 +115,43 @@ func main() { fmt.Println(b) } `}, 1, gosec.NewConfig()}, + {[]string{ + ` +package main + +import ( + "fmt" + "math" +) + +func main() { + var a uint = math.MaxUint + // #nosec G115 + b := int64(a) + fmt.Println(b) +} + `, + }, 0, gosec.NewConfig()}, + {[]string{ + ` +package main + +import ( + "fmt" + "math" +) + +func main() { + var a uint = math.MaxUint + // #nosec G115 + b := int64(a) + fmt.Println(b) +} + `, ` +package main + +func ExampleFunction() { +} +`, + }, 0, gosec.NewConfig()}, }