gosec/testutils/g114_samples.go
Cosmin Cojocar 2aad3f02a5 Fix lint warnings by properly formatting the files
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
2023-12-08 14:46:36 +01:00

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()},
}