Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12380,11 +12380,11 @@ SOFTWARE

--------------------------------------------------------------------------------
Dependency : github.com/elastic/elastic-agent-libs
Version: v0.21.4
Version: v0.21.5
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.21.4/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.21.5/LICENSE:

Apache License
Version 2.0, January 2004
Expand Down
2 changes: 1 addition & 1 deletion filebeat/input/kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func newSaramaConfig(config kafkaInputConfig, logger *logp.Logger) (*sarama.Conf
k.Consumer.Group.Rebalance.Retry.Backoff = config.Rebalance.RetryBackoff
k.Consumer.Group.Rebalance.Retry.Max = config.Rebalance.MaxRetries

tls, err := tlscommon.LoadTLSConfig(config.TLS)
tls, err := tlscommon.LoadTLSConfig(config.TLS, logger)
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions filebeat/input/mqtt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ package mqtt
import (
libmqtt "github.com/eclipse/paho.mqtt.golang"

"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/transport/tlscommon"
)

func createClientOptions(config mqttInputConfig, onConnectHandler func(client libmqtt.Client)) (*libmqtt.ClientOptions, error) {
func createClientOptions(config mqttInputConfig, onConnectHandler func(client libmqtt.Client), logger *logp.Logger) (*libmqtt.ClientOptions, error) {
clientOptions := libmqtt.NewClientOptions().
SetClientID(config.ClientID).
SetUsername(config.Username).
Expand All @@ -37,7 +38,7 @@ func createClientOptions(config mqttInputConfig, onConnectHandler func(client li
}

if config.TLS != nil {
tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS)
tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS, logger)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion filebeat/input/mqtt/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func newInput(
clientSubscriptions := createClientSubscriptions(config)
onMessageHandler := createOnMessageHandler(logger, out, inflightMessages)
onConnectHandler := createOnConnectHandler(logger, &inputContext, onMessageHandler, clientSubscriptions, newBackoff)
clientOptions, err := createClientOptions(config, onConnectHandler)
clientOptions, err := createClientOptions(config, onConnectHandler, logger)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion filebeat/input/redis/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NewInput(cfg *conf.C, connector channel.Connector, context input.Context, l
}

if config.TLS.IsEnabled() {
tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS)
tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS, logger)
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions filebeat/input/redis/redis_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/elastic/beats/v7/filebeat/input"
"github.com/elastic/beats/v7/libbeat/beat"
conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/logp/logptest"
"github.com/elastic/elastic-agent-libs/mapstr"
"github.com/elastic/elastic-agent-libs/transport/tlscommon"
Expand Down Expand Up @@ -191,7 +192,7 @@ func createRedisClient(t *testing.T) *rd.Pool {
Certificate: "_meta/certs/server-cert.pem",
Key: "_meta/certs/server-key.pem",
},
})
}, logptest.NewTestingLogger(t, ""))
if err != nil {
t.Fatalf("failed to load TLS configuration: %v", err)
}
Expand Down Expand Up @@ -303,7 +304,7 @@ func createRedisConfig(username string, password string) config {
}

if redisConfig.TLS.IsEnabled() {
tlsConfig, _ := tlscommon.LoadTLSConfig(redisConfig.TLS)
tlsConfig, _ := tlscommon.LoadTLSConfig(redisConfig.TLS, logp.NewNopLogger())
redisConfig.tlsConfig = tlsConfig.ToConfig()
}

