From 22dcdfd092fe9b69ab8cced03546032e0539a5a4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:52:58 +0200 Subject: [PATCH] [8.15](backport #5120) refactor: bump github.com/gofrs/uuid to current major version (#5249) --- .golangci.yml | 5 + NOTICE.txt | 104 +++++++----------- go.mod | 3 +- go.sum | 2 - .../pkg/agent/application/info/agent_id.go | 2 +- pkg/component/runtime/manager.go | 2 +- .../runtime/manager_fake_input_test.go | 2 +- pkg/component/runtime/runtime_comm.go | 2 +- pkg/testing/tools/estools/elasticsearch.go | 4 +- pkg/testing/tools/fleettools/fleet.go | 4 +- testing/fleetservertest/server.go | 4 +- .../agent_long_running_leak_test.go | 8 +- testing/integration/beats_serverless_test.go | 2 +- testing/integration/container_cmd_test.go | 10 +- testing/integration/delay_enroll_test.go | 6 +- testing/integration/endpoint_security_test.go | 12 +- testing/integration/endpoint_test_tools.go | 4 +- testing/integration/event_logging_test.go | 4 +- testing/integration/fleetserver_test.go | 6 +- testing/integration/log_level_test.go | 4 +- testing/integration/logs_ingestion_test.go | 14 +-- .../integration/metrics_monitoring_test.go | 6 +- .../integration/monitoring_endpoint_test.go | 4 +- ...monitoring_probe_preserve_text_cfg_test.go | 6 +- .../monitoring_probe_reload_test.go | 6 +- testing/integration/proxy_url_test.go | 4 +- testing/integration/upgrade_fleet_test.go | 6 +- testing/proxytest/proxytest.go | 4 +- 28 files changed, 106 insertions(+), 134 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 46fea870c08..6b05f6191d1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -99,6 +99,11 @@ linters-settings: - errors - fmt reason: "This package is deprecated, use `fmt.Errorf` with `%w` instead" + - github.com/google/uuid: + # Recommended modules that should be used instead. (Optional) + recommendations: + - github.com/gofrs/uuid/v5 + reason: "Use one uuid library consistently across the codebase" gomoddirectives: # Forbid local `replace` directives diff --git a/NOTICE.txt b/NOTICE.txt index cf081d6a4dc..a2b8034d195 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -3092,36 +3092,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Dependency : github.com/gofrs/uuid -Version: v4.4.0+incompatible -Licence type (autodetected): MIT --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid@v4.4.0+incompatible/LICENSE: - -Copyright (C) 2013-2018 by Maxim Bublis - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -------------------------------------------------------------------------------- Dependency : github.com/gofrs/uuid/v5 Version: v5.2.0 @@ -3401,43 +3371,6 @@ Contents of probable licence file $GOMODCACHE/github.com/google/pprof@v0.0.0-202 limitations under the License. --------------------------------------------------------------------------------- -Dependency : github.com/google/uuid -Version: v1.6.0 -Licence type (autodetected): BSD-3-Clause --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/google/uuid@v1.6.0/LICENSE: - -Copyright (c) 2009,2014 Google Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -------------------------------------------------------------------------------- Dependency : github.com/gorilla/mux Version: v1.8.0 @@ -23340,6 +23273,43 @@ Contents of probable licence file $GOMODCACHE/github.com/google/shlex@v0.0.0-201 limitations under the License. +-------------------------------------------------------------------------------- +Dependency : github.com/google/uuid +Version: v1.6.0 +Licence type (autodetected): BSD-3-Clause +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/google/uuid@v1.6.0/LICENSE: + +Copyright (c) 2009,2014 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + -------------------------------------------------------------------------------- Dependency : github.com/grpc-ecosystem/go-grpc-middleware Version: v1.0.0 diff --git a/go.mod b/go.mod index a64475f8208..54463d244a7 100644 --- a/go.mod +++ b/go.mod @@ -27,11 +27,9 @@ require ( github.com/fatih/color v1.16.0 github.com/fsnotify/fsnotify v1.7.0 github.com/gofrs/flock v0.8.1 - github.com/gofrs/uuid v4.4.0+incompatible github.com/gofrs/uuid/v5 v5.2.0 github.com/google/go-cmp v0.6.0 github.com/google/pprof v0.0.0-20230426061923-93006964c1fc - github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.0 github.com/hashicorp/go-multierror v1.1.1 github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95 @@ -180,6 +178,7 @@ require ( github.com/google/gofuzz v1.2.0 // indirect github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/hashicorp/consul/api v1.29.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect diff --git a/go.sum b/go.sum index e959fee5ea6..36d045284b8 100644 --- a/go.sum +++ b/go.sum @@ -274,8 +274,6 @@ github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PU github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= -github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM= github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= diff --git a/internal/pkg/agent/application/info/agent_id.go b/internal/pkg/agent/application/info/agent_id.go index 48b7c30c4d4..bd0ef9dceb6 100644 --- a/internal/pkg/agent/application/info/agent_id.go +++ b/internal/pkg/agent/application/info/agent_id.go @@ -11,7 +11,7 @@ import ( "io" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "gopkg.in/yaml.v2" "github.com/elastic/elastic-agent/internal/pkg/agent/application/filelock" diff --git a/pkg/component/runtime/manager.go b/pkg/component/runtime/manager.go index 2bc1ec5ae7f..c14ea5f4692 100644 --- a/pkg/component/runtime/manager.go +++ b/pkg/component/runtime/manager.go @@ -19,7 +19,7 @@ import ( "sync/atomic" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "go.elastic.co/apm/module/apmgrpc/v2" "go.elastic.co/apm/v2" "google.golang.org/grpc" diff --git a/pkg/component/runtime/manager_fake_input_test.go b/pkg/component/runtime/manager_fake_input_test.go index 3aeb4e14f57..0d3d9ee20c3 100644 --- a/pkg/component/runtime/manager_fake_input_test.go +++ b/pkg/component/runtime/manager_fake_input_test.go @@ -27,7 +27,7 @@ import ( fakecmp "github.com/elastic/elastic-agent/pkg/component/fake/component/comp" "github.com/elastic/elastic-agent/pkg/core/logger" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" diff --git a/pkg/component/runtime/runtime_comm.go b/pkg/component/runtime/runtime_comm.go index c5e26863bc2..a509e88d483 100644 --- a/pkg/component/runtime/runtime_comm.go +++ b/pkg/component/runtime/runtime_comm.go @@ -15,7 +15,7 @@ import ( "google.golang.org/grpc/status" protobuf "google.golang.org/protobuf/proto" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/elastic-agent-client/v7/pkg/client" "github.com/elastic/elastic-agent-client/v7/pkg/client/chunk" diff --git a/pkg/testing/tools/estools/elasticsearch.go b/pkg/testing/tools/estools/elasticsearch.go index b722350c411..acce0c38b5a 100644 --- a/pkg/testing/tools/estools/elasticsearch.go +++ b/pkg/testing/tools/estools/elasticsearch.go @@ -13,7 +13,7 @@ import ( "strconv" "strings" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/elastic-agent-libs/mapstr" "github.com/elastic/elastic-transport-go/v8/elastictransport" @@ -207,7 +207,7 @@ func CreateServiceToken(ctx context.Context, client elastictransport.Interface, req := esapi.SecurityCreateServiceTokenRequest{ Namespace: "elastic", Service: service, - Name: uuid.New().String(), // FIXME(michel-laterman): We need to specify a random name until an upstream issue is fixed: https://github.com/elastic/go-elasticsearch/issues/861 + Name: uuid.Must(uuid.NewV4()).String(), // FIXME(michel-laterman): We need to specify a random name until an upstream issue is fixed: https://github.com/elastic/go-elasticsearch/issues/861 } resp, err := req.Do(ctx, client) if err != nil { diff --git a/pkg/testing/tools/fleettools/fleet.go b/pkg/testing/tools/fleettools/fleet.go index 8b83f691d62..9f7e23f57d5 100644 --- a/pkg/testing/tools/fleettools/fleet.go +++ b/pkg/testing/tools/fleettools/fleet.go @@ -11,7 +11,7 @@ import ( "os" "strings" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/elastic-agent-libs/kibana" ) @@ -157,7 +157,7 @@ func DefaultURL(ctx context.Context, client *kibana.Client) (string, error) { // an enrollment token and returns an EnrollParams with the information to enroll // an agent. If an error happens, it returns nil and a non-nil error. func NewEnrollParams(ctx context.Context, client *kibana.Client) (*EnrollParams, error) { - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() policy := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, Namespace: "default", diff --git a/testing/fleetservertest/server.go b/testing/fleetservertest/server.go index 154887f956d..c3d62150522 100644 --- a/testing/fleetservertest/server.go +++ b/testing/fleetservertest/server.go @@ -13,7 +13,7 @@ import ( "strconv" "sync" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/gorilla/mux" ) @@ -121,7 +121,7 @@ func NewRouter(handlers *Handlers) *mux.Router { ww := &statusResponseWriter{w: w} - requestID := uuid.New().String() + requestID := uuid.Must(uuid.NewV4()).String() handlers.logFn("[%s] STARTING - %s %s %s %s\n", requestID, r.Method, r.URL, r.Proto, r.RemoteAddr) route.Handler. diff --git a/testing/integration/agent_long_running_leak_test.go b/testing/integration/agent_long_running_leak_test.go index 32b0ff69e6c..f3862665771 100644 --- a/testing/integration/agent_long_running_leak_test.go +++ b/testing/integration/agent_long_running_leak_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -96,7 +96,7 @@ func (runner *ExtendedRunner) SetupSuite() { out, err = cmd.CombinedOutput() require.NoError(runner.T(), err, "got out: %s", string(out)) - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() installOpts := atesting.InstallOpts{ NonInteractive: true, Force: true, @@ -120,10 +120,10 @@ func (runner *ExtendedRunner) SetupSuite() { policyResp, err := tools.InstallAgentWithPolicy(ctx, runner.T(), installOpts, runner.agentFixture, runner.info.KibanaClient, basePolicy) require.NoError(runner.T(), err) - _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "agent_long_test_base_system_integ.json", uuid.New().String(), policyResp.ID) + _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "agent_long_test_base_system_integ.json", uuid.Must(uuid.NewV4()).String(), policyResp.ID) require.NoError(runner.T(), err) - _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "apache", "1.17.0", "agent_long_test_apache.json", uuid.New().String(), policyResp.ID) + _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "apache", "1.17.0", "agent_long_test_apache.json", uuid.Must(uuid.NewV4()).String(), policyResp.ID) require.NoError(runner.T(), err) } diff --git a/testing/integration/beats_serverless_test.go b/testing/integration/beats_serverless_test.go index 730d1d5075e..3c5d62e28b9 100644 --- a/testing/integration/beats_serverless_test.go +++ b/testing/integration/beats_serverless_test.go @@ -19,7 +19,7 @@ import ( "text/template" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" diff --git a/testing/integration/container_cmd_test.go b/testing/integration/container_cmd_test.go index 92e8dcd6eb9..d7b6e788128 100644 --- a/testing/integration/container_cmd_test.go +++ b/testing/integration/container_cmd_test.go @@ -22,7 +22,7 @@ import ( "text/template" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -155,7 +155,7 @@ func TestContainerCMD(t *testing.T) { ctx, agentFixture, info, - fmt.Sprintf("%s-%s", t.Name(), uuid.New().String()), + fmt.Sprintf("%s-%s", t.Name(), uuid.Must(uuid.NewV4()).String()), "") env := []string{ "FLEET_ENROLL=1", @@ -242,7 +242,7 @@ func TestContainerCMDWithAVeryLongStatePath(t *testing.T) { ctx, agentFixture, info, - fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()), + fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()), "") env := []string{ @@ -333,7 +333,7 @@ func TestContainerCMDEventToStderr(t *testing.T) { ctx, agentFixture, info, - fmt.Sprintf("%s-%s", t.Name(), uuid.New().String()), + fmt.Sprintf("%s-%s", t.Name(), uuid.Must(uuid.NewV4()).String()), outputID) fleetURL, err := fleettools.DefaultURL(ctx, info.KibanaClient) @@ -403,7 +403,7 @@ func createMockESOutput(t *testing.T, info *define.Info) (string, string) { ` // The API will return an error if the output ID/name contains an // UUID substring, so we replace the '-' by '_' to keep the API happy. - outputUUID := strings.Replace(uuid.New().String(), "-", "_", -1) + outputUUID := strings.Replace(uuid.Must(uuid.NewV4()).String(), "-", "_", -1) bodyStr := fmt.Sprintf(createOutputBody, outputUUID, mockesURL) bodyReader := strings.NewReader(bodyStr) // THE URL IS MISSING diff --git a/testing/integration/delay_enroll_test.go b/testing/integration/delay_enroll_test.go index 59e0abd10c6..5500968246a 100644 --- a/testing/integration/delay_enroll_test.go +++ b/testing/integration/delay_enroll_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/elastic-agent-libs/kibana" @@ -44,7 +44,7 @@ func TestDelayEnroll(t *testing.T) { // name. This policy does not contain any integration. t.Log("Enrolling agent in Fleet with a test policy") createPolicyReq := kibana.AgentPolicy{ - Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()), + Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()), Namespace: info.Namespace, Description: "test policy for agent enrollment", MonitoringEnabled: []kibana.MonitoringEnabledOption{ @@ -104,7 +104,7 @@ func TestDelayEnrollUnprivileged(t *testing.T) { // name. This policy does not contain any integration. t.Log("Enrolling agent in Fleet with a test policy") createPolicyReq := kibana.AgentPolicy{ - Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()), + Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()), Namespace: info.Namespace, Description: "test policy for agent enrollment", MonitoringEnabled: []kibana.MonitoringEnabledOption{ diff --git a/testing/integration/endpoint_security_test.go b/testing/integration/endpoint_security_test.go index c3e20d8f43c..bcda661ca95 100644 --- a/testing/integration/endpoint_security_test.go +++ b/testing/integration/endpoint_security_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -143,7 +143,7 @@ func installSecurityAgent(ctx context.Context, t *testing.T, info *define.Info, require.NoError(t, err, "could not create agent fixture") t.Log("Enrolling the agent in Fleet") - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() createPolicyReq := buildPolicyWithTamperProtection( kibana.AgentPolicy{ @@ -411,7 +411,7 @@ func TestEndpointSecurityNonDefaultBasePath(t *testing.T) { require.NoError(t, err) t.Log("Enrolling the agent in Fleet") - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() createPolicyReq := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, Namespace: "default", @@ -489,7 +489,7 @@ func TestEndpointSecurityUnprivileged(t *testing.T) { require.NoError(t, err) t.Log("Enrolling the agent in Fleet") - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() createPolicyReq := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, Namespace: "default", @@ -569,7 +569,7 @@ func TestEndpointSecurityCannotSwitchToUnprivileged(t *testing.T) { require.NoError(t, err) t.Log("Enrolling the agent in Fleet") - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() createPolicyReq := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, Namespace: "default", @@ -635,7 +635,7 @@ func TestEndpointLogsAreCollectedInDiagnostics(t *testing.T) { require.NoError(t, err) t.Log("Enrolling the agent in Fleet") - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() createPolicyReq := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, Namespace: "default", diff --git a/testing/integration/endpoint_test_tools.go b/testing/integration/endpoint_test_tools.go index db924be4845..742d6eae393 100644 --- a/testing/integration/endpoint_test_tools.go +++ b/testing/integration/endpoint_test_tools.go @@ -17,7 +17,7 @@ import ( "text/template" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/elastic-agent-libs/kibana" "github.com/elastic/elastic-agent/pkg/control/v2/client" @@ -96,7 +96,7 @@ func installElasticDefendPackage(t *testing.T, info *define.Info, policyID strin return r, fmt.Errorf("error creating new template: %w", err) } - packagePolicyID := uuid.New().String() + packagePolicyID := uuid.Must(uuid.NewV4()).String() var pkgPolicyBuf bytes.Buffer // Need unique name for Endpoint integration otherwise on multiple runs on the same instance you get diff --git a/testing/integration/event_logging_test.go b/testing/integration/event_logging_test.go index b67b78caab6..ea52c1f5278 100644 --- a/testing/integration/event_logging_test.go +++ b/testing/integration/event_logging_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -172,7 +172,7 @@ func TestEventLogOutputConfiguredViaFleet(t *testing.T) { require.NoError(t, err) _, outputID := createMockESOutput(t, info) - policyName := fmt.Sprintf("%s-%s", t.Name(), uuid.New().String()) + policyName := fmt.Sprintf("%s-%s", t.Name(), uuid.Must(uuid.NewV4()).String()) policyID, enrollmentAPIKey := createPolicy( t, ctx, diff --git a/testing/integration/fleetserver_test.go b/testing/integration/fleetserver_test.go index 0c3c377c612..ab1e2b5a77b 100644 --- a/testing/integration/fleetserver_test.go +++ b/testing/integration/fleetserver_test.go @@ -17,7 +17,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/elastic-agent-libs/kibana" @@ -29,7 +29,7 @@ import ( ) func fleetPolicy() kibana.AgentPolicy { - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() return kibana.AgentPolicy{ ID: "test-fleet-policy-" + policyUUID, @@ -75,7 +75,7 @@ func TestInstallFleetServerBootstrap(t *testing.T) { policyResp, err := info.KibanaClient.CreatePolicy(ctx, fleetPolicy()) require.NoError(t, err, "failed creating policy") policy := policyResp.AgentPolicy - _, err = tools.InstallPackageFromDefaultFile(ctx, info.KibanaClient, "fleet-server", "1.5.0", "fleet-server.json", uuid.New().String(), policy.ID) + _, err = tools.InstallPackageFromDefaultFile(ctx, info.KibanaClient, "fleet-server", "1.5.0", "fleet-server.json", uuid.Must(uuid.NewV4()).String(), policy.ID) require.NoError(t, err, "failed creating fleet-server integration") t.Log("Get fleet-server service token...") diff --git a/testing/integration/log_level_test.go b/testing/integration/log_level_test.go index 4e1dc6940bd..43677776857 100644 --- a/testing/integration/log_level_test.go +++ b/testing/integration/log_level_test.go @@ -18,7 +18,7 @@ import ( "text/template" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -382,7 +382,7 @@ func createPolicyAndEnrollmentToken(ctx context.Context, t *testing.T, kibClient return policyResp, enrollmentToken } func createBasicPolicy() kibana.AgentPolicy { - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() return kibana.AgentPolicy{ Name: "testloglevel-policy-" + policyUUID, Namespace: "default", diff --git a/testing/integration/logs_ingestion_test.go b/testing/integration/logs_ingestion_test.go index 56bc52d8c6d..56cd831b32e 100644 --- a/testing/integration/logs_ingestion_test.go +++ b/testing/integration/logs_ingestion_test.go @@ -22,7 +22,7 @@ import ( "text/template" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/hectane/go-acl" "github.com/elastic/elastic-agent-libs/kibana" @@ -64,7 +64,7 @@ func TestLogIngestionFleetManaged(t *testing.T) { // name. This policy does not contain any integration. t.Log("Enrolling agent in Fleet with a test policy") createPolicyReq := kibana.AgentPolicy{ - Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()), + Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()), Namespace: info.Namespace, Description: "test policy for agent enrollment", MonitoringEnabled: []kibana.MonitoringEnabledOption{ @@ -135,7 +135,7 @@ func TestDebLogIngestFleetManaged(t *testing.T) { // name. This policy does not contain any integration. t.Log("Enrolling agent in Fleet with a test policy") createPolicyReq := kibana.AgentPolicy{ - Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()), + Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()), Namespace: info.Namespace, Description: "test policy for agent enrollment", MonitoringEnabled: []kibana.MonitoringEnabledOption{ @@ -203,7 +203,7 @@ func TestRpmLogIngestFleetManaged(t *testing.T) { // name. This policy does not contain any integration. t.Log("Enrolling agent in Fleet with a test policy") createPolicyReq := kibana.AgentPolicy{ - Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()), + Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()), Namespace: info.Namespace, Description: "test policy for agent enrollment", MonitoringEnabled: []kibana.MonitoringEnabledOption{ @@ -247,8 +247,8 @@ func TestRpmLogIngestFleetManaged(t *testing.T) { func startMockES(t *testing.T) string { registry := metrics.NewRegistry() - uid := uuid.New() - clusterUUID := uuid.New().String() + uid := uuid.Must(uuid.NewV4()) + clusterUUID := uuid.Must(uuid.NewV4()).String() mux := http.NewServeMux() mux.Handle("/", mockes.NewAPIHandler( @@ -426,7 +426,7 @@ func testFlattenedDatastreamFleetPolicy( policy kibana.PolicyResponse, ) { dsType := "logs" - id := uuid.New().String() + id := uuid.Must(uuid.NewV4()).String() dsNamespace := cleanString(fmt.Sprintf("namespace-%s", id)) dsDataset := cleanString(fmt.Sprintf("dataset-%s", id)) numEvents := 60 diff --git a/testing/integration/metrics_monitoring_test.go b/testing/integration/metrics_monitoring_test.go index 7b7c93e03f0..1c3fe8b6807 100644 --- a/testing/integration/metrics_monitoring_test.go +++ b/testing/integration/metrics_monitoring_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -51,7 +51,7 @@ func (runner *MetricsRunner) SetupSuite() { require.NoError(runner.T(), err) runner.agentFixture = fixture - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() basePolicy := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, Namespace: "default", @@ -74,7 +74,7 @@ func (runner *MetricsRunner) SetupSuite() { policyResp, err := tools.InstallAgentWithPolicy(ctx, runner.T(), installOpts, runner.agentFixture, runner.info.KibanaClient, basePolicy) require.NoError(runner.T(), err) - _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "system_integration_setup.json", uuid.New().String(), policyResp.ID) + _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "system_integration_setup.json", uuid.Must(uuid.NewV4()).String(), policyResp.ID) require.NoError(runner.T(), err) } diff --git a/testing/integration/monitoring_endpoint_test.go b/testing/integration/monitoring_endpoint_test.go index b91a0fe55fe..0959cc0060d 100644 --- a/testing/integration/monitoring_endpoint_test.go +++ b/testing/integration/monitoring_endpoint_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -62,7 +62,7 @@ func (runner *EndpointMetricsMonRunner) SetupSuite() { defer cancel() runner.T().Log("Enrolling the agent in Fleet") - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() createPolicyReq := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, diff --git a/testing/integration/monitoring_probe_preserve_text_cfg_test.go b/testing/integration/monitoring_probe_preserve_text_cfg_test.go index 085877e690b..a4e76d6b075 100644 --- a/testing/integration/monitoring_probe_preserve_text_cfg_test.go +++ b/testing/integration/monitoring_probe_preserve_text_cfg_test.go @@ -15,7 +15,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -96,7 +96,7 @@ func (runner *MonitoringTextRunner) SetupSuite() { require.NoError(runner.T(), err) runner.agentFixture = fixture - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() basePolicy := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, Namespace: "default", @@ -126,7 +126,7 @@ func (runner *MonitoringTextRunner) SetupSuite() { runner.policyID = policyResp.ID runner.policyName = basePolicy.Name - _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "system_integration_setup.json", uuid.New().String(), policyResp.ID) + _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "system_integration_setup.json", uuid.Must(uuid.NewV4()).String(), policyResp.ID) require.NoError(runner.T(), err) } diff --git a/testing/integration/monitoring_probe_reload_test.go b/testing/integration/monitoring_probe_reload_test.go index 4b46490ff71..e456be40c6d 100644 --- a/testing/integration/monitoring_probe_reload_test.go +++ b/testing/integration/monitoring_probe_reload_test.go @@ -15,7 +15,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -60,7 +60,7 @@ func (runner *MonitoringRunner) SetupSuite() { require.NoError(runner.T(), err) runner.agentFixture = fixture - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() basePolicy := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, Namespace: "default", @@ -86,7 +86,7 @@ func (runner *MonitoringRunner) SetupSuite() { runner.policyID = policyResp.ID runner.policyName = basePolicy.Name - _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "system_integration_setup.json", uuid.New().String(), policyResp.ID) + _, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "system_integration_setup.json", uuid.Must(uuid.NewV4()).String(), policyResp.ID) require.NoError(runner.T(), err) } diff --git a/testing/integration/proxy_url_test.go b/testing/integration/proxy_url_test.go index bca27fcf406..81439cd3701 100644 --- a/testing/integration/proxy_url_test.go +++ b/testing/integration/proxy_url_test.go @@ -19,7 +19,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" @@ -766,7 +766,7 @@ func createBasicFleetPolicyData(t *testing.T, fleetHost string) (fleetservertest } agentID := strings.Replace(t.Name(), "/", "-", -1) + "-agent-id" - policyUUID, err := uuid.NewUUID() + policyUUID, err := uuid.NewV4() require.NoError(t, err, "error generating UUID for policy") policyID := policyUUID.String() diff --git a/testing/integration/upgrade_fleet_test.go b/testing/integration/upgrade_fleet_test.go index 185431cfdd5..3c6d8fa759f 100644 --- a/testing/integration/upgrade_fleet_test.go +++ b/testing/integration/upgrade_fleet_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -180,7 +180,7 @@ func testFleetAirGappedUpgrade(t *testing.T, stack *define.Info, unprivileged bo define.Version(), latest) downloadSource := kibana.DownloadSource{ - Name: "local-air-gaped-" + uuid.NewString(), + Name: "local-air-gaped-" + uuid.Must(uuid.NewV4()).String(), Host: s.URL + "/downloads/beats/elastic-agent/", IsDefault: false, // other tests reuse the stack, let's not mess things up } @@ -324,7 +324,7 @@ func testUpgradeFleetManagedElasticAgent( } func defaultPolicy() kibana.AgentPolicy { - policyUUID := uuid.New().String() + policyUUID := uuid.Must(uuid.NewV4()).String() policy := kibana.AgentPolicy{ Name: "test-policy-" + policyUUID, diff --git a/testing/proxytest/proxytest.go b/testing/proxytest/proxytest.go index 520e65dccb3..0b82e27f4de 100644 --- a/testing/proxytest/proxytest.go +++ b/testing/proxytest/proxytest.go @@ -17,7 +17,7 @@ import ( "sync" "testing" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" ) type Proxy struct { @@ -126,7 +126,7 @@ func New(t *testing.T, optns ...Option) *Proxy { http.HandlerFunc(func(ww http.ResponseWriter, r *http.Request) { w := &statusResponseWriter{w: ww} - requestID := uuid.New().String() + requestID := uuid.Must(uuid.NewV4()).String() opts.logFn("[%s] STARTING - %s %s %s %s\n", requestID, r.Method, r.URL, r.Proto, r.RemoteAddr)