summaryrefslogtreecommitdiff
path: root/integration/plugin
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2022-09-04 14:44:55 +0200
committerSebastiaan van Stijn <github@gone.nl>2022-09-04 15:36:51 +0200
commit31fb92c6099110b6cc036be263ab4cd02e0d2bf7 (patch)
tree93145faae37a7503fa4a54abbfe5d17ed6355b13 /integration/plugin
parent561a010161d20fa3367b6b7e9efefe04161c1291 (diff)
downloaddocker-31fb92c6099110b6cc036be263ab4cd02e0d2bf7.tar.gz
linting: gosec: fix or suppress G112, G114 in test code
Updating test-code only; set ReadHeaderTimeout for some, or suppress the linter error for others. contrib/httpserver/server.go:11:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) log.Panic(http.ListenAndServe(":80", nil)) ^ integration/plugin/logging/cmd/close_on_start/main.go:42:12: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec) server := http.Server{ Addr: l.Addr().String(), Handler: mux, } integration/plugin/logging/cmd/discard/main.go:17:12: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec) server := http.Server{ Addr: l.Addr().String(), Handler: mux, } integration/plugin/logging/cmd/dummy/main.go:14: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(), } integration/plugin/volumes/cmd/dummy/main.go:14: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(), } testutil/fixtures/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(), } volume/testutils/testutils.go:170:5: G114: Use of net/http serve function that has no support for setting timeouts (gosec) go http.Serve(l, mux) ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'integration/plugin')
-rw-r--r--integration/plugin/logging/cmd/close_on_start/main.go6
-rw-r--r--integration/plugin/logging/cmd/discard/main.go6
-rw-r--r--integration/plugin/logging/cmd/dummy/main.go6
-rw-r--r--integration/plugin/volumes/cmd/dummy/main.go6
4 files changed, 16 insertions, 8 deletions
diff --git a/integration/plugin/logging/cmd/close_on_start/main.go b/integration/plugin/logging/cmd/close_on_start/main.go
index 6891d6a995..66a9ae257d 100644
--- a/integration/plugin/logging/cmd/close_on_start/main.go
+++ b/integration/plugin/logging/cmd/close_on_start/main.go
@@ -6,6 +6,7 @@ import (
"net"
"net/http"
"os"
+ "time"
)
type start struct {
@@ -40,8 +41,9 @@ func main() {
fmt.Fprintln(w, `{}`)
})
server := http.Server{
- Addr: l.Addr().String(),
- Handler: mux,
+ Addr: l.Addr().String(),
+ Handler: mux,
+ ReadHeaderTimeout: 2 * time.Second, // This server is not for production code; picked an arbitrary timeout to statisfy gosec (G112: Potential Slowloris Attack)
}
server.Serve(l)
diff --git a/integration/plugin/logging/cmd/discard/main.go b/integration/plugin/logging/cmd/discard/main.go
index 15577ca0a9..3a7f2a88c1 100644
--- a/integration/plugin/logging/cmd/discard/main.go
+++ b/integration/plugin/logging/cmd/discard/main.go
@@ -3,6 +3,7 @@ package main
import (
"net"
"net/http"
+ "time"
)
func main() {
@@ -15,8 +16,9 @@ func main() {
handle(mux)
server := http.Server{
- Addr: l.Addr().String(),
- Handler: mux,
+ Addr: l.Addr().String(),
+ Handler: mux,
+ ReadHeaderTimeout: 2 * time.Second, // This server is not for production code; picked an arbitrary timeout to statisfy gosec (G112: Potential Slowloris Attack)
}
server.Serve(l)
}
diff --git a/integration/plugin/logging/cmd/dummy/main.go b/integration/plugin/logging/cmd/dummy/main.go
index f91b4f3b02..f2c81229a3 100644
--- a/integration/plugin/logging/cmd/dummy/main.go
+++ b/integration/plugin/logging/cmd/dummy/main.go
@@ -3,6 +3,7 @@ package main
import (
"net"
"net/http"
+ "time"
)
func main() {
@@ -12,8 +13,9 @@ func main() {
}
server := http.Server{
- Addr: l.Addr().String(),
- Handler: http.NewServeMux(),
+ Addr: l.Addr().String(),
+ Handler: http.NewServeMux(),
+ ReadHeaderTimeout: 2 * time.Second, // This server is not for production code; picked an arbitrary timeout to statisfy gosec (G112: Potential Slowloris Attack)
}
server.Serve(l)
}
diff --git a/integration/plugin/volumes/cmd/dummy/main.go b/integration/plugin/volumes/cmd/dummy/main.go
index f91b4f3b02..f2c81229a3 100644
--- a/integration/plugin/volumes/cmd/dummy/main.go
+++ b/integration/plugin/volumes/cmd/dummy/main.go
@@ -3,6 +3,7 @@ package main
import (
"net"
"net/http"
+ "time"
)
func main() {
@@ -12,8 +13,9 @@ func main() {
}
server := http.Server{
- Addr: l.Addr().String(),
- Handler: http.NewServeMux(),
+ Addr: l.Addr().String(),
+ Handler: http.NewServeMux(),
+ ReadHeaderTimeout: 2 * time.Second, // This server is not for production code; picked an arbitrary timeout to statisfy gosec (G112: Potential Slowloris Attack)
}
server.Serve(l)
}