From f48170d781fe0c5717cf5337dfeca68c00cd00e9 Mon Sep 17 00:00:00 2001 From: Anderson Queiroz Date: Tue, 23 Jul 2024 18:23:49 +0200 Subject: [PATCH] comply with ECS for `host.name` Upgrades go-sysinfo to v1.14.1, which does not lower-case the FQDN. Therefore, `host.name` returned by `host.MapHostInfo` is lower-cased to comply with ECS. --- NOTICE.txt | 42 ++++++++++++++++++++++++++++----- go.mod | 2 ++ go.sum | 4 ++-- metric/system/host/host.go | 4 +++- metric/system/host/host_test.go | 6 ++--- 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 5e00c03ed5..f8407537fd 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -845,12 +845,12 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-structform@v -------------------------------------------------------------------------------- -Dependency : github.com/elastic/go-sysinfo -Version: v1.14.0 +Dependency : github.com/AndersonQ/go-sysinfo +Version: v0.0.0-20240723133639-576a5a94e18c Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.14.0/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/!anderson!q/go-sysinfo@v0.0.0-20240723133639-576a5a94e18c/LICENSE.txt: Apache License @@ -1480,12 +1480,12 @@ limitations under the License. -------------------------------------------------------------------------------- -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 @@ -3243,6 +3243,36 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- +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/gogo/protobuf Version: v1.3.2 diff --git a/go.mod b/go.mod index bac5904cda..c0f8d00dc8 100644 --- a/go.mod +++ b/go.mod @@ -64,3 +64,5 @@ require ( gotest.tools/v3 v3.5.1 // indirect howett.net/plist v1.0.1 // indirect ) + +replace github.com/elastic/go-sysinfo => github.com/AndersonQ/go-sysinfo v0.0.0-20240723133639-576a5a94e18c diff --git a/go.sum b/go.sum index e834057cd2..f4c2944e6b 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/AndersonQ/go-sysinfo v0.0.0-20240723133639-576a5a94e18c h1:JmYm9QiTPvea7Ya4NSVG0vUwZ9Q+qbfAW3mpkMgHB0E= +github.com/AndersonQ/go-sysinfo v0.0.0-20240723133639-576a5a94e18c/go.mod h1:FKUXnZWhnYI0ueO7jhsGV3uQJ5hiz8OqM5b3oGyaRr8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= @@ -23,8 +25,6 @@ github.com/elastic/go-licenser v0.4.2 h1:bPbGm8bUd8rxzSswFOqvQh1dAkKGkgAmrPxbUi+ github.com/elastic/go-licenser v0.4.2/go.mod h1:W8eH6FaZDR8fQGm+7FnVa7MxI1b/6dAqxz+zPB8nm5c= github.com/elastic/go-structform v0.0.9 h1:HpcS7xljL4kSyUfDJ8cXTJC6rU5ChL1wYb6cx3HLD+o= github.com/elastic/go-structform v0.0.9/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= -github.com/elastic/go-sysinfo v1.14.0 h1:dQRtiqLycoOOla7IflZg3aN213vqJmP0lpVpKQ9lUEY= -github.com/elastic/go-sysinfo v1.14.0/go.mod h1:FKUXnZWhnYI0ueO7jhsGV3uQJ5hiz8OqM5b3oGyaRr8= github.com/elastic/go-ucfg v0.8.8 h1:54KIF/2zFKfl0MzsSOCGOsZ3O2bnjFQJ0nDJcLhviyk= github.com/elastic/go-ucfg v0.8.8/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA= github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0= diff --git a/metric/system/host/host.go b/metric/system/host/host.go index 730556e8d7..a547fcfc07 100644 --- a/metric/system/host/host.go +++ b/metric/system/host/host.go @@ -18,6 +18,8 @@ package host import ( + "strings" + "github.com/elastic/elastic-agent-libs/mapstr" "github.com/elastic/elastic-agent-libs/monitoring" "github.com/elastic/go-sysinfo" @@ -33,7 +35,7 @@ func MapHostInfo(info types.HostInfo, fqdn string) mapstr.M { data := mapstr.M{ "host": mapstr.M{ - "name": name, + "name": strings.ToLower(name), "hostname": info.Hostname, "architecture": info.Architecture, "os": mapstr.M{ diff --git a/metric/system/host/host_test.go b/metric/system/host/host_test.go index 03a56e0f49..f573d30f77 100644 --- a/metric/system/host/host_test.go +++ b/metric/system/host/host_test.go @@ -46,7 +46,7 @@ func TestMapHostInfo(t *testing.T) { Architecture: "x86_64", BootTime: bootTime, Containerized: &containerized, - Hostname: "foo", + Hostname: "fOo", IPs: []string{"1.2.3.4", "192.168.1.1"}, KernelVersion: "22.3.0", MACs: []string{"56:9c:17:54:19:15", "5c:e9:1e:c4:37:66"}, @@ -66,7 +66,7 @@ func TestMapHostInfo(t *testing.T) { "host": mapstr.M{ "architecture": "x86_64", "containerized": true, - "hostname": "foo", + "hostname": "fOo", "id": "a39b4c1ee4", "name": "foo.bar.local", "os": mapstr.M{ @@ -87,7 +87,7 @@ func TestMapHostInfo(t *testing.T) { "host": mapstr.M{ "architecture": "x86_64", "containerized": true, - "hostname": "foo", + "hostname": "fOo", "id": "a39b4c1ee4", "name": "foo", "os": mapstr.M{