mirror of
https://github.com/securego/gosec.git
synced 2024-11-05 19:45:51 +00:00
74 lines
1 KiB
Go
74 lines
1 KiB
Go
|
package testutils
|
||
|
|
||
|
import "github.com/securego/gosec/v2"
|
||
|
|
||
|
var (
|
||
|
// SampleCodeG114 - Use of net/http serve functions that have no support for setting timeouts
|
||
|
SampleCodeG114 = []CodeSample{
|
||
|
{[]string{`
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
err := http.ListenAndServe(":8080", nil)
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
`}, 1, gosec.NewConfig()},
|
||
|
{[]string{`
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
err := http.ListenAndServeTLS(":8443", "cert.pem", "key.pem", nil)
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
`}, 1, gosec.NewConfig()},
|
||
|
{[]string{`
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"net"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
l, err := net.Listen("tcp", ":8080")
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
defer l.Close()
|
||
|
err = http.Serve(l, nil)
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
`}, 1, gosec.NewConfig()},
|
||
|
{[]string{`
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"net"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
l, err := net.Listen("tcp", ":8443")
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
defer l.Close()
|
||
|
err = http.ServeTLS(l, nil, "cert.pem", "key.pem")
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
`}, 1, gosec.NewConfig()},
|
||
|
}
|
||
|
)
|