From e5c9387cd9982f51e220f192bbd2f9b642ec8503 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 12 May 2023 23:51:20 +0800 Subject: [PATCH] Update Github Actions Go Version (#12391) * update github actions * use quotes or it is go 1.2 lol * Update gosec * Update gosec * Update go lint * fix gosec violations --------- Co-authored-by: Preston Van Loon --- .github/workflows/go.yml | 14 +++++++------- runtime/debug/debug.go | 6 +++++- tools/bootnode/bootnode.go | 8 +++++++- tools/eth1exporter/main.go | 6 +++++- tools/http-request-sink/main.go | 7 ++++++- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6ff354d1a1..9ea889caac 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -26,14 +26,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Set up Go 1.19 + - name: Set up Go 1.20 uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: '1.20' - name: Run Gosec Security Scanner run: | # https://github.com/securego/gosec/issues/469 export PATH=$PATH:$(go env GOPATH)/bin - go install github.com/securego/gosec/v2/cmd/gosec@v2.12.0 + go install github.com/securego/gosec/v2/cmd/gosec@v2.15.0 gosec -exclude=G307 -exclude-dir=crypto/bls/herumi ./... lint: @@ -43,16 +43,16 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Set up Go 1.19 + - name: Set up Go 1.20 uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: '1.20' id: go - name: Golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.50.1 + version: v1.52.2 args: --config=.golangci.yml --out-${NO_FUTURE}format colored-line-number build: @@ -62,7 +62,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: 1.19 + go-version: '1.20' id: go - name: Check out code into the Go module directory diff --git a/runtime/debug/debug.go b/runtime/debug/debug.go index 368f358516..c34d5ccdc3 100644 --- a/runtime/debug/debug.go +++ b/runtime/debug/debug.go @@ -354,7 +354,11 @@ func startPProf(address string) { http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize)) log.WithField("addr", fmt.Sprintf("http://%s/debug/pprof", address)).Info("Starting pprof server") go func() { - if err := http.ListenAndServe(address, nil); err != nil { + srv := &http.Server{ + Addr: address, + ReadHeaderTimeout: 3 * time.Second, + } + if err := srv.ListenAndServe(); err != nil { log.Error("Failure in running pprof server", "err", err) } }() diff --git a/tools/bootnode/bootnode.go b/tools/bootnode/bootnode.go index 830d080ec8..e03850955d 100644 --- a/tools/bootnode/bootnode.go +++ b/tools/bootnode/bootnode.go @@ -114,7 +114,13 @@ func main() { mux := http.NewServeMux() mux.HandleFunc("/p2p", handler.httpHandler) - if err := http.ListenAndServe(fmt.Sprintf(":%d", *metricsPort), mux); err != nil { + srv := &http.Server{ + Addr: fmt.Sprintf(":%d", *metricsPort), + ReadHeaderTimeout: 3 * time.Second, + Handler: mux, + } + + if err := srv.ListenAndServe(); err != nil { log.WithError(err).Fatal("Failed to start server") } diff --git a/tools/eth1exporter/main.go b/tools/eth1exporter/main.go index 289b25a4fd..00b9738c9f 100644 --- a/tools/eth1exporter/main.go +++ b/tools/eth1exporter/main.go @@ -76,7 +76,11 @@ func main() { http.HandleFunc("/metrics", MetricsHTTP) http.HandleFunc("/reload", ReloadHTTP) - log.Fatal(http.ListenAndServe(fmt.Sprintf("127.0.0.1:%d", *port), nil)) + srv := &http.Server{ + Addr: fmt.Sprintf("127.0.0.1:%d", *port), + ReadHeaderTimeout: 3 * time.Second, + } + log.Fatal(srv.ListenAndServe()) } // Watching address wrapper diff --git a/tools/http-request-sink/main.go b/tools/http-request-sink/main.go index 1ebecbf09e..1dd8e21156 100644 --- a/tools/http-request-sink/main.go +++ b/tools/http-request-sink/main.go @@ -13,6 +13,7 @@ import ( "os" "path/filepath" "strconv" + "time" "github.com/prysmaticlabs/prysm/v4/config/params" ) @@ -51,7 +52,11 @@ func main() { } }) log.Printf("Listening on port %d", *port) - log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil)) + srv := &http.Server{ + Addr: ":" + strconv.Itoa(*port), + ReadHeaderTimeout: 3 * time.Second, + } + log.Fatal(srv.ListenAndServe()) } func captureRequest(f *os.File, m map[string]interface{}) error {