Resolve the TLS min version when is declarted in the same package but in a different file

This commit is contained in:
Cosmin Cojocar 2022-01-26 19:21:32 +01:00
parent 1fbcf10e18
commit 2fad8a4193

View file

@ -87,8 +87,17 @@ func (t *insecureConfigTLS) processTLSConfVal(n *ast.KeyValueExpr, c *gosec.Cont
} }
case "MinVersion": case "MinVersion":
if d, ok := n.Value.(*ast.Ident); ok && d.Obj != nil { if d, ok := n.Value.(*ast.Ident); ok {
if vs, ok := d.Obj.Decl.(*ast.ValueSpec); ok && len(vs.Values) > 0 { obj := d.Obj
if obj == nil {
for _, f := range c.PkgFiles {
obj = f.Scope.Lookup(d.Name)
if obj != nil {
break
}
}
}
if vs, ok := obj.Decl.(*ast.ValueSpec); ok && len(vs.Values) > 0 {
if s, ok := vs.Values[0].(*ast.SelectorExpr); ok { if s, ok := vs.Values[0].(*ast.SelectorExpr); ok {
x := s.X.(*ast.Ident).Name x := s.X.(*ast.Ident).Name
sel := s.Sel.Name sel := s.Sel.Name