From 7b041ba327011d85471cfd37f1014f054ae43436 Mon Sep 17 00:00:00 2001 From: Mauri de Souza Meneguzzo Date: Mon, 12 Aug 2024 08:59:36 -0300 Subject: [PATCH] beats: import time/tzdata explicitly in main (#40420) In order to handle timezones we import Go's own timezone database. This import is done indirectly by libbeat/common/cfgtype. We trust that this package will end up being required by the dependency chain of every beats main binary. To ensure that the binaries continue to handle timezones correctly and to avoid any unexpected issues, let's import time/tzdata explicitly in the main packages. See https://github.com/elastic/beats/pull/40326. Co-authored-by: Pierre HILBERT --- auditbeat/main.go | 1 + filebeat/main.go | 1 + heartbeat/main.go | 1 + metricbeat/main.go | 1 + packetbeat/main.go | 1 + winlogbeat/main.go | 1 + x-pack/agentbeat/main.go | 1 + x-pack/auditbeat/main.go | 1 + x-pack/dockerlogbeat/main.go | 1 + x-pack/filebeat/main.go | 1 + x-pack/functionbeat/main.go | 1 + x-pack/heartbeat/main.go | 1 + x-pack/metricbeat/main.go | 1 + x-pack/osquerybeat/main.go | 1 + x-pack/packetbeat/main.go | 1 + x-pack/winlogbeat/main.go | 1 + 16 files changed, 16 insertions(+) diff --git a/auditbeat/main.go b/auditbeat/main.go index 48b9086acd27..ff3f400f0864 100644 --- a/auditbeat/main.go +++ b/auditbeat/main.go @@ -19,6 +19,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/auditbeat/cmd" ) diff --git a/filebeat/main.go b/filebeat/main.go index b7f128a266f1..e6feb5484af2 100644 --- a/filebeat/main.go +++ b/filebeat/main.go @@ -19,6 +19,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/filebeat/cmd" inputs "github.com/elastic/beats/v7/filebeat/input/default-inputs" diff --git a/heartbeat/main.go b/heartbeat/main.go index 6218bf004322..a30277c84fe1 100644 --- a/heartbeat/main.go +++ b/heartbeat/main.go @@ -19,6 +19,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/heartbeat/cmd" diff --git a/metricbeat/main.go b/metricbeat/main.go index 749ec8001bdd..5dcea740b21f 100644 --- a/metricbeat/main.go +++ b/metricbeat/main.go @@ -26,6 +26,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/metricbeat/cmd" ) diff --git a/packetbeat/main.go b/packetbeat/main.go index c820e23e3236..1f5324d4b4b9 100644 --- a/packetbeat/main.go +++ b/packetbeat/main.go @@ -19,6 +19,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/packetbeat/cmd" ) diff --git a/winlogbeat/main.go b/winlogbeat/main.go index 600debc0a552..61828c64c93f 100644 --- a/winlogbeat/main.go +++ b/winlogbeat/main.go @@ -26,6 +26,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/winlogbeat/cmd" ) diff --git a/x-pack/agentbeat/main.go b/x-pack/agentbeat/main.go index d567e2eed085..f7c36c2f7d3e 100644 --- a/x-pack/agentbeat/main.go +++ b/x-pack/agentbeat/main.go @@ -7,6 +7,7 @@ package main import ( "fmt" "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/libbeat/cfgfile" "github.com/elastic/beats/v7/libbeat/cmd" diff --git a/x-pack/auditbeat/main.go b/x-pack/auditbeat/main.go index d08d6d4c31a6..58844e4f6411 100644 --- a/x-pack/auditbeat/main.go +++ b/x-pack/auditbeat/main.go @@ -6,6 +6,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/x-pack/auditbeat/cmd" ) diff --git a/x-pack/dockerlogbeat/main.go b/x-pack/dockerlogbeat/main.go index d725d2a46c4a..c0735f354b6e 100644 --- a/x-pack/dockerlogbeat/main.go +++ b/x-pack/dockerlogbeat/main.go @@ -8,6 +8,7 @@ import ( "fmt" "os" "strconv" + _ "time/tzdata" // for timezone handling "github.com/docker/go-plugins-helpers/sdk" diff --git a/x-pack/filebeat/main.go b/x-pack/filebeat/main.go index 4902d835fe64..bb7606bedb7f 100644 --- a/x-pack/filebeat/main.go +++ b/x-pack/filebeat/main.go @@ -6,6 +6,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/x-pack/filebeat/cmd" ) diff --git a/x-pack/functionbeat/main.go b/x-pack/functionbeat/main.go index d6c63e4f7097..47c4c10ad4f6 100644 --- a/x-pack/functionbeat/main.go +++ b/x-pack/functionbeat/main.go @@ -6,6 +6,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling _ "github.com/elastic/beats/v7/x-pack/functionbeat/include" // imports features "github.com/elastic/beats/v7/x-pack/functionbeat/manager/cmd" diff --git a/x-pack/heartbeat/main.go b/x-pack/heartbeat/main.go index c7bab4764993..ce265bd35467 100644 --- a/x-pack/heartbeat/main.go +++ b/x-pack/heartbeat/main.go @@ -6,6 +6,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/x-pack/heartbeat/cmd" ) diff --git a/x-pack/metricbeat/main.go b/x-pack/metricbeat/main.go index 333a0d30fa56..92469da9c174 100644 --- a/x-pack/metricbeat/main.go +++ b/x-pack/metricbeat/main.go @@ -13,6 +13,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/x-pack/metricbeat/cmd" ) diff --git a/x-pack/osquerybeat/main.go b/x-pack/osquerybeat/main.go index ee2d6597729e..570f848729ea 100644 --- a/x-pack/osquerybeat/main.go +++ b/x-pack/osquerybeat/main.go @@ -6,6 +6,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/x-pack/osquerybeat/cmd" ) diff --git a/x-pack/packetbeat/main.go b/x-pack/packetbeat/main.go index 6ae71ec15c20..f6f55b6d25b8 100644 --- a/x-pack/packetbeat/main.go +++ b/x-pack/packetbeat/main.go @@ -6,6 +6,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/x-pack/packetbeat/cmd" ) diff --git a/x-pack/winlogbeat/main.go b/x-pack/winlogbeat/main.go index 21fd70be7f68..1ca2aa11a31e 100644 --- a/x-pack/winlogbeat/main.go +++ b/x-pack/winlogbeat/main.go @@ -6,6 +6,7 @@ package main import ( "os" + _ "time/tzdata" // for timezone handling "github.com/elastic/beats/v7/x-pack/winlogbeat/cmd" )