mirror of
https://github.com/securego/gosec.git
synced 2025-07-07 00:35:35 +02:00
Update the subproc rule to detect the syscall.ForkExec and syscall.StartProces calls
Also add the corresponding tests for this. Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
committed by
Cosmin Cojocar
parent
c998389da2
commit
f97f86103c
@ -1066,6 +1066,44 @@ func main() {
|
||||
}
|
||||
}`}, 0, gosec.NewConfig()},
|
||||
{[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func RunCmd(command string) {
|
||||
_, err := syscall.ForkExec(command, []string{}, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
RunCmd("sleep")
|
||||
}`}, 1, gosec.NewConfig(),
|
||||
},
|
||||
{[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func RunCmd(command string) {
|
||||
_, err := syscall.StartProcess(command, []string{}, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
RunCmd("sleep")
|
||||
}`}, 1, gosec.NewConfig(),
|
||||
},
|
||||
{[]string{`
|
||||
// starting a process with a variable as an argument
|
||||
// even if not constant is not considered as dangerous
|
||||
// because it has harcoded value
|
||||
|
Reference in New Issue
Block a user