Skip to content

Commit d7ec2fc

Browse files
committed
add CommandContext as subprocess launcher
1 parent 4ae8c95 commit d7ec2fc

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

rules/subproc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (r *subprocess) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) {
5858
func NewSubproc(id string, conf gas.Config) (gas.Rule, []ast.Node) {
5959
rule := &subprocess{gas.MetaData{ID: id}, gas.NewCallList()}
6060
rule.Add("os/exec", "Command")
61+
rule.Add("os/exec", "CommandContext")
6162
rule.Add("syscall", "Exec")
6263
return rule, []ast.Node{(*ast.CallExpr)(nil)}
6364
}

testutils/source.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,20 @@ func main() {
408408
log.Printf("Command finished with error: %v", err)
409409
}`, 1}, {`
410410
package main
411+
import (
412+
"log"
413+
"os/exec"
414+
"context"
415+
)
416+
func main() {
417+
err := exec.CommandContext(context.Background(), "sleep", "5").Run()
418+
if err != nil {
419+
log.Fatal(err)
420+
}
421+
log.Printf("Command finished with error: %v", err)
422+
}
423+
}`, 1}, {`
424+
package main
411425
import (
412426
"log"
413427
"os"

0 commit comments

Comments
 (0)