Skip to content

Commit e0aadf9

Browse files
committed
chore: adding some bad code that triggers semgrep
Signed-off-by: chaosinthecrd <[email protected]>
1 parent 5348010 commit e0aadf9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

main.go

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package main
22

33
import (
44
"github.com/common-nighthawk/go-figure"
5+
"os"
6+
"syscall"
57
)
68

79
func Hello() string {
@@ -11,4 +13,16 @@ func Hello() string {
1113
func main() {
1214
myFigure := figure.NewFigure(Hello(), "usaflag", true)
1315
myFigure.Print()
16+
//
17+
// User input from environment variables or other untrusted sources
18+
command := os.Getenv("USER_COMMAND") // Example of untrusted user input
19+
if command == "" {
20+
command = "/bin/bash" // Default fallback
21+
}
22+
23+
// Potentially dangerous syscall.Exec with non-static input
24+
err := syscall.Exec(command, []string{command, "-c", "ls -la"}, os.Environ())
25+
if err != nil {
26+
panic(err)
27+
}
1428
}

0 commit comments

Comments
 (0)