diff --git a/.golangci.yml b/.golangci.yml index 9ee1feec..164f0a17 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -20,6 +20,7 @@ linters: - unconvert - unparam - unused + - gosec settings: revive: rules: @@ -34,6 +35,12 @@ linters: - dupl - lll path: internal/* + - linters: + - gosec + path: _test\.go + - linters: + - gosec + path: test/ paths: - third_party$ - builtin$ diff --git a/internal/controller/funcs.go b/internal/controller/funcs.go index 2be67ed9..218ebb79 100644 --- a/internal/controller/funcs.go +++ b/internal/controller/funcs.go @@ -18,8 +18,10 @@ package controller import ( "context" + "crypto/rand" "fmt" - "math/rand" + "math" + "math/big" "strconv" apiv1beta1 "github.com/openstack-lightspeed/operator/api/v1beta1" @@ -354,7 +356,11 @@ func OLSConfigPing(ctx context.Context, helper *common_helper.Helper) error { labels = make(map[string]string) } - labels[randomLabelKey] = strconv.Itoa(rand.Int()) + randInt, err := rand.Int(rand.Reader, big.NewInt(math.MaxInt64)) + if err != nil { + return err + } + labels[randomLabelKey] = strconv.FormatInt(randInt.Int64(), 10) olsConfig.SetLabels(labels) if err := helper.GetClient().Update(ctx, &olsConfig); err != nil {