1
0
mirror of https://github.com/securego/gosec.git synced 2025-06-18 23:57:33 +02:00

Fix the errors rule whitelist to work on types methods

Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
Cosmin Cojocar
2020-01-28 14:11:00 +01:00
committed by Cosmin Cojocar
parent 459e2d3e91
commit 3e069e7756
17 changed files with 286 additions and 38 deletions

View File

@ -16,8 +16,9 @@ package rules
import (
"fmt"
"github.com/securego/gosec"
"go/ast"
"github.com/securego/gosec"
)
type integerOverflowCheck struct {
@ -47,7 +48,7 @@ func (i *integerOverflowCheck) Match(node ast.Node, ctx *gosec.Context) (*gosec.
switch n := node.(type) {
case *ast.AssignStmt:
for _, expr := range n.Rhs {
if callExpr, ok := expr.(*ast.CallExpr); ok && i.calls.ContainsCallExpr(callExpr, ctx, false) != nil {
if callExpr, ok := expr.(*ast.CallExpr); ok && i.calls.ContainsPkgCallExpr(callExpr, ctx, false) != nil {
if idt, ok := n.Lhs[0].(*ast.Ident); ok && idt.Name != "_" {
// Example:
// v, _ := strconv.Atoi("1111")