From b42cf3cb5e9652f3f2e65a89223f785b4ad92fb3 Mon Sep 17 00:00:00 2001 From: kskrzypczyn-arista Date: Wed, 11 Dec 2024 11:47:08 +0100 Subject: [PATCH] [MFW-5820] Update dependencies (#439) * [MFW-5820] Update dependencies * go.mod point to go version 1.22.7 * Bump go version in Dockerfile * Remove mount of SSH_AUTH_SOCK * Bump golangci-lint and its timeout (2 min) * Fix deprecated calls to rand.Seed --- Makefile | 4 +-- build/Dockerfile.build-glibc | 2 +- build/Dockerfile.build-musl | 4 +-- build/docker-compose.build.yml | 4 --- go.mod | 10 +++---- go.sum | 18 ++++++----- .../cacher/randomreplacementcache_test.go | 1 - util/net/interfaces/interfaces_test.go | 5 ++-- util/util_test.go | 30 ++++++++----------- 9 files changed, 35 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index cdfd3c1f..3b822d80 100644 --- a/Makefile +++ b/Makefile @@ -51,9 +51,9 @@ modules: environment lint: modules logscan $(call LOG_FUNCTION,"Running golang linter...") - cd /tmp; GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2 + cd /tmp; GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 $(shell go env GOPATH)/bin/golangci-lint --version - $(shell go env GOPATH)/bin/golangci-lint run + $(shell go env GOPATH)/bin/golangci-lint run --timeout 2m test: build $(call LOG_FUNCTION,"Running unit tests...") diff --git a/build/Dockerfile.build-glibc b/build/Dockerfile.build-glibc index b918afb2..93a436b5 100644 --- a/build/Dockerfile.build-glibc +++ b/build/Dockerfile.build-glibc @@ -1,4 +1,4 @@ -FROM golang:1.18.10 +FROM golang:1.22.9-bullseye LABEL maintainer="Sebastien Delafond " USER root diff --git a/build/Dockerfile.build-musl b/build/Dockerfile.build-musl index dcfdd658..cabb17f5 100644 --- a/build/Dockerfile.build-musl +++ b/build/Dockerfile.build-musl @@ -1,5 +1,5 @@ -# this is based on alpine:3.16 -FROM golang:1.19.9-alpine3.18 + +FROM golang:1.22.9-alpine3.20 LABEL maintainer="Sebastien Delafond " RUN apk update diff --git a/build/docker-compose.build.yml b/build/docker-compose.build.yml index 155445ef..f7af60fa 100644 --- a/build/docker-compose.build.yml +++ b/build/docker-compose.build.yml @@ -5,19 +5,15 @@ services: context: . dockerfile: Dockerfile.build-musl environment: - SSH_AUTH_SOCK: /ssh-agent UNIT_TEST: "yes" volumes: - ..:/go/untangle-shared - - ${SSH_AUTH_SOCK}:/ssh-agent glibc-local: build: context: . dockerfile: Dockerfile.build-glibc environment: - SSH_AUTH_SOCK: /ssh-agent UNIT_TEST: "yes" volumes: - ..:/go/untangle-shared - - ${SSH_AUTH_SOCK}:/ssh-agent diff --git a/go.mod b/go.mod index 35fdcc4b..b971662f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/untangle/golang-shared -go 1.18 +go 1.22 require ( github.com/gin-gonic/gin v1.9.1 @@ -39,10 +39,10 @@ require ( github.com/ugorji/go/codec v1.2.11 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/crypto v0.30.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 3a966b41..6adc5444 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= 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= @@ -29,6 +30,7 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= @@ -86,15 +88,15 @@ golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -104,8 +106,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -113,8 +115,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/util/cache/cacher/randomreplacementcache_test.go b/util/cache/cacher/randomreplacementcache_test.go index 0411719d..6081c5db 100644 --- a/util/cache/cacher/randomreplacementcache_test.go +++ b/util/cache/cacher/randomreplacementcache_test.go @@ -139,7 +139,6 @@ func (suite *RRCacheTestSuite) TestCapacityExceeded() { func TestMultiThreaded(t *testing.T) { var cacheSize uint = 1000 cache := NewRandomReplacementCache(cacheSize, "Multithreaded") - rand.Seed(1) elementRange := 20000 var wg sync.WaitGroup diff --git a/util/net/interfaces/interfaces_test.go b/util/net/interfaces/interfaces_test.go index 1ed3d6f1..3d275daa 100644 --- a/util/net/interfaces/interfaces_test.go +++ b/util/net/interfaces/interfaces_test.go @@ -1,7 +1,6 @@ package interfaces import ( - "fmt" "net" "testing" @@ -161,11 +160,11 @@ func TestGetNetworks(t *testing.T) { } else { printStr = "Test %s: IP '%s' is on the network '%s'" } - t.Errorf(fmt.Sprintf(printStr, testName, ip.String(), ipStr)) + t.Errorf(printStr, testName, ip.String(), ipStr) } } else { - t.Errorf(fmt.Sprintf("Test %s: IP '%s' did not parse correctly from %s", testName, ip.String(), ipStr)) + t.Errorf("Test %s: IP '%s' did not parse correctly from %s", testName, ip.String(), ipStr) } } } diff --git a/util/util_test.go b/util/util_test.go index 283324df..87c1f5d5 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -1,7 +1,6 @@ package util import ( - "math/rand" "os" "reflect" "sync" @@ -19,7 +18,6 @@ const ( // Test RandomizeSlice func TestRandomizeSlice(t *testing.T) { - seeds := []int64{10, 20, 30} tests := []struct { name string actual []interface{} @@ -38,24 +36,22 @@ func TestRandomizeSlice(t *testing.T) { }, } - for _, seed := range seeds { - rand.Seed(seed) + // setting custom seed wua Seed has been depricated - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - // Make a copy of the input slice to compare with the result - inputCopy := make([]interface{}, len(test.actual)) - copy(inputCopy, test.actual) + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + // Make a copy of the input slice to compare with the result + inputCopy := make([]interface{}, len(test.actual)) + copy(inputCopy, test.actual) - RandomizeSlice(test.actual) + RandomizeSlice(test.actual) - // Check if the input slice is not equal to the expected slice. - // lists of size <= 1 excluded. - if len(test.actual) > 1 && reflect.DeepEqual(test.actual, inputCopy) { - t.Errorf("Expected slice to be randomized, but it's the same as the original: %v", test.actual) - } - }) - } + // Check if the input slice is not equal to the expected slice. + // lists of size <= 1 excluded. + if len(test.actual) > 1 && reflect.DeepEqual(test.actual, inputCopy) { + t.Errorf("Expected slice to be randomized, but it's the same as the original: %v", test.actual) + } + }) } }