diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c8a962..47682a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,12 +15,12 @@ jobs: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: - go-version: '1.23' + go-version: '1.24' cache: true cache-dependency-path: rpc-health-checker/go.sum @@ -30,7 +30,7 @@ jobs: go mod download - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v9 with: version: latest working-directory: rpc-health-checker @@ -42,12 +42,12 @@ jobs: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: - go-version: '1.23' + go-version: '1.24' cache: true cache-dependency-path: go-proxy-cache/go.sum @@ -57,7 +57,7 @@ jobs: go mod download - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v9 with: version: latest working-directory: go-proxy-cache \ No newline at end of file diff --git a/.github/workflows/lua_tests.yml b/.github/workflows/lua_tests.yml index 850e843..af266fc 100644 --- a/.github/workflows/lua_tests.yml +++ b/.github/workflows/lua_tests.yml @@ -23,7 +23,7 @@ jobs: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Install Lua and LuaRocks run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f084eef..61c562b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,12 +15,12 @@ jobs: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: - go-version: '1.23' + go-version: '1.24' cache: true cache-dependency-path: rpc-health-checker/go.sum @@ -42,12 +42,12 @@ jobs: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: - go-version: '1.23' + go-version: '1.24' cache: true cache-dependency-path: go-proxy-cache/go.sum diff --git a/go-auth-service/Dockerfile b/go-auth-service/Dockerfile index eb58a39..3225929 100644 --- a/go-auth-service/Dockerfile +++ b/go-auth-service/Dockerfile @@ -1,5 +1,5 @@ # Build stage -FROM golang:1.23-alpine AS builder +FROM golang:1.24-alpine AS builder WORKDIR /app diff --git a/go-auth-service/cmd/test-puzzle-auth/main.go b/go-auth-service/cmd/test-puzzle-auth/main.go index bf2a78d..442ccc0 100644 --- a/go-auth-service/cmd/test-puzzle-auth/main.go +++ b/go-auth-service/cmd/test-puzzle-auth/main.go @@ -181,7 +181,9 @@ func checkServiceStatus(baseURL string) bool { if err != nil { return false } - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() return resp.StatusCode == 200 } @@ -190,7 +192,9 @@ func getPuzzle(baseURL string) (*PuzzleResponse, error) { if err != nil { return nil, err } - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() if resp.StatusCode != 200 { body, _ := io.ReadAll(resp.Body) @@ -215,7 +219,9 @@ func submitSolution(baseURL string, solveReq SolveRequest) (*TokenResponse, erro if err != nil { return nil, err } - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() if resp.StatusCode != 200 { body, _ := io.ReadAll(resp.Body) @@ -243,7 +249,9 @@ func verifyToken(baseURL, token string) bool { if err != nil { return false } - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() return resp.StatusCode == 200 } diff --git a/go-auth-service/go.mod b/go-auth-service/go.mod index e15289a..def3473 100644 --- a/go-auth-service/go.mod +++ b/go-auth-service/go.mod @@ -1,22 +1,22 @@ module go-auth-service -go 1.23.0 - -toolchain go1.23.10 +go 1.24.0 require ( - github.com/golang-jwt/jwt/v5 v5.2.2 - github.com/prometheus/client_golang v1.22.0 - golang.org/x/crypto v0.39.0 + github.com/golang-jwt/jwt/v5 v5.3.0 + github.com/prometheus/client_golang v1.23.2 + golang.org/x/crypto v0.46.0 ) require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.62.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - golang.org/x/sys v0.33.0 // indirect - google.golang.org/protobuf v1.36.5 // indirect + github.com/prometheus/client_model v0.6.2 // indirect + github.com/prometheus/common v0.66.1 // indirect + github.com/prometheus/procfs v0.16.1 // indirect + go.yaml.in/yaml/v2 v2.4.2 // indirect + golang.org/x/sys v0.39.0 // indirect + google.golang.org/protobuf v1.36.8 // indirect ) diff --git a/go-auth-service/go.sum b/go-auth-service/go.sum index 91c0818..af8e7bb 100644 --- a/go-auth-service/go.sum +++ b/go-auth-service/go.sum @@ -2,31 +2,49 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q= -github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0= -github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= -github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= -github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= -github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= -github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= -golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= -google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= +github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= +github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= +github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= +github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs= +github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= +github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg= +github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= +go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= +golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= +google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go-auth-service/internal/handlers/handlers.go b/go-auth-service/internal/handlers/handlers.go index c081a72..fa691f4 100644 --- a/go-auth-service/internal/handlers/handlers.go +++ b/go-auth-service/internal/handlers/handlers.go @@ -3,6 +3,7 @@ package handlers import ( "encoding/json" "fmt" + "log/slog" "net/http" "strings" "sync" @@ -51,7 +52,9 @@ func (h *Handlers) PuzzleHandler(w http.ResponseWriter, r *http.Request) { }, } - json.NewEncoder(w).Encode(response) + if err := json.NewEncoder(w).Encode(response); err != nil { + slog.Error("failed to encode puzzle response", "error", err) + } } // SolveRequest for puzzle solving @@ -138,7 +141,9 @@ func (h *Handlers) SolveHandler(w http.ResponseWriter, r *http.Request) { "request_limit": h.config.RequestsPerToken, } - json.NewEncoder(w).Encode(response) + if err := json.NewEncoder(w).Encode(response); err != nil { + slog.Error("failed to encode solve response", "error", err) + } } // TestSolveHandler provides a test endpoint that generates a valid solution with HMAC @@ -176,7 +181,9 @@ func (h *Handlers) TestSolveHandler(w http.ResponseWriter, r *http.Request) { }, } - json.NewEncoder(w).Encode(response) + if err := json.NewEncoder(w).Encode(response); err != nil { + slog.Error("failed to encode test-solve response", "error", err) + } } // VerifyHandler handles JWT token verification for nginx auth_request @@ -260,5 +267,7 @@ func (h *Handlers) StatusHandler(w http.ResponseWriter, r *http.Request) { }, } - json.NewEncoder(w).Encode(response) + if err := json.NewEncoder(w).Encode(response); err != nil { + slog.Error("failed to encode status response", "error", err) + } } diff --git a/go-proxy-cache/Dockerfile b/go-proxy-cache/Dockerfile index 499cccb..f07996d 100644 --- a/go-proxy-cache/Dockerfile +++ b/go-proxy-cache/Dockerfile @@ -1,5 +1,5 @@ # Build stage -FROM golang:1.23-alpine AS builder +FROM golang:1.24-alpine AS builder # Install dependencies RUN apk add --no-cache git diff --git a/go-proxy-cache/go.mod b/go-proxy-cache/go.mod index 1087dac..55ad7a3 100644 --- a/go-proxy-cache/go.mod +++ b/go-proxy-cache/go.mod @@ -1,34 +1,30 @@ module go-proxy-cache -go 1.23.0 - -toolchain go1.23.11 +go 1.24.0 require ( github.com/allegro/bigcache/v3 v3.1.0 github.com/go-redis/redis/v8 v8.11.5 - github.com/gorilla/mux v1.8.0 - github.com/prometheus/client_golang v1.23.0 - github.com/stretchr/testify v1.10.0 + github.com/gorilla/mux v1.8.1 + github.com/prometheus/client_golang v1.23.2 + github.com/stretchr/testify v1.11.1 go.uber.org/mock v0.6.0 - go.uber.org/zap v1.24.0 + go.uber.org/zap v1.27.1 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/benbjohnson/clock v1.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/kr/text v0.2.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.65.0 // indirect + github.com/prometheus/common v0.66.1 // indirect github.com/prometheus/procfs v0.16.1 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect - golang.org/x/sys v0.33.0 // indirect - google.golang.org/protobuf v1.36.6 // indirect + go.uber.org/multierr v1.10.0 // indirect + go.yaml.in/yaml/v2 v2.4.2 // indirect + golang.org/x/sys v0.35.0 // indirect + google.golang.org/protobuf v1.36.8 // indirect ) diff --git a/go-proxy-cache/go.sum b/go-proxy-cache/go.sum index cb29f27..daac04e 100644 --- a/go-proxy-cache/go.sum +++ b/go-proxy-cache/go.sum @@ -1,13 +1,9 @@ github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk= github.com/allegro/bigcache/v3 v3.1.0/go.mod h1:aPyh7jEvrog9zAwx5N7+JUQX5dZTSGpxF1LAR4dr35I= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -18,8 +14,8 @@ github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -36,42 +32,38 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc= -github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE= +github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= +github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE= -github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8= +github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs= +github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg= github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= -google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= -google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= +go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= +go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= +golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= +golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= +google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= +google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/go-proxy-cache/internal/cache/l2/keydb_client.go b/go-proxy-cache/internal/cache/l2/keydb_client.go index 01602c2..e89f2c8 100644 --- a/go-proxy-cache/internal/cache/l2/keydb_client.go +++ b/go-proxy-cache/internal/cache/l2/keydb_client.go @@ -69,7 +69,7 @@ func NewRedisKeyDbClient(keydbCfg *config.KeyDBConfig, keydbURL string, logger * defer cancel() if err := client.Ping(ctx).Err(); err != nil { - client.Close() // Clean up the client + _ = client.Close() // Clean up the client return nil, fmt.Errorf("failed to connect to KeyDB at %s: %w", opts.Addr, err) } diff --git a/go-proxy-cache/internal/cache_rules/config_reader.go b/go-proxy-cache/internal/cache_rules/config_reader.go index b0efeb4..3532e46 100644 --- a/go-proxy-cache/internal/cache_rules/config_reader.go +++ b/go-proxy-cache/internal/cache_rules/config_reader.go @@ -18,7 +18,7 @@ func LoadCacheRulesConfig(rulesPath string, logger *zap.Logger) (interfaces.Cach if err != nil { return nil, fmt.Errorf("failed to open cache rules file: %w", err) } - defer file.Close() + defer func() { _ = file.Close() }() var config CacheRulesConfig decoder := yaml.NewDecoder(file) diff --git a/go-proxy-cache/internal/cache_rules/config_reader_test.go b/go-proxy-cache/internal/cache_rules/config_reader_test.go index 9f51a9d..83b412b 100644 --- a/go-proxy-cache/internal/cache_rules/config_reader_test.go +++ b/go-proxy-cache/internal/cache_rules/config_reader_test.go @@ -36,7 +36,7 @@ cache_rules: ` tmpFile := createTempYAMLFile(t, validYAML) - defer os.Remove(tmpFile) + defer func() { _ = os.Remove(tmpFile) }() // Test loading the configuration config, err := LoadCacheRulesConfig(tmpFile, logger) @@ -92,7 +92,7 @@ cache_rules: ` tmpFile := createTempYAMLFile(t, invalidYAML) - defer os.Remove(tmpFile) + defer func() { _ = os.Remove(tmpFile) }() config, err := LoadCacheRulesConfig(tmpFile, logger) @@ -144,7 +144,7 @@ cache_rules: for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { tmpFile := createTempYAMLFile(t, tc.yaml) - defer os.Remove(tmpFile) + defer func() { _ = os.Remove(tmpFile) }() config, err := LoadCacheRulesConfig(tmpFile, logger) @@ -261,7 +261,7 @@ cache_rules: ` tmpFile := createTempYAMLFile(t, complexYAML) - defer os.Remove(tmpFile) + defer func() { _ = os.Remove(tmpFile) }() config, err := LoadCacheRulesConfig(tmpFile, logger) @@ -288,7 +288,7 @@ func TestLoadCacheRulesConfig_EmptyFile(t *testing.T) { logger := zaptest.NewLogger(t) tmpFile := createTempYAMLFile(t, "") - defer os.Remove(tmpFile) + defer func() { _ = os.Remove(tmpFile) }() config, err := LoadCacheRulesConfig(tmpFile, logger) @@ -313,7 +313,7 @@ cache_rules: ` tmpFile := createTempYAMLFile(t, invalidCacheTypeYAML) - defer os.Remove(tmpFile) + defer func() { _ = os.Remove(tmpFile) }() config, err := LoadCacheRulesConfig(tmpFile, logger) @@ -338,7 +338,7 @@ cache_rules: ` tmpFile := createTempYAMLFile(t, validYAML) - defer os.Remove(tmpFile) + defer func() { _ = os.Remove(tmpFile) }() config, err := LoadCacheRulesConfig(tmpFile, logger) diff --git a/go-proxy-cache/internal/config/config.go b/go-proxy-cache/internal/config/config.go index f14b118..c8a8df0 100644 --- a/go-proxy-cache/internal/config/config.go +++ b/go-proxy-cache/internal/config/config.go @@ -62,7 +62,7 @@ func LoadConfig(configPath string, logger *zap.Logger) (*Config, error) { if err != nil { return nil, fmt.Errorf("failed to open config file: %w", err) } - defer file.Close() + defer func() { _ = file.Close() }() var config Config decoder := yaml.NewDecoder(file) diff --git a/go-proxy-cache/internal/config/config_test.go b/go-proxy-cache/internal/config/config_test.go index 1b4ba8e..8e9c0b0 100644 --- a/go-proxy-cache/internal/config/config_test.go +++ b/go-proxy-cache/internal/config/config_test.go @@ -51,7 +51,11 @@ multi_cache: ` configFile := createTestConfigFile(t, validConfig) - defer os.Remove(configFile) + defer func() { + if err := os.Remove(configFile); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() config, err := LoadConfig(configFile, logger) if err != nil { @@ -98,7 +102,11 @@ keydb: ` configFile := createTestConfigFile(t, minimalConfig) - defer os.Remove(configFile) + defer func() { + if err := os.Remove(configFile); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() config, err := LoadConfig(configFile, logger) if err != nil { @@ -139,7 +147,11 @@ bigcache: ` configFile := createTestConfigFile(t, invalidConfig) - defer os.Remove(configFile) + defer func() { + if err := os.Remove(configFile); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() _, err := LoadConfig(configFile, logger) if err == nil { diff --git a/go-proxy-cache/internal/httpserver/server.go b/go-proxy-cache/internal/httpserver/server.go index 1303c28..281e740 100644 --- a/go-proxy-cache/internal/httpserver/server.go +++ b/go-proxy-cache/internal/httpserver/server.go @@ -104,7 +104,7 @@ func (s *Server) parseRequest(r *http.Request, v interface{}) error { if err != nil { return err } - defer r.Body.Close() + defer func() { _ = r.Body.Close() }() return json.Unmarshal(body, v) } diff --git a/rpc-health-checker/Dockerfile b/rpc-health-checker/Dockerfile index 36170ec..8cd4414 100644 --- a/rpc-health-checker/Dockerfile +++ b/rpc-health-checker/Dockerfile @@ -1,5 +1,5 @@ # Build stage -FROM golang:1.23-alpine AS builder +FROM golang:1.24-alpine AS builder WORKDIR /app COPY . . diff --git a/rpc-health-checker/api/server.go b/rpc-health-checker/api/server.go index a39d3c4..bbc4d89 100644 --- a/rpc-health-checker/api/server.go +++ b/rpc-health-checker/api/server.go @@ -91,7 +91,11 @@ func (s *httpServer) loadProviders(w io.Writer, path string) error { if err != nil { return err } - defer f.Close() + defer func() { + if closeErr := f.Close(); closeErr != nil { + s.logger.Error("failed to close file", "error", closeErr) + } + }() _, err = io.Copy(w, f) return err diff --git a/rpc-health-checker/config/chainconfig_test.go b/rpc-health-checker/config/chainconfig_test.go index 5e52172..94130f2 100644 --- a/rpc-health-checker/config/chainconfig_test.go +++ b/rpc-health-checker/config/chainconfig_test.go @@ -32,11 +32,17 @@ func TestLoadChains(t *testing.T) { tmpFile, err := os.CreateTemp("", "test-config-*.json") assert.NoError(t, err) - defer os.Remove(tmpFile.Name()) + defer func() { + if err := os.Remove(tmpFile.Name()); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() _, err = tmpFile.WriteString(content) assert.NoError(t, err) - tmpFile.Close() + if err := tmpFile.Close(); err != nil { + t.Fatalf("failed to close temp file: %v", err) + } t.Run("successful load", func(t *testing.T) { chains, err := LoadChains(tmpFile.Name()) @@ -57,11 +63,17 @@ func TestLoadChains(t *testing.T) { t.Run("invalid json", func(t *testing.T) { invalidFile, err := os.CreateTemp("", "invalid-*.json") assert.NoError(t, err) - defer os.Remove(invalidFile.Name()) + defer func() { + if err := os.Remove(invalidFile.Name()); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() _, err = invalidFile.WriteString("{invalid}") assert.NoError(t, err) - invalidFile.Close() + if err := invalidFile.Close(); err != nil { + t.Fatalf("failed to close temp file: %v", err) + } _, err = LoadChains(invalidFile.Name()) assert.Error(t, err) @@ -90,11 +102,17 @@ func TestLoadReferenceChains(t *testing.T) { tmpFile, err := os.CreateTemp("", "test-ref-config-*.json") assert.NoError(t, err) - defer os.Remove(tmpFile.Name()) + defer func() { + if err := os.Remove(tmpFile.Name()); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() _, err = tmpFile.WriteString(content) assert.NoError(t, err) - tmpFile.Close() + if err := tmpFile.Close(); err != nil { + t.Fatalf("failed to close temp file: %v", err) + } t.Run("successful load", func(t *testing.T) { chains, err := LoadReferenceChains(tmpFile.Name()) @@ -115,11 +133,17 @@ func TestLoadReferenceChains(t *testing.T) { t.Run("invalid json", func(t *testing.T) { invalidFile, err := os.CreateTemp("", "invalid-ref-*.json") assert.NoError(t, err) - defer os.Remove(invalidFile.Name()) + defer func() { + if err := os.Remove(invalidFile.Name()); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() _, err = invalidFile.WriteString("{invalid}") assert.NoError(t, err) - invalidFile.Close() + if err := invalidFile.Close(); err != nil { + t.Fatalf("failed to close temp file: %v", err) + } _, err = LoadReferenceChains(invalidFile.Name()) assert.Error(t, err) @@ -128,11 +152,17 @@ func TestLoadReferenceChains(t *testing.T) { t.Run("missing required fields", func(t *testing.T) { invalidFile, err := os.CreateTemp("", "missing-fields-*.json") assert.NoError(t, err) - defer os.Remove(invalidFile.Name()) + defer func() { + if err := os.Remove(invalidFile.Name()); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() _, err = invalidFile.WriteString(`{"chains": [{"name": "ethereum"}]}`) assert.NoError(t, err) - invalidFile.Close() + if err := invalidFile.Close(); err != nil { + t.Fatalf("failed to close temp file: %v", err) + } _, err = LoadReferenceChains(invalidFile.Name()) assert.Error(t, err) @@ -159,11 +189,17 @@ func TestLoadReferenceChains(t *testing.T) { tmpFile, err := os.CreateTemp("", "test-ref-upper-*.json") assert.NoError(t, err) - defer os.Remove(tmpFile.Name()) + defer func() { + if err := os.Remove(tmpFile.Name()); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() _, err = tmpFile.WriteString(content) assert.NoError(t, err) - tmpFile.Close() + if err := tmpFile.Close(); err != nil { + t.Fatalf("failed to close temp file: %v", err) + } chains, err := LoadReferenceChains(tmpFile.Name()) assert.NoError(t, err) diff --git a/rpc-health-checker/config/configreader_test.go b/rpc-health-checker/config/configreader_test.go index d3f6fa7..75d5069 100644 --- a/rpc-health-checker/config/configreader_test.go +++ b/rpc-health-checker/config/configreader_test.go @@ -68,14 +68,20 @@ func TestReadCheckerConfig(t *testing.T) { if err != nil { t.Fatalf("Failed to create temp file: %v", err) } - defer os.Remove(tmpFile.Name()) + defer func() { + if err := os.Remove(tmpFile.Name()); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() if tt.configJSON != "" { if _, err := tmpFile.WriteString(tt.configJSON); err != nil { t.Fatalf("Failed to write test config: %v", err) } } - tmpFile.Close() + if err := tmpFile.Close(); err != nil { + t.Fatalf("Failed to close temp file: %v", err) + } // Test ReadCheckerConfig config, err := ReadCheckerConfig(tmpFile.Name()) diff --git a/rpc-health-checker/config/testconfig_test.go b/rpc-health-checker/config/testconfig_test.go index 820efc6..ad9e7a0 100644 --- a/rpc-health-checker/config/testconfig_test.go +++ b/rpc-health-checker/config/testconfig_test.go @@ -25,11 +25,17 @@ func TestReadConfig(t *testing.T) { tmpFile, err := os.CreateTemp("", "test-config-*.json") require.NoError(t, err) - defer os.Remove(tmpFile.Name()) + defer func() { + if err := os.Remove(tmpFile.Name()); err != nil { + t.Logf("failed to remove temp file: %v", err) + } + }() _, err = tmpFile.WriteString(content) require.NoError(t, err) - tmpFile.Close() + if err := tmpFile.Close(); err != nil { + t.Fatalf("Failed to close temp file: %v", err) + } // Test reading config configs, err := ReadConfig(tmpFile.Name()) diff --git a/rpc-health-checker/e2e/e2e_test.go b/rpc-health-checker/e2e/e2e_test.go index 6939db1..49bcced 100644 --- a/rpc-health-checker/e2e/e2e_test.go +++ b/rpc-health-checker/e2e/e2e_test.go @@ -240,7 +240,9 @@ func (s *E2ETestSuite) TearDownSuite() { if err := s.providerSetup.Close(); err != nil { s.T().Logf("error stopping mock servers: %v", err) } - os.RemoveAll(testTempDir) + if err := os.RemoveAll(testTempDir); err != nil { + s.T().Logf("error removing temp directory: %v", err) + } } func (s *E2ETestSuite) writeJSONFile(path string, data interface{}) { @@ -352,7 +354,11 @@ func (s *E2ETestSuite) TestE2E() { s.Run("HTTP API returns providers", func() { resp, err := http.Get(fmt.Sprintf("http://localhost:%s/providers", testPort)) s.NoError(err) - defer resp.Body.Close() + defer func() { + if err := resp.Body.Close(); err != nil { + s.T().Logf("error closing response body: %v", err) + } + }() s.Equal(http.StatusOK, resp.StatusCode) diff --git a/rpc-health-checker/go.mod b/rpc-health-checker/go.mod index ee78fe4..c8361b3 100644 --- a/rpc-health-checker/go.mod +++ b/rpc-health-checker/go.mod @@ -1,34 +1,31 @@ module github.com/status-im/eth-rpc-proxy -go 1.23.0 - -toolchain go1.23.9 +go 1.24.0 require ( - github.com/go-playground/validator/v10 v10.23.0 - github.com/prometheus/client_golang v1.20.5 - github.com/stretchr/testify v1.10.0 + github.com/go-playground/validator/v10 v10.30.1 + github.com/prometheus/client_golang v1.23.2 + github.com/stretchr/testify v1.11.1 ) require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/gabriel-vasile/mimetype v1.4.12 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/klauspost/compress v1.17.9 // indirect github.com/kr/text v0.2.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - golang.org/x/crypto v0.36.0 // indirect - golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect - golang.org/x/text v0.23.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect + github.com/prometheus/client_model v0.6.2 // indirect + github.com/prometheus/common v0.66.1 // indirect + github.com/prometheus/procfs v0.16.1 // indirect + go.yaml.in/yaml/v2 v2.4.2 // indirect + golang.org/x/crypto v0.46.0 // indirect + golang.org/x/sys v0.39.0 // indirect + golang.org/x/text v0.32.0 // indirect + google.golang.org/protobuf v1.36.8 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/rpc-health-checker/go.sum b/rpc-health-checker/go.sum index c746f0c..ad9e7e7 100644 --- a/rpc-health-checker/go.sum +++ b/rpc-health-checker/go.sum @@ -5,20 +5,20 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= -github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw= +github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o= -github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w= +github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -31,28 +31,30 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= -github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= -github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= -github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= -github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= -github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= +github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= +github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= +github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= +github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs= +github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= +github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg= +github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= +go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= +golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= +google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= +google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/rpc-health-checker/metrics/metrics.go b/rpc-health-checker/metrics/metrics.go index 96fc52c..5dac094 100644 --- a/rpc-health-checker/metrics/metrics.go +++ b/rpc-health-checker/metrics/metrics.go @@ -78,17 +78,20 @@ func RecordRPCRequest(metrics RPCRequestMetrics) { errCategory := CategorizeError(metrics.RequestErr, metrics.HTTPStatus, metrics.EVMErrorCode) // Determine status code based on error type - statusCode := "success" // Default for successful requests - if errCategory == HTTPError { + var statusCode string + switch errCategory { + case HTTPError: statusCode = fmt.Sprintf("http_%d", metrics.HTTPStatus) - } else if errCategory == EVMError { + case EVMError: statusCode = fmt.Sprintf("evm_%d", metrics.EVMErrorCode) - } else if errCategory == JSONRPCError { + case JSONRPCError: statusCode = "jsonrpc_error" - } else if errCategory == NetworkError { + case NetworkError: statusCode = "network_error" - } else if errCategory == UnknownError { + case UnknownError: statusCode = "unknown_error" + default: + statusCode = "success" } rpcRequestsTotal.WithLabelValues( diff --git a/rpc-health-checker/provider/provider_utils.go b/rpc-health-checker/provider/provider_utils.go index 7fb7d04..ce8374c 100644 --- a/rpc-health-checker/provider/provider_utils.go +++ b/rpc-health-checker/provider/provider_utils.go @@ -18,7 +18,9 @@ func ReadRpcProviders(filename string) ([]RPCProvider, error) { if err != nil { return nil, err } - defer f.Close() + defer func() { + _ = f.Close() + }() var pf RPCProvidersFile if err := json.NewDecoder(f).Decode(&pf); err != nil { @@ -49,7 +51,9 @@ func WriteRpcProviders(filename string, providers []RPCProvider) error { if err != nil { return err } - defer f.Close() + defer func() { + _ = f.Close() + }() encoder := json.NewEncoder(f) encoder.SetIndent("", " ") // For readability diff --git a/rpc-health-checker/provider/provider_utils_test.go b/rpc-health-checker/provider/provider_utils_test.go index c47ad79..1f86b64 100644 --- a/rpc-health-checker/provider/provider_utils_test.go +++ b/rpc-health-checker/provider/provider_utils_test.go @@ -84,14 +84,18 @@ func (suite *RpcProviderTestSuite) SetupSuite() { // TearDownSuite is executed after all tests in the suite func (suite *RpcProviderTestSuite) TearDownSuite() { // Remove the temporary directory and all its contents - os.RemoveAll(suite.tempDir) + if err := os.RemoveAll(suite.tempDir); err != nil { + suite.T().Logf("failed to remove temp directory: %v", err) + } } // SetupTest is executed before each test func (suite *RpcProviderTestSuite) SetupTest() { // Clear the file before each test if it exists if _, err := os.Stat(suite.tempFile); err == nil { - os.Remove(suite.tempFile) + if err := os.Remove(suite.tempFile); err != nil { + suite.T().Logf("failed to remove temp file: %v", err) + } } } diff --git a/rpc-health-checker/requests_runner/method_caller_impl.go b/rpc-health-checker/requests_runner/method_caller_impl.go index 568710e..90f1768 100644 --- a/rpc-health-checker/requests_runner/method_caller_impl.go +++ b/rpc-health-checker/requests_runner/method_caller_impl.go @@ -103,7 +103,9 @@ func (r *RequestsRunner) CallMethod( ElapsedTime: time.Since(startTime), } } - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() httpStatus = resp.StatusCode