From 251f66ebb86f715c74f1d436c1f7cfc31538f3bd Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Thu, 28 Mar 2019 12:04:58 -0400 Subject: [PATCH 1/3] Update github.com/elastic/go-sysinfo (#11494) Fixes #11490 Fixes #9134 (cherry picked from commit e044c9ca5545c065c741aeb3e0f34ff5a9a1bf90) --- CHANGELOG.next.asciidoc | 1 + NOTICE.txt | 2 +- .../go-sysinfo/providers/linux/container.go | 5 +++ .../go-sysinfo/providers/linux/machineid.go | 32 +++++++++++++++++-- .../elastic/go-sysinfo/providers/linux/os.go | 5 +-- vendor/vendor.json | 30 ++++++++--------- 6 files changed, 54 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 92fa021b00c..150e54891d3 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -35,6 +35,7 @@ https://github.com/elastic/beats/compare/v6.7.0...6.x[Check the HEAD diff] - Relax validation of the X-Pack license UID value. {issue}11640[11640] - Fix a parsing error with the X-Pack license check on 32-bit system. {issue}11650[11650] +- Fixed OS family classification in `add_host_metadata` for Amazon Linux, Raspbian, and RedHat Linux. {issue}9134[9134] {pull}11494[11494] *Auditbeat* diff --git a/NOTICE.txt b/NOTICE.txt index 2f67472b252..4e485ba13b2 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -541,7 +541,7 @@ Apache License 2.0 -------------------------------------------------------------------- Dependency: github.com/elastic/go-sysinfo -Revision: 59ef8c0eae46c0929e3b219ac86368d4b5934f91 +Revision: ab4f04edfc3d6b3864f5f06a068ddab9ad79774f License type (autodetected): Apache-2.0 ./vendor/github.com/elastic/go-sysinfo/LICENSE.txt: -------------------------------------------------------------------- diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go index 45a8e9b6f36..cfacf013d12 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go @@ -21,6 +21,7 @@ import ( "bufio" "bytes" "io/ioutil" + "os" "github.com/pkg/errors" ) @@ -31,6 +32,10 @@ const procOneCgroup = "/proc/1/cgroup" func IsContainerized() (bool, error) { data, err := ioutil.ReadFile(procOneCgroup) if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, errors.Wrap(err, "failed to read process cgroups") } diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go index b5ff0538564..a84d085c9ea 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go @@ -27,11 +27,37 @@ import ( "github.com/elastic/go-sysinfo/types" ) +var ( + // Possible (current and historic) locations of the machine-id file. + // These will be searched in order. + machineIDFiles = []string{"/etc/machine-id", "/var/lib/dbus/machine-id", "/var/db/dbus/machine-id"} +) + func MachineID() (string, error) { - id, err := ioutil.ReadFile("/etc/machine-id") + var contents []byte + var err error + + for _, file := range machineIDFiles { + contents, err = ioutil.ReadFile(file) + if err != nil { + if os.IsNotExist(err) { + // Try next location + continue + } + + // Return with error on any other error + return "", errors.Wrapf(err, "failed to read %v", file) + } + + // Found it + break + } + if os.IsNotExist(err) { + // None of the locations existed return "", types.ErrNotImplemented } - id = bytes.TrimSpace(id) - return string(id), errors.Wrap(err, "failed to read machine-id") + + contents = bytes.TrimSpace(contents) + return string(contents), nil } diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go index a54c1d3258a..d4daedd506f 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go @@ -47,9 +47,10 @@ var ( versionRegexp = regexp.MustCompile(versionGrok) ) +// familyMap contains a mapping of family -> []platforms. var familyMap = map[string][]string{ - "redhat": {"redhat", "fedora", "centos", "scientific", "oraclelinux", "amazon"}, - "debian": {"debian", "ubuntu"}, + "redhat": {"redhat", "fedora", "centos", "scientific", "oraclelinux", "amzn", "rhel"}, + "debian": {"debian", "ubuntu", "raspbian"}, "suse": {"suse", "sles", "opensuse"}, } diff --git a/vendor/vendor.json b/vendor/vendor.json index 9dae402be3d..7632873fa9c 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -880,44 +880,44 @@ { "checksumSHA1": "QhFIpuHPaV6hKejKcc2wm6y4MSQ=", "path": "github.com/elastic/go-sysinfo", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "GiZCjX17K265TtamGZZw4R2Jwbk=", "path": "github.com/elastic/go-sysinfo/internal/registry", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "ovafihHzpBx9Y7+lZh9X5KwNCvE=", "path": "github.com/elastic/go-sysinfo/providers/darwin", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { - "checksumSHA1": "AK76ZxnuvK02Dfpmj7b2TD/aiSI=", + "checksumSHA1": "OyI+VwDiT4UZjncsDr1GYg1xcdw=", "path": "github.com/elastic/go-sysinfo/providers/linux", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "RWLvcP1w9ynKbuCqiW6prwd+EDU=", "path": "github.com/elastic/go-sysinfo/providers/shared", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "aF05MEkMjbRekzHlwFxmd5WBpeY=", "path": "github.com/elastic/go-sysinfo/providers/windows", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "MLQioPEjULYbNqqCjfB1/cux08E=", "path": "github.com/elastic/go-sysinfo/types", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "bNf3GDGhZh86bfCIMM5c5AYfo3g=", From 2564040ec1d2643b32379175e6ade8af0eeef22c Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Tue, 9 Apr 2019 17:56:07 -0400 Subject: [PATCH 2/3] Add to the release notes --- CHANGELOG.next.asciidoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 150e54891d3..3886ee83cbf 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -35,7 +35,9 @@ https://github.com/elastic/beats/compare/v6.7.0...6.x[Check the HEAD diff] - Relax validation of the X-Pack license UID value. {issue}11640[11640] - Fix a parsing error with the X-Pack license check on 32-bit system. {issue}11650[11650] -- Fixed OS family classification in `add_host_metadata` for Amazon Linux, Raspbian, and RedHat Linux. {issue}9134[9134] {pull}11494[11494] +- Fix OS family classification in `add_host_metadata` for Amazon Linux, Raspbian, and RedHat Linux. {issue}9134[9134] {pull}11494[11494] +- Fix false positives reported in the `host.containerized` field by `add_host_metadata`. {pull}11494[11494] +- Fix the add_host_metadata's `host.id` field on older Linux versions. {pull}11494[11494] *Auditbeat* From 57cbea76a5661939f0108b9cb5af2a31d811ea76 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Tue, 9 Apr 2019 17:58:08 -0400 Subject: [PATCH 3/3] Update CHANGELOG.next.asciidoc --- CHANGELOG.next.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 3886ee83cbf..b280be4ec15 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -36,7 +36,7 @@ https://github.com/elastic/beats/compare/v6.7.0...6.x[Check the HEAD diff] - Relax validation of the X-Pack license UID value. {issue}11640[11640] - Fix a parsing error with the X-Pack license check on 32-bit system. {issue}11650[11650] - Fix OS family classification in `add_host_metadata` for Amazon Linux, Raspbian, and RedHat Linux. {issue}9134[9134] {pull}11494[11494] -- Fix false positives reported in the `host.containerized` field by `add_host_metadata`. {pull}11494[11494] +- Fix false positives reported in the `host.containerized` field added by `add_host_metadata`. {pull}11494[11494] - Fix the add_host_metadata's `host.id` field on older Linux versions. {pull}11494[11494] *Auditbeat*