Skip to content

Commit 2153c26

Browse files
committed
rules/sdk: return if we cannot infer the arg or func type
1 parent 181ab08 commit 2153c26

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

rules/sdk/integer.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,19 @@ func (i *integerOverflowCheck) Match(node ast.Node, ctx *gosec.Context) (*gosec.
6565
}
6666

6767
arg := n.Args[0]
68-
argType := ctx.Info.TypeOf(arg).Underlying()
69-
destType := ctx.Info.TypeOf(fun).Underlying()
68+
argT := ctx.Info.TypeOf(arg)
69+
if argT == nil {
70+
// TODO: Perhaps log and investigate this case more.
71+
return nil, nil
72+
}
73+
fnType := ctx.Info.TypeOf(fun)
74+
if fnType == nil {
75+
// TODO: Perhaps log and investigate this case more.
76+
return nil, nil
77+
}
7078

79+
argType := argT.Underlying()
80+
destType := fnType.Underlying()
7181
intCast := hasAnyPrefix(destType.String(), "int", "uint")
7282
if !intCast {
7383
return nil, nil

0 commit comments

Comments
 (0)