Skip to content

Commit 0076267

Browse files
gartneraccojocar
authored andcommitted
Fix multifile ignores
1 parent 2f1b81b commit 0076267

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

analyzer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ func (gosec *Analyzer) CheckRules(pkg *packages.Package) {
390390
gosec.context.PkgFiles = pkg.Syntax
391391
gosec.context.Imports = NewImportTracker()
392392
gosec.context.PassedValues = make(map[string]interface{})
393-
gosec.context.Ignores = newIgnores()
394393
gosec.updateIgnores()
395394
ast.Walk(gosec, file)
396395
gosec.stats.NumFiles++

testutils/g115_samples.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,43 @@ func main() {
115115
fmt.Println(b)
116116
}
117117
`}, 1, gosec.NewConfig()},
118+
{[]string{
119+
`
120+
package main
121+
122+
import (
123+
"fmt"
124+
"math"
125+
)
126+
127+
func main() {
128+
var a uint = math.MaxUint
129+
// #nosec G115
130+
b := int64(a)
131+
fmt.Println(b)
132+
}
133+
`,
134+
}, 0, gosec.NewConfig()},
135+
{[]string{
136+
`
137+
package main
138+
139+
import (
140+
"fmt"
141+
"math"
142+
)
143+
144+
func main() {
145+
var a uint = math.MaxUint
146+
// #nosec G115
147+
b := int64(a)
148+
fmt.Println(b)
149+
}
150+
`, `
151+
package main
152+
153+
func ExampleFunction() {
154+
}
155+
`,
156+
}, 0, gosec.NewConfig()},
118157
}

0 commit comments

Comments
 (0)