Expand Down
2 changes: 1 addition & 1 deletion filebeat/inputsource/tcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func New(
factory streaming.HandlerFactory,
logger *logp.Logger,
) (*Server, error) {
tlsConfig, err := tlscommon.LoadTLSServerConfig(config.TLS)
tlsConfig, err := tlscommon.LoadTLSServerConfig(config.TLS, logger)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ require (
github.com/elastic/bayeux v1.0.5
github.com/elastic/ebpfevents v0.7.0
github.com/elastic/elastic-agent-autodiscover v0.10.0
github.com/elastic/elastic-agent-libs v0.21.4
github.com/elastic/elastic-agent-libs v0.21.5
github.com/elastic/elastic-agent-system-metrics v0.11.11
github.com/elastic/go-elasticsearch/v8 v8.18.1
github.com/elastic/go-freelru v0.16.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ github.com/elastic/elastic-agent-autodiscover v0.10.0 h1:WJ4zl9uSfk1kHmn2B/0byQB
github.com/elastic/elastic-agent-autodiscover v0.10.0/go.mod h1:Nf3zh9FcJ9nTTswTwDTUAqXmvQllOrNliM6xmORSxwE=
github.com/elastic/elastic-agent-client/v7 v7.15.0 h1:nDB7v8TBoNuD6IIzC3z7Q0y+7bMgXoT2DsHfolO2CHE=
github.com/elastic/elastic-agent-client/v7 v7.15.0/go.mod h1:6h+f9QdIr3GO2ODC0Y8+aEXRwzbA5W4eV4dd/67z7nI=
github.com/elastic/elastic-agent-libs v0.21.4 h1:Xf7zeJ2hiyt13VRhyH22/nsDmlY8/TEfFb36X9uvw34=
github.com/elastic/elastic-agent-libs v0.21.4/go.mod h1:xSeIP3NtOIT4N2pPS4EyURmS1Q8mK0lWZ8Wd1Du6q3w=
github.com/elastic/elastic-agent-libs v0.21.5 h1:YTMwaBPgOPvQnxBPv7fLpUqjw2HgY3ymC9TwdzdOD8U=
github.com/elastic/elastic-agent-libs v0.21.5/go.mod h1:xSeIP3NtOIT4N2pPS4EyURmS1Q8mK0lWZ8Wd1Du6q3w=
github.com/elastic/elastic-agent-system-metrics v0.11.11 h1:Qjh3Zef23PfGlG91AF+9ciNLNQf/8cDJ4CalnLZtV3g=
github.com/elastic/elastic-agent-system-metrics v0.11.11/go.mod h1:GNqmKfvOt8PwORjbS6GllNdMfkLpOWyTa7P8oQq4E5o=
github.com/elastic/elastic-transport-go/v8 v8.7.0 h1:OgTneVuXP2uip4BA658Xi6Hfw+PeIOod2rY3GVMGoVE=
Expand Down
4 changes: 3 additions & 1 deletion heartbeat/monitors/active/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/elastic/beats/v7/heartbeat/monitors/wrappers/wraputil"
"github.com/elastic/beats/v7/libbeat/version"
conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"

"github.com/elastic/beats/v7/heartbeat/monitors/jobs"
"github.com/elastic/elastic-agent-libs/transport/httpcommon"
Expand Down Expand Up @@ -91,7 +92,8 @@ func create(
}
} else {
// preload TLS configuration
tls, err := tlscommon.LoadTLSConfig(config.Transport.TLS)
// TODO: Use local logger
tls, err := tlscommon.LoadTLSConfig(config.Transport.TLS, logp.NewLogger(""))
if err != nil {
return plugin.Plugin{}, err
}
Expand Down
3 changes: 2 additions & 1 deletion heartbeat/monitors/active/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ func (jf *jobFactory) loadConfig(commonCfg *conf.C) error {
return err
}

jf.tlsConfig, err = tlscommon.LoadTLSConfig(jf.config.TLS)
// TOOD: use local logger
jf.tlsConfig, err = tlscommon.LoadTLSConfig(jf.config.TLS, logp.NewLogger(""))
if err != nil {
return err
}
Expand Down
6 changes: 4 additions & 2 deletions libbeat/common/transport/transptest/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"testing"
"time"

"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/logp/logptest"
"github.com/elastic/elastic-agent-libs/transport"
"github.com/elastic/elastic-agent-libs/transport/tlscommon"
)
Expand Down Expand Up @@ -130,7 +132,7 @@
Certificate: cert + ".pem",
Key: cert + ".key",
},
})
}, logptest.NewTestingLogger(t, ""))
if err != nil {
t.Fatalf("failed to load certificate")
}
Expand Down Expand Up @@ -177,7 +179,7 @@
return func(addr string, proxy *transport.ProxyConfig) (*transport.Client, error) {
tlsConfig, err := tlscommon.LoadTLSConfig(&tlscommon.Config{
CAs: []string{certName + ".pem"},
})
}, logp.NewNopLogger())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -266,7 +268,7 @@
if err != nil {
t.Fatalf("failed to open key file for writing: %v", err)
}
pem.Encode(keyOut, pemBlock)

Check failure on line 271 in libbeat/common/transport/transptest/testing.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Error return value of `pem.Encode` is not checked (errcheck)
keyOut.Close()

//Decrypt pem block to add it later to the certificate
Expand Down Expand Up @@ -301,7 +303,7 @@
if err != nil {
t.Fatalf("failed to open cert.pem for writing: %s", err)
}
pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: caBytes})

