From 54f1c837cf8ce9546b2dd531c0d58a8d9866cb96 Mon Sep 17 00:00:00 2001 From: Diana Devasia Date: Tue, 12 Mar 2024 13:29:25 -0400 Subject: [PATCH] Updating the version of go in golangci.yml, fixing the linters and added unreleased changelog --- .golangci.yml | 2 +- CHANGELOG.md | 2 ++ api_test.go | 6 +++--- cmd/server/server.go | 2 +- test/e2e/benchmark_test.go | 10 +++++----- testhelper/tcp_server.go | 4 ++-- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fbf43834..e11a2c82 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ --- run: - go: "1.15" + go: "1.22" linters: disable-all: true enable: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ddc8612..61a7bf3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # [Unreleased] +* Updated go version to 1.22.1 to fix 3 CVEs +* Updated the version of golangci to 1.56.2 and disabled depguard rule in golangci # [2.8.0] - 2024-02-27 diff --git a/api_test.go b/api_test.go index 61e99971..c1a91a69 100644 --- a/api_test.go +++ b/api_test.go @@ -3,7 +3,7 @@ package toxiproxy_test import ( "bytes" "flag" - "io/ioutil" + "io" "net/http" "os" "testing" @@ -197,7 +197,7 @@ func TestPopulateDefaultEnabled(t *testing.T) { defer resp.Body.Close() if resp.StatusCode != http.StatusCreated { - message, _ := ioutil.ReadAll(resp.Body) + message, _ := io.ReadAll(resp.Body) t.Fatalf("Failed to populate proxy list: HTTP %s\n%s", resp.Status, string(message)) } @@ -1098,7 +1098,7 @@ func TestVersionEndpointReturnsVersion(t *testing.T) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { t.Fatal("Unable to read body from response") } diff --git a/cmd/server/server.go b/cmd/server/server.go index d188adb1..2bb66639 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -67,7 +67,7 @@ func run() error { return nil } - rand.Seed(cli.seed) + rand.New(rand.NewSource(cli.seed)) // #nosec G404 -- ignoring this rule logger := setupLogger() log.Logger = logger diff --git a/test/e2e/benchmark_test.go b/test/e2e/benchmark_test.go index 10c879ed..7f1fe949 100644 --- a/test/e2e/benchmark_test.go +++ b/test/e2e/benchmark_test.go @@ -1,7 +1,7 @@ package main import ( - "io/ioutil" + "io" "net/http" "testing" ) @@ -38,7 +38,7 @@ func BenchmarkDirect(b *testing.B) { if err != nil { b.Fatal(err) } - _, err = ioutil.ReadAll(resp.Body) + _, err = io.ReadAll(resp.Body) if err != nil { b.Fatal(err) } @@ -55,7 +55,7 @@ func BenchmarkProxy(b *testing.B) { if err != nil { b.Fatal(err) } - _, err = ioutil.ReadAll(resp.Body) + _, err = io.ReadAll(resp.Body) if err != nil { b.Fatal(err) } @@ -72,7 +72,7 @@ func BenchmarkDirectSmall(b *testing.B) { if err != nil { b.Fatal(err) } - _, err = ioutil.ReadAll(resp.Body) + _, err = io.ReadAll(resp.Body) if err != nil { b.Fatal(err) } @@ -89,7 +89,7 @@ func BenchmarkProxySmall(b *testing.B) { if err != nil { b.Fatal(err) } - _, err = ioutil.ReadAll(resp.Body) + _, err = io.ReadAll(resp.Body) if err != nil { b.Fatal(err) } diff --git a/testhelper/tcp_server.go b/testhelper/tcp_server.go index a5a58dd9..0ef7eed7 100644 --- a/testhelper/tcp_server.go +++ b/testhelper/tcp_server.go @@ -1,7 +1,7 @@ package testhelper import ( - "io/ioutil" + "io" "net" "testing" ) @@ -40,7 +40,7 @@ func (server *TCPServer) handle_connection() (err error) { } defer conn.Close() - val, err := ioutil.ReadAll(conn) + val, err := io.ReadAll(conn) if err != nil { return }