From a88bcb45e998aa20de50d3ba3249ecf83c45aa95 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Wed, 10 Jul 2024 04:00:41 +0200 Subject: [PATCH 01/26] refactor: consistently use one uuid library the codebase is using a mix of github.com/google/uuid and github.com/gofrs/uuid Update the codebase to use github.com/gofrs/uuid consistently and bump to the current major version. --- NOTICE.txt | 110 +++++++++++------- filebeat/fileset/factory.go | 2 +- filebeat/harvester/harvester.go | 2 +- filebeat/harvester/registry.go | 2 +- filebeat/input/log/harvester.go | 2 +- filebeat/input/log/input.go | 2 +- filebeat/input/redis/harvester.go | 2 +- go.mod | 5 +- go.sum | 2 + heartbeat/monitors/mocks.go | 2 +- .../wrappers/monitorstate/esloader_test.go | 2 +- .../wrappers/summarizer/plugstatestat.go | 2 +- heartbeat/tracer/tracer_test.go | 2 +- libbeat/autodiscover/autodiscover_test.go | 2 +- libbeat/autodiscover/provider.go | 2 +- .../autodiscover/providers/docker/docker.go | 2 +- .../docker/docker_integration_test.go | 2 +- .../providers/jolokia/discovery.go | 2 +- .../autodiscover/providers/jolokia/jolokia.go | 2 +- .../providers/kubernetes/kubernetes.go | 2 +- .../providers/kubernetes/kubernetes_test.go | 2 +- .../autodiscover/providers/kubernetes/node.go | 2 +- .../providers/kubernetes/node_test.go | 2 +- .../autodiscover/providers/kubernetes/pod.go | 2 +- .../providers/kubernetes/pod_test.go | 2 +- .../providers/kubernetes/service.go | 2 +- .../providers/kubernetes/service_test.go | 2 +- libbeat/beat/info.go | 2 +- libbeat/cmd/instance/beat.go | 2 +- libbeat/cmd/instance/beat_test.go | 2 +- libbeat/common/event_test.go | 2 +- .../client_handler_integration_test.go | 2 +- libbeat/monitoring/inputmon/input.go | 2 +- libbeat/outputs/elasticsearch/callbacks.go | 2 +- .../add_host_metadata/add_host_metadata.go | 2 +- libbeat/publisher/processing/default_test.go | 2 +- libbeat/tests/integration/framework.go | 2 +- metricbeat/mb/builders.go | 2 +- .../module/system/package/package.go | 2 +- .../module/system/process/process.go | 2 +- x-pack/auditbeat/module/system/user/user.go | 2 +- .../pipelinemanager/libbeattools.go | 2 +- x-pack/filebeat/input/awss3/sqs_test.go | 2 +- .../internal/collections/uuid_set.go | 2 +- .../internal/collections/uuid_set_test.go | 2 +- .../internal/collections/uuid_tree.go | 2 +- .../internal/collections/uuid_tree_test.go | 2 +- .../entityanalytics/provider/azuread/azure.go | 2 +- .../provider/azuread/fetcher/device.go | 2 +- .../provider/azuread/fetcher/device_test.go | 2 +- .../provider/azuread/fetcher/graph/graph.go | 2 +- .../azuread/fetcher/graph/graph_test.go | 2 +- .../provider/azuread/fetcher/group.go | 2 +- .../provider/azuread/fetcher/group_test.go | 2 +- .../provider/azuread/fetcher/mock/mock.go | 2 +- .../provider/azuread/fetcher/user.go | 2 +- .../provider/azuread/fetcher/user_test.go | 2 +- .../provider/azuread/statestore.go | 2 +- .../provider/azuread/statestore_test.go | 2 +- .../provider/jamf/internal/jamf/jamf_test.go | 2 +- .../provider/jamf/jamf_test.go | 2 +- x-pack/filebeat/input/httpjson/value_tpl.go | 2 +- .../manager/aws/op_cloudformation.go | 2 +- .../manager/aws/op_delete_cloudformation.go | 2 +- .../manager/aws/op_update_cloudformation.go | 2 +- .../monitors/browser/synthexec/enrich.go | 2 +- .../scenarios/framework/framework.go | 2 +- .../providers/aws/ec2/provider.go | 2 +- .../providers/aws/ec2/provider_test.go | 2 +- .../providers/aws/elb/provider.go | 2 +- .../providers/aws/elb/provider_test.go | 2 +- .../autodiscover/providers/nomad/nomad.go | 2 +- .../providers/nomad/nomad_test.go | 2 +- .../libbeat/common/cloudfoundry/cache_test.go | 2 +- .../common/cloudfoundry/test/config.go | 2 +- x-pack/libbeat/common/nomad/metadata_test.go | 2 +- x-pack/libbeat/common/nomad/watcher_test.go | 2 +- .../persistentcache/persistentcache_test.go | 2 +- .../add_cloudfoundry_metadata.go | 2 +- .../add_cloudfoundry_metadata_test.go | 2 +- .../module/azure/app_insights/client.go | 2 +- .../osquerybeat/beater/action_handler_test.go | 2 +- x-pack/osquerybeat/beater/osquerybeat.go | 2 +- .../osquerybeat/internal/fetch/fetch_test.go | 2 +- .../internal/osqd/osqueryd_test.go | 2 +- .../internal/osqd/osqueryd_windows.go | 2 +- .../internal/pub/publisher_test.go | 2 +- 87 files changed, 159 insertions(+), 126 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index b09a41fbbc8..dbc87674970 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -17435,12 +17435,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- -Dependency : github.com/gofrs/uuid -Version: v4.4.0+incompatible +Dependency : github.com/gofrs/uuid/v5 +Version: v5.2.0 Licence type (autodetected): MIT -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid@v4.4.0+incompatible/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/v5@v5.2.0/LICENSE: Copyright (C) 2013-2018 by Maxim Bublis @@ -18494,43 +18494,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -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/googleapis/gax-go/v2 Version: v2.12.0 @@ -39898,6 +39861,36 @@ Contents of probable licence file $GOMODCACHE/github.com/godror/knownpb@v0.1.0/L limitations under the License. +-------------------------------------------------------------------------------- +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/golang-jwt/jwt/v4 Version: v4.5.0 @@ -42101,6 +42094,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/googleapis/enterprise-certificate-proxy Version: v0.2.4 diff --git a/filebeat/fileset/factory.go b/filebeat/fileset/factory.go index 1e1215d7cdd..a289ca15170 100644 --- a/filebeat/fileset/factory.go +++ b/filebeat/fileset/factory.go @@ -21,7 +21,7 @@ import ( "fmt" "sync" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/mitchellh/hashstructure" "github.com/elastic/beats/v7/libbeat/beat" diff --git a/filebeat/harvester/harvester.go b/filebeat/harvester/harvester.go index 39f9b45bb2b..4d1b7211a7b 100644 --- a/filebeat/harvester/harvester.go +++ b/filebeat/harvester/harvester.go @@ -18,7 +18,7 @@ package harvester import ( - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" ) // Harvester contains all methods which must be supported by each harvester diff --git a/filebeat/harvester/registry.go b/filebeat/harvester/registry.go index 989557d08bc..0097bb82a07 100644 --- a/filebeat/harvester/registry.go +++ b/filebeat/harvester/registry.go @@ -21,7 +21,7 @@ import ( "errors" "sync" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/elastic-agent-libs/logp" ) diff --git a/filebeat/input/log/harvester.go b/filebeat/input/log/harvester.go index ee08a3ff184..319ba430e70 100644 --- a/filebeat/input/log/harvester.go +++ b/filebeat/input/log/harvester.go @@ -37,7 +37,7 @@ import ( "sync" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "golang.org/x/text/transform" "github.com/elastic/beats/v7/libbeat/beat" diff --git a/filebeat/input/log/input.go b/filebeat/input/log/input.go index 4882735d36b..ef26606d4fb 100644 --- a/filebeat/input/log/input.go +++ b/filebeat/input/log/input.go @@ -27,7 +27,7 @@ import ( "sync" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/filebeat/channel" "github.com/elastic/beats/v7/filebeat/harvester" diff --git a/filebeat/input/redis/harvester.go b/filebeat/input/redis/harvester.go index 79929a4ee4f..e92880d8353 100644 --- a/filebeat/input/redis/harvester.go +++ b/filebeat/input/redis/harvester.go @@ -22,7 +22,7 @@ import ( "strings" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" rd "github.com/gomodule/redigo/redis" "github.com/elastic/beats/v7/libbeat/beat" diff --git a/go.mod b/go.mod index ccdfe7efd37..4cdcd3effc6 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( github.com/godbus/dbus/v5 v5.0.6 github.com/godror/godror v0.33.2 github.com/gofrs/flock v0.8.1 - github.com/gofrs/uuid v4.4.0+incompatible + github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 github.com/golang/snappy v0.0.4 @@ -101,7 +101,7 @@ require ( github.com/google/flatbuffers v23.5.26+incompatible github.com/google/go-cmp v0.6.0 github.com/google/gopacket v1.1.19 - github.com/google/uuid v1.6.0 + github.com/google/uuid v1.6.0 // indirect github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 github.com/h2non/filetype v1.1.1 github.com/hashicorp/go-retryablehttp v0.7.7 @@ -208,6 +208,7 @@ require ( github.com/elastic/toutoumomoma v0.0.0-20221026030040-594ef30cb640 github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15 github.com/go-ldap/ldap/v3 v3.4.6 + github.com/gofrs/uuid/v5 v5.2.0 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/cel-go v0.19.0 github.com/googleapis/gax-go/v2 v2.12.0 diff --git a/go.sum b/go.sum index a0789be18f4..397300758f3 100644 --- a/go.sum +++ b/go.sum @@ -853,6 +853,8 @@ github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= 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/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= diff --git a/heartbeat/monitors/mocks.go b/heartbeat/monitors/mocks.go index f8747a80400..c172d24464c 100644 --- a/heartbeat/monitors/mocks.go +++ b/heartbeat/monitors/mocks.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/elastic-agent-libs/config" diff --git a/heartbeat/monitors/wrappers/monitorstate/esloader_test.go b/heartbeat/monitors/wrappers/monitorstate/esloader_test.go index db70c1cc72e..88664f562c8 100644 --- a/heartbeat/monitors/wrappers/monitorstate/esloader_test.go +++ b/heartbeat/monitors/wrappers/monitorstate/esloader_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/go-elasticsearch/v8" diff --git a/heartbeat/monitors/wrappers/summarizer/plugstatestat.go b/heartbeat/monitors/wrappers/summarizer/plugstatestat.go index cf7e90af5f3..1c3dc887680 100644 --- a/heartbeat/monitors/wrappers/summarizer/plugstatestat.go +++ b/heartbeat/monitors/wrappers/summarizer/plugstatestat.go @@ -20,7 +20,7 @@ package summarizer import ( "fmt" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/heartbeat/eventext" "github.com/elastic/beats/v7/heartbeat/look" diff --git a/heartbeat/tracer/tracer_test.go b/heartbeat/tracer/tracer_test.go index 45d0a4125e7..14d68ca231f 100644 --- a/heartbeat/tracer/tracer_test.go +++ b/heartbeat/tracer/tracer_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" ) diff --git a/libbeat/autodiscover/autodiscover_test.go b/libbeat/autodiscover/autodiscover_test.go index 93918180a92..b83a4e78045 100644 --- a/libbeat/autodiscover/autodiscover_test.go +++ b/libbeat/autodiscover/autodiscover_test.go @@ -26,7 +26,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/libbeat/autodiscover/provider.go b/libbeat/autodiscover/provider.go index 8d70e80ee29..74a6d56f23d 100644 --- a/libbeat/autodiscover/provider.go +++ b/libbeat/autodiscover/provider.go @@ -21,7 +21,7 @@ import ( "fmt" "strings" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/elastic-agent-autodiscover/bus" diff --git a/libbeat/autodiscover/providers/docker/docker.go b/libbeat/autodiscover/providers/docker/docker.go index a659135c7e7..8398762aa27 100644 --- a/libbeat/autodiscover/providers/docker/docker.go +++ b/libbeat/autodiscover/providers/docker/docker.go @@ -25,7 +25,7 @@ import ( "strconv" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/autodiscover" "github.com/elastic/beats/v7/libbeat/autodiscover/template" diff --git a/libbeat/autodiscover/providers/docker/docker_integration_test.go b/libbeat/autodiscover/providers/docker/docker_integration_test.go index f8a76077978..fa2ddabdf23 100644 --- a/libbeat/autodiscover/providers/docker/docker_integration_test.go +++ b/libbeat/autodiscover/providers/docker/docker_integration_test.go @@ -23,7 +23,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/elastic/beats/v7/libbeat/autodiscover/template" diff --git a/libbeat/autodiscover/providers/jolokia/discovery.go b/libbeat/autodiscover/providers/jolokia/discovery.go index cf0f1f5199d..45d5e04c941 100644 --- a/libbeat/autodiscover/providers/jolokia/discovery.go +++ b/libbeat/autodiscover/providers/jolokia/discovery.go @@ -25,7 +25,7 @@ import ( "sync" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" s "github.com/elastic/beats/v7/libbeat/common/schema" c "github.com/elastic/beats/v7/libbeat/common/schema/mapstriface" diff --git a/libbeat/autodiscover/providers/jolokia/jolokia.go b/libbeat/autodiscover/providers/jolokia/jolokia.go index beb566805c4..a83e5425f7e 100644 --- a/libbeat/autodiscover/providers/jolokia/jolokia.go +++ b/libbeat/autodiscover/providers/jolokia/jolokia.go @@ -20,7 +20,7 @@ package jolokia import ( "fmt" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/autodiscover" "github.com/elastic/beats/v7/libbeat/autodiscover/template" diff --git a/libbeat/autodiscover/providers/kubernetes/kubernetes.go b/libbeat/autodiscover/providers/kubernetes/kubernetes.go index 1ee4d01a06c..823989787fd 100644 --- a/libbeat/autodiscover/providers/kubernetes/kubernetes.go +++ b/libbeat/autodiscover/providers/kubernetes/kubernetes.go @@ -29,7 +29,7 @@ import ( "k8s.io/client-go/tools/leaderelection" "k8s.io/client-go/tools/leaderelection/resourcelock" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/autodiscover" "github.com/elastic/beats/v7/libbeat/autodiscover/template" diff --git a/libbeat/autodiscover/providers/kubernetes/kubernetes_test.go b/libbeat/autodiscover/providers/kubernetes/kubernetes_test.go index b767d87be04..12f5c824423 100644 --- a/libbeat/autodiscover/providers/kubernetes/kubernetes_test.go +++ b/libbeat/autodiscover/providers/kubernetes/kubernetes_test.go @@ -23,7 +23,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" v1 "k8s.io/api/coordination/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/libbeat/autodiscover/providers/kubernetes/node.go b/libbeat/autodiscover/providers/kubernetes/node.go index 4747c751cbf..27957998575 100644 --- a/libbeat/autodiscover/providers/kubernetes/node.go +++ b/libbeat/autodiscover/providers/kubernetes/node.go @@ -25,7 +25,7 @@ import ( "github.com/elastic/elastic-agent-autodiscover/utils" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" k8s "k8s.io/client-go/kubernetes" diff --git a/libbeat/autodiscover/providers/kubernetes/node_test.go b/libbeat/autodiscover/providers/kubernetes/node_test.go index 5336ddde758..bd4aa1fa211 100644 --- a/libbeat/autodiscover/providers/kubernetes/node_test.go +++ b/libbeat/autodiscover/providers/kubernetes/node_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/libbeat/autodiscover/providers/kubernetes/pod.go b/libbeat/autodiscover/providers/kubernetes/pod.go index c5f9c721eb9..764dab44f46 100644 --- a/libbeat/autodiscover/providers/kubernetes/pod.go +++ b/libbeat/autodiscover/providers/kubernetes/pod.go @@ -24,7 +24,7 @@ import ( "sync" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" k8s "k8s.io/client-go/kubernetes" "github.com/elastic/elastic-agent-autodiscover/bus" diff --git a/libbeat/autodiscover/providers/kubernetes/pod_test.go b/libbeat/autodiscover/providers/kubernetes/pod_test.go index 84712615ec1..bb8731275b3 100644 --- a/libbeat/autodiscover/providers/kubernetes/pod_test.go +++ b/libbeat/autodiscover/providers/kubernetes/pod_test.go @@ -22,7 +22,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/libbeat/autodiscover/providers/kubernetes/service.go b/libbeat/autodiscover/providers/kubernetes/service.go index e9e71c921bd..c1604cd0fe4 100644 --- a/libbeat/autodiscover/providers/kubernetes/service.go +++ b/libbeat/autodiscover/providers/kubernetes/service.go @@ -25,7 +25,7 @@ import ( "github.com/elastic/elastic-agent-autodiscover/utils" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" k8s "k8s.io/client-go/kubernetes" "github.com/elastic/elastic-agent-autodiscover/bus" diff --git a/libbeat/autodiscover/providers/kubernetes/service_test.go b/libbeat/autodiscover/providers/kubernetes/service_test.go index 90ff678e11c..cd7aa2a603c 100644 --- a/libbeat/autodiscover/providers/kubernetes/service_test.go +++ b/libbeat/autodiscover/providers/kubernetes/service_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/libbeat/beat/info.go b/libbeat/beat/info.go index 23dfe9be0be..57f9a570fbc 100644 --- a/libbeat/beat/info.go +++ b/libbeat/beat/info.go @@ -20,7 +20,7 @@ package beat import ( "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" ) // Info stores a beats instance meta data. diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index c15d9b8c200..b38405a94fd 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -37,7 +37,7 @@ import ( "strings" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "go.uber.org/zap" "github.com/elastic/beats/v7/libbeat/api" diff --git a/libbeat/cmd/instance/beat_test.go b/libbeat/cmd/instance/beat_test.go index 1a011b56daf..4069e248320 100644 --- a/libbeat/cmd/instance/beat_test.go +++ b/libbeat/cmd/instance/beat_test.go @@ -31,7 +31,7 @@ import ( "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/go-ucfg/yaml" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libbeat/common/event_test.go b/libbeat/common/event_test.go index 0d598d02174..a2069498b4b 100644 --- a/libbeat/common/event_test.go +++ b/libbeat/common/event_test.go @@ -22,7 +22,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/elastic/elastic-agent-libs/logp" diff --git a/libbeat/idxmgmt/lifecycle/client_handler_integration_test.go b/libbeat/idxmgmt/lifecycle/client_handler_integration_test.go index 2df919d55d5..67b9a1cfb06 100644 --- a/libbeat/idxmgmt/lifecycle/client_handler_integration_test.go +++ b/libbeat/idxmgmt/lifecycle/client_handler_integration_test.go @@ -25,7 +25,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/libbeat/monitoring/inputmon/input.go b/libbeat/monitoring/inputmon/input.go index 7814f79234f..5d54a71a68c 100644 --- a/libbeat/monitoring/inputmon/input.go +++ b/libbeat/monitoring/inputmon/input.go @@ -21,7 +21,7 @@ import ( "encoding/json" "strings" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/monitoring" diff --git a/libbeat/outputs/elasticsearch/callbacks.go b/libbeat/outputs/elasticsearch/callbacks.go index dcbbd971adb..5196fe13802 100644 --- a/libbeat/outputs/elasticsearch/callbacks.go +++ b/libbeat/outputs/elasticsearch/callbacks.go @@ -22,7 +22,7 @@ import ( "github.com/elastic/beats/v7/libbeat/esleg/eslegclient" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" ) // ConnectCallback defines the type for the function to be called when the Elasticsearch client successfully connects to the cluster diff --git a/libbeat/processors/add_host_metadata/add_host_metadata.go b/libbeat/processors/add_host_metadata/add_host_metadata.go index 5fe28194b55..3a7e7b40c55 100644 --- a/libbeat/processors/add_host_metadata/add_host_metadata.go +++ b/libbeat/processors/add_host_metadata/add_host_metadata.go @@ -23,7 +23,7 @@ import ( "sync" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/elastic-agent-libs/monitoring" "github.com/elastic/go-sysinfo" diff --git a/libbeat/publisher/processing/default_test.go b/libbeat/publisher/processing/default_test.go index 6fe05785037..81bdb25dcba 100644 --- a/libbeat/publisher/processing/default_test.go +++ b/libbeat/publisher/processing/default_test.go @@ -22,7 +22,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/libbeat/tests/integration/framework.go b/libbeat/tests/integration/framework.go index fe5a1bbfd60..c3dc61ac2c6 100644 --- a/libbeat/tests/integration/framework.go +++ b/libbeat/tests/integration/framework.go @@ -37,7 +37,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/libbeat/common/atomic" diff --git a/metricbeat/mb/builders.go b/metricbeat/mb/builders.go index c9b1ace587d..c97528c522b 100644 --- a/metricbeat/mb/builders.go +++ b/metricbeat/mb/builders.go @@ -22,7 +22,7 @@ import ( "fmt" "strings" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/joeshaw/multierror" conf "github.com/elastic/elastic-agent-libs/config" diff --git a/x-pack/auditbeat/module/system/package/package.go b/x-pack/auditbeat/module/system/package/package.go index 66d85bb7f17..bf0e71aeefb 100644 --- a/x-pack/auditbeat/module/system/package/package.go +++ b/x-pack/auditbeat/module/system/package/package.go @@ -22,7 +22,7 @@ import ( "time" "github.com/cespare/xxhash/v2" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/joeshaw/multierror" "go.etcd.io/bbolt" diff --git a/x-pack/auditbeat/module/system/process/process.go b/x-pack/auditbeat/module/system/process/process.go index b835a03bfb9..a73b44b7145 100644 --- a/x-pack/auditbeat/module/system/process/process.go +++ b/x-pack/auditbeat/module/system/process/process.go @@ -14,7 +14,7 @@ import ( "time" "github.com/cespare/xxhash/v2" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/auditbeat/ab" "github.com/elastic/beats/v7/auditbeat/datastore" diff --git a/x-pack/auditbeat/module/system/user/user.go b/x-pack/auditbeat/module/system/user/user.go index 3220c7ffeb4..7618a1a8d9c 100644 --- a/x-pack/auditbeat/module/system/user/user.go +++ b/x-pack/auditbeat/module/system/user/user.go @@ -19,7 +19,7 @@ import ( "time" "github.com/cespare/xxhash/v2" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/joeshaw/multierror" "github.com/elastic/beats/v7/auditbeat/ab" diff --git a/x-pack/dockerlogbeat/pipelinemanager/libbeattools.go b/x-pack/dockerlogbeat/pipelinemanager/libbeattools.go index de3436156b4..b4820f73408 100644 --- a/x-pack/dockerlogbeat/pipelinemanager/libbeattools.go +++ b/x-pack/dockerlogbeat/pipelinemanager/libbeattools.go @@ -11,7 +11,7 @@ import ( "os" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/beat" "github.com/elastic/beats/v7/libbeat/cloudid" diff --git a/x-pack/filebeat/input/awss3/sqs_test.go b/x-pack/filebeat/input/awss3/sqs_test.go index cf82f03c6de..8ad01a032dc 100644 --- a/x-pack/filebeat/input/awss3/sqs_test.go +++ b/x-pack/filebeat/input/awss3/sqs_test.go @@ -14,7 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/sqs/types" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" diff --git a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set.go b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set.go index 1a36edec554..46f6422c303 100644 --- a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set.go +++ b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set.go @@ -9,7 +9,7 @@ import ( "encoding/json" "sort" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" ) type UUIDSet struct { diff --git a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set_test.go b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set_test.go index cc9cdba83b9..5af67892289 100644 --- a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set_test.go +++ b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set_test.go @@ -9,7 +9,7 @@ import ( "fmt" "testing" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" ) diff --git a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree.go b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree.go index 07b35284301..1ebda5ebf41 100644 --- a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree.go +++ b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree.go @@ -7,7 +7,7 @@ package collections import ( "encoding/json" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" ) type UUIDTree struct { diff --git a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree_test.go b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree_test.go index f82e7e74267..5414d1ad929 100644 --- a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree_test.go +++ b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree_test.go @@ -9,7 +9,7 @@ import ( "fmt" "testing" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" ) diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/azure.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/azure.go index d67031753fd..21556823866 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/azure.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/azure.go @@ -11,7 +11,7 @@ import ( "fmt" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" v2 "github.com/elastic/beats/v7/filebeat/input/v2" "github.com/elastic/beats/v7/libbeat/beat" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device.go index 46139d27820..2a8bc0e2561 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device.go @@ -5,7 +5,7 @@ package fetcher import ( - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/collections" "github.com/elastic/elastic-agent-libs/mapstr" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device_test.go index 37e6563eb3a..0ff5c0396cc 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device_test.go @@ -7,7 +7,7 @@ package fetcher import ( "testing" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/collections" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go index 4b98bdb05be..47f1c394f78 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go @@ -20,7 +20,7 @@ import ( "path/filepath" "strings" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "go.elastic.co/ecszap" "go.uber.org/zap" "go.uber.org/zap/zapcore" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go index bafddc20a00..6c122f22ffc 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go @@ -18,7 +18,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "gopkg.in/natefinch/lumberjack.v2" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group.go index 77a7c24deeb..b3dc6809382 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group.go @@ -4,7 +4,7 @@ package fetcher -import "github.com/google/uuid" +import "github.com/gofrs/uuid/v5" // MemberType indicates the type of member in a Group. type MemberType int diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group_test.go index a9958ef2245..560f54362d2 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group_test.go @@ -7,7 +7,7 @@ package fetcher import ( "testing" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" ) diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/mock/mock.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/mock/mock.go index 11d77871f3b..c840325c1bc 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/mock/mock.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/mock/mock.go @@ -8,7 +8,7 @@ package mock import ( "context" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher" "github.com/elastic/elastic-agent-libs/logp" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user.go index d629e3ef7bf..1a99e4ea889 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user.go @@ -5,7 +5,7 @@ package fetcher import ( - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/collections" "github.com/elastic/elastic-agent-libs/mapstr" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user_test.go index af5488b2424..7ff2df55376 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user_test.go @@ -7,7 +7,7 @@ package fetcher import ( "testing" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/collections" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore.go index 392ce5f0460..dfa425c6c6e 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore.go @@ -10,7 +10,7 @@ import ( "fmt" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/collections" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/kvstore" diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore_test.go index ef1ba2b240a..c6e857f4eac 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/collections" diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go index e11269878cf..3c457a4e1ea 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go @@ -20,7 +20,7 @@ import ( _ "embed" "github.com/google/go-cmp/cmp" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" ) var logResponses = flag.Bool("log_response", false, "use to log users/devices returned from the API") diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go index dc759166d7b..fa8deb5c0e6 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go @@ -19,7 +19,7 @@ import ( _ "embed" "github.com/google/go-cmp/cmp" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "gopkg.in/natefinch/lumberjack.v2" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf" diff --git a/x-pack/filebeat/input/httpjson/value_tpl.go b/x-pack/filebeat/input/httpjson/value_tpl.go index cf7e43cf8e4..5ac1e0d74ed 100644 --- a/x-pack/filebeat/input/httpjson/value_tpl.go +++ b/x-pack/filebeat/input/httpjson/value_tpl.go @@ -24,7 +24,7 @@ import ( "text/template" "time" - "github.com/google/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/version" "github.com/elastic/elastic-agent-libs/logp" diff --git a/x-pack/functionbeat/manager/aws/op_cloudformation.go b/x-pack/functionbeat/manager/aws/op_cloudformation.go index 3298d866080..028c78cd4a4 100644 --- a/x-pack/functionbeat/manager/aws/op_cloudformation.go +++ b/x-pack/functionbeat/manager/aws/op_cloudformation.go @@ -14,7 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudformation" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/x-pack/functionbeat/manager/executor" "github.com/elastic/elastic-agent-libs/logp" diff --git a/x-pack/functionbeat/manager/aws/op_delete_cloudformation.go b/x-pack/functionbeat/manager/aws/op_delete_cloudformation.go index 0f9fb60c593..4954e70b266 100644 --- a/x-pack/functionbeat/manager/aws/op_delete_cloudformation.go +++ b/x-pack/functionbeat/manager/aws/op_delete_cloudformation.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudformation" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/x-pack/functionbeat/manager/executor" "github.com/elastic/elastic-agent-libs/logp" diff --git a/x-pack/functionbeat/manager/aws/op_update_cloudformation.go b/x-pack/functionbeat/manager/aws/op_update_cloudformation.go index 8441c89ca2c..9a75909f247 100644 --- a/x-pack/functionbeat/manager/aws/op_update_cloudformation.go +++ b/x-pack/functionbeat/manager/aws/op_update_cloudformation.go @@ -11,7 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudformation" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/x-pack/functionbeat/manager/executor" "github.com/elastic/elastic-agent-libs/logp" diff --git a/x-pack/heartbeat/monitors/browser/synthexec/enrich.go b/x-pack/heartbeat/monitors/browser/synthexec/enrich.go index 05d726d6398..9201c11d1e5 100644 --- a/x-pack/heartbeat/monitors/browser/synthexec/enrich.go +++ b/x-pack/heartbeat/monitors/browser/synthexec/enrich.go @@ -13,7 +13,7 @@ import ( "github.com/elastic/beats/v7/libbeat/processors/add_data_stream" "github.com/elastic/elastic-agent-libs/mapstr" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/heartbeat/eventext" "github.com/elastic/beats/v7/heartbeat/monitors/stdfields" diff --git a/x-pack/heartbeat/scenarios/framework/framework.go b/x-pack/heartbeat/scenarios/framework/framework.go index c6dc0ae9ad6..a2fb77e6307 100644 --- a/x-pack/heartbeat/scenarios/framework/framework.go +++ b/x-pack/heartbeat/scenarios/framework/framework.go @@ -16,7 +16,7 @@ import ( "github.com/elastic/beats/v7/heartbeat/monitors/stdfields" "github.com/elastic/beats/v7/heartbeat/monitors/wrappers/monitorstate" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/elastic-agent-libs/config" diff --git a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go index 0c4d7720974..0d4dc472f6c 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go +++ b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go @@ -10,7 +10,7 @@ import ( awssdk "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ec2" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/autodiscover" "github.com/elastic/beats/v7/libbeat/autodiscover/template" diff --git a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go index a157d287882..9b1b753c5b1 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x-pack/libbeat/autodiscover/providers/aws/elb/provider.go b/x-pack/libbeat/autodiscover/providers/aws/elb/provider.go index ea44596e52a..2440f2c6f83 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/elb/provider.go +++ b/x-pack/libbeat/autodiscover/providers/aws/elb/provider.go @@ -8,7 +8,7 @@ import ( awssdk "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/autodiscover" "github.com/elastic/beats/v7/libbeat/autodiscover/template" diff --git a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go index 688323e26f2..4d34744cd14 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x-pack/libbeat/autodiscover/providers/nomad/nomad.go b/x-pack/libbeat/autodiscover/providers/nomad/nomad.go index 3cfd4ce5fee..4d1bba4bc25 100644 --- a/x-pack/libbeat/autodiscover/providers/nomad/nomad.go +++ b/x-pack/libbeat/autodiscover/providers/nomad/nomad.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/elastic-agent-autodiscover/utils" diff --git a/x-pack/libbeat/autodiscover/providers/nomad/nomad_test.go b/x-pack/libbeat/autodiscover/providers/nomad/nomad_test.go index 6f88261a1f0..95d24f8bad8 100644 --- a/x-pack/libbeat/autodiscover/providers/nomad/nomad_test.go +++ b/x-pack/libbeat/autodiscover/providers/nomad/nomad_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/hashicorp/nomad/api" "github.com/stretchr/testify/assert" diff --git a/x-pack/libbeat/common/cloudfoundry/cache_test.go b/x-pack/libbeat/common/cloudfoundry/cache_test.go index d77ba9633d5..8d4cef2c2fb 100644 --- a/x-pack/libbeat/common/cloudfoundry/cache_test.go +++ b/x-pack/libbeat/common/cloudfoundry/cache_test.go @@ -11,7 +11,7 @@ import ( "time" "github.com/cloudfoundry-community/go-cfclient" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x-pack/libbeat/common/cloudfoundry/test/config.go b/x-pack/libbeat/common/cloudfoundry/test/config.go index 45059fc559c..c9f2293eb30 100644 --- a/x-pack/libbeat/common/cloudfoundry/test/config.go +++ b/x-pack/libbeat/common/cloudfoundry/test/config.go @@ -8,7 +8,7 @@ import ( "os" "testing" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" ) func GetConfigFromEnv(t *testing.T) map[string]interface{} { diff --git a/x-pack/libbeat/common/nomad/metadata_test.go b/x-pack/libbeat/common/nomad/metadata_test.go index 16855fa9c41..9f9b59407a7 100644 --- a/x-pack/libbeat/common/nomad/metadata_test.go +++ b/x-pack/libbeat/common/nomad/metadata_test.go @@ -7,7 +7,7 @@ package nomad import ( "testing" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/hashicorp/nomad/api" "github.com/stretchr/testify/assert" diff --git a/x-pack/libbeat/common/nomad/watcher_test.go b/x-pack/libbeat/common/nomad/watcher_test.go index a8cd6555acc..f6978666b05 100644 --- a/x-pack/libbeat/common/nomad/watcher_test.go +++ b/x-pack/libbeat/common/nomad/watcher_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" api "github.com/hashicorp/nomad/api" "github.com/stretchr/testify/assert" diff --git a/x-pack/libbeat/persistentcache/persistentcache_test.go b/x-pack/libbeat/persistentcache/persistentcache_test.go index 416905d2e40..95e3e8397ea 100644 --- a/x-pack/libbeat/persistentcache/persistentcache_test.go +++ b/x-pack/libbeat/persistentcache/persistentcache_test.go @@ -14,7 +14,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata.go b/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata.go index f20d713c7b6..26afdbf925b 100644 --- a/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata.go +++ b/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata.go @@ -9,7 +9,7 @@ package add_cloudfoundry_metadata import ( "fmt" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/elastic/beats/v7/libbeat/beat" "github.com/elastic/beats/v7/libbeat/processors" diff --git a/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata_test.go b/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata_test.go index 002418c9825..6154d6f0b90 100644 --- a/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata_test.go +++ b/x-pack/libbeat/processors/add_cloudfoundry_metadata/add_cloudfoundry_metadata_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/cloudfoundry-community/go-cfclient" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/elastic/beats/v7/libbeat/beat" diff --git a/x-pack/metricbeat/module/azure/app_insights/client.go b/x-pack/metricbeat/module/azure/app_insights/client.go index d2bed8fbf0e..267de2f8de1 100644 --- a/x-pack/metricbeat/module/azure/app_insights/client.go +++ b/x-pack/metricbeat/module/azure/app_insights/client.go @@ -8,7 +8,7 @@ import ( "fmt" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/Azure/azure-sdk-for-go/services/preview/appinsights/v1/insights" diff --git a/x-pack/osquerybeat/beater/action_handler_test.go b/x-pack/osquerybeat/beater/action_handler_test.go index f3008e4ee76..d446b883175 100644 --- a/x-pack/osquerybeat/beater/action_handler_test.go +++ b/x-pack/osquerybeat/beater/action_handler_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/elastic/beats/v7/x-pack/osquerybeat/internal/ecs" diff --git a/x-pack/osquerybeat/beater/osquerybeat.go b/x-pack/osquerybeat/beater/osquerybeat.go index b4fe30a47d8..974444c981b 100644 --- a/x-pack/osquerybeat/beater/osquerybeat.go +++ b/x-pack/osquerybeat/beater/osquerybeat.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" lru "github.com/hashicorp/golang-lru" "github.com/osquery/osquery-go" kconfig "github.com/osquery/osquery-go/plugin/config" diff --git a/x-pack/osquerybeat/internal/fetch/fetch_test.go b/x-pack/osquerybeat/internal/fetch/fetch_test.go index f234a78f256..3e89ada6f5a 100644 --- a/x-pack/osquerybeat/internal/fetch/fetch_test.go +++ b/x-pack/osquerybeat/internal/fetch/fetch_test.go @@ -11,7 +11,7 @@ import ( "os" "testing" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" ) diff --git a/x-pack/osquerybeat/internal/osqd/osqueryd_test.go b/x-pack/osquerybeat/internal/osqd/osqueryd_test.go index 8a07cfd9d73..12b20b4e09c 100644 --- a/x-pack/osquerybeat/internal/osqd/osqueryd_test.go +++ b/x-pack/osquerybeat/internal/osqd/osqueryd_test.go @@ -15,7 +15,7 @@ import ( "github.com/elastic/beats/v7/x-pack/osquerybeat/internal/fileutil" "github.com/elastic/elastic-agent-libs/logp" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" ) diff --git a/x-pack/osquerybeat/internal/osqd/osqueryd_windows.go b/x-pack/osquerybeat/internal/osqd/osqueryd_windows.go index 0d14c417cbf..65550e4332a 100644 --- a/x-pack/osquerybeat/internal/osqd/osqueryd_windows.go +++ b/x-pack/osquerybeat/internal/osqd/osqueryd_windows.go @@ -11,7 +11,7 @@ import ( "os/exec" "syscall" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" ) const ( diff --git a/x-pack/osquerybeat/internal/pub/publisher_test.go b/x-pack/osquerybeat/internal/pub/publisher_test.go index ad592bf7ec6..7b7d2120e84 100644 --- a/x-pack/osquerybeat/internal/pub/publisher_test.go +++ b/x-pack/osquerybeat/internal/pub/publisher_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/elastic/beats/v7/libbeat/beat/events" From e8c21b55154b469a69f634c902119cf2150442dd Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Wed, 10 Jul 2024 05:34:18 +0200 Subject: [PATCH 02/26] lint: fix linting issues --- filebeat/input/log/harvester.go | 27 +++++++++---------- filebeat/input/redis/harvester.go | 20 +++++++++++--- libbeat/autodiscover/autodiscover_test.go | 2 +- .../docker/docker_integration_test.go | 10 +++++-- .../providers/jolokia/discovery.go | 5 +++- .../autodiscover/providers/jolokia/jolokia.go | 2 +- libbeat/common/event_test.go | 1 - metricbeat/mb/builders.go | 4 +-- .../module/system/process/process.go | 7 +++-- .../providers/aws/ec2/provider.go | 2 +- .../providers/aws/elb/provider_test.go | 6 ++--- x-pack/libbeat/common/nomad/metadata_test.go | 4 +++ x-pack/libbeat/common/nomad/watcher_test.go | 7 ++++- .../persistentcache/persistentcache_test.go | 27 +++---------------- .../module/azure/app_insights/client.go | 1 + 15 files changed, 68 insertions(+), 57 deletions(-) diff --git a/filebeat/input/log/harvester.go b/filebeat/input/log/harvester.go index 319ba430e70..92e310bb333 100644 --- a/filebeat/input/log/harvester.go +++ b/filebeat/input/log/harvester.go @@ -191,7 +191,7 @@ func (h *Harvester) ID() uuid.UUID { func (h *Harvester) Setup() error { err := h.open() if err != nil { - return fmt.Errorf("Harvester setup failed. Unexpected file opening error: %s", err) + return fmt.Errorf("Harvester setup failed. Unexpected file opening error: %w", err) } h.reader, err = h.newLogFileReader() @@ -199,7 +199,7 @@ func (h *Harvester) Setup() error { if h.source != nil { h.source.Close() } - return fmt.Errorf("Harvester setup failed. Unexpected encoding line reader error: %s", err) + return fmt.Errorf("Harvester setup failed. Unexpected encoding line reader error: %w", err) } h.metrics = newHarvesterProgressMetrics(h.id.String()) @@ -325,20 +325,20 @@ func (h *Harvester) Run() error { message, err := h.reader.Next() if err != nil { - switch err { - case ErrFileTruncate: + switch { + case errors.Is(err, ErrFileTruncate): logger.Info("File was truncated. Begin reading file from offset 0.") h.state.Offset = 0 filesTruncated.Add(1) - case ErrRemoved: + case errors.Is(err, ErrRemoved): logger.Info("File was removed. Closing because close_removed is enabled.") - case ErrRenamed: + case errors.Is(err, ErrRenamed): logger.Info("File was renamed. Closing because close_renamed is enabled.") - case ErrClosed: + case errors.Is(err, ErrClosed): logger.Info("Reader was closed. Closing.") - case io.EOF: + case errors.Is(err, io.EOF): logger.Info("End of file reached. Closing because close_eof is enabled.") - case ErrInactive: + case errors.Is(err, ErrInactive): logger.Infof("File is inactive. Closing because close_inactive of %v reached.", h.config.CloseInactive) default: logger.Errorf("Read line error: %v", err) @@ -519,7 +519,7 @@ func (h *Harvester) shouldExportLine(line string) bool { func (h *Harvester) openFile() error { fi, err := os.Stat(h.state.Source) if err != nil { - return fmt.Errorf("failed to stat source file %s: %v", h.state.Source, err) + return fmt.Errorf("failed to stat source file %s: %w", h.state.Source, err) } if fi.Mode()&os.ModeNamedPipe != 0 { return fmt.Errorf("failed to open file %s, named pipes are not supported", h.state.Source) @@ -563,8 +563,7 @@ func (h *Harvester) validateFile(f *os.File) error { h.encoding, err = h.encodingFactory(f) if err != nil { - - if err == transform.ErrShortSrc { + if errors.Is(err, transform.ErrShortSrc) { logger.Infof("Initialising encoding for '%v' failed due to file being too short", f) } else { logger.Errorf("Initialising encoding for '%v' failed: %v", f, err) @@ -588,12 +587,12 @@ func (h *Harvester) initFileOffset(file *os.File) (int64, error) { // continue from last known offset if h.state.Offset > 0 { h.logger.Debugf("Set previous offset: %d ", h.state.Offset) - return file.Seek(h.state.Offset, os.SEEK_SET) + return file.Seek(h.state.Offset, io.SeekStart) } // get offset from file in case of encoding factory was required to read some data. h.logger.Debug("Setting offset to: 0") - return file.Seek(0, os.SEEK_CUR) + return file.Seek(0, io.SeekCurrent) } // getState returns an updated copy of the harvester state diff --git a/filebeat/input/redis/harvester.go b/filebeat/input/redis/harvester.go index e92880d8353..2cd8568547e 100644 --- a/filebeat/input/redis/harvester.go +++ b/filebeat/input/redis/harvester.go @@ -82,8 +82,12 @@ func (h *Harvester) Run() error { default: } // Writes Slowlog get and slowlog reset both to the buffer so they are executed together - h.conn.Send("SLOWLOG", "GET") - h.conn.Send("SLOWLOG", "RESET") + if err := h.conn.Send("SLOWLOG", "GET"); err != nil { + return fmt.Errorf("error sending slowlog get: %w", err) + } + if err := h.conn.Send("SLOWLOG", "RESET"); err != nil { + return fmt.Errorf("error sending slowlog reset: %w", err) + } // Flush the buffer to execute both commands and receive the reply from SLOWLOG GET h.conn.Flush() @@ -115,7 +119,11 @@ func (h *Harvester) Run() error { var log log var args []string - rd.Scan(entry, &log.id, &log.timestamp, &log.duration, &args) + _, err = rd.Scan(entry, &log.id, &log.timestamp, &log.duration, &args) + if err != nil { + logp.Err("Error scanning slowlog entry: %s", err) + continue + } // This splits up the args into cmd, key, args. argsLen := len(args) @@ -144,7 +152,7 @@ func (h *Harvester) Run() error { slowlogEntry["args"] = log.args } - h.forwarder.Send(beat.Event{ + err = h.forwarder.Send(beat.Event{ Timestamp: time.Unix(log.timestamp, 0).UTC(), Fields: mapstr.M{ "message": strings.Join(args, " "), @@ -156,6 +164,10 @@ func (h *Harvester) Run() error { }, }, }) + if err != nil { + logp.Err("Error sending beat event: %s", err) + continue + } } return nil } diff --git a/libbeat/autodiscover/autodiscover_test.go b/libbeat/autodiscover/autodiscover_test.go index b83a4e78045..5343c093941 100644 --- a/libbeat/autodiscover/autodiscover_test.go +++ b/libbeat/autodiscover/autodiscover_test.go @@ -129,7 +129,7 @@ func (m *mockAdapter) Create(_ beat.PipelineConnector, config *conf.C) (cfgfile. func (m *mockAdapter) Runners() []*mockRunner { m.mutex.Lock() defer m.mutex.Unlock() - var res []*mockRunner + res := make([]*mockRunner, 0, len(m.runners)) for _, r := range m.runners { res = append(res, r.Clone()) } diff --git a/libbeat/autodiscover/providers/docker/docker_integration_test.go b/libbeat/autodiscover/providers/docker/docker_integration_test.go index fa2ddabdf23..c9986aad668 100644 --- a/libbeat/autodiscover/providers/docker/docker_integration_test.go +++ b/libbeat/autodiscover/providers/docker/docker_integration_test.go @@ -73,12 +73,18 @@ func TestDockerStart(t *testing.T) { if err != nil { t.Fatal(err) } - defer d.ContainerRemove(ID) + defer func() { + if err := d.ContainerRemove(ID); err != nil { + t.Error(err) + } + }() checkEvent(t, listener, ID, true) // Kill - d.ContainerKill(ID) + if err := d.ContainerKill(ID); err != nil { + t.Error(err) + } checkEvent(t, listener, ID, false) } diff --git a/libbeat/autodiscover/providers/jolokia/discovery.go b/libbeat/autodiscover/providers/jolokia/discovery.go index 45d5e04c941..97fb6d6650e 100644 --- a/libbeat/autodiscover/providers/jolokia/discovery.go +++ b/libbeat/autodiscover/providers/jolokia/discovery.go @@ -238,7 +238,9 @@ func (d *Discovery) sendProbe(config InterfaceConfig) { if timeout > config.Interval { timeout = config.Interval } - conn.SetDeadline(time.Now().Add(timeout)) + if err := conn.SetDeadline(time.Now().Add(timeout)); err != nil { + log.Error(err.Error()) + } if _, err := conn.WriteTo(queryMessage, &discoveryAddress); err != nil { log.Error(err.Error()) @@ -249,6 +251,7 @@ func (d *Discovery) sendProbe(config InterfaceConfig) { for { n, _, err := conn.ReadFrom(b) if err != nil { + //nolint:errcheck false positive if netErr, ok := err.(net.Error); !ok || !netErr.Timeout() { log.Error(err.Error()) } diff --git a/libbeat/autodiscover/providers/jolokia/jolokia.go b/libbeat/autodiscover/providers/jolokia/jolokia.go index a83e5425f7e..dfc7e403ebb 100644 --- a/libbeat/autodiscover/providers/jolokia/jolokia.go +++ b/libbeat/autodiscover/providers/jolokia/jolokia.go @@ -30,6 +30,7 @@ import ( ) func init() { + //nolint:errcheck init function autodiscover.Registry.AddProvider("jolokia", AutodiscoverBuilder) } @@ -42,7 +43,6 @@ type DiscoveryProber interface { // Provider is the Jolokia Discovery autodiscover provider type Provider struct { - config *Config bus bus.Bus builders autodiscover.Builders appenders autodiscover.Appenders diff --git a/libbeat/common/event_test.go b/libbeat/common/event_test.go index a2069498b4b..d6bd9eab99f 100644 --- a/libbeat/common/event_test.go +++ b/libbeat/common/event_test.go @@ -206,7 +206,6 @@ func TestConvertWithNullEmission(t *testing.T) { Output mapstr.M } - type String string type TestStruct struct { A interface{} } diff --git a/metricbeat/mb/builders.go b/metricbeat/mb/builders.go index c97528c522b..4c55e3e3944 100644 --- a/metricbeat/mb/builders.go +++ b/metricbeat/mb/builders.go @@ -108,8 +108,7 @@ func createModule(r *Register, bm BaseModule) (Module, error) { func initMetricSets(r *Register, m Module) ([]MetricSet, error) { var ( - errs multierror.Errors - metricsets []MetricSet + errs multierror.Errors ) bms, err := newBaseMetricSets(r, m) @@ -117,6 +116,7 @@ func initMetricSets(r *Register, m Module) ([]MetricSet, error) { return nil, err } + metricsets := make([]MetricSet, 0, len(bms)) for _, bm := range bms { registration, err := r.metricSetRegistration(bm.Module().Name(), bm.Name()) if err != nil { diff --git a/x-pack/auditbeat/module/system/process/process.go b/x-pack/auditbeat/module/system/process/process.go index a73b44b7145..dc3850c2111 100644 --- a/x-pack/auditbeat/module/system/process/process.go +++ b/x-pack/auditbeat/module/system/process/process.go @@ -115,7 +115,9 @@ type Process struct { // Hash creates a hash for Process. func (p Process) Hash() uint64 { h := xxhash.New() + //nolint:errcheck always return nil err h.WriteString(strconv.Itoa(p.Info.PID)) + //nolint:errcheck always return nil err h.WriteString(p.Info.StartTime.String()) return h.Sum64() } @@ -139,7 +141,9 @@ func (p Process) toMapStr() mapstr.M { func (p Process) entityID(hostID string) string { h := system.NewEntityHash() h.Write([]byte(hostID)) + //nolint:errcheck no error handling binary.Write(h, binary.LittleEndian, int64(p.Info.PID)) + //nolint:errcheck no error handling binary.Write(h, binary.LittleEndian, int64(p.Info.StartTime.Nanosecond())) return h.Sum() } @@ -445,13 +449,12 @@ func convertToCacheable(processes []*Process) []cache.Cacheable { } func (ms *MetricSet) getProcesses() ([]*Process, error) { - var processes []*Process - sysinfoProcs, err := sysinfo.Processes() if err != nil { return nil, fmt.Errorf("failed to fetch processes: %w", err) } + processes := make([]*Process, 0, len(sysinfoProcs)) for _, sysinfoProc := range sysinfoProcs { var process *Process diff --git a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go index 0d4dc472f6c..c58967c37c9 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go +++ b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider.go @@ -79,7 +79,7 @@ func AutodiscoverBuilder( config.Regions = completeRegionsList } - var clients []ec2.DescribeInstancesAPIClient + clients := make([]ec2.DescribeInstancesAPIClient, 0, len(config.Regions)) for _, region := range config.Regions { if err != nil { logp.Error(fmt.Errorf("error loading AWS config for aws_ec2 autodiscover provider: %w", err)) diff --git a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go index 4d34744cd14..fb0ff515c03 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go @@ -52,7 +52,7 @@ func (tea *testEventAccumulator) get() []bus.Event { func (tea *testEventAccumulator) waitForNumEvents(t *testing.T, targetLen int, timeout time.Duration) { start := time.Now() - for time.Now().Sub(start) < timeout { + for time.Since(start) < timeout { if tea.len() >= targetLen { return } @@ -100,8 +100,8 @@ func Test_internalBuilder(t *testing.T) { // Let run twice to ensure that duplicates don't create two start events // Since we're turning a list of assets into a list of changes the second once() call should be a noop - provider.watcher.once() - provider.watcher.once() + require.NoError(t, provider.watcher.once()) + require.NoError(t, provider.watcher.once()) events.waitForNumEvents(t, 1, time.Second) assert.Equal(t, 1, events.len()) diff --git a/x-pack/libbeat/common/nomad/metadata_test.go b/x-pack/libbeat/common/nomad/metadata_test.go index 9f9b59407a7..08616be9f83 100644 --- a/x-pack/libbeat/common/nomad/metadata_test.go +++ b/x-pack/libbeat/common/nomad/metadata_test.go @@ -10,6 +10,7 @@ import ( "github.com/gofrs/uuid/v5" "github.com/hashicorp/nomad/api" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" conf "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/mapstr" @@ -75,6 +76,7 @@ func TestAllocationMetadata(t *testing.T) { "annotations.dedot": false, "include_annotations": []string{"b", "b.key"}, }) + require.NoError(t, err) metaGen, err := NewMetaGenerator(config, nil) if err != nil { @@ -105,6 +107,7 @@ func TestExcludeMetadata(t *testing.T) { config, err := conf.NewConfigFrom(map[string]interface{}{ "exclude_labels": []string{"key1", "canary_tags"}, }) + require.NoError(t, err) metaGen, err := NewMetaGenerator(config, nil) if err != nil { @@ -158,6 +161,7 @@ func TestCronJob(t *testing.T) { } config, err := conf.NewConfigFrom(map[string]interface{}{}) + require.NoError(t, err) metaGen, err := NewMetaGenerator(config, nil) if err != nil { diff --git a/x-pack/libbeat/common/nomad/watcher_test.go b/x-pack/libbeat/common/nomad/watcher_test.go index f6978666b05..383fd96f5a4 100644 --- a/x-pack/libbeat/common/nomad/watcher_test.go +++ b/x-pack/libbeat/common/nomad/watcher_test.go @@ -15,6 +15,7 @@ import ( "github.com/gofrs/uuid/v5" api "github.com/hashicorp/nomad/api" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/libbeat/tests/resources" ) @@ -31,6 +32,7 @@ func nomadRoutes(node api.Node, allocs []api.Allocation, waitIndex uint64) *http payload, err := json.Marshal([]interface{}{node}) if err != nil { w.WriteHeader(http.StatusInternalServerError) + //nolint:errcheck ignore w.Write([]byte(err.Error())) } @@ -42,10 +44,12 @@ func nomadRoutes(node api.Node, allocs []api.Allocation, waitIndex uint64) *http payload, err := json.Marshal(allocs) if err != nil { w.WriteHeader(http.StatusInternalServerError) + //nolint:errcheck ignore w.Write([]byte(err.Error())) } w.Header().Add(NomadIndexHeader, fmt.Sprint(waitIndex)) + //nolint:errcheck ignore w.Write(payload) }) @@ -300,7 +304,8 @@ func TestAllocationWatcher(t *testing.T) { goroutines := resources.NewGoroutinesChecker() defer goroutines.Check(t) - watcher.Start() + err = watcher.Start() + require.NoError(t, err) defer watcher.Stop() assert.Equal(t, tt.expected, events) diff --git a/x-pack/libbeat/persistentcache/persistentcache_test.go b/x-pack/libbeat/persistentcache/persistentcache_test.go index 95e3e8397ea..cdeb00f5675 100644 --- a/x-pack/libbeat/persistentcache/persistentcache_test.go +++ b/x-pack/libbeat/persistentcache/persistentcache_test.go @@ -6,7 +6,6 @@ package persistentcache import ( "fmt" - "io/ioutil" "math/rand" "os" "path/filepath" @@ -277,6 +276,7 @@ func BenchmarkPut(b *testing.B) { for i := 0; i < b.N; i++ { cache := c.factory(b, b.Name()) for _, object := range objects { + //nolint:errcheck benchmarks cache.Put(object.ID, object) } cache.Close() @@ -392,6 +392,7 @@ func BenchmarkGet(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { expected := objects[rand.Intn(size)] + //nolint:errcheck benchmarks cache.Get(expected.ID, &result) if expected.ID != result.ID { b.Fatalf("%s != %s", expected.ID, result.ID) @@ -408,29 +409,7 @@ func BenchmarkGet(b *testing.B) { func testOptions(t testing.TB) Options { t.Helper() - tempDir, err := ioutil.TempDir("", "beat-data-dir-") - require.NoError(t, err) - - t.Cleanup(func() { os.RemoveAll(tempDir) }) - return Options{ - RootPath: filepath.Join(tempDir, cacheFile), + RootPath: filepath.Join(t.TempDir(), cacheFile), } } - -func dirSize(tb testing.TB, path string) int64 { - var size int64 - - err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error { - if err != nil { - return err - } - if !info.IsDir() { - size += info.Size() - } - return nil - }) - require.NoError(tb, err) - - return size -} diff --git a/x-pack/metricbeat/module/azure/app_insights/client.go b/x-pack/metricbeat/module/azure/app_insights/client.go index 267de2f8de1..75e931b7132 100644 --- a/x-pack/metricbeat/module/azure/app_insights/client.go +++ b/x-pack/metricbeat/module/azure/app_insights/client.go @@ -40,6 +40,7 @@ func (client *Client) GetMetricValues() (insights.ListMetricsResultsItem, error) var bodyMetrics []insights.MetricsPostBodySchema var result insights.ListMetricsResultsItem for _, metrics := range client.Config.Metrics { + metrics := metrics var aggregations []insights.MetricsAggregation var segments []insights.MetricsSegment for _, agg := range metrics.Aggregation { From 0fee800c071ebccdd5c3dd7dbd82f232858e3bcb Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 01:29:05 +0200 Subject: [PATCH 03/26] refactor: move to gofrs/uuid --- NOTICE.txt | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- heartbeat/tracer/tracer_test.go | 4 ++-- libbeat/monitoring/inputmon/input.go | 2 +- .../entityanalytics/provider/jamf/internal/jamf/jamf_test.go | 2 +- .../filebeat/input/entityanalytics/provider/jamf/jamf_test.go | 2 +- x-pack/filebeat/input/httpjson/value_tpl.go | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 94c3c0e60f9..72b311fad01 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -13180,11 +13180,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-l -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-system-metrics -Version: v0.10.3 +Version: v0.10.4 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-system-metrics@v0.10.3/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-system-metrics@v0.10.4/LICENSE.txt: Apache License Version 2.0, January 2004 diff --git a/go.mod b/go.mod index 72f896b5ab4..bae7bd77c15 100644 --- a/go.mod +++ b/go.mod @@ -199,7 +199,7 @@ require ( github.com/elastic/ebpfevents v0.6.0 github.com/elastic/elastic-agent-autodiscover v0.7.0 github.com/elastic/elastic-agent-libs v0.9.13 - github.com/elastic/elastic-agent-system-metrics v0.10.3 + github.com/elastic/elastic-agent-system-metrics v0.10.4 github.com/elastic/go-elasticsearch/v8 v8.14.0 github.com/elastic/go-sfdc v0.0.0-20240621062639-bcc8456508ff github.com/elastic/mito v1.13.0 diff --git a/go.sum b/go.sum index e84c629ac1c..b60615d1066 100644 --- a/go.sum +++ b/go.sum @@ -551,8 +551,8 @@ github.com/elastic/elastic-agent-client/v7 v7.13.0 h1:ENCfV5XIMmjWo9/0J7t//5N7xg github.com/elastic/elastic-agent-client/v7 v7.13.0/go.mod h1:h2yJHN8Q5rhfi9i6FfyPufh+StFN+UD9PYGv8blXKbE= github.com/elastic/elastic-agent-libs v0.9.13 h1:D1rh1s67zlkDWmixWQaNWzn+qy6DafIDPTQnLpBNBUA= github.com/elastic/elastic-agent-libs v0.9.13/go.mod h1:G9ljFvDE+muOOOQBf2eRituF0fE4suGkv25rfjTwY+c= -github.com/elastic/elastic-agent-system-metrics v0.10.3 h1:8pWdj8DeY8PBG/BA0DJalRpJWruDoP5QrIP/YKug5dE= -github.com/elastic/elastic-agent-system-metrics v0.10.3/go.mod h1:3JwPa3zZJjmBYN87xwdLcFpHrUkWpR863jiYdg39sSc= +github.com/elastic/elastic-agent-system-metrics v0.10.4 h1:Tmb1rPRDyVv9M453YlPyl/gwUm9s4nSiI2xH76GGEz4= +github.com/elastic/elastic-agent-system-metrics v0.10.4/go.mod h1:cd7YgcTEjBNeLGnH/C9cEvP/YexohwS6CpmN9Ju58Mw= github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHoSjSRSJCApolgfthA= github.com/elastic/elastic-transport-go/v8 v8.6.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= github.com/elastic/fsevents v0.0.0-20181029231046-e1d381a4d270 h1:cWPqxlPtir4RoQVCpGSRXmLqjEHpJKbR60rxh1nQZY4= diff --git a/heartbeat/tracer/tracer_test.go b/heartbeat/tracer/tracer_test.go index 14d68ca231f..654ec53fcf6 100644 --- a/heartbeat/tracer/tracer_test.go +++ b/heartbeat/tracer/tracer_test.go @@ -63,7 +63,7 @@ func TestSockTracer(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - sockName, err := uuid.NewRandom() + sockName, err := uuid.NewV4() require.NoError(t, err) sockPath := filepath.Join(os.TempDir(), sockName.String()) @@ -94,7 +94,7 @@ func TestSockTracerWaitSuccess(t *testing.T) { waitFor := 5 * time.Second delay := time.Millisecond * 1500 - sockName, err := uuid.NewRandom() + sockName, err := uuid.NewV4() require.NoError(t, err) sockPath := filepath.Join(os.TempDir(), sockName.String()) diff --git a/libbeat/monitoring/inputmon/input.go b/libbeat/monitoring/inputmon/input.go index 5d54a71a68c..38876aed848 100644 --- a/libbeat/monitoring/inputmon/input.go +++ b/libbeat/monitoring/inputmon/input.go @@ -59,7 +59,7 @@ func NewInputRegistry(inputType, id string, optionalParent *monitoring.Registry) // logs during support interactions. log := logp.NewLogger("metric_registry") // Make an orthogonal ID to allow tracking register/deregister pairs. - uuid := uuid.New().String() + uuid := uuid.Must(uuid.NewV4()).String() log.Infow("registering", "input_type", inputType, "id", id, "key", key, "uuid", uuid) reg = parentRegistry.NewRegistry(key) diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go index 3c457a4e1ea..fdf4b3f90a6 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go @@ -79,7 +79,7 @@ var jamfTests = []struct { w.Write([]byte("{\n \"httpStatus\" : 405,\n \"errors\" : [ ]\n}")) return } - tok.Token = uuid.New().String() + tok.Token = uuid.Must(uuid.NewV4()).String() tok.Expires = time.Now().In(time.UTC).Add(time.Hour) fmt.Fprintf(w, "{\n \"token\" : \"%s\",\n \"expires\" : \"%s\"\n}", tok.Token, tok.Expires.Format(time.RFC3339)) })) diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go index fa8deb5c0e6..71967dddd57 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go @@ -118,7 +118,7 @@ func testContext() (tenant string, username string, password string, client *htt w.Write([]byte("{\n \"httpStatus\" : 405,\n \"errors\" : [ ]\n}")) return } - tok.Token = uuid.New().String() + tok.Token = uuid.Must(uuid.NewV4()).String() tok.Expires = time.Now().In(time.UTC).Add(time.Hour) fmt.Fprintf(w, "{\n \"token\" : \"%s\",\n \"expires\" : \"%s\"\n}", tok.Token, tok.Expires.Format(time.RFC3339)) })) diff --git a/x-pack/filebeat/input/httpjson/value_tpl.go b/x-pack/filebeat/input/httpjson/value_tpl.go index 5ac1e0d74ed..b7258680dea 100644 --- a/x-pack/filebeat/input/httpjson/value_tpl.go +++ b/x-pack/filebeat/input/httpjson/value_tpl.go @@ -483,7 +483,7 @@ func hexDecode(enc string) string { } func uuidString() string { - uuid, err := uuid.NewRandom() + uuid, err := uuid.NewV4() if err != nil { return "" } From fb77a5a7ff5c93fdcb9d122626afbebad44adb93 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 01:30:55 +0200 Subject: [PATCH 04/26] lint: add gomodguard setting --- .golangci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 70aae1d462c..24508f94a25 100755 --- a/.golangci.yml +++ b/.golangci.yml @@ -121,6 +121,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" gosimple: # Select the Go version to target. The default is '1.13'. From 74beaf94f3ea53de7cf2249072586698d9645ea4 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 01:49:17 +0200 Subject: [PATCH 05/26] lint: fix more linter issues --- filebeat/input/log/harvester.go | 4 ++-- filebeat/input/redis/harvester.go | 2 +- libbeat/autodiscover/providers/jolokia/discovery.go | 2 +- libbeat/autodiscover/providers/jolokia/jolokia.go | 2 +- x-pack/auditbeat/module/system/process/process.go | 8 ++++---- .../input/entityanalytics/provider/jamf/jamf_test.go | 4 ++-- x-pack/libbeat/common/nomad/watcher_test.go | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/filebeat/input/log/harvester.go b/filebeat/input/log/harvester.go index 92e310bb333..84a62bcdfa4 100644 --- a/filebeat/input/log/harvester.go +++ b/filebeat/input/log/harvester.go @@ -527,7 +527,7 @@ func (h *Harvester) openFile() error { f, err := file_helper.ReadOpen(h.state.Source) if err != nil { - return fmt.Errorf("Failed opening %s: %s", h.state.Source, err) + return fmt.Errorf("Failed opening %s: %w", h.state.Source, err) } harvesterOpenFiles.Add(1) @@ -549,7 +549,7 @@ func (h *Harvester) validateFile(f *os.File) error { info, err := f.Stat() if err != nil { - return fmt.Errorf("Failed getting stats for file %s: %s", h.state.Source, err) + return fmt.Errorf("Failed getting stats for file %s: %w", h.state.Source, err) } if !info.Mode().IsRegular() { diff --git a/filebeat/input/redis/harvester.go b/filebeat/input/redis/harvester.go index 2cd8568547e..7a41150a203 100644 --- a/filebeat/input/redis/harvester.go +++ b/filebeat/input/redis/harvester.go @@ -95,7 +95,7 @@ func (h *Harvester) Run() error { // Receives first reply from redis which is the one from GET logs, err := rd.Values(h.conn.Receive()) if err != nil { - return fmt.Errorf("error receiving slowlog data: %s", err) + return fmt.Errorf("error receiving slowlog data: %w", err) } // Read reply from RESET diff --git a/libbeat/autodiscover/providers/jolokia/discovery.go b/libbeat/autodiscover/providers/jolokia/discovery.go index 97fb6d6650e..b7a4ff0d480 100644 --- a/libbeat/autodiscover/providers/jolokia/discovery.go +++ b/libbeat/autodiscover/providers/jolokia/discovery.go @@ -251,7 +251,7 @@ func (d *Discovery) sendProbe(config InterfaceConfig) { for { n, _, err := conn.ReadFrom(b) if err != nil { - //nolint:errcheck false positive + //nolint:errcheck // false positive if netErr, ok := err.(net.Error); !ok || !netErr.Timeout() { log.Error(err.Error()) } diff --git a/libbeat/autodiscover/providers/jolokia/jolokia.go b/libbeat/autodiscover/providers/jolokia/jolokia.go index dfc7e403ebb..0c3cfa62b7e 100644 --- a/libbeat/autodiscover/providers/jolokia/jolokia.go +++ b/libbeat/autodiscover/providers/jolokia/jolokia.go @@ -30,7 +30,7 @@ import ( ) func init() { - //nolint:errcheck init function + //nolint:errcheck // init function autodiscover.Registry.AddProvider("jolokia", AutodiscoverBuilder) } diff --git a/x-pack/auditbeat/module/system/process/process.go b/x-pack/auditbeat/module/system/process/process.go index dc3850c2111..793bb70a4fb 100644 --- a/x-pack/auditbeat/module/system/process/process.go +++ b/x-pack/auditbeat/module/system/process/process.go @@ -115,9 +115,9 @@ type Process struct { // Hash creates a hash for Process. func (p Process) Hash() uint64 { h := xxhash.New() - //nolint:errcheck always return nil err + //nolint:errcheck // always return nil err h.WriteString(strconv.Itoa(p.Info.PID)) - //nolint:errcheck always return nil err + //nolint:errcheck // always return nil err h.WriteString(p.Info.StartTime.String()) return h.Sum64() } @@ -141,9 +141,9 @@ func (p Process) toMapStr() mapstr.M { func (p Process) entityID(hostID string) string { h := system.NewEntityHash() h.Write([]byte(hostID)) - //nolint:errcheck no error handling + //nolint:errcheck // no error handling binary.Write(h, binary.LittleEndian, int64(p.Info.PID)) - //nolint:errcheck no error handling + //nolint:errcheck // no error handling binary.Write(h, binary.LittleEndian, int64(p.Info.StartTime.Nanosecond())) return h.Sum() } diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go index 71967dddd57..edd123225ce 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go @@ -18,8 +18,8 @@ import ( _ "embed" - "github.com/google/go-cmp/cmp" "github.com/gofrs/uuid/v5" + "github.com/google/go-cmp/cmp" "gopkg.in/natefinch/lumberjack.v2" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf" @@ -39,13 +39,13 @@ func TestJamfDoFetch(t *testing.T) { }) var ( - wantComputers []*Computer rawComputers jamf.Computers ) err := json.Unmarshal(computers, &rawComputers) if err != nil { t.Fatalf("failed to unmarshal device data: %v", err) } + wantComputers := make([]*Computer, 0, len(rawComputers.Results)) for _, c := range rawComputers.Results { wantComputers = append(wantComputers, &Computer{ Computer: c, diff --git a/x-pack/libbeat/common/nomad/watcher_test.go b/x-pack/libbeat/common/nomad/watcher_test.go index 383fd96f5a4..e63d28c64c4 100644 --- a/x-pack/libbeat/common/nomad/watcher_test.go +++ b/x-pack/libbeat/common/nomad/watcher_test.go @@ -32,7 +32,7 @@ func nomadRoutes(node api.Node, allocs []api.Allocation, waitIndex uint64) *http payload, err := json.Marshal([]interface{}{node}) if err != nil { w.WriteHeader(http.StatusInternalServerError) - //nolint:errcheck ignore + //nolint:errcheck // ignore w.Write([]byte(err.Error())) } @@ -44,12 +44,12 @@ func nomadRoutes(node api.Node, allocs []api.Allocation, waitIndex uint64) *http payload, err := json.Marshal(allocs) if err != nil { w.WriteHeader(http.StatusInternalServerError) - //nolint:errcheck ignore + //nolint:errcheck // ignore w.Write([]byte(err.Error())) } w.Header().Add(NomadIndexHeader, fmt.Sprint(waitIndex)) - //nolint:errcheck ignore + //nolint:errcheck // ignore w.Write(payload) }) From 3e40b837bdefe2e7ae48c3f9d87340aa3fd4dc4c Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 02:38:34 +0200 Subject: [PATCH 06/26] lint: more linting errors --- filebeat/input/redis/harvester.go | 2 +- libbeat/autodiscover/providers/jolokia/discovery.go | 2 +- .../provider/jamf/internal/jamf/jamf_test.go | 8 +++++++- .../autodiscover/providers/aws/elb/provider_test.go | 8 ++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/filebeat/input/redis/harvester.go b/filebeat/input/redis/harvester.go index 7a41150a203..141c5f15773 100644 --- a/filebeat/input/redis/harvester.go +++ b/filebeat/input/redis/harvester.go @@ -101,7 +101,7 @@ func (h *Harvester) Run() error { // Read reply from RESET _, err = h.conn.Receive() if err != nil { - return fmt.Errorf("error receiving reset data: %s", err) + return fmt.Errorf("error receiving reset data: %w", err) } for _, item := range logs { diff --git a/libbeat/autodiscover/providers/jolokia/discovery.go b/libbeat/autodiscover/providers/jolokia/discovery.go index b7a4ff0d480..1834766dd36 100644 --- a/libbeat/autodiscover/providers/jolokia/discovery.go +++ b/libbeat/autodiscover/providers/jolokia/discovery.go @@ -251,7 +251,7 @@ func (d *Discovery) sendProbe(config InterfaceConfig) { for { n, _, err := conn.ReadFrom(b) if err != nil { - //nolint:errcheck // false positive + //nolint:errorlint // false positive if netErr, ok := err.(net.Error); !ok || !netErr.Timeout() { log.Error(err.Error()) } diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go index fdf4b3f90a6..ba43bc12c6a 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go @@ -19,8 +19,8 @@ import ( _ "embed" - "github.com/google/go-cmp/cmp" "github.com/gofrs/uuid/v5" + "github.com/google/go-cmp/cmp" ) var logResponses = flag.Bool("log_response", false, "use to log users/devices returned from the API") @@ -68,14 +68,20 @@ var jamfTests = []struct { mux.Handle("/api/v1/auth/token", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { user, pass, ok := r.BasicAuth() if !ok || user != username || pass != password { + //nolint:errcheck // no error handling w.WriteHeader(http.StatusUnauthorized) + //nolint:errcheck // no error handling w.Header().Set("content-type", "application/json;charset=UTF-8") + //nolint:errcheck // no error handling w.Write([]byte("{\n \"httpStatus\" : 401,\n \"errors\" : [ ]\n}")) return } if r.Method != http.MethodPost { + //nolint:errcheck // no error handling w.WriteHeader(http.StatusMethodNotAllowed) + //nolint:errcheck // no error handling w.Header().Set("content-type", "application/json;charset=UTF-8") + //nolint:errcheck // no error handling w.Write([]byte("{\n \"httpStatus\" : 405,\n \"errors\" : [ ]\n}")) return } diff --git a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go index fb0ff515c03..0330d148d34 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go @@ -129,8 +129,8 @@ func Test_internalBuilder(t *testing.T) { fetcher.setLbls([]*lbListener{}) // Let run twice to ensure that duplicates don't cause an issue - provider.watcher.once() - provider.watcher.once() + require.NoError(t, provider.watcher.once()) + require.NoError(t, provider.watcher.once()) events.waitForNumEvents(t, 2, time.Second) require.Equal(t, 2, events.len()) @@ -148,8 +148,8 @@ func Test_internalBuilder(t *testing.T) { fetcher.setError(errors.New("oops")) // Let run twice to ensure that duplicates don't cause an issue - provider.watcher.once() - provider.watcher.once() + require.NoError(t, provider.watcher.once()) + require.NoError(t, provider.watcher.once()) assert.Equal(t, preErrorEventCount, events.len()) } From 7772b1584f57339e01fb8abfa51126dd84fdda6b Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:05:58 +0200 Subject: [PATCH 07/26] lint: completely remove gofrs/uuid v4 --- NOTICE.txt | 38 ++++---------------------------------- go.mod | 5 ++--- go.sum | 10 ++++------ 3 files changed, 10 insertions(+), 43 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 72b311fad01..5fc049b6053 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -12736,11 +12736,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-a -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-client/v7 -Version: v7.13.0 +Version: v7.14.0 Licence type (autodetected): Elastic -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-client/v7@v7.13.0/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-client/v7@v7.14.0/LICENSE.txt: ELASTIC LICENSE AGREEMENT @@ -12969,11 +12969,11 @@ SOFTWARE -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-libs -Version: v0.9.13 +Version: v0.9.14 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.9.13/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.9.14/LICENSE: Apache License Version 2.0, January 2004 @@ -39861,36 +39861,6 @@ Contents of probable licence file $GOMODCACHE/github.com/godror/knownpb@v0.1.0/L limitations under the License. --------------------------------------------------------------------------------- -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/golang-jwt/jwt/v4 Version: v4.5.0 diff --git a/go.mod b/go.mod index bae7bd77c15..22766344221 100644 --- a/go.mod +++ b/go.mod @@ -70,7 +70,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/eapache/go-resiliency v1.2.0 github.com/eclipse/paho.mqtt.golang v1.3.5 - github.com/elastic/elastic-agent-client/v7 v7.13.0 + github.com/elastic/elastic-agent-client/v7 v7.14.0 github.com/elastic/go-concert v0.3.0 github.com/elastic/go-libaudit/v2 v2.5.0 github.com/elastic/go-licenser v0.4.2 @@ -92,7 +92,6 @@ require ( github.com/godbus/dbus/v5 v5.0.6 github.com/godror/godror v0.33.2 github.com/gofrs/flock v0.8.1 - github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 github.com/golang/snappy v0.0.4 @@ -198,7 +197,7 @@ require ( github.com/elastic/bayeux v1.0.5 github.com/elastic/ebpfevents v0.6.0 github.com/elastic/elastic-agent-autodiscover v0.7.0 - github.com/elastic/elastic-agent-libs v0.9.13 + github.com/elastic/elastic-agent-libs v0.9.14 github.com/elastic/elastic-agent-system-metrics v0.10.4 github.com/elastic/go-elasticsearch/v8 v8.14.0 github.com/elastic/go-sfdc v0.0.0-20240621062639-bcc8456508ff diff --git a/go.sum b/go.sum index b60615d1066..5dfc956b415 100644 --- a/go.sum +++ b/go.sum @@ -547,10 +547,10 @@ github.com/elastic/ebpfevents v0.6.0 h1:BrL3m7JFK7U6h2jkbk3xAWWs//IZnugCHEDds5u2 github.com/elastic/ebpfevents v0.6.0/go.mod h1:ESG9gw7N+n5yCCMgdg1IIJENKWSmX7+X0Fi9GUs9nvU= github.com/elastic/elastic-agent-autodiscover v0.7.0 h1:FCrHXh5AZGrPlpAx8kBu/s/guw9d/EXt+GKlFCnrgsc= github.com/elastic/elastic-agent-autodiscover v0.7.0/go.mod h1:zLf0SDdQXisVZxzXPxKXdj3Fa+H4bsu4HHbTEQImDz8= -github.com/elastic/elastic-agent-client/v7 v7.13.0 h1:ENCfV5XIMmjWo9/0J7t//5N7xgm43Ktg0SyIomupRcA= -github.com/elastic/elastic-agent-client/v7 v7.13.0/go.mod h1:h2yJHN8Q5rhfi9i6FfyPufh+StFN+UD9PYGv8blXKbE= -github.com/elastic/elastic-agent-libs v0.9.13 h1:D1rh1s67zlkDWmixWQaNWzn+qy6DafIDPTQnLpBNBUA= -github.com/elastic/elastic-agent-libs v0.9.13/go.mod h1:G9ljFvDE+muOOOQBf2eRituF0fE4suGkv25rfjTwY+c= +github.com/elastic/elastic-agent-client/v7 v7.14.0 h1:X6S2RyjZNKsDCvA2igch2I5dgHrkfldVe0ZanH/DRCM= +github.com/elastic/elastic-agent-client/v7 v7.14.0/go.mod h1:6h+f9QdIr3GO2ODC0Y8+aEXRwzbA5W4eV4dd/67z7nI= +github.com/elastic/elastic-agent-libs v0.9.14 h1:BckPivb9dkG7u09ketu9SjB3XU+svnooAwf7PaZboMo= +github.com/elastic/elastic-agent-libs v0.9.14/go.mod h1:NzK4AsPpsgDGZMm8NmN7ia9J3xxE4ZMcKYFKXWV5GoY= github.com/elastic/elastic-agent-system-metrics v0.10.4 h1:Tmb1rPRDyVv9M453YlPyl/gwUm9s4nSiI2xH76GGEz4= github.com/elastic/elastic-agent-system-metrics v0.10.4/go.mod h1:cd7YgcTEjBNeLGnH/C9cEvP/YexohwS6CpmN9Ju58Mw= github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHoSjSRSJCApolgfthA= @@ -850,8 +850,6 @@ 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 v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -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/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= From f50037929718d308dd6589be20b2a22752b68e33 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:12:30 +0200 Subject: [PATCH 08/26] lint: more linting errors --- .../providers/kubernetes/service_test.go | 1 + .../provider/jamf/internal/jamf/jamf_test.go | 15 ++++++++------- .../providers/aws/ec2/provider_test.go | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libbeat/autodiscover/providers/kubernetes/service_test.go b/libbeat/autodiscover/providers/kubernetes/service_test.go index cd7aa2a603c..b7e0701fbd6 100644 --- a/libbeat/autodiscover/providers/kubernetes/service_test.go +++ b/libbeat/autodiscover/providers/kubernetes/service_test.go @@ -511,6 +511,7 @@ func TestServiceEventer_NamespaceWatcher(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { config := conf.MustNewConfigFrom(&test.cfg) diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go index ba43bc12c6a..5222a2943d3 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go @@ -8,6 +8,7 @@ import ( "context" "crypto/tls" "encoding/json" + "errors" "flag" "fmt" "net/http" @@ -68,18 +69,14 @@ var jamfTests = []struct { mux.Handle("/api/v1/auth/token", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { user, pass, ok := r.BasicAuth() if !ok || user != username || pass != password { - //nolint:errcheck // no error handling w.WriteHeader(http.StatusUnauthorized) - //nolint:errcheck // no error handling w.Header().Set("content-type", "application/json;charset=UTF-8") //nolint:errcheck // no error handling w.Write([]byte("{\n \"httpStatus\" : 401,\n \"errors\" : [ ]\n}")) return } if r.Method != http.MethodPost { - //nolint:errcheck // no error handling w.WriteHeader(http.StatusMethodNotAllowed) - //nolint:errcheck // no error handling w.Header().Set("content-type", "application/json;charset=UTF-8") //nolint:errcheck // no error handling w.Write([]byte("{\n \"httpStatus\" : 405,\n \"errors\" : [ ]\n}")) @@ -93,12 +90,14 @@ var jamfTests = []struct { if r.Header.Get("Authorization") != "Bearer "+tok.Token || !tok.IsValidFor(0) { w.WriteHeader(http.StatusUnauthorized) w.Header().Set("content-type", "application/json;charset=UTF-8") + //nolint:errcheck // no error handling w.Write([]byte("{\n \"httpStatus\" : 401,\n \"errors\" : [ {\n \"code\" : \"INVALID_TOKEN\",\n \"description\" : \"Unauthorized\",\n \"id\" : \"0\",\n \"field\" : null\n } ]\n}")) return false } if r.Method != http.MethodGet { w.WriteHeader(http.StatusMethodNotAllowed) w.Header().Set("content-type", "application/json;charset=UTF-8") + //nolint:errcheck // no error handling w.Write([]byte("{\n \"httpStatus\" : 405,\n \"errors\" : [ ]\n}")) return false } @@ -106,11 +105,13 @@ var jamfTests = []struct { } mux.Handle("/api/preview/computers", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if isValidRequest(w, r) { + //nolint:errcheck // no error handling w.Write(computers) } })) mux.Handle("/JSSResource/users", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if isValidRequest(w, r) { + //nolint:errcheck // no error handling w.Write(users) } })) @@ -153,9 +154,9 @@ func TestJamf(t *testing.T) { for _, test := range jamfTests { t.Run(test.name, func(t *testing.T) { tenant, username, password, client, cleanup, err := test.context() - switch err := err.(type) { - case nil: - case skipError: + switch { + case err == nil: + case errors.Is(err, skipError("")): t.Skip(err) default: t.Fatalf("unexpected error getting env context: %v", err) diff --git a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go index 9b1b753c5b1..415fc951254 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go @@ -59,8 +59,8 @@ func Test_internalBuilder(t *testing.T) { // Let run twice to ensure that duplicates don't create two start events // Since we're turning a list of assets into a list of changes the second once() call should be a noop - provider.watcher.once() - provider.watcher.once() + require.NoError(t, provider.watcher.once()) + require.NoError(t, provider.watcher.once()) events.WaitForNumEvents(t, 1, time.Second) assert.Equal(t, 1, events.Len()) From ec7de41b1c65865d680d1834704746ae989fbdcf Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:27:57 +0200 Subject: [PATCH 09/26] lint: more linting errors --- libbeat/tests/integration/framework.go | 4 ++-- x-pack/auditbeat/module/system/user/user.go | 20 +++++++++++++++---- .../providers/aws/ec2/provider_test.go | 8 ++++---- x-pack/libbeat/common/nomad/watcher_test.go | 1 + 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/libbeat/tests/integration/framework.go b/libbeat/tests/integration/framework.go index c3dc61ac2c6..dc3c5855c07 100644 --- a/libbeat/tests/integration/framework.go +++ b/libbeat/tests/integration/framework.go @@ -292,7 +292,7 @@ func (b *BeatProc) LogMatch(match string) bool { logFile := b.openLogFile() defer logFile.Close() - found := false + var found bool found, b.logFileOffset = b.logRegExpMatch(re, logFile, b.logFileOffset) if found { return found @@ -355,7 +355,7 @@ func (b *BeatProc) LogContains(s string) bool { logFile := b.openLogFile() defer logFile.Close() - found := false + var found bool found, b.logFileOffset = b.searchStrInLogs(logFile, s, b.logFileOffset) if found { return found diff --git a/x-pack/auditbeat/module/system/user/user.go b/x-pack/auditbeat/module/system/user/user.go index 7618a1a8d9c..f48019af572 100644 --- a/x-pack/auditbeat/module/system/user/user.go +++ b/x-pack/auditbeat/module/system/user/user.go @@ -10,6 +10,7 @@ import ( "bytes" "encoding/binary" "encoding/gob" + "errors" "fmt" "io" "os/user" @@ -136,17 +137,27 @@ type User struct { func (user User) Hash() uint64 { h := xxhash.New() // Use everything except userInfo + //nolint:errcheck // err always nil h.WriteString(user.Name) + //nolint:errcheck // err always nil binary.Write(h, binary.BigEndian, uint8(user.PasswordType)) + //nolint:errcheck // err always nil h.WriteString(user.PasswordChanged.String()) + //nolint:errcheck // err always nil h.Write(user.PasswordHashHash) + //nolint:errcheck // err always nil h.WriteString(user.UID) + //nolint:errcheck // err always nil h.WriteString(user.GID) + //nolint:errcheck // err always nil h.WriteString(user.Dir) + //nolint:errcheck // err always nil h.WriteString(user.Shell) for _, group := range user.Groups { + //nolint:errcheck // err always nil h.WriteString(group.Name) + //nolint:errcheck // err always nil h.WriteString(group.Gid) } @@ -199,11 +210,11 @@ func (user User) PrimaryGroup() *user.Group { } // entityID creates an ID that uniquely identifies this user across machines. -func (u User) entityID(hostID string) string { +func (user User) entityID(hostID string) string { h := system.NewEntityHash() h.Write([]byte(hostID)) - h.Write([]byte(u.Name)) - h.Write([]byte(u.UID)) + h.Write([]byte(user.Name)) + h.Write([]byte(user.UID)) return h.Sum() } @@ -555,7 +566,7 @@ func (ms *MetricSet) restoreUsersFromDisk() (users []*User, err error) { err = decoder.Decode(user) if err == nil { users = append(users, user) - } else if err == io.EOF { + } else if errors.Is(err, io.EOF) { // Read all users break } else { @@ -594,6 +605,7 @@ func (ms *MetricSet) haveFilesChanged() (bool, error) { return true, fmt.Errorf("failed to stat %v: %w", path, err) } + //nolint:unconvert // false positive ctime := time.Unix(int64(stats.Ctim.Sec), int64(stats.Ctim.Nsec)) if ms.lastRead.Before(ctime) { ms.log.Debugf("File changed: %v (lastRead=%v, ctime=%v)", path, ms.lastRead, ctime) diff --git a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go index 415fc951254..58665c943ac 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go @@ -86,8 +86,8 @@ func Test_internalBuilder(t *testing.T) { fetcher.setEC2s([]*ec2Instance{}) // Let run twice to ensure that duplicates don't cause an issue - provider.watcher.once() - provider.watcher.once() + require.NoError(t, provider.watcher.once()) + require.NoError(t, provider.watcher.once()) events.WaitForNumEvents(t, 2, time.Second) require.Equal(t, 2, events.Len()) @@ -105,8 +105,8 @@ func Test_internalBuilder(t *testing.T) { fetcher.setError(errors.New("oops")) // Let run twice to ensure that duplicates don't cause an issue - provider.watcher.once() - provider.watcher.once() + require.NoError(t, provider.watcher.once()) + require.NoError(t, provider.watcher.once()) assert.Equal(t, preErrorEventCount, events.Len()) } diff --git a/x-pack/libbeat/common/nomad/watcher_test.go b/x-pack/libbeat/common/nomad/watcher_test.go index e63d28c64c4..488d9ef8bf8 100644 --- a/x-pack/libbeat/common/nomad/watcher_test.go +++ b/x-pack/libbeat/common/nomad/watcher_test.go @@ -37,6 +37,7 @@ func nomadRoutes(node api.Node, allocs []api.Allocation, waitIndex uint64) *http } w.Header().Add(NomadIndexHeader, fmt.Sprint(time.Now().Unix())) + //nolint:errcheck // ignore w.Write(payload) }) From 9eaa809fe098231d95c10691651f54dc36c7335b Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 22:03:21 +0200 Subject: [PATCH 10/26] lint: fix more linting errors --- .../provider/jamf/internal/jamf/jamf_test.go | 8 +------- .../entityanalytics/provider/jamf/jamf_test.go | 17 +++++++---------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go index 5222a2943d3..3d4872f2055 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go @@ -124,13 +124,7 @@ var jamfTests = []struct { } tenant = u.Host - cli := &http.Client{ - Transport: &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - }, - }, - } + cli := srv.Client() return tenant, username, password, cli, srv.Close, nil }, diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go index edd123225ce..af872ec7068 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go @@ -38,9 +38,7 @@ func TestJamfDoFetch(t *testing.T) { testCleanupStore(store, dbFilename) }) - var ( - rawComputers jamf.Computers - ) + var rawComputers jamf.Computers err := json.Unmarshal(computers, &rawComputers) if err != nil { t.Fatalf("failed to unmarshal device data: %v", err) @@ -109,12 +107,14 @@ func testContext() (tenant string, username string, password string, client *htt if !ok || user != username || pass != password { w.WriteHeader(http.StatusUnauthorized) w.Header().Set("content-type", "application/json;charset=UTF-8") + //nolint:errcheck // ignore w.Write([]byte("{\n \"httpStatus\" : 401,\n \"errors\" : [ ]\n}")) return } if r.Method != http.MethodPost { w.WriteHeader(http.StatusMethodNotAllowed) w.Header().Set("content-type", "application/json;charset=UTF-8") + //nolint:errcheck // ignore w.Write([]byte("{\n \"httpStatus\" : 405,\n \"errors\" : [ ]\n}")) return } @@ -126,15 +126,18 @@ func testContext() (tenant string, username string, password string, client *htt if r.Header.Get("Authorization") != "Bearer "+tok.Token || !tok.IsValidFor(0) { w.WriteHeader(http.StatusUnauthorized) w.Header().Set("content-type", "application/json;charset=UTF-8") + //nolint:errcheck // ignore w.Write([]byte("{\n \"httpStatus\" : 401,\n \"errors\" : [ {\n \"code\" : \"INVALID_TOKEN\",\n \"description\" : \"Unauthorized\",\n \"id\" : \"0\",\n \"field\" : null\n } ]\n}")) return } if r.Method != http.MethodGet { w.WriteHeader(http.StatusMethodNotAllowed) w.Header().Set("content-type", "application/json;charset=UTF-8") + //nolint:errcheck // ignore w.Write([]byte("{\n \"httpStatus\" : 405,\n \"errors\" : [ ]\n}")) return } + //nolint:errcheck // ignore w.Write(computers) })) @@ -146,13 +149,7 @@ func testContext() (tenant string, username string, password string, client *htt } tenant = u.Host - cli := &http.Client{ - Transport: &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - }, - }, - } + cli := srv.Client() return tenant, username, password, cli, srv.Close, nil } From f3ecc1f732530ee6e0aa841be5a20dbf3695bd4b Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 11 Jul 2024 23:02:02 +0200 Subject: [PATCH 11/26] fix: replace uuid.MustParse with uuid.Must(uuid.FromString()) --- .../internal/collections/uuid_set_test.go | 10 ++-- .../provider/azuread/fetcher/device_test.go | 50 +++++++++---------- .../azuread/fetcher/graph/graph_test.go | 38 +++++++------- .../provider/azuread/fetcher/group_test.go | 2 +- .../provider/azuread/fetcher/mock/mock.go | 26 +++++----- .../provider/azuread/fetcher/user_test.go | 28 +++++------ .../provider/azuread/statestore_test.go | 8 +-- 7 files changed, 81 insertions(+), 81 deletions(-) diff --git a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set_test.go b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set_test.go index 5af67892289..f3d05077b02 100644 --- a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set_test.go +++ b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_set_test.go @@ -22,11 +22,11 @@ const ( ) var ( - testUUID1 = uuid.MustParse(testUUID1Str) - testUUID2 = uuid.MustParse(testUUID2Str) - testUUID3 = uuid.MustParse(testUUID3Str) - testUUID4 = uuid.MustParse(testUUID4Str) - testUUID5 = uuid.MustParse(testUUID5Str) + testUUID1 = uuid.Must(uuid.FromString(testUUID1Str)) + testUUID2 = uuid.Must(uuid.FromString(testUUID2Str)) + testUUID3 = uuid.Must(uuid.FromString(testUUID3Str)) + testUUID4 = uuid.Must(uuid.FromString(testUUID4Str)) + testUUID5 = uuid.Must(uuid.FromString(testUUID5Str)) ) func TestNewUUIDSet(t *testing.T) { diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device_test.go index 0ff5c0396cc..5f9e1bd11ce 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/device_test.go @@ -20,59 +20,59 @@ func TestDevice_Merge(t *testing.T) { Want *Device }{ "id-mismatch": { - In: &Device{ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd")}, - InOther: &Device{ID: uuid.MustParse("80c3f9af-75ae-45f5-b22b-53f005d5880d")}, - Want: &Device{ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd")}, + In: &Device{ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd"))}, + InOther: &Device{ID: uuid.Must(uuid.FromString("80c3f9af-75ae-45f5-b22b-53f005d5880d"))}, + Want: &Device{ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd"))}, }, "ok": { In: &Device{ - ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd"), + ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd")), Fields: map[string]interface{}{ "a": "alpha", }, - MemberOf: collections.NewUUIDSet(uuid.MustParse("fcda226a-c920-4d99-81bc-d2d691a6c212")), - TransitiveMemberOf: collections.NewUUIDSet(uuid.MustParse("ca777ad5-9abf-4c9b-be1f-c38c6ec28f28")), - RegisteredOwners: collections.NewUUIDSet(uuid.MustParse("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a")), + MemberOf: collections.NewUUIDSet(uuid.Must(uuid.FromString("fcda226a-c920-4d99-81bc-d2d691a6c212"))), + TransitiveMemberOf: collections.NewUUIDSet(uuid.Must(uuid.FromString("ca777ad5-9abf-4c9b-be1f-c38c6ec28f28"))), + RegisteredOwners: collections.NewUUIDSet(uuid.Must(uuid.FromString("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a"))), RegisteredUsers: collections.NewUUIDSet( - uuid.MustParse("27cea005-7377-4175-b2ef-e9d64c977f4d"), - uuid.MustParse("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a"), + uuid.Must(uuid.FromString("27cea005-7377-4175-b2ef-e9d64c977f4d")), + uuid.Must(uuid.FromString("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a")), ), }, InOther: &Device{ - ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd"), + ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd")), Fields: map[string]interface{}{ "b": "beta", }, - MemberOf: collections.NewUUIDSet(uuid.MustParse("a77e8cbb-27a5-49d3-9d5e-801997621f87")), - TransitiveMemberOf: collections.NewUUIDSet(uuid.MustParse("c550d32c-09b2-4851-b0f2-1bc431e26d01")), - RegisteredOwners: collections.NewUUIDSet(uuid.MustParse("81d1b5cd-7cd6-469d-9fe8-0a5c6cf2a7b6")), + MemberOf: collections.NewUUIDSet(uuid.Must(uuid.FromString("a77e8cbb-27a5-49d3-9d5e-801997621f87"))), + TransitiveMemberOf: collections.NewUUIDSet(uuid.Must(uuid.FromString("c550d32c-09b2-4851-b0f2-1bc431e26d01"))), + RegisteredOwners: collections.NewUUIDSet(uuid.Must(uuid.FromString("81d1b5cd-7cd6-469d-9fe8-0a5c6cf2a7b6"))), RegisteredUsers: collections.NewUUIDSet( - uuid.MustParse("5e6d279a-ce2b-43b8-a38f-3110907e1974"), - uuid.MustParse("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a"), + uuid.Must(uuid.FromString("5e6d279a-ce2b-43b8-a38f-3110907e1974")), + uuid.Must(uuid.FromString("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a")), ), }, Want: &Device{ - ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd"), + ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd")), Fields: map[string]interface{}{ "a": "alpha", "b": "beta", }, MemberOf: collections.NewUUIDSet( - uuid.MustParse("fcda226a-c920-4d99-81bc-d2d691a6c212"), - uuid.MustParse("a77e8cbb-27a5-49d3-9d5e-801997621f87"), + uuid.Must(uuid.FromString("fcda226a-c920-4d99-81bc-d2d691a6c212")), + uuid.Must(uuid.FromString("a77e8cbb-27a5-49d3-9d5e-801997621f87")), ), TransitiveMemberOf: collections.NewUUIDSet( - uuid.MustParse("ca777ad5-9abf-4c9b-be1f-c38c6ec28f28"), - uuid.MustParse("c550d32c-09b2-4851-b0f2-1bc431e26d01"), + uuid.Must(uuid.FromString("ca777ad5-9abf-4c9b-be1f-c38c6ec28f28")), + uuid.Must(uuid.FromString("c550d32c-09b2-4851-b0f2-1bc431e26d01")), ), RegisteredOwners: collections.NewUUIDSet( - uuid.MustParse("81d1b5cd-7cd6-469d-9fe8-0a5c6cf2a7b6"), - uuid.MustParse("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a"), + uuid.Must(uuid.FromString("81d1b5cd-7cd6-469d-9fe8-0a5c6cf2a7b6")), + uuid.Must(uuid.FromString("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a")), ), RegisteredUsers: collections.NewUUIDSet( - uuid.MustParse("27cea005-7377-4175-b2ef-e9d64c977f4d"), - uuid.MustParse("5e6d279a-ce2b-43b8-a38f-3110907e1974"), - uuid.MustParse("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a"), + uuid.Must(uuid.FromString("27cea005-7377-4175-b2ef-e9d64c977f4d")), + uuid.Must(uuid.FromString("5e6d279a-ce2b-43b8-a38f-3110907e1974")), + uuid.Must(uuid.FromString("c59fbdb8-e442-46b1-8d72-c8ac0b78ec0a")), ), }, }, diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go index 6c122f22ffc..fe53ad55f4c 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go @@ -143,11 +143,11 @@ var deviceUserResponses = map[string]apiUserResponse{ var groupsResponse1 = apiGroupResponse{ Groups: []groupAPI{ { - ID: uuid.MustParse("331676df-b8fd-4492-82ed-02b927f8dd80"), + ID: uuid.Must(uuid.FromString("331676df-b8fd-4492-82ed-02b927f8dd80")), DisplayName: "group1", MembersDelta: []memberAPI{ { - ID: uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + ID: uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), Type: apiUserType, }, }, @@ -158,15 +158,15 @@ var groupsResponse1 = apiGroupResponse{ var groupsResponse2 = apiGroupResponse{ Groups: []groupAPI{ { - ID: uuid.MustParse("d140978f-d641-4f01-802f-4ecc1acf8935"), + ID: uuid.Must(uuid.FromString("d140978f-d641-4f01-802f-4ecc1acf8935")), DisplayName: "group2", MembersDelta: []memberAPI{ { - ID: uuid.MustParse("331676df-b8fd-4492-82ed-02b927f8dd80"), + ID: uuid.Must(uuid.FromString("331676df-b8fd-4492-82ed-02b927f8dd80")), Type: apiGroupType, }, { - ID: uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + ID: uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), Type: apiGroupType, Removed: &removed{Reason: "changed"}, }, @@ -288,25 +288,25 @@ func TestGraph_Groups(t *testing.T) { wantDeltaLink := "http://" + testSrv.addr + "/groups/delta?$deltatoken=test" wantGroups := []*fetcher.Group{ { - ID: uuid.MustParse("331676df-b8fd-4492-82ed-02b927f8dd80"), + ID: uuid.Must(uuid.FromString("331676df-b8fd-4492-82ed-02b927f8dd80")), Name: "group1", Members: []fetcher.Member{ { - ID: uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + ID: uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), Type: fetcher.MemberUser, }, }, }, { - ID: uuid.MustParse("d140978f-d641-4f01-802f-4ecc1acf8935"), + ID: uuid.Must(uuid.FromString("d140978f-d641-4f01-802f-4ecc1acf8935")), Name: "group2", Members: []fetcher.Member{ { - ID: uuid.MustParse("331676df-b8fd-4492-82ed-02b927f8dd80"), + ID: uuid.Must(uuid.FromString("331676df-b8fd-4492-82ed-02b927f8dd80")), Type: fetcher.MemberGroup, }, { - ID: uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + ID: uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), Type: fetcher.MemberGroup, Deleted: true, }, @@ -347,7 +347,7 @@ func TestGraph_Users(t *testing.T) { wantDeltaLink := "http://" + testSrv.addr + "/users/delta?$deltatoken=test" wantUsers := []*fetcher.User{ { - ID: uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + ID: uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), Fields: map[string]interface{}{ "userPrincipalName": "user.one@example.com", "mail": "user.one@example.com", @@ -362,7 +362,7 @@ func TestGraph_Users(t *testing.T) { }, }, { - ID: uuid.MustParse("d897d560-3d17-4dae-81b3-c898fe82bf84"), + ID: uuid.Must(uuid.FromString("d897d560-3d17-4dae-81b3-c898fe82bf84")), Fields: map[string]interface{}{ "userPrincipalName": "user.two@example.com", "mail": "user.two@example.com", @@ -411,7 +411,7 @@ func TestGraph_Devices(t *testing.T) { wantDeltaLink := "http://" + testSrv.addr + "/devices/delta?$deltatoken=test" wantDevices := []*fetcher.Device{ { - ID: uuid.MustParse("6a59ea83-02bd-468f-a40b-f2c3d1821983"), + ID: uuid.Must(uuid.FromString("6a59ea83-02bd-468f-a40b-f2c3d1821983")), Fields: map[string]interface{}{ "accountEnabled": true, "deviceId": "eab73519-780d-4d43-be6d-a4a89af2a348", @@ -434,15 +434,15 @@ func TestGraph_Devices(t *testing.T) { }, }, RegisteredOwners: collections.NewUUIDSet( - uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), ), RegisteredUsers: collections.NewUUIDSet( - uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), - uuid.MustParse("d897d560-3d17-4dae-81b3-c898fe82bf84"), + uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), + uuid.Must(uuid.FromString("d897d560-3d17-4dae-81b3-c898fe82bf84")), ), }, { - ID: uuid.MustParse("adbbe40a-0627-4328-89f1-88cac84dbc7f"), + ID: uuid.Must(uuid.FromString("adbbe40a-0627-4328-89f1-88cac84dbc7f")), Fields: map[string]interface{}{ "accountEnabled": true, "deviceId": "2fbbb8f9-ff67-4a21-b867-a344d18a4198", @@ -465,10 +465,10 @@ func TestGraph_Devices(t *testing.T) { }, }, RegisteredOwners: collections.NewUUIDSet( - uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), ), RegisteredUsers: collections.NewUUIDSet( - uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), ), }, } diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group_test.go index 560f54362d2..7c6a1ff5ba3 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/group_test.go @@ -13,7 +13,7 @@ import ( func TestGroup_ToECS(t *testing.T) { in := Group{ - ID: uuid.MustParse("88ecb4e8-5a1a-461e-a062-f1d3c5aa4ca4"), + ID: uuid.Must(uuid.FromString("88ecb4e8-5a1a-461e-a062-f1d3c5aa4ca4")), Name: "group1", } want := GroupECS{ diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/mock/mock.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/mock/mock.go index c840325c1bc..4385385367d 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/mock/mock.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/mock/mock.go @@ -22,43 +22,43 @@ var ( var GroupResponse = []*fetcher.Group{ { - ID: uuid.MustParse("331676df-b8fd-4492-82ed-02b927f8dd80"), + ID: uuid.Must(uuid.FromString("331676df-b8fd-4492-82ed-02b927f8dd80")), Name: "group1", Members: []fetcher.Member{ { - ID: uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + ID: uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), Type: fetcher.MemberUser, }, { - ID: uuid.MustParse("6a59ea83-02bd-468f-a40b-f2c3d1821983"), + ID: uuid.Must(uuid.FromString("6a59ea83-02bd-468f-a40b-f2c3d1821983")), Type: fetcher.MemberDevice, }, }, }, { - ID: uuid.MustParse("d140978f-d641-4f01-802f-4ecc1acf8935"), + ID: uuid.Must(uuid.FromString("d140978f-d641-4f01-802f-4ecc1acf8935")), Name: "group2", Members: []fetcher.Member{ { - ID: uuid.MustParse("331676df-b8fd-4492-82ed-02b927f8dd80"), + ID: uuid.Must(uuid.FromString("331676df-b8fd-4492-82ed-02b927f8dd80")), Type: fetcher.MemberGroup, }, { - ID: uuid.MustParse("d897d560-3d17-4dae-81b3-c898fe82bf84"), + ID: uuid.Must(uuid.FromString("d897d560-3d17-4dae-81b3-c898fe82bf84")), Type: fetcher.MemberUser, }, { - ID: uuid.MustParse("adbbe40a-0627-4328-89f1-88cac84dbc7f"), + ID: uuid.Must(uuid.FromString("adbbe40a-0627-4328-89f1-88cac84dbc7f")), Type: fetcher.MemberDevice, }, }, }, { - ID: uuid.MustParse("10db9800-3908-40cc-81c5-511fa8ccf7fd"), + ID: uuid.Must(uuid.FromString("10db9800-3908-40cc-81c5-511fa8ccf7fd")), Name: "group3", Members: []fetcher.Member{ { - ID: uuid.MustParse("d140978f-d641-4f01-802f-4ecc1acf8935"), + ID: uuid.Must(uuid.FromString("d140978f-d641-4f01-802f-4ecc1acf8935")), Type: fetcher.MemberGroup, }, }, @@ -67,7 +67,7 @@ var GroupResponse = []*fetcher.Group{ var UserResponse = []*fetcher.User{ { - ID: uuid.MustParse("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc"), + ID: uuid.Must(uuid.FromString("5ebc6a0f-05b7-4f42-9c8a-682bbc75d0fc")), Fields: map[string]interface{}{ "userPrincipalName": "user.one@example.com", "mail": "user.one@example.com", @@ -80,7 +80,7 @@ var UserResponse = []*fetcher.User{ }, }, { - ID: uuid.MustParse("d897d560-3d17-4dae-81b3-c898fe82bf84"), + ID: uuid.Must(uuid.FromString("d897d560-3d17-4dae-81b3-c898fe82bf84")), Fields: map[string]interface{}{ "userPrincipalName": "user.two@example.com", "mail": "user.two@example.com", @@ -96,7 +96,7 @@ var UserResponse = []*fetcher.User{ var DeviceResponse = []*fetcher.Device{ { - ID: uuid.MustParse("6a59ea83-02bd-468f-a40b-f2c3d1821983"), + ID: uuid.Must(uuid.FromString("6a59ea83-02bd-468f-a40b-f2c3d1821983")), Fields: map[string]interface{}{ "accountEnabled": true, "deviceId": "eab73519-780d-4d43-be6d-a4a89af2a348", @@ -120,7 +120,7 @@ var DeviceResponse = []*fetcher.Device{ }, }, { - ID: uuid.MustParse("adbbe40a-0627-4328-89f1-88cac84dbc7f"), + ID: uuid.Must(uuid.FromString("adbbe40a-0627-4328-89f1-88cac84dbc7f")), Fields: map[string]interface{}{ "accountEnabled": true, "deviceId": "2fbbb8f9-ff67-4a21-b867-a344d18a4198", diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user_test.go index 7ff2df55376..afb361f982f 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/user_test.go @@ -20,40 +20,40 @@ func TestUser_Merge(t *testing.T) { Want *User }{ "id-mismatch": { - In: &User{ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd")}, - InOther: &User{ID: uuid.MustParse("80c3f9af-75ae-45f5-b22b-53f005d5880d")}, - Want: &User{ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd")}, + In: &User{ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd"))}, + InOther: &User{ID: uuid.Must(uuid.FromString("80c3f9af-75ae-45f5-b22b-53f005d5880d"))}, + Want: &User{ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd"))}, }, "ok": { In: &User{ - ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd"), + ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd")), Fields: map[string]interface{}{ "a": "alpha", }, - MemberOf: collections.NewUUIDSet(uuid.MustParse("fcda226a-c920-4d99-81bc-d2d691a6c212")), - TransitiveMemberOf: collections.NewUUIDSet(uuid.MustParse("ca777ad5-9abf-4c9b-be1f-c38c6ec28f28")), + MemberOf: collections.NewUUIDSet(uuid.Must(uuid.FromString("fcda226a-c920-4d99-81bc-d2d691a6c212"))), + TransitiveMemberOf: collections.NewUUIDSet(uuid.Must(uuid.FromString("ca777ad5-9abf-4c9b-be1f-c38c6ec28f28"))), }, InOther: &User{ - ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd"), + ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd")), Fields: map[string]interface{}{ "b": "beta", }, - MemberOf: collections.NewUUIDSet(uuid.MustParse("a77e8cbb-27a5-49d3-9d5e-801997621f87")), - TransitiveMemberOf: collections.NewUUIDSet(uuid.MustParse("c550d32c-09b2-4851-b0f2-1bc431e26d01")), + MemberOf: collections.NewUUIDSet(uuid.Must(uuid.FromString("a77e8cbb-27a5-49d3-9d5e-801997621f87"))), + TransitiveMemberOf: collections.NewUUIDSet(uuid.Must(uuid.FromString("c550d32c-09b2-4851-b0f2-1bc431e26d01"))), }, Want: &User{ - ID: uuid.MustParse("187f924c-e867-477e-8d74-dd762d6379dd"), + ID: uuid.Must(uuid.FromString("187f924c-e867-477e-8d74-dd762d6379dd")), Fields: map[string]interface{}{ "a": "alpha", "b": "beta", }, MemberOf: collections.NewUUIDSet( - uuid.MustParse("fcda226a-c920-4d99-81bc-d2d691a6c212"), - uuid.MustParse("a77e8cbb-27a5-49d3-9d5e-801997621f87"), + uuid.Must(uuid.FromString("fcda226a-c920-4d99-81bc-d2d691a6c212")), + uuid.Must(uuid.FromString("a77e8cbb-27a5-49d3-9d5e-801997621f87")), ), TransitiveMemberOf: collections.NewUUIDSet( - uuid.MustParse("ca777ad5-9abf-4c9b-be1f-c38c6ec28f28"), - uuid.MustParse("c550d32c-09b2-4851-b0f2-1bc431e26d01"), + uuid.Must(uuid.FromString("ca777ad5-9abf-4c9b-be1f-c38c6ec28f28")), + uuid.Must(uuid.FromString("c550d32c-09b2-4851-b0f2-1bc431e26d01")), ), }, }, diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore_test.go index c6e857f4eac..66f08d018d5 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/statestore_test.go @@ -116,10 +116,10 @@ func TestStateStore_Close(t *testing.T) { ss.devicesLink = "devices-link" ss.groupsLink = "groups-link" - user1ID := uuid.MustParse("a77e8cbb-27a5-49d3-9d5e-801997621f87") - device1ID := uuid.MustParse("adbbe40a-0627-4328-89f1-88cac84dbc7f") - group1ID := uuid.MustParse("331676df-b8fd-4492-82ed-02b927f8dd80") - group2ID := uuid.MustParse("ec8b17ae-ce9d-4099-97ee-4a959638bc29") + user1ID := uuid.Must(uuid.FromString("a77e8cbb-27a5-49d3-9d5e-801997621f87")) + device1ID := uuid.Must(uuid.FromString("adbbe40a-0627-4328-89f1-88cac84dbc7f")) + group1ID := uuid.Must(uuid.FromString("331676df-b8fd-4492-82ed-02b927f8dd80")) + group2ID := uuid.Must(uuid.FromString("ec8b17ae-ce9d-4099-97ee-4a959638bc29")) ss.users = map[uuid.UUID]*fetcher.User{ user1ID: { From 9e3317599fc4fe16a11a5cf9c59e354ca34e349e Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 12 Jul 2024 01:25:40 +0200 Subject: [PATCH 12/26] refactor: update uuid.Parse to uuid.FromString --- .../entityanalytics/provider/azuread/fetcher/graph/graph.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go index 47f1c394f78..62af0c379d4 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go @@ -488,7 +488,7 @@ func newUserFromAPI(u userAPI) (*fetcher.User, error) { if idRaw, ok := newUser.Fields["id"]; ok { idStr, _ := idRaw.(string) - if newUser.ID, err = uuid.Parse(idStr); err != nil { + if newUser.ID, err = uuid.FromString(idStr); err != nil { return nil, fmt.Errorf("unable to unmarshal user, invalid ID: %w", err) } delete(newUser.Fields, "id") @@ -542,7 +542,7 @@ func newDeviceFromAPI(d deviceAPI) (*fetcher.Device, error) { if idRaw, ok := newDevice.Fields["id"]; ok { idStr, _ := idRaw.(string) - if newDevice.ID, err = uuid.Parse(idStr); err != nil { + if newDevice.ID, err = uuid.FromString(idStr); err != nil { return nil, fmt.Errorf("unable to unmarshal device, invalid ID: %w", err) } delete(newDevice.Fields, "id") From 90968082180a942194b2b57db5b9f9a65503c9d3 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 12 Jul 2024 01:38:36 +0200 Subject: [PATCH 13/26] lint: fix linting errors --- .../provider/azuread/fetcher/graph/graph_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go index fe53ad55f4c..64f31be104d 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go @@ -17,8 +17,8 @@ import ( "testing" "time" - "github.com/google/go-cmp/cmp" "github.com/gofrs/uuid/v5" + "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" "gopkg.in/natefinch/lumberjack.v2" From 1c17360280ca6a755e1119e8e9c114674fc71c7f Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 12 Jul 2024 03:36:13 +0200 Subject: [PATCH 14/26] lint: fix linting errors --- .../entityanalytics/provider/jamf/internal/jamf/jamf_test.go | 1 - x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go | 1 - x-pack/libbeat/persistentcache/persistentcache_test.go | 1 - 3 files changed, 3 deletions(-) diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go index 3d4872f2055..287b733f013 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go @@ -6,7 +6,6 @@ package jamf import ( "context" - "crypto/tls" "encoding/json" "errors" "flag" diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go index af872ec7068..9ca7128d11c 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go @@ -6,7 +6,6 @@ package jamf import ( "context" - "crypto/tls" "encoding/json" "flag" "fmt" diff --git a/x-pack/libbeat/persistentcache/persistentcache_test.go b/x-pack/libbeat/persistentcache/persistentcache_test.go index cdeb00f5675..e14c90f1dd8 100644 --- a/x-pack/libbeat/persistentcache/persistentcache_test.go +++ b/x-pack/libbeat/persistentcache/persistentcache_test.go @@ -7,7 +7,6 @@ package persistentcache import ( "fmt" "math/rand" - "os" "path/filepath" "strconv" "testing" From d6d7ee3a9b65279c1087fb6241433b1f44134c80 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 12 Jul 2024 03:52:40 +0200 Subject: [PATCH 15/26] docs: fix nolint comments --- x-pack/libbeat/persistentcache/persistentcache_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/libbeat/persistentcache/persistentcache_test.go b/x-pack/libbeat/persistentcache/persistentcache_test.go index e14c90f1dd8..7a3b61b8cb3 100644 --- a/x-pack/libbeat/persistentcache/persistentcache_test.go +++ b/x-pack/libbeat/persistentcache/persistentcache_test.go @@ -275,7 +275,7 @@ func BenchmarkPut(b *testing.B) { for i := 0; i < b.N; i++ { cache := c.factory(b, b.Name()) for _, object := range objects { - //nolint:errcheck benchmarks + //nolint:errcheck // benchmarks cache.Put(object.ID, object) } cache.Close() @@ -391,7 +391,7 @@ func BenchmarkGet(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { expected := objects[rand.Intn(size)] - //nolint:errcheck benchmarks + //nolint:errcheck // benchmarks cache.Get(expected.ID, &result) if expected.ID != result.ID { b.Fatalf("%s != %s", expected.ID, result.ID) From bd1db14d5b10aa5570699c8475e622ace79dfc13 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 12 Jul 2024 04:25:46 +0200 Subject: [PATCH 16/26] lint: fix linting errors --- .../libbeat/autodiscover/providers/aws/ec2/provider_test.go | 6 ++++-- .../libbeat/autodiscover/providers/aws/elb/provider_test.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go index 58665c943ac..f270cd317c9 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go @@ -105,8 +105,10 @@ func Test_internalBuilder(t *testing.T) { fetcher.setError(errors.New("oops")) // Let run twice to ensure that duplicates don't cause an issue - require.NoError(t, provider.watcher.once()) - require.NoError(t, provider.watcher.once()) + // nolint:errcheck // ignore + provider.watcher.once() + // nolint:errcheck // ignore + provider.watcher.once() assert.Equal(t, preErrorEventCount, events.Len()) } diff --git a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go index 0330d148d34..cc7384cebdc 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go @@ -148,8 +148,10 @@ func Test_internalBuilder(t *testing.T) { fetcher.setError(errors.New("oops")) // Let run twice to ensure that duplicates don't cause an issue - require.NoError(t, provider.watcher.once()) - require.NoError(t, provider.watcher.once()) + // nolint:errcheck // ignore + provider.watcher.once() + // nolint:errcheck // ignore + provider.watcher.once() assert.Equal(t, preErrorEventCount, events.len()) } From 4ed1ee39765f347de499469ea923daa2d96354bf Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 12 Jul 2024 05:13:08 +0200 Subject: [PATCH 17/26] docs: update nolint comments --- .../libbeat/autodiscover/providers/aws/ec2/provider_test.go | 4 ++-- .../libbeat/autodiscover/providers/aws/elb/provider_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go index f270cd317c9..335acc3080f 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/ec2/provider_test.go @@ -105,9 +105,9 @@ func Test_internalBuilder(t *testing.T) { fetcher.setError(errors.New("oops")) // Let run twice to ensure that duplicates don't cause an issue - // nolint:errcheck // ignore + //nolint:errcheck // ignore provider.watcher.once() - // nolint:errcheck // ignore + //nolint:errcheck // ignore provider.watcher.once() assert.Equal(t, preErrorEventCount, events.Len()) diff --git a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go index cc7384cebdc..a6b08c8afe8 100644 --- a/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go +++ b/x-pack/libbeat/autodiscover/providers/aws/elb/provider_test.go @@ -148,9 +148,9 @@ func Test_internalBuilder(t *testing.T) { fetcher.setError(errors.New("oops")) // Let run twice to ensure that duplicates don't cause an issue - // nolint:errcheck // ignore + //nolint:errcheck // ignore provider.watcher.once() - // nolint:errcheck // ignore + //nolint:errcheck // ignore provider.watcher.once() assert.Equal(t, preErrorEventCount, events.len()) From 25cf98a1af0388b390123494c086059d63aa0ed6 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:36:36 +0200 Subject: [PATCH 18/26] test: update uuid parsing err --- .../entityanalytics/internal/collections/uuid_tree_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree_test.go b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree_test.go index 5414d1ad929..01b1e8b6e74 100644 --- a/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree_test.go +++ b/x-pack/filebeat/input/entityanalytics/internal/collections/uuid_tree_test.go @@ -36,7 +36,7 @@ func TestUUIDTree_UnmarshalJSON(t *testing.T) { }, "err-bad-uuid-key": { In: []byte(fmt.Sprintf(`{"1":["%s"]}`, testUUID1)), - WantErr: "invalid UUID length: 1", + WantErr: "uuid: incorrect UUID length 1 in string \"1\"", }, "err-bad-uuid-set": { In: []byte(fmt.Sprintf(`{"%s":[1]}`, testUUID1)), From bc7f2789e74d674023beac901cfb179a6309caa5 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:16:14 +0200 Subject: [PATCH 19/26] lint: fix linter issues --- .../provider/jamf/internal/jamf/jamf_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go index 287b733f013..bcb45c421c6 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go @@ -147,9 +147,10 @@ func TestJamf(t *testing.T) { for _, test := range jamfTests { t.Run(test.name, func(t *testing.T) { tenant, username, password, client, cleanup, err := test.context() - switch { - case err == nil: - case errors.Is(err, skipError("")): + //nolint:errorlint // false positive + switch err := err.(type) { + case nil: + case skipError: t.Skip(err) default: t.Fatalf("unexpected error getting env context: %v", err) From 9436142e6ef89844c3957ecb38c9148604f32285 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:45:07 +0200 Subject: [PATCH 20/26] lint: fix linter issues --- .../entityanalytics/provider/jamf/internal/jamf/jamf_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go index bcb45c421c6..47e6c27f6d3 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf/jamf_test.go @@ -7,7 +7,6 @@ package jamf import ( "context" "encoding/json" - "errors" "flag" "fmt" "net/http" From 055c2237e8a067c38185cdba91cb9593bcc5d223 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Wed, 17 Jul 2024 03:27:43 +0200 Subject: [PATCH 21/26] lint: run go mod tidy --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index 0f2090942d0..9c28f663495 100644 --- a/go.mod +++ b/go.mod @@ -291,7 +291,6 @@ require ( github.com/gobuffalo/here v0.6.7 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/godror/knownpb v0.1.0 // indirect - github.com/gofrs/uuid/v5 v5.2.0 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect From 56b0e58d28ff3f5b36505ef2984bf8671f2435b1 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Wed, 17 Jul 2024 04:10:36 +0200 Subject: [PATCH 22/26] lint: regenerate notice --- NOTICE.txt | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 72dd3d3936e..c67d5e703ee 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -39778,36 +39778,6 @@ Contents of probable licence file $GOMODCACHE/github.com/godror/knownpb@v0.1.0/L limitations under the License. --------------------------------------------------------------------------------- -Dependency : github.com/gofrs/uuid/v5 -Version: v5.2.0 -Licence type (autodetected): MIT --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/v5@v5.2.0/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/golang-jwt/jwt/v4 Version: v4.5.0 From cd282a6b5f3d83f18a77061b8df8eeda5004eb7b Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Mon, 22 Jul 2024 21:39:12 +0200 Subject: [PATCH 23/26] build: regenerate notice --- NOTICE.txt | 115 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 7a9b5470d89..878f5f83a3f 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,7 +1,7 @@ Elastic Beats Copyright 2014-2024 Elasticsearch BV -This product includes software developed by The Apache Software +This product includes software developed by The Apache Software Foundation (http://www.apache.org/). ================================================================================ @@ -11104,7 +11104,7 @@ Contents of probable licence file $GOMODCACHE/github.com/digitalocean/go-libvirt Apache License ============== -_Version 2.0, January 2004_ +_Version 2.0, January 2004_ _<>_ ### Terms and Conditions for use, reproduction, and distribution @@ -11283,13 +11283,13 @@ the same “printed page” as the copyright notice for easier identification wi third-party archives. Copyright [yyyy] [name of copyright owner] - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16664,7 +16664,7 @@ Mozilla Public License Version 2.0 means any form of the work other than Source Code Form. 1.7. "Larger Work" - means a work that combines Covered Software with other material, in + means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" @@ -25476,7 +25476,7 @@ Contents of probable licence file $GOMODCACHE/gopkg.in/natefinch/lumberjack.v2@v The MIT License (MIT) -Copyright (c) 2014 Nate Finch +Copyright (c) 2014 Nate Finch Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25930,13 +25930,13 @@ Contents of probable licence file $GOMODCACHE/howett.net/plist@v1.0.1/LICENSE: Copyright (c) 2013, Dustin L. Howett. All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. 2. 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. + and/or other materials provided with the distribution. 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 @@ -25950,7 +25950,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those -of the authors and should not be interpreted as representing official policies, +of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. -------------------------------------------------------------------------------- @@ -37833,7 +37833,7 @@ Contents of probable licence file $GOMODCACHE/github.com/evanphx/json-patch@v4.1 Copyright (c) 2014, Evan Phoenix All rights reserved. -Redistribution and use in source and binary forms, with or without +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 @@ -37841,19 +37841,19 @@ modification, are permitted provided that the following conditions are met: * 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 the Evan Phoenix nor the names of its contributors - may be used to endorse or promote products derived from this software +* Neither the name of the Evan Phoenix 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 +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. @@ -41981,6 +41981,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/googleapis/enterprise-certificate-proxy Version: v0.2.4 @@ -50020,22 +50057,22 @@ Contents of probable licence file $GOMODCACHE/github.com/smartystreets/assertion Copyright (c) 2016 SmartyStreets, LLC -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 +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 +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 +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. NOTE: Various optional and subordinate components carry their own licensing @@ -53382,19 +53419,19 @@ Licence type (autodetected): BSD-2-Clause Contents of probable licence file $GOMODCACHE/gopkg.in/check.v1@v1.0.0-20201130134442-10cb98267c6c/LICENSE: Gocheck - A rich testing framework for Go - + Copyright (c) 2010-2013 Gustavo Niemeyer All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. 2. 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. + and/or other materials provided with the distribution. 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 From 230244851caac703133cf76210bf4a5164646f58 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:59:56 +0200 Subject: [PATCH 24/26] build: regenerate notice --- NOTICE.txt | 78 +++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index c4164325ed9..c8ec2fc15d8 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,7 +1,7 @@ Elastic Beats Copyright 2014-2024 Elasticsearch BV -This product includes software developed by The Apache Software +This product includes software developed by The Apache Software Foundation (http://www.apache.org/). ================================================================================ @@ -11104,7 +11104,7 @@ Contents of probable licence file $GOMODCACHE/github.com/digitalocean/go-libvirt Apache License ============== -_Version 2.0, January 2004_ +_Version 2.0, January 2004_ _<>_ ### Terms and Conditions for use, reproduction, and distribution @@ -11283,13 +11283,13 @@ the same “printed page” as the copyright notice for easier identification wi third-party archives. Copyright [yyyy] [name of copyright owner] - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16664,7 +16664,7 @@ Mozilla Public License Version 2.0 means any form of the work other than Source Code Form. 1.7. "Larger Work" - means a work that combines Covered Software with other material, in + means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" @@ -25476,7 +25476,7 @@ Contents of probable licence file $GOMODCACHE/gopkg.in/natefinch/lumberjack.v2@v The MIT License (MIT) -Copyright (c) 2014 Nate Finch +Copyright (c) 2014 Nate Finch Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25930,13 +25930,13 @@ Contents of probable licence file $GOMODCACHE/howett.net/plist@v1.0.1/LICENSE: Copyright (c) 2013, Dustin L. Howett. All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. 2. 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. + and/or other materials provided with the distribution. 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 @@ -25950,7 +25950,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those -of the authors and should not be interpreted as representing official policies, +of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. -------------------------------------------------------------------------------- @@ -38277,7 +38277,7 @@ Contents of probable licence file $GOMODCACHE/github.com/evanphx/json-patch@v4.1 Copyright (c) 2014, Evan Phoenix All rights reserved. -Redistribution and use in source and binary forms, with or without +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 @@ -38285,19 +38285,19 @@ modification, are permitted provided that the following conditions are met: * 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 the Evan Phoenix nor the names of its contributors - may be used to endorse or promote products derived from this software +* Neither the name of the Evan Phoenix 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 +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. @@ -50501,22 +50501,22 @@ Contents of probable licence file $GOMODCACHE/github.com/smartystreets/assertion Copyright (c) 2016 SmartyStreets, LLC -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 +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 +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 +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. NOTE: Various optional and subordinate components carry their own licensing @@ -54102,19 +54102,19 @@ Licence type (autodetected): BSD-2-Clause Contents of probable licence file $GOMODCACHE/gopkg.in/check.v1@v1.0.0-20201130134442-10cb98267c6c/LICENSE: Gocheck - A rich testing framework for Go - + Copyright (c) 2010-2013 Gustavo Niemeyer All rights reserved. Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. 2. 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. + and/or other materials provided with the distribution. 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 From aa7452539c39c556e512e8515e1d05939a33158f Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 26 Jul 2024 17:02:11 +0200 Subject: [PATCH 25/26] refactor: cleanup double uuid conversion --- libbeat/cmd/instance/beat.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index 20e37d5048b..b38405a94fd 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -264,11 +264,6 @@ func NewBeat(name, indexPrefix, v string, elasticLicensed bool, initFuncs []func return nil, err } - eid, err := uuid.FromString(metricreport.EphemeralID().String()) - if err != nil { - return nil, fmt.Errorf("failed to generate EphemeralID from UUID string: %w", err) - } - b := beat.Beat{ Info: beat.Info{ Beat: name, @@ -280,7 +275,7 @@ func NewBeat(name, indexPrefix, v string, elasticLicensed bool, initFuncs []func ID: id, FirstStart: time.Now(), StartTime: time.Now(), - EphemeralID: eid, + EphemeralID: metricreport.EphemeralID(), }, Fields: fields, } From 4c5cf4c97051308cd56f937e39119f37cc22f428 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Thu, 1 Aug 2024 22:33:24 +0200 Subject: [PATCH 26/26] test: gracefully log the error --- .../autodiscover/providers/docker/docker_integration_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libbeat/autodiscover/providers/docker/docker_integration_test.go b/libbeat/autodiscover/providers/docker/docker_integration_test.go index c9986aad668..80106998fc6 100644 --- a/libbeat/autodiscover/providers/docker/docker_integration_test.go +++ b/libbeat/autodiscover/providers/docker/docker_integration_test.go @@ -75,7 +75,7 @@ func TestDockerStart(t *testing.T) { } defer func() { if err := d.ContainerRemove(ID); err != nil { - t.Error(err) + t.Log(err) } }() @@ -83,7 +83,7 @@ func TestDockerStart(t *testing.T) { // Kill if err := d.ContainerKill(ID); err != nil { - t.Error(err) + t.Log(err) } checkEvent(t, listener, ID, false) }