Check failure on line 306 in libbeat/common/transport/transptest/testing.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

Error return value of `pem.Encode` is not checked (errcheck)
certOut.Close()

return nil
Expand Down
2 changes: 1 addition & 1 deletion libbeat/esleg/eslegclient/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (conn *Connection) Test(d testing.Driver) {
d.Warn("TLS", "secure connection disabled")
} else {
d.Run("TLS", func(d testing.Driver) {
tls, err := tlscommon.LoadTLSConfig(conn.Transport.TLS)
tls, err := tlscommon.LoadTLSConfig(conn.Transport.TLS, conn.log)
if err != nil {
d.Fatal("load tls config", err)
}
Expand Down
2 changes: 1 addition & 1 deletion libbeat/otelbeat/oteltranslate/tls_otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TLSCommonToOTel(tlscfg *tlscommon.Config, logger *logp.Logger) (map[string]
certPem = string(certBytes)
}

tlsConfig, err := tlscommon.LoadTLSConfig(tlscfg)
tlsConfig, err := tlscommon.LoadTLSConfig(tlscfg, logger)
if err != nil {
return nil, fmt.Errorf("cannot load SSL configuration: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion libbeat/outputs/kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func newSaramaConfig(log *logp.Logger, config *kafkaConfig) (*sarama.Config, err
k.Producer.Timeout = config.BrokerTimeout
k.Producer.CompressionLevel = config.CompressionLevel

tls, err := tlscommon.LoadTLSConfig(config.TLS)
tls, err := tlscommon.LoadTLSConfig(config.TLS, log)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion libbeat/outputs/logstash/logstash.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func makeLogstash(
return outputs.Fail(err)
}

tls, err := tlscommon.LoadTLSConfig(lsConfig.TLS)
tls, err := tlscommon.LoadTLSConfig(lsConfig.TLS, beat.Logger)
if err != nil {
return outputs.Fail(err)
}
Expand Down
2 changes: 1 addition & 1 deletion libbeat/outputs/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func makeRedis(
return outputs.Fail(err)
}

tls, err := tlscommon.LoadTLSConfig(rConfig.TLS)
tls, err := tlscommon.LoadTLSConfig(rConfig.TLS, beat.Logger)
if err != nil {
return outputs.Fail(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func New(c *cfg.C, log *logp.Logger) (beat.Processor, error) {
return nil, fmt.Errorf("failed to unpack add_cloud_metadata config: %w", err)
}

tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS)
tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS, log)
if err != nil {
return nil, fmt.Errorf("TLS configuration load: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func newFromConfig(c config, logger *logp.Logger) (*processor, error) {
searchTimeLimit: c.LDAPSearchTimeLimit,
}
if c.LDAPTLS != nil {
tlsConfig, err := tlscommon.LoadTLSConfig(c.LDAPTLS)
tlsConfig, err := tlscommon.LoadTLSConfig(c.LDAPTLS, logger)
if err != nil {
return nil, fmt.Errorf("could not load provided LDAP TLS configuration: %w", err)
}
Expand Down
7 changes: 5 additions & 2 deletions metricbeat/helper/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"io"
"net/http"

"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/transport/httpcommon"
"github.com/elastic/elastic-agent-libs/useragent"

Expand Down Expand Up @@ -58,11 +59,11 @@ func NewHTTP(base mb.BaseMetricSet) (*HTTP, error) {
return nil, err
}

return NewHTTPFromConfig(config, base.HostData())
return NewHTTPFromConfig(config, base.HostData(), base.Logger())
}

// NewHTTPFromConfig newHTTPWithConfig creates a new http helper from some configuration
func NewHTTPFromConfig(config Config, hostData mb.HostData) (*HTTP, error) {
func NewHTTPFromConfig(config Config, hostData mb.HostData, logger *logp.Logger) (*HTTP, error) {
headers := http.Header{}
if config.Headers == nil {
config.Headers = map[string]string{}
Expand All @@ -83,6 +84,8 @@ func NewHTTPFromConfig(config Config, hostData mb.HostData) (*HTTP, error) {
}

client, err := config.Transport.Client(
// also sets a local logger for use by http transport
httpcommon.WithLogger(logger),
httpcommon.WithBaseDialer(dialer),
httpcommon.WithAPMHTTPInstrumentation(),
httpcommon.WithHeaderRoundTripper(map[string]string{"User-Agent": userAgent}),
Expand Down
19 changes: 10 additions & 9 deletions metricbeat/helper/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/elastic/beats/v7/metricbeat/helper/dialer"
"github.com/elastic/beats/v7/metricbeat/mb"
"github.com/elastic/beats/v7/metricbeat/mb/parse"
"github.com/elastic/elastic-agent-libs/logp/logptest"
)

func TestTimeout(t *testing.T) {
Expand All @@ -55,7 +56,7 @@ func TestTimeout(t *testing.T) {
SanitizedURI: ts.URL,
}

h, err := NewHTTPFromConfig(cfg, hostData)
h, err := NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

checkTimeout(t, h)
Expand All @@ -72,7 +73,7 @@ func TestConnectTimeout(t *testing.T) {
SanitizedURI: uri,
}

h, err := NewHTTPFromConfig(cfg, hostData)
h, err := NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

checkTimeout(t, h)
Expand All @@ -96,7 +97,7 @@ func TestAuthentication(t *testing.T) {
URI: ts.URL,
SanitizedURI: ts.URL,
}
h, err := NewHTTPFromConfig(cfg, hostData)
h, err := NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

response, err := h.FetchResponse()
Expand All @@ -111,7 +112,7 @@ func TestAuthentication(t *testing.T) {
User: expectedUser,
Password: expectedPassword,
}
h, err = NewHTTPFromConfig(cfg, hostData)
h, err = NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

response, err = h.FetchResponse()
Expand All @@ -126,7 +127,7 @@ func TestSetHeader(t *testing.T) {
"Override": "default",
}

h, err := NewHTTPFromConfig(cfg, mb.HostData{})
h, err := NewHTTPFromConfig(cfg, mb.HostData{}, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

h.SetHeader("Override", "overridden")
Expand All @@ -140,7 +141,7 @@ func TestSetHeaderDefault(t *testing.T) {
"Override": "default",
}

h, err := NewHTTPFromConfig(cfg, mb.HostData{})
h, err := NewHTTPFromConfig(cfg, mb.HostData{}, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

h.SetHeaderDefault("Override", "overridden")
Expand Down Expand Up @@ -213,7 +214,7 @@ func TestOverUnixSocket(t *testing.T) {
hostData, err := c.hostDataBuilder(sockFile)
require.NoError(t, err)

h, err := NewHTTPFromConfig(cfg, hostData)
h, err := NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

r, err := h.FetchResponse()
Expand All @@ -240,7 +241,7 @@ func TestUserAgentCheck(t *testing.T) {
SanitizedURI: ts.URL,
}

h, err := NewHTTPFromConfig(cfg, hostData)
h, err := NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

res, err := h.FetchResponse()
Expand Down Expand Up @@ -275,7 +276,7 @@ func TestRefreshAuthorizationHeader(t *testing.T) {
SanitizedURI: ts.URL,
}

h, err := NewHTTPFromConfig(cfg, hostData)
h, err := NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

res, err := h.FetchResponse()
Expand Down
5 changes: 3 additions & 2 deletions metricbeat/helper/http_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/elastic/beats/v7/libbeat/api/npipe"
"github.com/elastic/beats/v7/metricbeat/helper/dialer"
"github.com/elastic/beats/v7/metricbeat/mb"
"github.com/elastic/elastic-agent-libs/logp/logptest"
)

func TestOverNamedpipe(t *testing.T) {
Expand Down Expand Up @@ -62,7 +63,7 @@ func TestOverNamedpipe(t *testing.T) {
SanitizedURI: "http://npipe/",
}

h, err := NewHTTPFromConfig(cfg, hostData)
h, err := NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

r, err := h.FetchResponse()
Expand Down Expand Up @@ -95,7 +96,7 @@ func TestOverNamedpipe(t *testing.T) {
SanitizedURI: "http://npipe/ok",
}

h, err := NewHTTPFromConfig(cfg, hostData)
h, err := NewHTTPFromConfig(cfg, hostData, logptest.NewTestingLogger(t, ""))
require.NoError(t, err)

r, err := h.FetchResponse()
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/helper/server/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func getDefaultHttpServer(mb mb.BaseMetricSet) (*HttpServer, error) {
return nil, err
}

tlsConfig, err := tlscommon.LoadTLSServerConfig(config.TLS)
tlsConfig, err := tlscommon.LoadTLSServerConfig(config.TLS, mb.Logger())
if err != nil {
return nil, err
}
Expand Down
Loading
Loading