1
0
mirror of https://github.com/securego/gosec.git synced 2025-11-29 22:37:59 +02:00

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

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)