diff --git a/.chloggen/remove_net_interface_warn.yaml b/.chloggen/remove_net_interface_warn.yaml new file mode 100644 index 00000000000..02ed7a92357 --- /dev/null +++ b/.chloggen/remove_net_interface_warn.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: otelcol + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: This PR removes the warning when 0.0.0.0 is used + +# One or more tracking issues or pull requests related to the change +issues: [11713, 8510] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/config/configgrpc/configgrpc.go b/config/configgrpc/configgrpc.go index 5def5bbb0a1..b9c99d4d997 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -37,7 +37,6 @@ import ( "go.opentelemetry.io/collector/config/configopaque" "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/config/configtls" - "go.opentelemetry.io/collector/config/internal" "go.opentelemetry.io/collector/extension/auth" ) @@ -404,11 +403,6 @@ func (gss *ServerConfig) getGrpcServerOptions( settings component.TelemetrySettings, extraOpts []ToServerOption, ) ([]grpc.ServerOption, error) { - switch gss.NetAddr.Transport { - case confignet.TransportTypeTCP, confignet.TransportTypeTCP4, confignet.TransportTypeTCP6, confignet.TransportTypeUDP, confignet.TransportTypeUDP4, confignet.TransportTypeUDP6: - internal.WarnOnUnspecifiedHost(settings.Logger, gss.NetAddr.Endpoint) - } - var opts []grpc.ServerOption if gss.TLSSetting != nil { diff --git a/config/confighttp/confighttp.go b/config/confighttp/confighttp.go index c8ab4544aeb..6f8efc53f45 100644 --- a/config/confighttp/confighttp.go +++ b/config/confighttp/confighttp.go @@ -30,7 +30,6 @@ import ( "go.opentelemetry.io/collector/config/configopaque" "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/config/configtls" - configinternal "go.opentelemetry.io/collector/config/internal" "go.opentelemetry.io/collector/extension/auth" ) @@ -407,8 +406,6 @@ func WithDecoder(key string, dec func(body io.ReadCloser) (io.ReadCloser, error) // ToServer creates an http.Server from settings object. func (hss *ServerConfig) ToServer(_ context.Context, host component.Host, settings component.TelemetrySettings, handler http.Handler, opts ...ToServerOption) (*http.Server, error) { - configinternal.WarnOnUnspecifiedHost(settings.Logger, hss.Endpoint) - serverOpts := &toServerOptions{} serverOpts.Apply(opts...) diff --git a/config/internal/Makefile b/config/internal/Makefile deleted file mode 100644 index ded7a36092d..00000000000 --- a/config/internal/Makefile +++ /dev/null @@ -1 +0,0 @@ -include ../../Makefile.Common diff --git a/config/internal/go.mod b/config/internal/go.mod deleted file mode 100644 index 2327799b7d6..00000000000 --- a/config/internal/go.mod +++ /dev/null @@ -1,19 +0,0 @@ -module go.opentelemetry.io/collector/config/internal - -go 1.22.0 - -require ( - github.com/stretchr/testify v1.10.0 - go.uber.org/goleak v1.3.0 - go.uber.org/zap v1.27.0 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/config/internal/go.sum b/config/internal/go.sum deleted file mode 100644 index d451d407663..00000000000 --- a/config/internal/go.sum +++ /dev/null @@ -1,29 +0,0 @@ -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/config/internal/package_test.go b/config/internal/package_test.go deleted file mode 100644 index 4486cdb28aa..00000000000 --- a/config/internal/package_test.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package internal - -import ( - "testing" - - "go.uber.org/goleak" -) - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -} diff --git a/config/internal/warning.go b/config/internal/warning.go deleted file mode 100644 index 0f5f6363431..00000000000 --- a/config/internal/warning.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package internal // import "go.opentelemetry.io/collector/config/internal" - -import ( - "net" - "strconv" - "strings" - - "go.uber.org/zap" -) - -func shouldWarn(endpoint string) bool { - if endpoint == ":" { - // : (aka 0.0.0.0:0) - return true - } - - if strings.HasPrefix(endpoint, ":") { - // : (aka 0.0.0.0:) - _, err := strconv.ParseInt(endpoint[1:], 10, 64) - // If it's not a number, it's probably invalid, don't warn. - return err == nil - } - - // : - host, _, err := net.SplitHostPort(endpoint) - if err != nil { // Probably invalid, don't warn. - return false - } - - ip := net.ParseIP(host) - return ip != nil && ip.IsUnspecified() -} - -// WarnOnUnspecifiedHost emits a warning if an endpoint has an unspecified host. -func WarnOnUnspecifiedHost(logger *zap.Logger, endpoint string) { - if shouldWarn(endpoint) { - logger.Warn( - "Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks.", - zap.String( - "documentation", - "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks", - ), - ) - } -} diff --git a/config/internal/warning_test.go b/config/internal/warning_test.go deleted file mode 100644 index 3e8a2f01387..00000000000 --- a/config/internal/warning_test.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package internal // import "go.opentelemetry.io/collector/config/internal" - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestShouldWarn(t *testing.T) { - tests := []struct { - endpoint string - warn bool - }{ - { - endpoint: "0.0.0.0:0", - warn: true, - }, - { - endpoint: ":0", - warn: true, - }, - { - // Valid input for net.Listen - endpoint: ":+0", - warn: true, - }, - { - // Valid input for net.Listen - endpoint: ":-0", - warn: true, - }, - { - // Valid input for net.Listen, same as zero port. - // https://github.com/golang/go/issues/13610 - endpoint: ":", - warn: true, - }, - { - endpoint: "127.0.0.1:0", - }, - { - endpoint: "localhost:0", - }, - { - // invalid, don't warn - endpoint: "localhost::0", - }, - } - for _, test := range tests { - t.Run(test.endpoint, func(t *testing.T) { - assert.Equal(t, shouldWarn(test.endpoint), test.warn) - }) - } -}