mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
Fix multifile ignores
This commit is contained in:
parent
2f1b81b889
commit
007626773c
2 changed files with 39 additions and 1 deletions
|
@ -390,7 +390,6 @@ func (gosec *Analyzer) CheckRules(pkg *packages.Package) {
|
||||||
gosec.context.PkgFiles = pkg.Syntax
|
gosec.context.PkgFiles = pkg.Syntax
|
||||||
gosec.context.Imports = NewImportTracker()
|
gosec.context.Imports = NewImportTracker()
|
||||||
gosec.context.PassedValues = make(map[string]interface{})
|
gosec.context.PassedValues = make(map[string]interface{})
|
||||||
gosec.context.Ignores = newIgnores()
|
|
||||||
gosec.updateIgnores()
|
gosec.updateIgnores()
|
||||||
ast.Walk(gosec, file)
|
ast.Walk(gosec, file)
|
||||||
gosec.stats.NumFiles++
|
gosec.stats.NumFiles++
|
||||||
|
|
|
@ -115,4 +115,43 @@ func main() {
|
||||||
fmt.Println(b)
|
fmt.Println(b)
|
||||||
}
|
}
|
||||||
`}, 1, gosec.NewConfig()},
|
`}, 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()},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue