From 2bfac382f7c09659493de3fe178bf8689415aa41 Mon Sep 17 00:00:00 2001 From: ChrsMark Date: Mon, 16 Dec 2024 17:50:09 +0200 Subject: [PATCH] remove internal pkg Signed-off-by: ChrsMark --- config/internal/Makefile | 1 - config/internal/go.mod | 19 ----------- config/internal/go.sum | 29 ----------------- config/internal/package_test.go | 14 -------- config/internal/warning.go | 48 --------------------------- config/internal/warning_test.go | 57 --------------------------------- 6 files changed, 168 deletions(-) delete mode 100644 config/internal/Makefile delete mode 100644 config/internal/go.mod delete mode 100644 config/internal/go.sum delete mode 100644 config/internal/package_test.go delete mode 100644 config/internal/warning.go delete mode 100644 config/internal/warning_test.go 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) - }) - } -}