Skip to content

Commit e57efa8

Browse files
authored
Fix a panic in suproc rule when the declaration of the variable is not available in the AST (#728)
1 parent ff17c30 commit e57efa8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rules/subproc.go

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func (r *subprocess) Match(n ast.Node, c *gosec.Context) (*gosec.Issue, error) {
5555
// .. indeed it is a variable then processing is different than a normal
5656
// field assignment
5757
if variable {
58+
// skip the check when the declaration is not available
59+
if ident.Obj == nil {
60+
continue
61+
}
5862
switch ident.Obj.Decl.(type) {
5963
case *ast.AssignStmt:
6064
_, assignment := ident.Obj.Decl.(*ast.AssignStmt)

0 commit comments

Comments
 (0)