Skip to content

Commit

Permalink
Resolve the TLS min version when is declarted in the same package but…
Browse files Browse the repository at this point in the history
… in a different file
  • Loading branch information
ccojocar committed Jan 26, 2022
1 parent 1fbcf10 commit 2fad8a4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions rules/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,17 @@ func (t *insecureConfigTLS) processTLSConfVal(n *ast.KeyValueExpr, c *gosec.Cont
}

case "MinVersion":
if d, ok := n.Value.(*ast.Ident); ok && d.Obj != nil {
if vs, ok := d.Obj.Decl.(*ast.ValueSpec); ok && len(vs.Values) > 0 {
if d, ok := n.Value.(*ast.Ident); ok {
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 {
x := s.X.(*ast.Ident).Name
sel := s.Sel.Name
Expand Down

0 comments on commit 2fad8a4

Please sign in to comment.