mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
2aad3f02a5
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
27 lines
543 B
Go
27 lines
543 B
Go
package testutils
|
|
|
|
import "github.com/securego/gosec/v2"
|
|
|
|
// SampleCodeG111 - potential directory traversal
|
|
var 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()},
|
|
}
|