From f5be71bf4534d493b2047b0f38f6958acc93a9cf Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 3 May 2024 12:28:35 -0700 Subject: [PATCH 01/16] add logic for user-agent header --- libbeat/esleg/eslegclient/connection.go | 4 ++++ libbeat/esleg/eslegclient/connection_test.go | 25 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/libbeat/esleg/eslegclient/connection.go b/libbeat/esleg/eslegclient/connection.go index 953e68439935..c109b751068d 100644 --- a/libbeat/esleg/eslegclient/connection.go +++ b/libbeat/esleg/eslegclient/connection.go @@ -30,6 +30,7 @@ import ( "go.elastic.co/apm/module/apmelasticsearch/v2" "github.com/elastic/beats/v7/libbeat/common" + "github.com/elastic/beats/v7/libbeat/common/fleetmode" "github.com/elastic/beats/v7/libbeat/common/productorigin" "github.com/elastic/beats/v7/libbeat/common/transport/kerberos" "github.com/elastic/beats/v7/libbeat/version" @@ -135,6 +136,9 @@ func NewConnection(s ConnectionSettings) (*Connection, error) { if s.Beatname == "" { s.Beatname = "Libbeat" } + if fleetmode.Enabled() { + s.Beatname = fmt.Sprintf("%s-Managed", s.Beatname) + } userAgent := useragent.UserAgent(s.Beatname, version.GetDefaultVersion(), version.Commit(), version.BuildTime().String()) // Default the product origin header to beats if it wasn't already set. diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index de9e134414a8..b1cbb1d0299a 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -22,12 +22,14 @@ import ( "bytes" "context" "encoding/base64" + "flag" "net/http" "testing" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/libbeat/common/productorigin" + cfglib "github.com/elastic/elastic-agent-libs/config" ) func TestAPIKeyEncoding(t *testing.T) { @@ -104,9 +106,32 @@ func TestHeaders(t *testing.T) { require.NoError(t, err) require.Equal(t, req.Header, http.Header(td.expected)) + } } +func TestUserAgentHeader(t *testing.T) { + // manually set cli to put beats into agent mode + _ = cfglib.SettingFlag(nil, "E", "Configuration overwrite") + flag.Set("E", "management.enabled=true") + flag.Parse() + + conn, err := NewConnection(ConnectionSettings{ + Beatname: "testbeat", + }) + require.NoError(t, err) + + req, err := http.NewRequestWithContext(context.Background(), "GET", "http://localhost/some/path", nil) + require.NoError(t, err) + + rawClient, ok := conn.HTTP.(*http.Client) + require.True(t, ok) + + _, _ = rawClient.Transport.RoundTrip(req) + require.Contains(t, req.Header.Get("User-Agent"), "Elastic-testbeat-Managed") + +} + func BenchmarkExecHTTPRequest(b *testing.B) { for _, td := range []struct { input map[string]string From e1792fc24866fa9c86daddd4a0e602caf9afc27b Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 3 May 2024 12:56:21 -0700 Subject: [PATCH 02/16] change UA name --- libbeat/esleg/eslegclient/connection.go | 2 +- libbeat/esleg/eslegclient/connection_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libbeat/esleg/eslegclient/connection.go b/libbeat/esleg/eslegclient/connection.go index c109b751068d..8172a8511a57 100644 --- a/libbeat/esleg/eslegclient/connection.go +++ b/libbeat/esleg/eslegclient/connection.go @@ -137,7 +137,7 @@ func NewConnection(s ConnectionSettings) (*Connection, error) { s.Beatname = "Libbeat" } if fleetmode.Enabled() { - s.Beatname = fmt.Sprintf("%s-Managed", s.Beatname) + s.Beatname = fmt.Sprintf("%s-Agent", s.Beatname) } userAgent := useragent.UserAgent(s.Beatname, version.GetDefaultVersion(), version.Commit(), version.BuildTime().String()) diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index b1cbb1d0299a..ea95a7edf849 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -113,7 +113,7 @@ func TestHeaders(t *testing.T) { func TestUserAgentHeader(t *testing.T) { // manually set cli to put beats into agent mode _ = cfglib.SettingFlag(nil, "E", "Configuration overwrite") - flag.Set("E", "management.enabled=true") + _ = flag.Set("E", "management.enabled=true") flag.Parse() conn, err := NewConnection(ConnectionSettings{ @@ -128,7 +128,7 @@ func TestUserAgentHeader(t *testing.T) { require.True(t, ok) _, _ = rawClient.Transport.RoundTrip(req) - require.Contains(t, req.Header.Get("User-Agent"), "Elastic-testbeat-Managed") + require.Contains(t, req.Header.Get("User-Agent"), "Elastic-testbeat-Agent") } From e47035bc0b466a007d9333aad20fe132f48120e7 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 3 May 2024 13:09:45 -0700 Subject: [PATCH 03/16] fix linter --- libbeat/esleg/eslegclient/connection_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index ea95a7edf849..2b92bcd7998f 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -127,7 +127,9 @@ func TestUserAgentHeader(t *testing.T) { rawClient, ok := conn.HTTP.(*http.Client) require.True(t, ok) - _, _ = rawClient.Transport.RoundTrip(req) + // don't want to check the error, since the URL doesn't exist, so we'll always return an error. + resp, _ := rawClient.Transport.RoundTrip(req) + resp.Body.Close() require.Contains(t, req.Header.Get("User-Agent"), "Elastic-testbeat-Agent") } From 36402f908f877756d22907d140e0d904f2a4f627 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 3 May 2024 14:03:05 -0700 Subject: [PATCH 04/16] fix tests --- libbeat/esleg/eslegclient/connection_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index 2b92bcd7998f..e6985353f756 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -129,7 +129,12 @@ func TestUserAgentHeader(t *testing.T) { // don't want to check the error, since the URL doesn't exist, so we'll always return an error. resp, _ := rawClient.Transport.RoundTrip(req) - resp.Body.Close() + // just to make linter happy, there's no body + if resp.Body != nil { + resp.Body.Close() + } + + // the `RoundTrip` will set the header in our request require.Contains(t, req.Header.Get("User-Agent"), "Elastic-testbeat-Agent") } From 03505d8fcc13dc4bbb219c899232fa88bf22fdef Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 3 May 2024 14:35:36 -0700 Subject: [PATCH 05/16] linter... --- metricbeat/module/windows/perfmon/data.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/metricbeat/module/windows/perfmon/data.go b/metricbeat/module/windows/perfmon/data.go index 9add5c03896a..84069dc77b6f 100644 --- a/metricbeat/module/windows/perfmon/data.go +++ b/metricbeat/module/windows/perfmon/data.go @@ -20,6 +20,7 @@ package perfmon import ( + "errors" "fmt" "regexp" "strconv" @@ -48,7 +49,7 @@ func (re *Reader) groupToEvents(counters map[string][]pdh.CounterValue) []mb.Eve // The counter has a negative value or the counter was successfully found, but the data returned is not valid. // This error can occur if the counter value is less than the previous value. (Because counter values always increment, the counter value rolls over to zero when it reaches its maximum value.) // This is not an error that stops the application from running successfully and a positive counter value should be retrieved in the later calls. - if val.Err.Error == pdh.PDH_CALC_NEGATIVE_VALUE || val.Err.Error == pdh.PDH_INVALID_DATA { + if errors.Is(val.Err.Error, pdh.PDH_CALC_NEGATIVE_VALUE) || errors.Is(val.Err.Error, pdh.PDH_INVALID_DATA) { re.log.Debugw("Counter value retrieval returned", "error", val.Err.Error, "cstatus", pdh.PdhErrno(val.Err.CStatus), logp.Namespace("perfmon"), "query", counterPath) continue @@ -93,9 +94,11 @@ func (re *Reader) groupToEvents(counters map[string][]pdh.CounterValue) []mb.Eve } } // Write the values into the map. - var events []mb.Event + events := make([]mb.Event, len(eventMap)) + iter := 0 for _, val := range eventMap { - events = append(events, *val) + events[iter] = *val + iter++ } return events } @@ -111,7 +114,7 @@ func (re *Reader) groupToSingleEvent(counters map[string][]pdh.CounterValue) mb. // Some counters, such as rate counters, require two counter values in order to compute a displayable value. In this case we must call PdhCollectQueryData twice before calling PdhGetFormattedCounterValue. // For more information, see Collecting Performance Data (https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/collecting-performance-data). if val.Err.Error != nil { - if val.Err.Error == pdh.PDH_CALC_NEGATIVE_VALUE || val.Err.Error == pdh.PDH_INVALID_DATA { + if errors.Is(val.Err.Error, pdh.PDH_CALC_NEGATIVE_VALUE) || errors.Is(val.Err.Error, pdh.PDH_INVALID_DATA) { re.log.Debugw("Counter value retrieval returned", "error", val.Err.Error, "cstatus", pdh.PdhErrno(val.Err.CStatus), logp.Namespace("perfmon"), "query", counterPath) continue From 61aa9221b3094281c1bc29c599e65b2a18e16200 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 3 May 2024 14:36:15 -0700 Subject: [PATCH 06/16] Revert "linter..." This reverts commit 03505d8fcc13dc4bbb219c899232fa88bf22fdef. --- metricbeat/module/windows/perfmon/data.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/metricbeat/module/windows/perfmon/data.go b/metricbeat/module/windows/perfmon/data.go index 84069dc77b6f..9add5c03896a 100644 --- a/metricbeat/module/windows/perfmon/data.go +++ b/metricbeat/module/windows/perfmon/data.go @@ -20,7 +20,6 @@ package perfmon import ( - "errors" "fmt" "regexp" "strconv" @@ -49,7 +48,7 @@ func (re *Reader) groupToEvents(counters map[string][]pdh.CounterValue) []mb.Eve // The counter has a negative value or the counter was successfully found, but the data returned is not valid. // This error can occur if the counter value is less than the previous value. (Because counter values always increment, the counter value rolls over to zero when it reaches its maximum value.) // This is not an error that stops the application from running successfully and a positive counter value should be retrieved in the later calls. - if errors.Is(val.Err.Error, pdh.PDH_CALC_NEGATIVE_VALUE) || errors.Is(val.Err.Error, pdh.PDH_INVALID_DATA) { + if val.Err.Error == pdh.PDH_CALC_NEGATIVE_VALUE || val.Err.Error == pdh.PDH_INVALID_DATA { re.log.Debugw("Counter value retrieval returned", "error", val.Err.Error, "cstatus", pdh.PdhErrno(val.Err.CStatus), logp.Namespace("perfmon"), "query", counterPath) continue @@ -94,11 +93,9 @@ func (re *Reader) groupToEvents(counters map[string][]pdh.CounterValue) []mb.Eve } } // Write the values into the map. - events := make([]mb.Event, len(eventMap)) - iter := 0 + var events []mb.Event for _, val := range eventMap { - events[iter] = *val - iter++ + events = append(events, *val) } return events } @@ -114,7 +111,7 @@ func (re *Reader) groupToSingleEvent(counters map[string][]pdh.CounterValue) mb. // Some counters, such as rate counters, require two counter values in order to compute a displayable value. In this case we must call PdhCollectQueryData twice before calling PdhGetFormattedCounterValue. // For more information, see Collecting Performance Data (https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/collecting-performance-data). if val.Err.Error != nil { - if errors.Is(val.Err.Error, pdh.PDH_CALC_NEGATIVE_VALUE) || errors.Is(val.Err.Error, pdh.PDH_INVALID_DATA) { + if val.Err.Error == pdh.PDH_CALC_NEGATIVE_VALUE || val.Err.Error == pdh.PDH_INVALID_DATA { re.log.Debugw("Counter value retrieval returned", "error", val.Err.Error, "cstatus", pdh.PdhErrno(val.Err.CStatus), logp.Namespace("perfmon"), "query", counterPath) continue From 04a6b66cff342d6f7811853e472ee2fde2110b9f Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 3 May 2024 14:59:37 -0700 Subject: [PATCH 07/16] oops --- libbeat/esleg/eslegclient/connection_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index e6985353f756..ed1424fd2b48 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -130,7 +130,7 @@ func TestUserAgentHeader(t *testing.T) { // don't want to check the error, since the URL doesn't exist, so we'll always return an error. resp, _ := rawClient.Transport.RoundTrip(req) // just to make linter happy, there's no body - if resp.Body != nil { + if resp != nil { resp.Body.Close() } From b1fc5ec2e621b4c35ecce34451cfb04f8315522f Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 7 Jun 2024 08:54:29 -0700 Subject: [PATCH 08/16] major update for new features --- NOTICE.txt | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- libbeat/beat/info.go | 23 ++++++++++--------- libbeat/cmd/instance/beat.go | 14 +++++++++++ libbeat/esleg/eslegclient/connection.go | 11 ++++++--- libbeat/esleg/eslegclient/connection_test.go | 10 ++------ .../outputs/elasticsearch/elasticsearch.go | 1 + 8 files changed, 42 insertions(+), 27 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 951b7e7785c1..291b3145a20a 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.8.1 +Version: v7.11.0 Licence type (autodetected): Elastic -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-client/v7@v7.8.1/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-client/v7@v7.11.0/LICENSE.txt: ELASTIC LICENSE AGREEMENT diff --git a/go.mod b/go.mod index ad13afabd8da..a75ca6c5b860 100644 --- a/go.mod +++ b/go.mod @@ -69,7 +69,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.8.1 + github.com/elastic/elastic-agent-client/v7 v7.11.0 github.com/elastic/go-concert v0.2.0 github.com/elastic/go-libaudit/v2 v2.5.0 github.com/elastic/go-licenser v0.4.1 diff --git a/go.sum b/go.sum index 5c45bdee7488..54cccc251cd5 100644 --- a/go.sum +++ b/go.sum @@ -553,8 +553,8 @@ 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.6.14 h1:0zJYNyv9GKTOiNqCHqEVboP+WioV73ia17Et+UlFbz8= github.com/elastic/elastic-agent-autodiscover v0.6.14/go.mod h1:39/fHHlnyTK6oUNZfAhxJwBTVahO9tNasEIjzsxGMu8= -github.com/elastic/elastic-agent-client/v7 v7.8.1 h1:J9wZc/0mUvSEok0X5iR5+n60Jgb+AWooKddb3XgPWqM= -github.com/elastic/elastic-agent-client/v7 v7.8.1/go.mod h1:axl1nkdqc84YRFkeJGD9jExKNPUrOrzf3DFo2m653nY= +github.com/elastic/elastic-agent-client/v7 v7.11.0 h1:YpkFQyE3qPnVai2a2NiKTMpBXXmPcHRV86AtW7LdpA8= +github.com/elastic/elastic-agent-client/v7 v7.11.0/go.mod h1:/AeiwX9zxG99eUNrLhpApTpwmE71Qwuh4ozObn7a0ss= github.com/elastic/elastic-agent-libs v0.7.5 h1:4UMqB3BREvhwecYTs/L23oQp1hs/XUkcunPlmTZn5yg= github.com/elastic/elastic-agent-libs v0.7.5/go.mod h1:pGMj5myawdqu+xE+WKvM5FQzKQ/MonikkWOzoFTJxaU= github.com/elastic/elastic-agent-shipper-client v0.5.1-0.20230228231646-f04347b666f3 h1:sb+25XJn/JcC9/VL8HX4r4QXSUq4uTNzGS2kxOE7u1U= diff --git a/libbeat/beat/info.go b/libbeat/beat/info.go index e1068d17ff5e..32ec35fe44d6 100644 --- a/libbeat/beat/info.go +++ b/libbeat/beat/info.go @@ -25,17 +25,18 @@ import ( // Info stores a beats instance meta data. type Info struct { - Beat string // The actual beat's name - IndexPrefix string // The beat's index prefix in Elasticsearch. - Version string // The beat version. Defaults to the libbeat version when an implementation does not set a version - ElasticLicensed bool // Whether the beat is licensed under and Elastic License - Name string // configured beat name - Hostname string // hostname - FQDN string // FQDN - ID uuid.UUID // ID assigned to beat machine - EphemeralID uuid.UUID // ID assigned to beat process invocation (PID) - FirstStart time.Time // The time of the first start of the Beat. - StartTime time.Time // The time of last start of the Beat. Updated when the Beat is started or restarted. + Beat string // The actual beat's name + IndexPrefix string // The beat's index prefix in Elasticsearch. + Version string // The beat version. Defaults to the libbeat version when an implementation does not set a version + ElasticLicensed bool // Whether the beat is licensed under and Elastic License + Name string // configured beat name + Hostname string // hostname + FQDN string // FQDN + ID uuid.UUID // ID assigned to beat machine + EphemeralID uuid.UUID // ID assigned to beat process invocation (PID) + FirstStart time.Time // The time of the first start of the Beat. + StartTime time.Time // The time of last start of the Beat. Updated when the Beat is started or restarted. + UserAgentPostfix string // A string postfix that's postfixed to the existing user-agent string used by the elasticsearch output // Monitoring-related fields Monitoring struct { diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index 8fa3678e0427..6762c29fc9c3 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -68,6 +68,7 @@ import ( "github.com/elastic/beats/v7/libbeat/publisher/processing" "github.com/elastic/beats/v7/libbeat/publisher/queue/diskqueue" "github.com/elastic/beats/v7/libbeat/version" + "github.com/elastic/elastic-agent-client/v7/pkg/proto" "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/file" "github.com/elastic/elastic-agent-libs/filewatcher" @@ -863,6 +864,19 @@ func (b *Beat) configure(settings Settings) error { version.SetPackageVersion(b.Info.Version) } + // if we're in fleet mode, construct a custom user-agent + if fleetmode.Enabled() { + userAgent := "" + info := b.Manager.AgentInfo() + if info.ManagedMode == proto.AgentManagedMode_MANAGED { + userAgent = "Agent-Managed" + } else if info.ManagedMode == proto.AgentManagedMode_STANDALONE { + userAgent = "Agent-Standalone" + } + b.Info.UserAgentPostfix = userAgent + } + logp.L().Infof("got user agent in beat: %s", b.Info.UserAgentPostfix) + if err := b.Manager.CheckRawConfig(b.RawConfig); err != nil { return err } diff --git a/libbeat/esleg/eslegclient/connection.go b/libbeat/esleg/eslegclient/connection.go index 8172a8511a57..24335f0ba5aa 100644 --- a/libbeat/esleg/eslegclient/connection.go +++ b/libbeat/esleg/eslegclient/connection.go @@ -30,7 +30,6 @@ import ( "go.elastic.co/apm/module/apmelasticsearch/v2" "github.com/elastic/beats/v7/libbeat/common" - "github.com/elastic/beats/v7/libbeat/common/fleetmode" "github.com/elastic/beats/v7/libbeat/common/productorigin" "github.com/elastic/beats/v7/libbeat/common/transport/kerberos" "github.com/elastic/beats/v7/libbeat/version" @@ -87,6 +86,11 @@ type ConnectionSettings struct { IdleConnTimeout time.Duration Transport httpcommon.HTTPTransportSettings + + // UserAgentPostfix can be used to report the agent running mode + // to ES via the User Agent string. If running under Agent (fleetmode.Enabled() == true) + // then this string will be appended to the user agent. + UserAgentPostfix string } type ESPingData struct { @@ -136,9 +140,10 @@ func NewConnection(s ConnectionSettings) (*Connection, error) { if s.Beatname == "" { s.Beatname = "Libbeat" } - if fleetmode.Enabled() { - s.Beatname = fmt.Sprintf("%s-Agent", s.Beatname) + if s.UserAgentPostfix != "" { + s.Beatname = fmt.Sprintf("%s-%s", s.Beatname, s.UserAgentPostfix) } + userAgent := useragent.UserAgent(s.Beatname, version.GetDefaultVersion(), version.Commit(), version.BuildTime().String()) // Default the product origin header to beats if it wasn't already set. diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index ed1424fd2b48..a46cc253719a 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -22,14 +22,12 @@ import ( "bytes" "context" "encoding/base64" - "flag" "net/http" "testing" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/libbeat/common/productorigin" - cfglib "github.com/elastic/elastic-agent-libs/config" ) func TestAPIKeyEncoding(t *testing.T) { @@ -111,13 +109,9 @@ func TestHeaders(t *testing.T) { } func TestUserAgentHeader(t *testing.T) { - // manually set cli to put beats into agent mode - _ = cfglib.SettingFlag(nil, "E", "Configuration overwrite") - _ = flag.Set("E", "management.enabled=true") - flag.Parse() - conn, err := NewConnection(ConnectionSettings{ - Beatname: "testbeat", + Beatname: "testbeat", + UserAgentPostfix: "Agent", }) require.NoError(t, err) diff --git a/libbeat/outputs/elasticsearch/elasticsearch.go b/libbeat/outputs/elasticsearch/elasticsearch.go index 9bc8498afe45..37d9222d4fc2 100644 --- a/libbeat/outputs/elasticsearch/elasticsearch.go +++ b/libbeat/outputs/elasticsearch/elasticsearch.go @@ -121,6 +121,7 @@ func makeES( EscapeHTML: esConfig.EscapeHTML, Transport: esConfig.Transport, IdleConnTimeout: esConfig.Transport.IdleConnTimeout, + UserAgentPostfix: beatInfo.UserAgentPostfix, }, indexSelector: indexSelector, pipelineSelector: pipelineSelector, From 100213d7e7d48528b1fda492f898b624a5a2d046 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Tue, 11 Jun 2024 08:17:18 -0700 Subject: [PATCH 09/16] fix tests --- NOTICE.txt | 57 +++++++++++++++++++- go.mod | 8 +-- go.sum | 7 ++- libbeat/esleg/eslegclient/connection_test.go | 34 ++++++++---- 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index c57628fc7303..d4e195cfc7cf 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -15964,6 +15964,29 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/mito@v1.12.2/LI limitations under the License. +-------------------------------------------------------------------------------- +Dependency : github.com/elastic/mock-es +Version: v0.0.0-20240610195132-8fc87dc3f130 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/elastic/mock-es@v0.0.0-20240610195132-8fc87dc3f130/LICENSE: + +Copyright 2024 Elasticsearch B.V. + +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. +See the License for the specific language governing permissions and +limitations under the License. + + -------------------------------------------------------------------------------- Dependency : github.com/elastic/tk-btf Version: v0.1.0 @@ -18527,11 +18550,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- Dependency : github.com/google/uuid -Version: v1.3.1 +Version: v1.6.0 Licence type (autodetected): BSD-3-Clause -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/google/uuid@v1.3.1/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/google/uuid@v1.6.0/LICENSE: Copyright (c) 2009,2014 Google Inc. All rights reserved. @@ -48277,6 +48300,36 @@ Contents of probable licence file $GOMODCACHE/github.com/matttproud/golang_proto limitations under the License. +-------------------------------------------------------------------------------- +Dependency : github.com/mileusna/useragent +Version: v1.3.4 +Licence type (autodetected): MIT +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/mileusna/useragent@v1.3.4/LICENSE.md: + +MIT License + +Copyright (c) 2017 Miloš Mileusnić + +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/minio/asm2plan9s Version: v0.0.0-20200509001527-cdd76441f9d8 diff --git a/go.mod b/go.mod index f0dcbbfb6924..93d489c8faa1 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/elastic/beats/v7 -go 1.21.0 +go 1.21.9 -toolchain go1.21.10 +toolchain go1.22.3 require ( cloud.google.com/go/bigquery v1.55.0 @@ -102,7 +102,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.3.1 + github.com/google/uuid v1.6.0 github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 github.com/h2non/filetype v1.1.1 github.com/hashicorp/go-multierror v1.1.1 @@ -210,6 +210,7 @@ require ( github.com/elastic/elastic-agent-system-metrics v0.10.2 github.com/elastic/go-elasticsearch/v8 v8.13.1 github.com/elastic/mito v1.12.2 + github.com/elastic/mock-es v0.0.0-20240610195132-8fc87dc3f130 github.com/elastic/tk-btf v0.1.0 github.com/elastic/toutoumomoma v0.0.0-20221026030040-594ef30cb640 github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15 @@ -351,6 +352,7 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/mileusna/useragent v1.3.4 // indirect github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect diff --git a/go.sum b/go.sum index c56eee10e5ea..9923f84b13ff 100644 --- a/go.sum +++ b/go.sum @@ -594,6 +594,8 @@ github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/u github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/elastic/mito v1.12.2 h1:DQCYWg4U7rwNP45Ed2cHtAY94HEK1rfVUbNUT/8cYXk= github.com/elastic/mito v1.12.2/go.mod h1:J+wCf4HccW2YoSFmZMGu+d06gN+WmnIlj5ehBqine74= +github.com/elastic/mock-es v0.0.0-20240610195132-8fc87dc3f130 h1:MSTfdpBTKMrrXUg0ucjFFQAgqxWa5kOkYvikqvlmUYM= +github.com/elastic/mock-es v0.0.0-20240610195132-8fc87dc3f130/go.mod h1:mVdKBYYwt30xRFjCegbcURHh+3LWOCkQM33fgWbUiRI= github.com/elastic/pkcs8 v1.0.0 h1:HhitlUKxhN288kcNcYkjW6/ouvuwJWd9ioxpjnD9jVA= github.com/elastic/pkcs8 v1.0.0/go.mod h1:ipsZToJfq1MxclVTwpG7U/bgeDtf+0HkUiOxebk95+0= github.com/elastic/ristretto v0.1.1-0.20220602190459-83b0895ca5b3 h1:ChPwRVv1RR4a0cxoGjKcyWjTEpxYfm5gydMIzo32cAw= @@ -992,8 +994,9 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.2.4 h1:uGy6JWR/uMIILU8wbf+OkstIrNiMjGpEIyhx8f6W7s4= github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -1310,6 +1313,8 @@ github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7 github.com/miekg/dns v1.1.42 h1:gWGe42RGaIqXQZ+r3WUGEKBEtvPHY2SXo4dqixDNxuY= github.com/miekg/dns v1.1.42/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/mileusna/useragent v0.0.0-20190129205925-3e331f0949a5/go.mod h1:JWhYAp2EXqUtsxTKdeGlY8Wp44M7VxThC9FEoNGi2IE= +github.com/mileusna/useragent v1.3.4 h1:MiuRRuvGjEie1+yZHO88UBYg8YBC/ddF6T7F56i3PCk= +github.com/mileusna/useragent v1.3.4/go.mod h1:3d8TOmwL/5I8pJjyVDteHtgDGcefrFUX4ccGOMKNYYc= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 h1:AMFGa4R4MiIpspGNG7Z948v4n35fFGB3RR3G/ry4FWs= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 h1:+n/aFZefKZp7spd8DFdX7uMikMLXX4oubIzJF4kv/wI= diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index a46cc253719a..5677f0910b1a 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -23,11 +23,17 @@ import ( "context" "encoding/base64" "net/http" + "net/http/httptest" + "strings" "testing" + "time" + "github.com/google/uuid" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/libbeat/common/productorigin" + mock "github.com/elastic/mock-es/pkg/api" + "github.com/rcrowley/go-metrics" ) func TestAPIKeyEncoding(t *testing.T) { @@ -109,27 +115,33 @@ func TestHeaders(t *testing.T) { } func TestUserAgentHeader(t *testing.T) { + metricsReg := metrics.NewRegistry() + + mux := http.NewServeMux() + mockHandler := mock.NewAPIHandler(uuid.New(), "", metricsReg, time.Now().Add(time.Hour), 0, 0, 0, 0, 0) + mux.Handle("/", mockHandler) + server := httptest.NewServer(mux) + defer server.Close() + conn, err := NewConnection(ConnectionSettings{ + URL: server.URL, Beatname: "testbeat", UserAgentPostfix: "Agent", }) require.NoError(t, err) - req, err := http.NewRequestWithContext(context.Background(), "GET", "http://localhost/some/path", nil) + err = conn.Connect() require.NoError(t, err) - rawClient, ok := conn.HTTP.(*http.Client) - require.True(t, ok) - - // don't want to check the error, since the URL doesn't exist, so we'll always return an error. - resp, _ := rawClient.Transport.RoundTrip(req) - // just to make linter happy, there's no body - if resp != nil { - resp.Body.Close() + // search mock metrics for our user-agent string + found := false + for key := range metricsReg.GetAll() { + if strings.Contains(key, "testbeat-Agent") { + found = true + } } - // the `RoundTrip` will set the header in our request - require.Contains(t, req.Header.Get("User-Agent"), "Elastic-testbeat-Agent") + require.True(t, found, "did not find user-agent in %#v", metricsReg.GetAll()) } From 0607ef077e8b19e6841034aca4aa2a1c0ac70c8d Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Tue, 11 Jun 2024 08:43:54 -0700 Subject: [PATCH 10/16] linter --- libbeat/esleg/eslegclient/connection_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index 5677f0910b1a..926571225485 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -29,11 +29,11 @@ import ( "time" "github.com/google/uuid" + "github.com/rcrowley/go-metrics" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/libbeat/common/productorigin" mock "github.com/elastic/mock-es/pkg/api" - "github.com/rcrowley/go-metrics" ) func TestAPIKeyEncoding(t *testing.T) { From e99cd67ca0e90339b2111f25d4cb8b08e5b9c16c Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Tue, 11 Jun 2024 12:03:43 -0700 Subject: [PATCH 11/16] somehow changed go versions --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 359b31ce901f..bb0b651146d0 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/elastic/beats/v7 go 1.21.9 -toolchain go1.22.3 +toolchain go1.21.10 require ( cloud.google.com/go/bigquery v1.55.0 From 9a1fb4843d031b1096621274d68e361f56ec1afa Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Tue, 18 Jun 2024 09:37:19 -0700 Subject: [PATCH 12/16] fix versioning, docs --- libbeat/esleg/eslegclient/connection_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index 926571225485..940121a0832d 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -33,6 +33,7 @@ import ( "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/libbeat/common/productorigin" + "github.com/elastic/beats/v7/libbeat/version" mock "github.com/elastic/mock-es/pkg/api" ) @@ -116,8 +117,10 @@ func TestHeaders(t *testing.T) { func TestUserAgentHeader(t *testing.T) { metricsReg := metrics.NewRegistry() + version.SetPackageVersion("8.15.0") mux := http.NewServeMux() + // create a fake elasticsearch endpoint to track the user-agent mockHandler := mock.NewAPIHandler(uuid.New(), "", metricsReg, time.Now().Add(time.Hour), 0, 0, 0, 0, 0) mux.Handle("/", mockHandler) server := httptest.NewServer(mux) @@ -133,7 +136,7 @@ func TestUserAgentHeader(t *testing.T) { err = conn.Connect() require.NoError(t, err) - // search mock metrics for our user-agent string + // the metrics object passed to the mock handler contains a list of reported user-agents, search those found := false for key := range metricsReg.GetAll() { if strings.Contains(key, "testbeat-Agent") { From 9d3738db138883012698bba3128de786ae9a0db6 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Tue, 18 Jun 2024 14:12:09 -0700 Subject: [PATCH 13/16] remove log line --- libbeat/cmd/instance/beat.go | 1 - 1 file changed, 1 deletion(-) diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index b2103142ecc6..ade1bba3778b 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -876,7 +876,6 @@ func (b *Beat) configure(settings Settings) error { } b.Info.UserAgentPostfix = userAgent } - logp.L().Infof("got user agent in beat: %s", b.Info.UserAgentPostfix) if err := b.Manager.CheckRawConfig(b.RawConfig); err != nil { return err From 7b2b4b7ad284db10b9bd03024d0c6823fe0853c4 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 21 Jun 2024 08:57:42 -0700 Subject: [PATCH 14/16] change test --- libbeat/esleg/eslegclient/connection_test.go | 36 +++++--------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index 940121a0832d..2e4c2df8d677 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -26,15 +26,10 @@ import ( "net/http/httptest" "strings" "testing" - "time" - "github.com/google/uuid" - "github.com/rcrowley/go-metrics" "github.com/stretchr/testify/require" "github.com/elastic/beats/v7/libbeat/common/productorigin" - "github.com/elastic/beats/v7/libbeat/version" - mock "github.com/elastic/mock-es/pkg/api" ) func TestAPIKeyEncoding(t *testing.T) { @@ -116,36 +111,21 @@ func TestHeaders(t *testing.T) { } func TestUserAgentHeader(t *testing.T) { - metricsReg := metrics.NewRegistry() - version.SetPackageVersion("8.15.0") - - mux := http.NewServeMux() - // create a fake elasticsearch endpoint to track the user-agent - mockHandler := mock.NewAPIHandler(uuid.New(), "", metricsReg, time.Now().Add(time.Hour), 0, 0, 0, 0, 0) - mux.Handle("/", mockHandler) - server := httptest.NewServer(mux) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + prefix := "Elastic-testbeat-Agent" + if !strings.HasPrefix(r.UserAgent(), prefix) { + t.Errorf("User-Agent must start with '%s', got '%s'", prefix, r.UserAgent()) + } + w.Write([]byte("{}")) + })) defer server.Close() - conn, err := NewConnection(ConnectionSettings{ URL: server.URL, Beatname: "testbeat", UserAgentPostfix: "Agent", }) require.NoError(t, err) - - err = conn.Connect() - require.NoError(t, err) - - // the metrics object passed to the mock handler contains a list of reported user-agents, search those - found := false - for key := range metricsReg.GetAll() { - if strings.Contains(key, "testbeat-Agent") { - found = true - } - } - - require.True(t, found, "did not find user-agent in %#v", metricsReg.GetAll()) - + require.NoError(t, conn.Connect(), "conn.Connect must not return an error") } func BenchmarkExecHTTPRequest(b *testing.B) { From 7e998f3f55f76415c5e2873d48a1d28dbc4396d2 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 21 Jun 2024 09:02:19 -0700 Subject: [PATCH 15/16] fix notice --- NOTICE.txt | 53 ----------------------------------------------------- go.mod | 2 -- go.sum | 4 ---- 3 files changed, 59 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 72604769e246..f1d9d006fdd3 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -15964,29 +15964,6 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/mito@v1.12.2/LI limitations under the License. --------------------------------------------------------------------------------- -Dependency : github.com/elastic/mock-es -Version: v0.0.0-20240610195132-8fc87dc3f130 -Licence type (autodetected): Apache-2.0 --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/elastic/mock-es@v0.0.0-20240610195132-8fc87dc3f130/LICENSE: - -Copyright 2024 Elasticsearch B.V. - -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. -See the License for the specific language governing permissions and -limitations under the License. - - -------------------------------------------------------------------------------- Dependency : github.com/elastic/tk-btf Version: v0.1.0 @@ -48004,36 +47981,6 @@ Contents of probable licence file $GOMODCACHE/github.com/matttproud/golang_proto limitations under the License. --------------------------------------------------------------------------------- -Dependency : github.com/mileusna/useragent -Version: v1.3.4 -Licence type (autodetected): MIT --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/mileusna/useragent@v1.3.4/LICENSE.md: - -MIT License - -Copyright (c) 2017 Miloš Mileusnić - -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/minio/asm2plan9s Version: v0.0.0-20200509001527-cdd76441f9d8 diff --git a/go.mod b/go.mod index 9aebce63a29d..a79562dccc15 100644 --- a/go.mod +++ b/go.mod @@ -209,7 +209,6 @@ require ( github.com/elastic/elastic-agent-system-metrics v0.10.2 github.com/elastic/go-elasticsearch/v8 v8.14.0 github.com/elastic/mito v1.12.2 - github.com/elastic/mock-es v0.0.0-20240610195132-8fc87dc3f130 github.com/elastic/tk-btf v0.1.0 github.com/elastic/toutoumomoma v0.0.0-20221026030040-594ef30cb640 github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15 @@ -350,7 +349,6 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect - github.com/mileusna/useragent v1.3.4 // indirect github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect diff --git a/go.sum b/go.sum index c44fd5589ae2..dedf0da3dda6 100644 --- a/go.sum +++ b/go.sum @@ -595,8 +595,6 @@ github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/u github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/elastic/mito v1.12.2 h1:DQCYWg4U7rwNP45Ed2cHtAY94HEK1rfVUbNUT/8cYXk= github.com/elastic/mito v1.12.2/go.mod h1:J+wCf4HccW2YoSFmZMGu+d06gN+WmnIlj5ehBqine74= -github.com/elastic/mock-es v0.0.0-20240610195132-8fc87dc3f130 h1:MSTfdpBTKMrrXUg0ucjFFQAgqxWa5kOkYvikqvlmUYM= -github.com/elastic/mock-es v0.0.0-20240610195132-8fc87dc3f130/go.mod h1:mVdKBYYwt30xRFjCegbcURHh+3LWOCkQM33fgWbUiRI= github.com/elastic/pkcs8 v1.0.0 h1:HhitlUKxhN288kcNcYkjW6/ouvuwJWd9ioxpjnD9jVA= github.com/elastic/pkcs8 v1.0.0/go.mod h1:ipsZToJfq1MxclVTwpG7U/bgeDtf+0HkUiOxebk95+0= github.com/elastic/ristretto v0.1.1-0.20220602190459-83b0895ca5b3 h1:ChPwRVv1RR4a0cxoGjKcyWjTEpxYfm5gydMIzo32cAw= @@ -1314,8 +1312,6 @@ github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7 github.com/miekg/dns v1.1.42 h1:gWGe42RGaIqXQZ+r3WUGEKBEtvPHY2SXo4dqixDNxuY= github.com/miekg/dns v1.1.42/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/mileusna/useragent v0.0.0-20190129205925-3e331f0949a5/go.mod h1:JWhYAp2EXqUtsxTKdeGlY8Wp44M7VxThC9FEoNGi2IE= -github.com/mileusna/useragent v1.3.4 h1:MiuRRuvGjEie1+yZHO88UBYg8YBC/ddF6T7F56i3PCk= -github.com/mileusna/useragent v1.3.4/go.mod h1:3d8TOmwL/5I8pJjyVDteHtgDGcefrFUX4ccGOMKNYYc= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 h1:AMFGa4R4MiIpspGNG7Z948v4n35fFGB3RR3G/ry4FWs= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 h1:+n/aFZefKZp7spd8DFdX7uMikMLXX4oubIzJF4kv/wI= From 395f5af9737ce60cd4e6c05685b4147a8af065e7 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Fri, 21 Jun 2024 09:18:26 -0700 Subject: [PATCH 16/16] linter --- libbeat/esleg/eslegclient/connection_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbeat/esleg/eslegclient/connection_test.go b/libbeat/esleg/eslegclient/connection_test.go index 2e4c2df8d677..f21a03974a2e 100644 --- a/libbeat/esleg/eslegclient/connection_test.go +++ b/libbeat/esleg/eslegclient/connection_test.go @@ -116,7 +116,7 @@ func TestUserAgentHeader(t *testing.T) { if !strings.HasPrefix(r.UserAgent(), prefix) { t.Errorf("User-Agent must start with '%s', got '%s'", prefix, r.UserAgent()) } - w.Write([]byte("{}")) + _, _ = w.Write([]byte("{}")) })) defer server.Close() conn, err := NewConnection(ConnectionSettings{