mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 12:05:52 +00:00
2aad3f02a5
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
71 lines
1 KiB
Go
71 lines
1 KiB
Go
package testutils
|
|
|
|
import "github.com/securego/gosec/v2"
|
|
|
|
// SampleCodeG114 - Use of net/http serve functions that have no support for setting timeouts
|
|
var 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()},
|
|
}
|