diff --git a/.golangci.yml b/.golangci.yml index a8b88ab06..a2fba7eb5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -25,7 +25,6 @@ issues: exclude: - G104 # Errors unhandled - G103 # Use of unsafe calls should be audited - - G114 # Use of net/http serve function without timeouts. - G115 # Integer overflow conversion should be audited - G204 # Subprocess launched with variable - G301 # Expect directory permissions to be 0750 or less diff --git a/internal/network_test_utils.go b/internal/network_test_utils.go index 200e24384..77aa01a9b 100644 --- a/internal/network_test_utils.go +++ b/internal/network_test_utils.go @@ -21,6 +21,7 @@ import ( "net/http" "os/exec" "testing" + "time" "github.com/miekg/dns" "golang.org/x/sync/errgroup" @@ -132,7 +133,14 @@ func (l localNetworkServices) Serve(ctx context.Context) error { }) } - return http.ListenAndServe(l.ipAddr+":80", nil) + srv := &http.Server{ + Addr: l.ipAddr + ":80", + Handler: nil, + ReadTimeout: 5 * time.Second, + WriteTimeout: 5 * time.Second, + IdleTimeout: 30 * time.Second, + } + return srv.ListenAndServe() }) return errGroup.Wait()