mirror of
https://github.com/securego/gosec.git
synced 2024-12-26 04:25:52 +00:00
add CommandContext as subprocess launcher
This commit is contained in:
parent
4ae8c95b40
commit
d7ec2fce7a
2 changed files with 15 additions and 0 deletions
|
@ -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) {
|
func NewSubproc(id string, conf gas.Config) (gas.Rule, []ast.Node) {
|
||||||
rule := &subprocess{gas.MetaData{ID: id}, gas.NewCallList()}
|
rule := &subprocess{gas.MetaData{ID: id}, gas.NewCallList()}
|
||||||
rule.Add("os/exec", "Command")
|
rule.Add("os/exec", "Command")
|
||||||
|
rule.Add("os/exec", "CommandContext")
|
||||||
rule.Add("syscall", "Exec")
|
rule.Add("syscall", "Exec")
|
||||||
return rule, []ast.Node{(*ast.CallExpr)(nil)}
|
return rule, []ast.Node{(*ast.CallExpr)(nil)}
|
||||||
}
|
}
|
||||||
|
|
|
@ -408,6 +408,20 @@ func main() {
|
||||||
log.Printf("Command finished with error: %v", err)
|
log.Printf("Command finished with error: %v", err)
|
||||||
}`, 1}, {`
|
}`, 1}, {`
|
||||||
package main
|
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 (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
Loading…
Reference in a new issue