From 98654202c2f70c4d53490a93dbfff4dc112958d2 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 3 Sep 2022 17:49:54 +0200 Subject: [PATCH] linting: G112: Potential Slowloris Attack Picking 2 seconds, although that's just a randomly picked timeout; given that this is only for testing, it's not too important. e2e/plugin/basic/basic.go:25:12: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec) server := http.Server{ Addr: l.Addr().String(), Handler: http.NewServeMux(), } Signed-off-by: Sebastiaan van Stijn --- e2e/plugin/basic/basic.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e/plugin/basic/basic.go b/e2e/plugin/basic/basic.go index 892272826..b03ca96ee 100644 --- a/e2e/plugin/basic/basic.go +++ b/e2e/plugin/basic/basic.go @@ -6,6 +6,7 @@ import ( "net/http" "os" "path/filepath" + "time" ) func main() { @@ -23,8 +24,9 @@ func main() { mux := http.NewServeMux() server := http.Server{ - Addr: l.Addr().String(), - Handler: http.NewServeMux(), + Addr: l.Addr().String(), + Handler: http.NewServeMux(), + ReadHeaderTimeout: 2 * time.Second, // G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server } mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1.1+json")