From 2153c261cc78c5d0f246038c4fc8da8f7d2e8dd0 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Thu, 20 Oct 2022 20:38:07 -0700 Subject: [PATCH] rules/sdk: return if we cannot infer the arg or func type --- rules/sdk/integer.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rules/sdk/integer.go b/rules/sdk/integer.go index 42cfd76..35bd7e3 100644 --- a/rules/sdk/integer.go +++ b/rules/sdk/integer.go @@ -65,9 +65,19 @@ func (i *integerOverflowCheck) Match(node ast.Node, ctx *gosec.Context) (*gosec. } arg := n.Args[0] - argType := ctx.Info.TypeOf(arg).Underlying() - destType := ctx.Info.TypeOf(fun).Underlying() + argT := ctx.Info.TypeOf(arg) + if argT == nil { + // TODO: Perhaps log and investigate this case more. + return nil, nil + } + fnType := ctx.Info.TypeOf(fun) + if fnType == nil { + // TODO: Perhaps log and investigate this case more. + return nil, nil + } + argType := argT.Underlying() + destType := fnType.Underlying() intCast := hasAnyPrefix(destType.String(), "int", "uint") if !intCast { return nil, nil