lint: add ReadHeaderTimeout (#1277)

currently build fail with:

```
run golangci-lint
  Running [/home/runner/golangci-lint-1.47.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
  Error: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec)
```

for example in this PR:
https://github.com/nektos/act/runs/7405009660?check_suite_focus=true

this sets the required ReadHeaderTimeout
This commit is contained in:
Robert Kowalski 2022-07-25 14:12:48 +02:00 committed by GitHub
parent 409446211f
commit 1a71c52ef3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ import (
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
"github.com/nektos/act/pkg/common" "github.com/nektos/act/pkg/common"
@ -277,7 +278,11 @@ func Serve(ctx context.Context, artifactPath string, port string) context.Cancel
downloads(router, fs) downloads(router, fs)
ip := common.GetOutboundIP().String() ip := common.GetOutboundIP().String()
server := &http.Server{Addr: fmt.Sprintf("%s:%s", ip, port), Handler: router} server := &http.Server{
Addr: fmt.Sprintf("%s:%s", ip, port),
ReadHeaderTimeout: 2 * time.Second,
Handler: router,
}
// run server // run server
go func() { go func() {