Skip to content

Commit

Permalink
rules/sdk: return if we cannot infer the arg or func type
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Oct 21, 2022
1 parent 181ab08 commit 2153c26
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rules/sdk/integer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2153c26

Please sign in to comment.