mirror of
https://github.com/securego/gosec.git
synced 2024-12-24 11:35:52 +00:00
fix ReadTimeout for G112 rule
This commit is contained in:
parent
05f3ca80f9
commit
b0f3e78e07
2 changed files with 24 additions and 1 deletions
|
@ -35,7 +35,7 @@ func containsReadHeaderTimeout(node *ast.CompositeLit) bool {
|
|||
for _, elt := range node.Elts {
|
||||
if kv, ok := elt.(*ast.KeyValueExpr); ok {
|
||||
if ident, ok := kv.Key.(*ast.Ident); ok {
|
||||
if ident.Name == "ReadHeaderTimeout" {
|
||||
if ident.Name == "ReadHeaderTimeout" || ident.Name == "ReadTimeout" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1050,6 +1050,29 @@ func HelloServer(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
`}, 0, gosec.NewConfig()},
|
||||
{[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
|
||||
})
|
||||
server := &http.Server{
|
||||
Addr: ":1234",
|
||||
ReadTimeout: 1 * time.Second,
|
||||
}
|
||||
err := server.ListenAndServe()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
`}, 0, gosec.NewConfig()},
|
||||
}
|
||||
|
||||
// SampleCodeG113 - Usage of Rat.SetString in math/big with an overflow
|
||||
|
|
Loading…
Reference in a new issue