mirror of
https://github.com/securego/gosec.git
synced 2025-03-19 21:08:30 +02:00
30 lines
551 B
Go
30 lines
551 B
Go
|
package testutils
|
||
|
|
||
|
import "github.com/securego/gosec/v2"
|
||
|
|
||
|
var (
|
||
|
// SampleCodeG111 - potential directory traversal
|
||
|
SampleCodeG111 = []CodeSample{
|
||
|
{[]string{`
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
http.Handle("/bad/", http.StripPrefix("/bad/", http.FileServer(http.Dir("/"))))
|
||
|
http.HandleFunc("/", HelloServer)
|
||
|
log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), nil))
|
||
|
}
|
||
|
|
||
|
func HelloServer(w http.ResponseWriter, r *http.Request) {
|
||
|
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
|
||
|
}
|
||
|
`}, 1, gosec.NewConfig()},
|
||
|
}
|
||
|
)
|