Fix a panic in suproc rule when the declaration of the variable is not available in the AST (#728)

This commit is contained in:
Cosmin Cojocar 2021-11-16 21:41:26 +01:00 committed by GitHub
parent ff17c30a97
commit e57efa8482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,6 +55,10 @@ func (r *subprocess) Match(n ast.Node, c *gosec.Context) (*gosec.Issue, error) {
// .. indeed it is a variable then processing is different than a normal
// field assignment
if variable {
// skip the check when the declaration is not available
if ident.Obj == nil {
continue
}
switch ident.Obj.Decl.(type) {
case *ast.AssignStmt:
_, assignment := ident.Obj.Decl.(*ast.AssignStmt)