From 9b360c991edb628e73180d4c27681d0d98707cff Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Wed, 15 Jul 2026 17:10:32 +0930 Subject: [PATCH] mod: replace gopkg.in/natefinch/lumberjack.v2 with elastic fork (#51950) (cherry picked from commit 3de26685929f06b435f0ca719ce340c62b2c2fac) --- NOTICE.txt | 62 ++++++++++--------- .../1784080439-49092-lumberjack.yaml | 3 + go.mod | 2 +- go.sum | 4 +- x-pack/filebeat/input/cel/config.go | 2 +- .../provider/azuread/fetcher/graph/graph.go | 2 +- .../azuread/fetcher/graph/graph_test.go | 2 +- .../entityanalytics/provider/jamf/conf.go | 3 +- .../provider/jamf/conf_test.go | 3 +- .../provider/jamf/jamf_test.go | 2 +- .../entityanalytics/provider/okta/conf.go | 3 +- .../provider/okta/conf_test.go | 3 +- .../provider/okta/okta_test.go | 3 +- x-pack/filebeat/input/http_endpoint/config.go | 3 +- .../input/http_endpoint/config_test.go | 2 +- .../input/http_endpoint/handler_test.go | 2 +- .../filebeat/input/httpjson/config_request.go | 3 +- 17 files changed, 51 insertions(+), 53 deletions(-) create mode 100644 changelog/fragments/1784080439-49092-lumberjack.yaml diff --git a/NOTICE.txt b/NOTICE.txt index d7348e6e936b..91aa1e069a2c 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -14349,6 +14349,38 @@ See the License for the specific language governing permissions and limitations under the License. +-------------------------------------------------------------------------------- +Dependency : github.com/elastic/lumberjack +Version: v0.0.0-20260715013204-c5b60bbeaaab +Licence type (autodetected): MIT +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/elastic/lumberjack@v0.0.0-20260715013204-c5b60bbeaaab/LICENSE: + +The MIT License (MIT) + +Copyright (c) 2014 Nate Finch +Copyright (c) 2026 Elasticsearch B.V. + +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/elastic/mito Version: v1.27.0 @@ -34787,36 +34819,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Dependency : gopkg.in/natefinch/lumberjack.v2 -Version: v2.2.1 -Licence type (autodetected): MIT --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/gopkg.in/natefinch/lumberjack.v2@v2.2.1/LICENSE: - -The MIT License (MIT) - -Copyright (c) 2014 Nate Finch - -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 : gopkg.in/yaml.v2 Version: v2.4.0 diff --git a/changelog/fragments/1784080439-49092-lumberjack.yaml b/changelog/fragments/1784080439-49092-lumberjack.yaml new file mode 100644 index 000000000000..9b6a5740d4f5 --- /dev/null +++ b/changelog/fragments/1784080439-49092-lumberjack.yaml @@ -0,0 +1,3 @@ +kind: bug-fix +summary: Fix goroutine leak in request trace logging infrastructure. +component: filebeat diff --git a/go.mod b/go.mod index 86080ca55368..09059e0b527e 100644 --- a/go.mod +++ b/go.mod @@ -226,7 +226,6 @@ require ( go.uber.org/mock v0.5.0 golang.org/x/term v0.44.0 google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa - gopkg.in/natefinch/lumberjack.v2 v2.2.1 gopkg.in/yaml.v3 v3.0.1 ) @@ -237,6 +236,7 @@ require ( github.com/coder/websocket v1.8.14 github.com/elastic/entcollect v0.0.0-20260706024408-4a12ea00f54d github.com/elastic/gokrb5/v8 v8.0.0-20251105095404-23cc45e6a102 + github.com/elastic/lumberjack v0.0.0-20260715013204-c5b60bbeaaab github.com/jimlambrt/gldap v0.1.14 github.com/mattn/go-sqlite3 v1.14.32 github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.155.0 diff --git a/go.sum b/go.sum index 40f3d9f4d88b..6e74d19ef552 100644 --- a/go.sum +++ b/go.sum @@ -433,6 +433,8 @@ github.com/elastic/gopacket v1.1.20-0.20260708143104-cfe2cc0f0cc7 h1:LTx9zlFG3yx github.com/elastic/gopacket v1.1.20-0.20260708143104-cfe2cc0f0cc7/go.mod h1:riddUzxTSBpJXk3qBHtYr4qOhFhT6k/1c0E3qkQjQpA= github.com/elastic/gosigar v0.14.4 h1:7NRnWJDFjEKpOjnHhtzrPGZWr9EMrYFsLjF4q0Czosk= github.com/elastic/gosigar v0.14.4/go.mod h1:tx91Eb3YgFk6y++h88fRAnxic3Si1ZDHooqnJU/hqo8= +github.com/elastic/lumberjack v0.0.0-20260715013204-c5b60bbeaaab h1:p33sNyLrsWoIoRFL3E6hKajacBbsHuST8xW7y7cxGzY= +github.com/elastic/lumberjack v0.0.0-20260715013204-c5b60bbeaaab/go.mod h1:t8v3y03G3KubyWgYqe+Jcxj/jDddnkp70743iSYrQiU= github.com/elastic/mito v1.27.0 h1:FM01Ql1OMx6uL3ogW0LoI8Ruc0O6gzmwLNBV8Zk13Yw= github.com/elastic/mito v1.27.0/go.mod h1:zFVE48AlN/iW7fryFDDPBh3yp1A4KWnkNuwxZt6HQ6A= github.com/elastic/mock-es v0.0.0-20250530054253-8c3b6053f9b6 h1:JVNuBrmOoqLJgp9o68YBMnOrXCzQI3mCppW+suwRSlw= @@ -1548,8 +1550,6 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/mcuadros/go-syslog.v2 v2.3.0 h1:kcsiS+WsTKyIEPABJBJtoG0KkOS6yzvJ+/eZlhD79kk= gopkg.in/mcuadros/go-syslog.v2 v2.3.0/go.mod h1:l5LPIyOOyIdQquNg+oU6Z3524YwrcqEm0aKH+5zpt2U= -gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= -gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= diff --git a/x-pack/filebeat/input/cel/config.go b/x-pack/filebeat/input/cel/config.go index 32c6bd4dfac3..7747d336831a 100644 --- a/x-pack/filebeat/input/cel/config.go +++ b/x-pack/filebeat/input/cel/config.go @@ -13,12 +13,12 @@ import ( "regexp" "time" - "gopkg.in/natefinch/lumberjack.v2" "gopkg.in/yaml.v3" "github.com/elastic/beats/v7/x-pack/filebeat/otel" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/transport/httpcommon" + "github.com/elastic/lumberjack" "github.com/elastic/mito/lib" ) diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go index b0c37f593f73..e0ddc1a27f2f 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph.go @@ -22,7 +22,6 @@ import ( "go.elastic.co/ecszap" "go.uber.org/zap" "go.uber.org/zap/zapcore" - "gopkg.in/natefinch/lumberjack.v2" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/collections" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/provider/azuread/authenticator" @@ -33,6 +32,7 @@ import ( "github.com/elastic/elastic-agent-libs/mapstr" "github.com/elastic/elastic-agent-libs/paths" "github.com/elastic/elastic-agent-libs/transport/httpcommon" + "github.com/elastic/lumberjack" ) const ( diff --git a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go index 5c1d07e8c8c8..a2a7e2e74194 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/azuread/fetcher/graph/graph_test.go @@ -20,7 +20,6 @@ import ( "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" - "gopkg.in/natefinch/lumberjack.v2" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/internal/collections" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/provider/azuread/authenticator/mock" @@ -28,6 +27,7 @@ import ( "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/paths" + "github.com/elastic/lumberjack" ) var trace = flag.Bool("request_trace", false, "enable request tracing during tests") diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/conf.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/conf.go index 0383c462e0fe..3b860eeb9bb5 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/conf.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/conf.go @@ -8,9 +8,8 @@ import ( "errors" "time" - "gopkg.in/natefinch/lumberjack.v2" - "github.com/elastic/elastic-agent-libs/transport/httpcommon" + "github.com/elastic/lumberjack" ) // defaultConfig returns a default configuration. diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/conf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/conf_test.go index ccf345445cff..7aa87ee3fd09 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/conf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/conf_test.go @@ -10,10 +10,9 @@ import ( "testing" "time" - "gopkg.in/natefinch/lumberjack.v2" - "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/transport/httpcommon" + "github.com/elastic/lumberjack" ) var validateTests = []struct { diff --git a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go index 9ca7128d11c3..825e34b67845 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/jamf/jamf_test.go @@ -19,10 +19,10 @@ import ( "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" - "gopkg.in/natefinch/lumberjack.v2" "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/provider/jamf/internal/jamf" "github.com/elastic/elastic-agent-libs/logp" + "github.com/elastic/lumberjack" ) var trace = flag.Bool("request_trace", false, "enable request tracing during tests") diff --git a/x-pack/filebeat/input/entityanalytics/provider/okta/conf.go b/x-pack/filebeat/input/entityanalytics/provider/okta/conf.go index e9877c9ec9f8..bf5189dcb789 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/okta/conf.go +++ b/x-pack/filebeat/input/entityanalytics/provider/okta/conf.go @@ -15,10 +15,9 @@ import ( "strings" "time" - "gopkg.in/natefinch/lumberjack.v2" - "github.com/elastic/beats/v7/libbeat/common" "github.com/elastic/elastic-agent-libs/transport/httpcommon" + "github.com/elastic/lumberjack" ) // defaultConfig returns a default configuration. diff --git a/x-pack/filebeat/input/entityanalytics/provider/okta/conf_test.go b/x-pack/filebeat/input/entityanalytics/provider/okta/conf_test.go index 1a5aed770e94..4c3f99fa476b 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/okta/conf_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/okta/conf_test.go @@ -10,10 +10,9 @@ import ( "testing" "time" - "gopkg.in/natefinch/lumberjack.v2" - "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/transport/httpcommon" + "github.com/elastic/lumberjack" ) var validateTests = []struct { diff --git a/x-pack/filebeat/input/entityanalytics/provider/okta/okta_test.go b/x-pack/filebeat/input/entityanalytics/provider/okta/okta_test.go index 103af14bc65d..e9664f377480 100644 --- a/x-pack/filebeat/input/entityanalytics/provider/okta/okta_test.go +++ b/x-pack/filebeat/input/entityanalytics/provider/okta/okta_test.go @@ -18,10 +18,9 @@ import ( "testing" "time" - "gopkg.in/natefinch/lumberjack.v2" - "github.com/elastic/beats/v7/x-pack/filebeat/input/entityanalytics/provider/okta/internal/okta" "github.com/elastic/elastic-agent-libs/logp" + "github.com/elastic/lumberjack" ) var trace = flag.Bool("request_trace", false, "enable request tracing during tests") diff --git a/x-pack/filebeat/input/http_endpoint/config.go b/x-pack/filebeat/input/http_endpoint/config.go index 5889824c9cb6..4ee9de08b183 100644 --- a/x-pack/filebeat/input/http_endpoint/config.go +++ b/x-pack/filebeat/input/http_endpoint/config.go @@ -12,9 +12,8 @@ import ( "net/textproto" "strings" - "gopkg.in/natefinch/lumberjack.v2" - "github.com/elastic/elastic-agent-libs/transport/tlscommon" + "github.com/elastic/lumberjack" ) // Available providers for CRC validation (use lowercase) diff --git a/x-pack/filebeat/input/http_endpoint/config_test.go b/x-pack/filebeat/input/http_endpoint/config_test.go index 2e10686f33cb..0fc34ee12ecd 100644 --- a/x-pack/filebeat/input/http_endpoint/config_test.go +++ b/x-pack/filebeat/input/http_endpoint/config_test.go @@ -11,9 +11,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/natefinch/lumberjack.v2" confpkg "github.com/elastic/elastic-agent-libs/config" + "github.com/elastic/lumberjack" ) func Test_validateConfig(t *testing.T) { diff --git a/x-pack/filebeat/input/http_endpoint/handler_test.go b/x-pack/filebeat/input/http_endpoint/handler_test.go index e1045bb932af..8cf0bed3a1fa 100644 --- a/x-pack/filebeat/input/http_endpoint/handler_test.go +++ b/x-pack/filebeat/input/http_endpoint/handler_test.go @@ -23,13 +23,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/natefinch/lumberjack.v2" "github.com/elastic/beats/v7/libbeat/beat" "github.com/elastic/beats/v7/testing/testutils" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" "github.com/elastic/elastic-agent-libs/monitoring" + "github.com/elastic/lumberjack" ) var withTraces = flag.Bool("log-traces", false, "specify logging request traces during tests") diff --git a/x-pack/filebeat/input/httpjson/config_request.go b/x-pack/filebeat/input/httpjson/config_request.go index 6e27066c8079..bec9ce9ac7ee 100644 --- a/x-pack/filebeat/input/httpjson/config_request.go +++ b/x-pack/filebeat/input/httpjson/config_request.go @@ -12,10 +12,9 @@ import ( "strings" "time" - "gopkg.in/natefinch/lumberjack.v2" - "github.com/elastic/elastic-agent-libs/mapstr" "github.com/elastic/elastic-agent-libs/transport/httpcommon" + "github.com/elastic/lumberjack" ) type retryConfig struct {