Skip to content

Commit

Permalink
add CommandContext as subprocess launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAbides committed Jun 3, 2018
1 parent 4ae8c95 commit d7ec2fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions rules/subproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (r *subprocess) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) {
func NewSubproc(id string, conf gas.Config) (gas.Rule, []ast.Node) {
rule := &subprocess{gas.MetaData{ID: id}, gas.NewCallList()}
rule.Add("os/exec", "Command")
rule.Add("os/exec", "CommandContext")
rule.Add("syscall", "Exec")
return rule, []ast.Node{(*ast.CallExpr)(nil)}
}
14 changes: 14 additions & 0 deletions testutils/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,20 @@ func main() {
log.Printf("Command finished with error: %v", err)
}`, 1}, {`
package main
import (
"log"
"os/exec"
"context"
)
func main() {
err := exec.CommandContext(context.Background(), "sleep", "5").Run()
if err != nil {
log.Fatal(err)
}
log.Printf("Command finished with error: %v", err)
}
}`, 1}, {`
package main
import (
"log"
"os"
Expand Down

0 comments on commit d7ec2fc

Please sign in to comment.