Skip to content

Commit 2fad8a4

Browse files
committed
Resolve the TLS min version when is declarted in the same package but in a different file
1 parent 1fbcf10 commit 2fad8a4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

rules/tls.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,17 @@ func (t *insecureConfigTLS) processTLSConfVal(n *ast.KeyValueExpr, c *gosec.Cont
8787
}
8888

8989
case "MinVersion":
90-
if d, ok := n.Value.(*ast.Ident); ok && d.Obj != nil {
91-
if vs, ok := d.Obj.Decl.(*ast.ValueSpec); ok && len(vs.Values) > 0 {
90+
if d, ok := n.Value.(*ast.Ident); ok {
91+
obj := d.Obj
92+
if obj == nil {
93+
for _, f := range c.PkgFiles {
94+
obj = f.Scope.Lookup(d.Name)
95+
if obj != nil {
96+
break
97+
}
98+
}
99+
}
100+
if vs, ok := obj.Decl.(*ast.ValueSpec); ok && len(vs.Values) > 0 {
92101
if s, ok := vs.Values[0].(*ast.SelectorExpr); ok {
93102
x := s.X.(*ast.Ident).Name
94103
sel := s.Sel.Name

0 commit comments

Comments
 (0)