From 2a22201010ed5944bfea62c2689cfd816c3ecea5 Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Thu, 27 Feb 2025 11:54:29 +0100 Subject: [PATCH 01/10] create FIPSConfig loaded from yaml file and filter beats --- dev-tools/mage/fips-settings.yaml | 7 +++ dev-tools/mage/settings.go | 18 ++++++ x-pack/agentbeat/magefile.go | 94 +++++++++++++++++++++---------- 3 files changed, 90 insertions(+), 29 deletions(-) create mode 100644 dev-tools/mage/fips-settings.yaml diff --git a/dev-tools/mage/fips-settings.yaml b/dev-tools/mage/fips-settings.yaml new file mode 100644 index 000000000000..9e84eb2b3fb3 --- /dev/null +++ b/dev-tools/mage/fips-settings.yaml @@ -0,0 +1,7 @@ +# beats contains the list of beats that are FIPS-enabled +beats: + - agentbeat + - auditbeat + - cloudbeat + - filebeat + - metricbeat \ No newline at end of file diff --git a/dev-tools/mage/settings.go b/dev-tools/mage/settings.go index b1394e66c4bd..748a0fee884e 100644 --- a/dev-tools/mage/settings.go +++ b/dev-tools/mage/settings.go @@ -18,6 +18,7 @@ package mage import ( + _ "embed" "errors" "fmt" "go/build" @@ -33,6 +34,7 @@ import ( "github.com/magefile/mage/sh" "golang.org/x/text/cases" "golang.org/x/text/language" + "gopkg.in/yaml.v2" "github.com/elastic/beats/v7/dev-tools/mage/gotool" ) @@ -83,6 +85,13 @@ var ( DevBuild bool FIPSBuild bool + //go:embed fips-settings.yaml + fipsConfigRaw []byte + + FIPSConfig struct { + Beats []string + } + versionQualified bool versionQualifier string @@ -134,6 +143,13 @@ func init() { panic(fmt.Errorf("failed to parse FIPS env value: %w", err)) } + if FIPSBuild { + err := yaml.Unmarshal(fipsConfigRaw, &FIPSConfig) + if err != nil { + panic(fmt.Errorf("failed to parse FIPS config: %w", err)) + } + } + versionQualifier, versionQualified = os.LookupEnv("VERSION_QUALIFIER") } @@ -186,6 +202,7 @@ func varMap(args ...map[string]interface{}) map[string]interface{} { "Snapshot": Snapshot, "DEV": DevBuild, "FIPS": FIPSBuild, + "FIPSConfig": FIPSConfig, "Qualifier": versionQualifier, "CI": CI, } @@ -221,6 +238,7 @@ VersionQualifier = {{.Qualifier}} PLATFORMS = {{.PLATFORMS}} PACKAGES = {{.PACKAGES}} CI = {{.CI}} +FIPSConfig = {{.FIPSConfig}} ## Functions diff --git a/x-pack/agentbeat/magefile.go b/x-pack/agentbeat/magefile.go index 3160ef5f2127..9530111a644c 100644 --- a/x-pack/agentbeat/magefile.go +++ b/x-pack/agentbeat/magefile.go @@ -11,6 +11,7 @@ import ( "fmt" "os" "path/filepath" + "slices" "time" "github.com/magefile/mage/sh" @@ -33,16 +34,6 @@ import ( _ "github.com/elastic/beats/v7/dev-tools/mage/target/test" ) -// beats are the beats the agentbeat combines -var beats = []string{ - "auditbeat", - "filebeat", - "heartbeat", - "metricbeat", - "osquerybeat", - "packetbeat", -} - func init() { common.RegisterCheckDeps(Update) @@ -78,12 +69,15 @@ func BuildSystemTestBinary() error { // GolangCrossBuild build the Beat binary inside of the golang-builder. // Do not use directly, use crossBuild instead. func GolangCrossBuild() error { - if err := xpacketbeat.CopyNPCAPInstaller("../packetbeat/npcap/installer/"); err != nil { - return err + args := devtools.DefaultGolangCrossBuildArgs() + if slices.Contains(getIncludedBeats(), "packetbeat") { + if err := xpacketbeat.CopyNPCAPInstaller("../packetbeat/npcap/installer/"); err != nil { + return err + } + // need packetbeat build arguments as it address the requirements for libpcap + args = packetbeat.GolangCrossBuildArgs() } - // need packetbeat build arguments as it address the requirements for libpcap - args := packetbeat.GolangCrossBuildArgs() args.ExtraFlags = append(args.ExtraFlags, "-tags=agentbeat") return multierr.Combine( @@ -94,9 +88,12 @@ func GolangCrossBuild() error { // CrossBuild cross-builds the beat for all target platforms. func CrossBuild() error { - return devtools.CrossBuild( - devtools.ImageSelector(xpacketbeat.ImageSelector), - ) + if slices.Contains(getIncludedBeats(), "packetbeat") { + return devtools.CrossBuild( + devtools.ImageSelector(xpacketbeat.ImageSelector), + ) + } + return devtools.CrossBuild() } // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single @@ -108,7 +105,11 @@ func AssembleDarwinUniversal() error { // CrossBuildDeps cross-builds the required dependencies. func CrossBuildDeps() error { - return callForBeat("crossBuildExt", "osquerybeat") + if slices.Contains(getIncludedBeats(), "osquerybeat") { + return callForBeat("crossBuildExt", "osquerybeat") + } + + return nil } // PrepareLightModules prepares the module packaging. @@ -130,15 +131,20 @@ func Package() error { // specific packaging just for agentbeat devtools.MustUsePackaging("agentbeat", "x-pack/agentbeat/dev-tools/packaging/packages.yml") - // Add osquery distro binaries, required for the osquerybeat subcommand. - osquerybeat.CustomizePackaging() - // Add metricbeat lightweight modules. if err := metricbeat.CustomizeLightModulesPackaging(); err != nil { return err } - mg.SerialDeps(Update, PrepareLightModules, osquerybeat.FetchOsqueryDistros, CrossBuildDeps, CrossBuild, devtools.Package, TestPackages) + mg.SerialDeps(Update, PrepareLightModules) + + if slices.Contains(getIncludedBeats(), "osquerybeat") { + // Add osquery distro binaries, required for the osquerybeat subcommand. + osquerybeat.CustomizePackaging() + mg.SerialDeps(osquerybeat.FetchOsqueryDistros) + } + + mg.SerialDeps(CrossBuildDeps, CrossBuild, devtools.Package, TestPackages) return nil } @@ -162,7 +168,7 @@ func Update() { } func callForEachBeat(target string) error { - for _, beat := range beats { + for _, beat := range getIncludedBeats() { err := callForBeat(target, beat) if err != nil { return fmt.Errorf("failed to perform mage %s for beat %s: %w", target, beat, err) @@ -205,7 +211,9 @@ func GoIntegTest(ctx context.Context) error { mg.Deps(BuildSystemTestBinary) args := devtools.DefaultGoTestIntegrationFromHostArgs() args.Tags = append(args.Tags, "agentbeat") - args.Packages = append(args.Packages, "../auditbeat/...", "../filebeat/...", "../heartbeat/...", "../osquerybeat/...", "../packetbeat/...") + for _, beat := range getIncludedBeats() { + args.Packages = append(args.Packages, "../"+beat+"/...") + } return devtools.GoIntegTestFromHost(ctx, args) } @@ -216,11 +224,39 @@ func PythonIntegTest(ctx context.Context) error { } func SystemTest(ctx context.Context) error { - mg.SerialDeps(xpacketbeat.GetNpcapInstallerFn("../packetbeat"), Update, devtools.BuildSystemTestBinary) + if slices.Contains(getIncludedBeats(), "packetbeat") { + mg.SerialDeps(xpacketbeat.GetNpcapInstallerFn("../packetbeat"), Update, devtools.BuildSystemTestBinary) - args := devtools.DefaultGoTestIntegrationArgs() - args.Packages = []string{"../packetbeat/tests/system/..."} - args.Tags = append(args.Tags, "agentbeat") + args := devtools.DefaultGoTestIntegrationArgs() + args.Packages = []string{"../packetbeat/tests/system/..."} + args.Tags = append(args.Tags, "agentbeat") + + return devtools.GoTest(ctx, args) + } + return nil +} + +func getIncludedBeats() []string { + // beats are all the beats the agentbeat can combine + includedBeats := []string{ + "auditbeat", + "filebeat", + "heartbeat", + "metricbeat", + "osquerybeat", + "packetbeat", + } + + if devtools.FIPSBuild { + // If a FIPS-compliant version of agentbeat is being built, restrict the list of beats to the fips-compliant ones + fipsCompliantBeats := make([]string, 0, len(includedBeats)) + for _, beat := range includedBeats { + if slices.Contains(devtools.FIPSConfig.Beats, beat) { + fipsCompliantBeats = append(fipsCompliantBeats, beat) + } + } + return fipsCompliantBeats + } - return devtools.GoTest(ctx, args) + return includedBeats } From 37239db8dec90052c013d94b16bdd34208b2810b Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Thu, 27 Feb 2025 13:53:09 +0100 Subject: [PATCH 02/10] Refactor FIPS-compliant main --- x-pack/agentbeat/main.go | 26 +------------ x-pack/agentbeat/prepare_root_command.go | 39 +++++++++++++++++++ x-pack/agentbeat/prepare_root_command_fips.go | 32 +++++++++++++++ 3 files changed, 72 insertions(+), 25 deletions(-) create mode 100644 x-pack/agentbeat/prepare_root_command.go create mode 100644 x-pack/agentbeat/prepare_root_command_fips.go diff --git a/x-pack/agentbeat/main.go b/x-pack/agentbeat/main.go index 44cc6ce33062..a95ceb27e3c8 100644 --- a/x-pack/agentbeat/main.go +++ b/x-pack/agentbeat/main.go @@ -13,13 +13,6 @@ import ( "github.com/elastic/beats/v7/libbeat/cmd" "github.com/spf13/cobra" - - auditbeat "github.com/elastic/beats/v7/x-pack/auditbeat/cmd" - filebeat "github.com/elastic/beats/v7/x-pack/filebeat/cmd" - heartbeat "github.com/elastic/beats/v7/x-pack/heartbeat/cmd" - metricbeat "github.com/elastic/beats/v7/x-pack/metricbeat/cmd" - osquerybeat "github.com/elastic/beats/v7/x-pack/osquerybeat/cmd" - packetbeat "github.com/elastic/beats/v7/x-pack/packetbeat/cmd" ) func main() { @@ -30,24 +23,7 @@ func main() { } func AgentBeat() *cobra.Command { - rootCmd := &cobra.Command{ - Use: "agentbeat", - Short: "Combined beat ran only by the Elastic Agent", - Long: `Combines auditbeat, filebeat, heartbeat, metricbeat, osquerybeat, and packetbeat -into a single agentbeat binary.`, - Example: "agentbeat filebeat run", - } - - rootCmd.AddCommand( - prepareCommand(auditbeat.RootCmd), - prepareCommand(filebeat.Filebeat()), - prepareCommand(heartbeat.RootCmd), - prepareCommand(metricbeat.Initialize()), - prepareCommand(osquerybeat.RootCmd), - prepareCommand(packetbeat.RootCmd), - ) - - return rootCmd + return prepareRootCommand() } func prepareCommand(rootCmd *cmd.BeatsRootCmd) *cobra.Command { diff --git a/x-pack/agentbeat/prepare_root_command.go b/x-pack/agentbeat/prepare_root_command.go new file mode 100644 index 000000000000..a8e230fa1f34 --- /dev/null +++ b/x-pack/agentbeat/prepare_root_command.go @@ -0,0 +1,39 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +//go:build !requirefips + +package main + +import ( + "github.com/spf13/cobra" + + auditbeat "github.com/elastic/beats/v7/x-pack/auditbeat/cmd" + filebeat "github.com/elastic/beats/v7/x-pack/filebeat/cmd" + heartbeat "github.com/elastic/beats/v7/x-pack/heartbeat/cmd" + metricbeat "github.com/elastic/beats/v7/x-pack/metricbeat/cmd" + osquerybeat "github.com/elastic/beats/v7/x-pack/osquerybeat/cmd" + packetbeat "github.com/elastic/beats/v7/x-pack/packetbeat/cmd" +) + +func prepareRootCommand() *cobra.Command { + rootCmd := &cobra.Command{ + Use: "agentbeat", + Short: "Combined beat ran only by the Elastic Agent", + Long: `Combines auditbeat, filebeat, heartbeat, metricbeat, osquerybeat, and packetbeat +into a single agentbeat binary.`, + Example: "agentbeat filebeat run", + } + + rootCmd.AddCommand( + prepareCommand(auditbeat.RootCmd), + prepareCommand(filebeat.Filebeat()), + prepareCommand(heartbeat.RootCmd), + prepareCommand(metricbeat.Initialize()), + prepareCommand(osquerybeat.RootCmd), + prepareCommand(packetbeat.RootCmd), + ) + + return rootCmd +} diff --git a/x-pack/agentbeat/prepare_root_command_fips.go b/x-pack/agentbeat/prepare_root_command_fips.go new file mode 100644 index 000000000000..31bdeffd8728 --- /dev/null +++ b/x-pack/agentbeat/prepare_root_command_fips.go @@ -0,0 +1,32 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +//go:build requirefips + +package main + +import ( + "github.com/spf13/cobra" + + auditbeat "github.com/elastic/beats/v7/x-pack/auditbeat/cmd" + filebeat "github.com/elastic/beats/v7/x-pack/filebeat/cmd" + metricbeat "github.com/elastic/beats/v7/x-pack/metricbeat/cmd" +) + +func prepareRootCommand() *cobra.Command { + rootCmd := &cobra.Command{ + Use: "agentbeat", + Short: "Combined beat ran only by the Elastic Agent", + Long: `Combines auditbeat, filebeat and metricbeat +into a single agentbeat binary.`, + Example: "agentbeat filebeat run", + } + rootCmd.AddCommand( + prepareCommand(auditbeat.RootCmd), + prepareCommand(filebeat.Filebeat()), + prepareCommand(metricbeat.Initialize()), + ) + + return rootCmd +} From 8899a54422ef75d19bea6269e15c601dce9da69f Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Thu, 27 Feb 2025 17:24:28 +0100 Subject: [PATCH 03/10] fixup! Refactor FIPS-compliant main --- dev-tools/mage/settings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-tools/mage/settings.go b/dev-tools/mage/settings.go index 748a0fee884e..054a45d19daa 100644 --- a/dev-tools/mage/settings.go +++ b/dev-tools/mage/settings.go @@ -34,7 +34,7 @@ import ( "github.com/magefile/mage/sh" "golang.org/x/text/cases" "golang.org/x/text/language" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" "github.com/elastic/beats/v7/dev-tools/mage/gotool" ) From c19581913ed2e70e3e607b6ece05f023d60daec1 Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Fri, 28 Feb 2025 09:15:19 +0100 Subject: [PATCH 04/10] Log what beats are being packaged within agentbeat --- x-pack/agentbeat/magefile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/agentbeat/magefile.go b/x-pack/agentbeat/magefile.go index 9530111a644c..62a186d7ea53 100644 --- a/x-pack/agentbeat/magefile.go +++ b/x-pack/agentbeat/magefile.go @@ -127,7 +127,7 @@ func PrepareLightModules() error { func Package() error { start := time.Now() defer func() { fmt.Println("package ran for", time.Since(start)) }() - + fmt.Printf(">> Packaging agentbeat that includes %v\n", getIncludedBeats()) // specific packaging just for agentbeat devtools.MustUsePackaging("agentbeat", "x-pack/agentbeat/dev-tools/packaging/packages.yml") From 7f51d3407d0469276dec8e1056b462a3ade34ca1 Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Thu, 6 Mar 2025 11:16:03 +0100 Subject: [PATCH 05/10] fix go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1d2156b98d39..efebf01f85e0 100644 --- a/go.mod +++ b/go.mod @@ -231,6 +231,7 @@ require ( golang.org/x/term v0.29.0 google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 gopkg.in/natefinch/lumberjack.v2 v2.2.1 + gopkg.in/yaml.v3 v3.0.1 ) require ( @@ -463,7 +464,6 @@ require ( golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect gonum.org/v1/gonum v0.15.1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect From db8860f2e9bce8594100f6608663575c0ef55d70 Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Fri, 7 Mar 2025 08:45:11 +0100 Subject: [PATCH 06/10] Add placeholders in fips settings yaml --- dev-tools/mage/fips-settings.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dev-tools/mage/fips-settings.yaml b/dev-tools/mage/fips-settings.yaml index 9e84eb2b3fb3..d7b6369494ef 100644 --- a/dev-tools/mage/fips-settings.yaml +++ b/dev-tools/mage/fips-settings.yaml @@ -4,4 +4,8 @@ beats: - auditbeat - cloudbeat - filebeat - - metricbeat \ No newline at end of file + - metricbeat +compile: + # placeholder for compiler settings +package: + # placeholder for global packaging settings \ No newline at end of file From 132958c011e8ba9c36e5898e6092d2a40fa0848f Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Fri, 7 Mar 2025 08:56:07 +0100 Subject: [PATCH 07/10] make notice --- NOTICE.txt | 120 ++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index e421f53385e0..d104edada3a8 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -28349,6 +28349,66 @@ Contents of probable licence file $GOMODCACHE/gopkg.in/yaml.v2@v2.4.0/LICENSE: limitations under the License. +-------------------------------------------------------------------------------- +Dependency : gopkg.in/yaml.v3 +Version: v3.0.1 +Licence type (autodetected): MIT +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/gopkg.in/yaml.v3@v3.0.1/LICENSE: + + +This project is covered by two different licenses: MIT and Apache. + +#### MIT License #### + +The following files were ported to Go from C files of libyaml, and thus +are still covered by their original MIT license, with the additional +copyright staring in 2011 when the project was ported over: + + apic.go emitterc.go parserc.go readerc.go scannerc.go + writerc.go yamlh.go yamlprivateh.go + +Copyright (c) 2006-2010 Kirill Simonov +Copyright (c) 2006-2011 Kirill Simonov + +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. + +### Apache License ### + +All the remaining project files are covered by the Apache license: + +Copyright (c) 2011-2019 Canonical Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + -------------------------------------------------------------------------------- Dependency : gotest.tools/gotestsum Version: v1.7.0 @@ -73878,66 +73938,6 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Dependency : gopkg.in/yaml.v3 -Version: v3.0.1 -Licence type (autodetected): MIT --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/gopkg.in/yaml.v3@v3.0.1/LICENSE: - - -This project is covered by two different licenses: MIT and Apache. - -#### MIT License #### - -The following files were ported to Go from C files of libyaml, and thus -are still covered by their original MIT license, with the additional -copyright staring in 2011 when the project was ported over: - - apic.go emitterc.go parserc.go readerc.go scannerc.go - writerc.go yamlh.go yamlprivateh.go - -Copyright (c) 2006-2010 Kirill Simonov -Copyright (c) 2006-2011 Kirill Simonov - -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. - -### Apache License ### - -All the remaining project files are covered by the Apache license: - -Copyright (c) 2011-2019 Canonical Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - -------------------------------------------------------------------------------- Dependency : gotest.tools/v3 Version: v3.5.1 From 1ea86921584e2017adcb35817e54fc631d313970 Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Fri, 7 Mar 2025 12:12:17 +0100 Subject: [PATCH 08/10] Skip metricbeat integration tests for agentbeat --- x-pack/agentbeat/magefile.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/agentbeat/magefile.go b/x-pack/agentbeat/magefile.go index 62a186d7ea53..87dfc0ac9aaa 100644 --- a/x-pack/agentbeat/magefile.go +++ b/x-pack/agentbeat/magefile.go @@ -212,7 +212,11 @@ func GoIntegTest(ctx context.Context) error { args := devtools.DefaultGoTestIntegrationFromHostArgs() args.Tags = append(args.Tags, "agentbeat") for _, beat := range getIncludedBeats() { - args.Packages = append(args.Packages, "../"+beat+"/...") + // original code never included metricbeat integration tests, see + // https://github.com/elastic/beats/blob/873743b78a16c16eb74fd0e3ac538769e63acfab/x-pack/agentbeat/magefile.go#L208 + if beat != "metricbeat" { + args.Packages = append(args.Packages, "../"+beat+"/...") + } } return devtools.GoIntegTestFromHost(ctx, args) } From e40558b58edad9a0d82752d03f68601b573c8a07 Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Fri, 7 Mar 2025 12:12:56 +0100 Subject: [PATCH 09/10] Fix linter false positive --- dev-tools/mage/settings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-tools/mage/settings.go b/dev-tools/mage/settings.go index 054a45d19daa..66cf6962231c 100644 --- a/dev-tools/mage/settings.go +++ b/dev-tools/mage/settings.go @@ -477,7 +477,7 @@ func getBuildVariableSources() *BuildVariableSources { panic(fmt.Errorf("magefile must call devtools.SetBuildVariableSources() "+ "because it is not an elastic beat (repo=%+v)", repo.RootImportPath)) -} +} //nolint:typecheck // typecheck linter complains about missing return here, however this is unreachable code with the panic() above // BuildVariableSources is used to explicitly define what files contain build // variables and how to parse the values from that file. This removes ambiguity From 40525e0b3ea512b5db25899fd52df66b9bc490fe Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Tue, 11 Mar 2025 07:43:24 +0100 Subject: [PATCH 10/10] Add details about skipping metribeat integration tests --- x-pack/agentbeat/magefile.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/agentbeat/magefile.go b/x-pack/agentbeat/magefile.go index 87dfc0ac9aaa..141ddcea6001 100644 --- a/x-pack/agentbeat/magefile.go +++ b/x-pack/agentbeat/magefile.go @@ -212,8 +212,8 @@ func GoIntegTest(ctx context.Context) error { args := devtools.DefaultGoTestIntegrationFromHostArgs() args.Tags = append(args.Tags, "agentbeat") for _, beat := range getIncludedBeats() { - // original code never included metricbeat integration tests, see - // https://github.com/elastic/beats/blob/873743b78a16c16eb74fd0e3ac538769e63acfab/x-pack/agentbeat/magefile.go#L208 + // matricbeat integration test TestIndexTotalFieldsLimitNotReached fails with + // `unable to find file "../../metricbeat.test"` error when invoked from agentbeat, skip it if beat != "metricbeat" { args.Packages = append(args.Packages, "../"+beat+"/...") }