1
0
mirror of https://github.com/securego/gosec.git synced 2025-06-14 23:45:03 +02:00

Initialize fresh import info for each file

The import information was being persisted between files. This was
causing false positives.

Fixes #87
This commit is contained in:
Grant Murphy
2016-11-15 11:58:28 -08:00
parent c7bb2dd3b7
commit ca42de24ba
2 changed files with 21 additions and 5 deletions

View File

@ -15,6 +15,7 @@
package rules
import (
"fmt"
"go/ast"
gas "github.com/GoASTScanner/gas/core"
@ -28,6 +29,16 @@ type WeakRand struct {
func (w *WeakRand) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) {
if _, matched := gas.MatchCallByPackage(n, c, w.packagePath, w.funcName); matched {
fmt.Println("Imported:")
for k, v := range c.Imports.Imported {
fmt.Printf("%s => %s\n", k, v)
}
fmt.Println("Aliased:")
for k, v := range c.Imports.Aliased {
fmt.Printf("%s => %s\n", k, v)
}
fmt.Println("----------------------------------------")
return gas.NewIssue(c, n, w.What, w.Severity, w.Confidence), nil
}