diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 78f9b3a110ea6..6d75876625030 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -238,6 +238,7 @@ /cmd/system-probe/windows_resources/ @DataDog/windows-kernel-integrations /cmd/system-probe/main_windows*.go @DataDog/windows-kernel-integrations /cmd/system-probe/api/client/client_windows.go @DataDog/windows-kernel-integrations +/cmd/system-probe/api/server/listener_windows.go @DataDog/windows-kernel-integrations /cmd/systray/ @DataDog/windows-agent /cmd/security-agent/ @DataDog/agent-security /cmd/installer/ @DataDog/fleet @DataDog/windows-agent @@ -487,7 +488,6 @@ /pkg/process/monitor/ @DataDog/universal-service-monitoring /pkg/process/net/ @DataDog/universal-service-monitoring @DataDog/Networks /pkg/process/net/common_windows.go @DataDog/windows-agent -/pkg/process/net/windows_pipe.go @DataDog/windows-kernel-integrations /pkg/proto/datadog/remoteconfig/ @DataDog/remote-config /pkg/proto/pbgo/ # do not notify anyone /pkg/proto/pbgo/trace @DataDog/agent-apm diff --git a/.gitlab/package_build/linux.yml b/.gitlab/package_build/linux.yml index 5dd7698bb2eda..6528757b0ad2c 100644 --- a/.gitlab/package_build/linux.yml +++ b/.gitlab/package_build/linux.yml @@ -37,34 +37,23 @@ .agent_build_x86: image: registry.ddbuild.io/ci/datadog-agent-buildimages/linux-glibc-2-17-x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES tags: ["arch:amd64"] - needs: - [ - "go_mod_tidy_check", - "build_system-probe-x64", - "go_deps", - "generate_minimized_btfs_x64", - ] + needs: ["build_system-probe-x64", "go_deps", "generate_minimized_btfs_x64"] variables: PACKAGE_ARCH: amd64 - DD_CC: 'x86_64-unknown-linux-gnu-gcc' - DD_CXX: 'x86_64-unknown-linux-gnu-g++' - DD_CMAKE_TOOLCHAIN: '/opt/cmake/x86_64-unknown-linux-gnu.toolchain.cmake' + DD_CC: "x86_64-unknown-linux-gnu-gcc" + DD_CXX: "x86_64-unknown-linux-gnu-g++" + DD_CMAKE_TOOLCHAIN: "/opt/cmake/x86_64-unknown-linux-gnu.toolchain.cmake" .agent_build_arm64: image: registry.ddbuild.io/ci/datadog-agent-buildimages/linux-glibc-2-23-arm64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES tags: ["arch:arm64"] needs: - [ - "go_mod_tidy_check", - "build_system-probe-arm64", - "go_deps", - "generate_minimized_btfs_arm64", - ] + ["build_system-probe-arm64", "go_deps", "generate_minimized_btfs_arm64"] variables: PACKAGE_ARCH: arm64 - DD_CC: 'aarch64-unknown-linux-gnu-gcc' - DD_CXX: 'aarch64-unknown-linux-gnu-g++' - DD_CMAKE_TOOLCHAIN: '/opt/cmake/aarch64-unknown-linux-gnu.toolchain.cmake' + DD_CC: "aarch64-unknown-linux-gnu-gcc" + DD_CXX: "aarch64-unknown-linux-gnu-g++" + DD_CMAKE_TOOLCHAIN: "/opt/cmake/aarch64-unknown-linux-gnu.toolchain.cmake" .agent_7_build: variables: @@ -116,16 +105,16 @@ iot-agent-x64: tags: ["arch:amd64"] image: registry.ddbuild.io/ci/datadog-agent-buildimages/linux-glibc-2-17-x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES variables: - DD_CC: 'x86_64-unknown-linux-gnu-gcc' - DD_CXX: 'x86_64-unknown-linux-gnu-g++' + DD_CC: "x86_64-unknown-linux-gnu-gcc" + DD_CXX: "x86_64-unknown-linux-gnu-g++" iot-agent-arm64: extends: .iot-agent-common tags: ["arch:arm64"] image: registry.ddbuild.io/ci/datadog-agent-buildimages/linux-glibc-2-23-arm64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES variables: - DD_CC: 'aarch64-unknown-linux-gnu-gcc' - DD_CXX: 'aarch64-unknown-linux-gnu-g++' + DD_CC: "aarch64-unknown-linux-gnu-gcc" + DD_CXX: "aarch64-unknown-linux-gnu-g++" iot-agent-armhf: extends: .iot-agent-common @@ -169,8 +158,8 @@ dogstatsd-x64: image: registry.ddbuild.io/ci/datadog-agent-buildimages/linux-glibc-2-17-x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES tags: ["arch:amd64"] variables: - DD_CC: 'x86_64-unknown-linux-gnu-gcc' - DD_CXX: 'x86_64-unknown-linux-gnu-g++' + DD_CC: "x86_64-unknown-linux-gnu-gcc" + DD_CXX: "x86_64-unknown-linux-gnu-g++" dogstatsd-arm64: extends: .dogstatsd_build_common @@ -178,6 +167,5 @@ dogstatsd-arm64: tags: ["arch:arm64"] needs: ["go_mod_tidy_check", "build_dogstatsd-binary_arm64", "go_deps"] variables: - DD_CC: 'aarch64-unknown-linux-gnu-gcc' - DD_CXX: 'aarch64-unknown-linux-gnu-g++' - + DD_CC: "aarch64-unknown-linux-gnu-gcc" + DD_CXX: "aarch64-unknown-linux-gnu-g++" diff --git a/cmd/agent/subcommands/flare/command_windows_test.go b/cmd/agent/subcommands/flare/command_windows_test.go index e2c52154f7c61..930860a424b90 100644 --- a/cmd/agent/subcommands/flare/command_windows_test.go +++ b/cmd/agent/subcommands/flare/command_windows_test.go @@ -15,8 +15,8 @@ import ( "github.com/stretchr/testify/require" + sysprobeserver "github.com/DataDog/datadog-agent/cmd/system-probe/api/server" "github.com/DataDog/datadog-agent/pkg/config/model" - processNet "github.com/DataDog/datadog-agent/pkg/process/net" ) const ( @@ -32,12 +32,12 @@ func sysprobeSocketPath(_ *testing.T) string { func NewSystemProbeTestServer(handler http.Handler) (*httptest.Server, error) { server := httptest.NewUnstartedServer(handler) - conn, err := processNet.NewSystemProbeListener(systemProbeTestPipeName) + conn, err := sysprobeserver.NewListener(systemProbeTestPipeName) if err != nil { return nil, err } - server.Listener = conn.GetListener() + server.Listener = conn return server, nil } diff --git a/cmd/cluster-agent/subcommands/start/command_test.go b/cmd/cluster-agent/subcommands/start/command_test.go index a620fa0d9a10f..f312c3b98cf78 100644 --- a/cmd/cluster-agent/subcommands/start/command_test.go +++ b/cmd/cluster-agent/subcommands/start/command_test.go @@ -3,7 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -//go:build !windows && kubeapiserver +//go:build !darwin && !windows && kubeapiserver package start diff --git a/cmd/system-probe/api/client/client.go b/cmd/system-probe/api/client/client.go index 4cfc13909aaf2..27093eab890c6 100644 --- a/cmd/system-probe/api/client/client.go +++ b/cmd/system-probe/api/client/client.go @@ -7,10 +7,16 @@ package client import ( + "encoding/json" "errors" + "fmt" + "io" "net/http" + "net/url" + "strings" "time" + "github.com/DataDog/datadog-agent/cmd/system-probe/config/types" "github.com/DataDog/datadog-agent/pkg/util/funcs" ) @@ -35,3 +41,47 @@ func get(socketPath string) *http.Client { }, } } + +// GetCheck returns data unmarshalled from JSON to T, from the specified module at the //check endpoint. +func GetCheck[T any](client *http.Client, module types.ModuleName) (T, error) { + var data T + req, err := http.NewRequest("GET", ModuleURL(module, "/check"), nil) + if err != nil { + return data, err + } + + resp, err := client.Do(req) + if err != nil { + return data, err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return data, err + } + if resp.StatusCode != http.StatusOK { + return data, fmt.Errorf("non-ok status code: url %s, status_code: %d, response: `%s`", req.URL, resp.StatusCode, string(body)) + } + + err = json.Unmarshal(body, &data) + return data, err +} + +func constructURL(module string, endpoint string) string { + u, _ := url.Parse("http://sysprobe") + if module != "" { + u = u.JoinPath(module) + } + path, query, found := strings.Cut(endpoint, "?") + u = u.JoinPath(path) + if found { + u.RawQuery = query + } + return u.String() +} + +// ModuleURL constructs a system-probe ModuleURL given the specified module and endpoint. +func ModuleURL(module types.ModuleName, endpoint string) string { + return constructURL(string(module), endpoint) +} diff --git a/cmd/system-probe/api/client/client_test.go b/cmd/system-probe/api/client/client_test.go new file mode 100644 index 0000000000000..d67af13e795af --- /dev/null +++ b/cmd/system-probe/api/client/client_test.go @@ -0,0 +1,53 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024-present Datadog, Inc. + +package client + +import ( + "context" + "net" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestConstructURL(t *testing.T) { + u := constructURL("", "/asdf?a=b") + assert.Equal(t, "http://sysprobe/asdf?a=b", u) + + u = constructURL("zzzz", "/asdf?a=b") + assert.Equal(t, "http://sysprobe/zzzz/asdf?a=b", u) + + u = constructURL("zzzz", "asdf") + assert.Equal(t, "http://sysprobe/zzzz/asdf", u) +} + +func TestGetCheck(t *testing.T) { + type testData struct { + Str string + Num int + } + + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/test/check" { + _, _ = w.Write([]byte(`{"Str": "asdf", "Num": 42}`)) + } else { + w.WriteHeader(http.StatusNotFound) + } + })) + t.Cleanup(server.Close) + + client := &http.Client{Transport: &http.Transport{DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { + return net.Dial("tcp", server.Listener.Addr().String()) + }}} + + resp, err := GetCheck[testData](client, "test") + require.NoError(t, err) + assert.Equal(t, "asdf", resp.Str) + assert.Equal(t, 42, resp.Num) +} diff --git a/cmd/system-probe/api/server.go b/cmd/system-probe/api/server.go index 5c6c31df8beab..1e4249eeb50ab 100644 --- a/cmd/system-probe/api/server.go +++ b/cmd/system-probe/api/server.go @@ -16,6 +16,7 @@ import ( gorilla "github.com/gorilla/mux" "github.com/DataDog/datadog-agent/cmd/system-probe/api/module" + "github.com/DataDog/datadog-agent/cmd/system-probe/api/server" sysconfigtypes "github.com/DataDog/datadog-agent/cmd/system-probe/config/types" "github.com/DataDog/datadog-agent/cmd/system-probe/modules" "github.com/DataDog/datadog-agent/cmd/system-probe/utils" @@ -23,13 +24,12 @@ import ( "github.com/DataDog/datadog-agent/comp/core/telemetry" workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def" "github.com/DataDog/datadog-agent/pkg/ebpf" - "github.com/DataDog/datadog-agent/pkg/process/net" "github.com/DataDog/datadog-agent/pkg/util/log" ) // StartServer starts the HTTP and gRPC servers for the system-probe, which registers endpoints from all enabled modules. func StartServer(cfg *sysconfigtypes.Config, telemetry telemetry.Component, wmeta workloadmeta.Component, settings settings.Component) error { - conn, err := net.NewSystemProbeListener(cfg.SocketAddress) + conn, err := server.NewListener(cfg.SocketAddress) if err != nil { return err } @@ -60,7 +60,7 @@ func StartServer(cfg *sysconfigtypes.Config, telemetry telemetry.Component, wmet } go func() { - err = http.Serve(conn.GetListener(), mux) + err = http.Serve(conn, mux) if err != nil && !errors.Is(err, http.ErrServerClosed) { log.Errorf("error creating HTTP server: %s", err) } diff --git a/cmd/system-probe/api/server/listener.go b/cmd/system-probe/api/server/listener.go new file mode 100644 index 0000000000000..615483c6f6f7f --- /dev/null +++ b/cmd/system-probe/api/server/listener.go @@ -0,0 +1,14 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024-present Datadog, Inc. + +// Package server contains system-probe API server functionality +package server + +import "errors" + +var ( + // ErrNotImplemented is an error used when system-probe is attempted to be accessed on an unsupported OS + ErrNotImplemented = errors.New("system-probe unsupported") +) diff --git a/cmd/system-probe/api/server/listener_others.go b/cmd/system-probe/api/server/listener_others.go new file mode 100644 index 0000000000000..80f4e62c6dffe --- /dev/null +++ b/cmd/system-probe/api/server/listener_others.go @@ -0,0 +1,15 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024-present Datadog, Inc. + +//go:build !unix && !windows + +package server + +import "net" + +// NewListener is not supported +func NewListener(_ string) (net.Listener, error) { + return nil, ErrNotImplemented +} diff --git a/cmd/system-probe/api/server/listener_unix.go b/cmd/system-probe/api/server/listener_unix.go new file mode 100644 index 0000000000000..fc589ab99d62c --- /dev/null +++ b/cmd/system-probe/api/server/listener_unix.go @@ -0,0 +1,59 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024-present Datadog, Inc. + +//go:build unix + +package server + +import ( + "errors" + "fmt" + "net" + "os" + + "github.com/DataDog/datadog-agent/pkg/util/filesystem" + "github.com/DataDog/datadog-agent/pkg/util/log" +) + +// NewListener creates a Unix Domain Socket Listener +func NewListener(socketAddr string) (net.Listener, error) { + if len(socketAddr) == 0 { + return nil, errors.New("uds: empty socket path provided") + } + + // Check to see if there's a pre-existing system probe socket. + fileInfo, err := os.Stat(socketAddr) + if err == nil { // No error means the socket file already exists + // If it's not a UNIX socket, then this is a problem. + if fileInfo.Mode()&os.ModeSocket == 0 { + return nil, fmt.Errorf("uds: reuse %s socket path: path already exists and it is not a UNIX socket", socketAddr) + } + // Attempt to remove the pre-existing socket + if err = os.Remove(socketAddr); err != nil { + return nil, fmt.Errorf("uds: remove stale UNIX socket: %v", err) + } + } + + conn, err := net.Listen("unix", socketAddr) + if err != nil { + return nil, fmt.Errorf("listen: %s", err) + } + + if err := os.Chmod(socketAddr, 0720); err != nil { + return nil, fmt.Errorf("socket chmod write-only: %s", err) + } + + perms, err := filesystem.NewPermission() + if err != nil { + return nil, err + } + + if err := perms.RestrictAccessToUser(socketAddr); err != nil { + return nil, err + } + + log.Debugf("uds: %s successfully initialized", conn.Addr()) + return conn, nil +} diff --git a/pkg/process/net/uds_test.go b/cmd/system-probe/api/server/listener_unix_test.go similarity index 54% rename from pkg/process/net/uds_test.go rename to cmd/system-probe/api/server/listener_unix_test.go index 51affd4815d5f..7c7045212f34b 100644 --- a/pkg/process/net/uds_test.go +++ b/cmd/system-probe/api/server/listener_unix_test.go @@ -1,11 +1,11 @@ // Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2016-present Datadog, Inc. +// Copyright 2024-present Datadog, Inc. -//go:build linux +//go:build unix -package net +package server import ( "net" @@ -19,36 +19,32 @@ import ( func testSocketExistsNewUDSListener(t *testing.T, socketPath string) { // Pre-create a socket - addr, err := net.ResolveUnixAddr("unix", socketPath) - assert.NoError(t, err) - _, err = net.Listen("unix", addr.Name) - assert.NoError(t, err) + _, err := net.Listen("unix", socketPath) + require.NoError(t, err) // Create a new socket using UDSListener - l, err := NewSystemProbeListener(socketPath) + l, err := NewListener(socketPath) require.NoError(t, err) - - l.Stop() + _ = l.Close() } func testSocketExistsAsRegularFileNewUDSListener(t *testing.T, socketPath string) { // Pre-create a file f, err := os.OpenFile(socketPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) - assert.NoError(t, err) + require.NoError(t, err) defer f.Close() // Create a new socket using UDSListener - _, err = NewSystemProbeListener(socketPath) + _, err = NewListener(socketPath) require.Error(t, err) } func testWorkingNewUDSListener(t *testing.T, socketPath string) { - s, err := NewSystemProbeListener(socketPath) + s, err := NewListener(socketPath) require.NoError(t, err) - defer s.Stop() + require.NotNil(t, s) + defer s.Close() - assert.NoError(t, err) - assert.NotNil(t, s) time.Sleep(1 * time.Second) fi, err := os.Stat(socketPath) require.NoError(t, err) @@ -56,18 +52,13 @@ func testWorkingNewUDSListener(t *testing.T, socketPath string) { } func TestNewUDSListener(t *testing.T) { - t.Run("socket_exists_but_is_successfully_removed", func(tt *testing.T) { - dir := t.TempDir() - testSocketExistsNewUDSListener(tt, dir+"/net.sock") + t.Run("socket exists", func(t *testing.T) { + testSocketExistsNewUDSListener(t, t.TempDir()+"/net.sock") }) - - t.Run("non_socket_exists_and_fails_to_be_removed", func(tt *testing.T) { - dir := t.TempDir() - testSocketExistsAsRegularFileNewUDSListener(tt, dir+"/net.sock") + t.Run("non socket exists", func(t *testing.T) { + testSocketExistsAsRegularFileNewUDSListener(t, t.TempDir()+"/net.sock") }) - - t.Run("working", func(tt *testing.T) { - dir := t.TempDir() - testWorkingNewUDSListener(tt, dir+"/net.sock") + t.Run("working", func(t *testing.T) { + testWorkingNewUDSListener(t, t.TempDir()+"/net.sock") }) } diff --git a/cmd/system-probe/api/server/listener_windows.go b/cmd/system-probe/api/server/listener_windows.go new file mode 100644 index 0000000000000..d4e13d58c80f7 --- /dev/null +++ b/cmd/system-probe/api/server/listener_windows.go @@ -0,0 +1,45 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024-present Datadog, Inc. + +package server + +import ( + "fmt" + "net" + + "github.com/Microsoft/go-winio" +) + +const ( + // Buffer sizes for the system probe named pipe. + // The sizes are advisory, Windows can adjust them, but should be small enough to preserve + // the non-paged pool. + namedPipeInputBufferSize = int32(4096) + namedPipeOutputBufferSize = int32(4096) + + // DACL for the system probe named pipe. + // SE_DACL_PROTECTED (P), SE_DACL_AUTO_INHERITED (AI) + // Allow Everyone (WD) + // nolint:revive // TODO: Hardened DACL and ensure the datadogagent run-as user is allowed. + namedPipeSecurityDescriptor = "D:PAI(A;;FA;;;WD)" +) + +// NewListener sets up a named pipe listener for the system probe service. +func NewListener(namedPipeName string) (net.Listener, error) { + // The DACL must allow the run-as user of datadogagent. + config := winio.PipeConfig{ + SecurityDescriptor: namedPipeSecurityDescriptor, + InputBufferSize: namedPipeInputBufferSize, + OutputBufferSize: namedPipeOutputBufferSize, + } + + // winio specifies virtually unlimited number of named pipe instances but is limited by + // the nonpaged pool. + namedPipe, err := winio.ListenPipe(namedPipeName, &config) + if err != nil { + return nil, fmt.Errorf("named pipe listener %q: %s", namedPipeName, err) + } + return namedPipe, nil +} diff --git a/comp/api/authtoken/go.mod b/comp/api/authtoken/go.mod index e0489f7f56c79..366648b435876 100644 --- a/comp/api/authtoken/go.mod +++ b/comp/api/authtoken/go.mod @@ -19,6 +19,7 @@ replace ( github.com/DataDog/datadog-agent/pkg/config/model => ../../../pkg/config/model github.com/DataDog/datadog-agent/pkg/config/nodetreemodel => ../../../pkg/config/nodetreemodel github.com/DataDog/datadog-agent/pkg/config/setup => ../../../pkg/config/setup + github.com/DataDog/datadog-agent/pkg/config/structure => ../../../pkg/config/structure github.com/DataDog/datadog-agent/pkg/config/teeconfig => ../../../pkg/config/teeconfig github.com/DataDog/datadog-agent/pkg/config/utils => ../../../pkg/config/utils github.com/DataDog/datadog-agent/pkg/util/defaultpaths => ../../../pkg/util/defaultpaths @@ -45,7 +46,7 @@ require ( github.com/DataDog/datadog-agent/comp/core/log/mock v0.58.0-devel github.com/DataDog/datadog-agent/pkg/api v0.56.0 github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0 - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 github.com/stretchr/testify v1.9.0 go.uber.org/fx v1.22.2 ) @@ -53,26 +54,27 @@ require ( require ( github.com/DataDog/datadog-agent/comp/core/flare/builder v0.56.0 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.56.0 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/log/setup v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/comp/forwarder/defaultforwarder/go.mod b/comp/forwarder/defaultforwarder/go.mod index 95c90138fe6b9..f6ff557ad4a8b 100644 --- a/comp/forwarder/defaultforwarder/go.mod +++ b/comp/forwarder/defaultforwarder/go.mod @@ -21,6 +21,7 @@ replace ( github.com/DataDog/datadog-agent/pkg/config/model => ../../../pkg/config/model github.com/DataDog/datadog-agent/pkg/config/nodetreemodel => ../../../pkg/config/nodetreemodel github.com/DataDog/datadog-agent/pkg/config/setup => ../../../pkg/config/setup + github.com/DataDog/datadog-agent/pkg/config/structure => ../../../pkg/config/structure github.com/DataDog/datadog-agent/pkg/config/teeconfig => ../../../pkg/config/teeconfig github.com/DataDog/datadog-agent/pkg/config/utils => ../../../pkg/config/utils github.com/DataDog/datadog-agent/pkg/obfuscate => ../../../pkg/obfuscate @@ -57,20 +58,20 @@ require ( github.com/DataDog/datadog-agent/comp/core/log/mock v0.0.0-00010101000000-000000000000 github.com/DataDog/datadog-agent/comp/core/status v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/api v0.57.1 - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 github.com/DataDog/datadog-agent/pkg/config/utils v0.57.1 github.com/DataDog/datadog-agent/pkg/orchestrator/model v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/status/health v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/common v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 github.com/DataDog/datadog-agent/pkg/util/fxutil v0.57.1 github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 github.com/DataDog/datadog-agent/pkg/version v0.57.1 github.com/golang/protobuf v1.5.3 github.com/hashicorp/go-multierror v1.1.1 @@ -83,21 +84,22 @@ require ( require ( github.com/DataDog/datadog-agent/comp/core/flare/builder v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.57.1 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/log/setup v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/comp/forwarder/orchestrator/orchestratorinterface/go.mod b/comp/forwarder/orchestrator/orchestratorinterface/go.mod index 8061abb3cdc0f..f2baa85f6fe88 100644 --- a/comp/forwarder/orchestrator/orchestratorinterface/go.mod +++ b/comp/forwarder/orchestrator/orchestratorinterface/go.mod @@ -22,6 +22,7 @@ replace ( github.com/DataDog/datadog-agent/pkg/config/model => ../../../../pkg/config/model github.com/DataDog/datadog-agent/pkg/config/nodetreemodel => ../../../../pkg/config/nodetreemodel github.com/DataDog/datadog-agent/pkg/config/setup => ../../../../pkg/config/setup + github.com/DataDog/datadog-agent/pkg/config/structure => ../../../../pkg/config/structure github.com/DataDog/datadog-agent/pkg/config/teeconfig => ../../../../pkg/config/teeconfig github.com/DataDog/datadog-agent/pkg/config/utils => ../../../../pkg/config/utils github.com/DataDog/datadog-agent/pkg/obfuscate => ../../../../pkg/obfuscate @@ -69,17 +70,18 @@ require ( github.com/DataDog/datadog-agent/comp/core/flare/builder v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/log/def v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/status v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/api v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/orchestrator/model v0.56.0-rc.3 // indirect @@ -87,18 +89,18 @@ require ( github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/common v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.57.1 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/comp/logs/agent/config/go.mod b/comp/logs/agent/config/go.mod index c0e125cf99fcb..db73485ea4ca4 100644 --- a/comp/logs/agent/config/go.mod +++ b/comp/logs/agent/config/go.mod @@ -38,13 +38,13 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/core/config v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 github.com/DataDog/viper v1.13.5 github.com/stretchr/testify v1.9.0 go.uber.org/fx v1.22.2 @@ -53,21 +53,21 @@ require ( require ( github.com/DataDog/datadog-agent/comp/core/flare/builder v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect diff --git a/comp/otelcol/ddflareextension/impl/go.mod b/comp/otelcol/ddflareextension/impl/go.mod index ebd7b3b7636e6..7c025399330b9 100644 --- a/comp/otelcol/ddflareextension/impl/go.mod +++ b/comp/otelcol/ddflareextension/impl/go.mod @@ -109,7 +109,7 @@ require ( github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/datadogexporter v0.59.0 github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/processor/infraattributesprocessor v0.59.0 github.com/DataDog/datadog-agent/pkg/api v0.57.1 - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.1 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 github.com/DataDog/datadog-agent/pkg/version v0.58.1 github.com/google/go-cmp v0.6.0 github.com/gorilla/mux v1.8.1 @@ -181,7 +181,7 @@ require ( github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.58.1 // indirect github.com/DataDog/datadog-agent/comp/core/log/def v0.58.1 // indirect github.com/DataDog/datadog-agent/comp/core/log/mock v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.58.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/status v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/tagger/tags v0.0.0-00010101000000-000000000000 // indirect github.com/DataDog/datadog-agent/comp/core/tagger/types v0.59.0 // indirect @@ -202,12 +202,12 @@ require ( github.com/DataDog/datadog-agent/comp/trace/compression/def v0.59.0-rc.6 // indirect github.com/DataDog/datadog-agent/comp/trace/compression/impl-gzip v0.59.0-rc.6 // indirect github.com/DataDog/datadog-agent/pkg/aggregator/ckey v0.59.0-rc.6 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0-rc.6 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.59.0-rc.6 // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.59.0-rc.6 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0-rc.6 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0-rc.6 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.58.1 // indirect github.com/DataDog/datadog-agent/pkg/logs/auditor v0.58.1 // indirect @@ -238,24 +238,24 @@ require ( github.com/DataDog/datadog-agent/pkg/util/buf v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/cgroups v0.58.1 // indirect github.com/DataDog/datadog-agent/pkg/util/common v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.58.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.58.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.58.1 // indirect github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.58.1 // indirect github.com/DataDog/datadog-agent/pkg/util/json v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/log/setup v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.58.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.58.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/sort v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/startstop v0.58.1 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.58.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.58.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.58.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.58.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-api-client-go/v2 v2.31.0 // indirect github.com/DataDog/datadog-go/v5 v5.5.0 // indirect github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect diff --git a/comp/otelcol/logsagentpipeline/go.mod b/comp/otelcol/logsagentpipeline/go.mod index 8a89effaebdc0..7fe6d0865adf0 100644 --- a/comp/otelcol/logsagentpipeline/go.mod +++ b/comp/otelcol/logsagentpipeline/go.mod @@ -65,17 +65,17 @@ require github.com/DataDog/datadog-agent/pkg/logs/pipeline v0.56.0-rc.3 require ( github.com/DataDog/agent-payload/v5 v5.0.106 // indirect github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/auditor v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/client v0.56.0-rc.3 // indirect @@ -91,21 +91,21 @@ require ( github.com/DataDog/datadog-agent/pkg/status/health v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/startstop v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect github.com/DataDog/viper v1.13.5 // indirect diff --git a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod index f1deca77ff94c..ee142226df975 100644 --- a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod +++ b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod @@ -68,8 +68,8 @@ require ( github.com/DataDog/datadog-agent/comp/core/log/mock v0.0.0-00010101000000-000000000000 github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 github.com/DataDog/datadog-agent/pkg/logs/auditor v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/client v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/diagnostic v0.56.0-rc.3 @@ -80,7 +80,7 @@ require ( github.com/DataDog/datadog-agent/pkg/logs/status/statusinterface v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/status/health v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 github.com/DataDog/datadog-agent/pkg/util/startstop v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/testutil v0.56.0-rc.3 github.com/stretchr/testify v1.9.0 @@ -92,14 +92,14 @@ require ( github.com/DataDog/agent-payload/v5 v5.0.106 // indirect github.com/DataDog/datadog-agent/comp/core/flare/builder v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/processor v0.56.0-rc.3 // indirect @@ -108,19 +108,19 @@ require ( github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/log/setup v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect github.com/DataDog/viper v1.13.5 // indirect diff --git a/comp/otelcol/otlp/components/exporter/datadogexporter/go.mod b/comp/otelcol/otlp/components/exporter/datadogexporter/go.mod index a9f6f44ae44a8..5a27d0b0c54e6 100644 --- a/comp/otelcol/otlp/components/exporter/datadogexporter/go.mod +++ b/comp/otelcol/otlp/components/exporter/datadogexporter/go.mod @@ -134,7 +134,7 @@ require ( github.com/DataDog/datadog-agent/comp/core/flare/types v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/log/def v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/status v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/def v0.57.1 // indirect @@ -145,13 +145,13 @@ require ( github.com/DataDog/datadog-agent/comp/trace/compression/def v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/aggregator/ckey v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/api v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/logs/auditor v0.56.0-rc.3 // indirect @@ -178,23 +178,23 @@ require ( github.com/DataDog/datadog-agent/pkg/util/buf v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/cgroups v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/common v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/json v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/sort v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/startstop v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.57.1 // indirect github.com/DataDog/datadog-api-client-go/v2 v2.26.0 // indirect github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect diff --git a/comp/otelcol/otlp/components/exporter/logsagentexporter/go.mod b/comp/otelcol/otlp/components/exporter/logsagentexporter/go.mod index 2e774f0f4fe00..e80f7a5905191 100644 --- a/comp/otelcol/otlp/components/exporter/logsagentexporter/go.mod +++ b/comp/otelcol/otlp/components/exporter/logsagentexporter/go.mod @@ -47,7 +47,7 @@ require ( github.com/DataDog/datadog-agent/comp/otelcol/otlp/testutil v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/message v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.21.0 github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs v0.21.0 github.com/stormcat24/protodep v0.1.8 @@ -64,28 +64,28 @@ require ( ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/proto v0.55.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/datadog-api-client-go/v2 v2.13.0 // indirect github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.21.0 // indirect diff --git a/comp/otelcol/otlp/components/exporter/serializerexporter/go.mod b/comp/otelcol/otlp/components/exporter/serializerexporter/go.mod index 74171b149750e..66e85d1bb086b 100644 --- a/comp/otelcol/otlp/components/exporter/serializerexporter/go.mod +++ b/comp/otelcol/otlp/components/exporter/serializerexporter/go.mod @@ -95,7 +95,7 @@ require ( github.com/DataDog/datadog-agent/comp/core/flare/builder v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/log/def v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/status v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/def v0.57.1 // indirect @@ -104,13 +104,13 @@ require ( github.com/DataDog/datadog-agent/comp/serializer/compression v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/aggregator/ckey v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/api v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/orchestrator/model v0.56.0-rc.3 // indirect @@ -121,19 +121,19 @@ require ( github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/buf v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/common v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/json v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/sort v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.57.1 // indirect github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49 // indirect github.com/DataDog/sketches-go v1.4.4 // indirect diff --git a/comp/trace/config/setup.go b/comp/trace/config/setup.go index fbfa318e30c72..cdb7d6f9c3064 100644 --- a/comp/trace/config/setup.go +++ b/comp/trace/config/setup.go @@ -396,8 +396,9 @@ func applyDatadogConfig(c *config.AgentConfig, core corecompcfg.Component) error } c.Obfuscation = new(config.ObfuscationConfig) if core.IsSet("apm_config.obfuscation") { + cfg := pkgconfigsetup.Datadog() var o config.ObfuscationConfig - err := pkgconfigsetup.Datadog().UnmarshalKey("apm_config.obfuscation", &o) + err := structure.UnmarshalKey(cfg, "apm_config.obfuscation", &o) if err == nil { c.Obfuscation = &o if o.RemoveStackTraces { @@ -536,7 +537,8 @@ func applyDatadogConfig(c *config.AgentConfig, core corecompcfg.Component) error "apm_config.trace_writer": c.TraceWriter, "apm_config.stats_writer": c.StatsWriter, } { - if err := pkgconfigsetup.Datadog().UnmarshalKey(key, cfg); err != nil { + ddcfg := pkgconfigsetup.Datadog() + if err := structure.UnmarshalKey(ddcfg, key, cfg); err != nil { log.Errorf("Error reading writer config %q: %v", key, err) } } @@ -556,7 +558,8 @@ func applyDatadogConfig(c *config.AgentConfig, core corecompcfg.Component) error // undocumented deprecated if core.IsSet("apm_config.analyzed_rate_by_service") { rateByService := make(map[string]float64) - if err := pkgconfigsetup.Datadog().UnmarshalKey("apm_config.analyzed_rate_by_service", &rateByService); err != nil { + cfg := pkgconfigsetup.Datadog() + if err := structure.UnmarshalKey(cfg, "apm_config.analyzed_rate_by_service", &rateByService); err != nil { return err } c.AnalyzedRateByServiceLegacy = rateByService diff --git a/go.mod b/go.mod index a1f0367beeed8..f91e78d06a064 100644 --- a/go.mod +++ b/go.mod @@ -157,7 +157,7 @@ require ( github.com/DataDog/datadog-agent/pkg/trace v0.59.0 github.com/DataDog/datadog-agent/pkg/util/cgroups v0.58.1 github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 - github.com/DataDog/datadog-agent/pkg/util/pointer v0.58.1 + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 github.com/DataDog/datadog-go/v5 v5.5.0 github.com/DataDog/datadog-operator v0.7.1-0.20241024104907-734366f3c0d1 @@ -172,7 +172,7 @@ require ( github.com/DataDog/watermarkpodautoscaler v0.5.3-0.20241023200123-ab786c1724cf github.com/DataDog/zstd v1.5.6 github.com/DataDog/zstd_0 v0.0.0-20210310093942-586c1286621f // indirect - github.com/Masterminds/semver/v3 v3.3.0 + github.com/Masterminds/semver/v3 v3.3.1 github.com/Masterminds/sprig/v3 v3.3.0 // indirect github.com/Microsoft/go-winio v0.6.2 github.com/Microsoft/hcsshim v0.12.9 @@ -642,7 +642,7 @@ require ( github.com/DataDog/datadog-agent/comp/core/log/impl v0.59.0 github.com/DataDog/datadog-agent/comp/core/log/impl-trace v0.59.0 github.com/DataDog/datadog-agent/comp/core/log/mock v0.58.0-devel - github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0-rc.6 + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 github.com/DataDog/datadog-agent/comp/core/status v0.59.0-rc.6 github.com/DataDog/datadog-agent/comp/core/status/statusimpl v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/core/tagger/tags v0.0.0-00010101000000-000000000000 @@ -672,12 +672,12 @@ require ( github.com/DataDog/datadog-agent/comp/trace/compression/impl-zstd v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/aggregator/ckey v0.59.0-rc.6 github.com/DataDog/datadog-agent/pkg/api v0.57.1 - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0-rc.6 - github.com/DataDog/datadog-agent/pkg/config/env v0.59.0-rc.6 - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.1 - github.com/DataDog/datadog-agent/pkg/config/model v0.59.0-rc.6 + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 github.com/DataDog/datadog-agent/pkg/config/remote v0.59.0-rc.5 - github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0-rc.6 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 github.com/DataDog/datadog-agent/pkg/config/utils v0.58.1 github.com/DataDog/datadog-agent/pkg/errors v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/auditor v0.58.1 @@ -707,8 +707,8 @@ require ( github.com/DataDog/datadog-agent/pkg/util/cache v0.59.0-rc.5 github.com/DataDog/datadog-agent/pkg/util/common v0.59.0 github.com/DataDog/datadog-agent/pkg/util/containers/image v0.56.2 - github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0-rc.6 - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0-rc.6 + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 github.com/DataDog/datadog-agent/pkg/util/flavor v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/fxutil v0.59.0 github.com/DataDog/datadog-agent/pkg/util/grpc v0.59.0 @@ -792,7 +792,7 @@ require ( github.com/DataDog/datadog-agent/pkg/logs/status/statusinterface v0.58.1 // indirect github.com/DataDog/datadog-agent/pkg/util/buf v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.58.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.58.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-api-client-go/v2 v2.31.0 // indirect github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata v0.21.0 // indirect diff --git a/go.sum b/go.sum index 2139597acb719..2bae1c0dacf96 100644 --- a/go.sum +++ b/go.sum @@ -204,8 +204,8 @@ github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy86 github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= -github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4= +github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= diff --git a/pkg/api/go.mod b/pkg/api/go.mod index 45bd6d6488659..0b901a2db57b9 100644 --- a/pkg/api/go.mod +++ b/pkg/api/go.mod @@ -17,6 +17,7 @@ replace ( github.com/DataDog/datadog-agent/pkg/config/model => ../config/model github.com/DataDog/datadog-agent/pkg/config/nodetreemodel => ../../pkg/config/nodetreemodel github.com/DataDog/datadog-agent/pkg/config/setup => ../config/setup + github.com/DataDog/datadog-agent/pkg/config/structure => ../../pkg/config/structure github.com/DataDog/datadog-agent/pkg/config/teeconfig => ../../pkg/config/teeconfig github.com/DataDog/datadog-agent/pkg/config/utils => ../config/utils github.com/DataDog/datadog-agent/pkg/telemetry => ../telemetry @@ -38,33 +39,34 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/core/config v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel - github.com/DataDog/datadog-agent/pkg/config/model v0.56.0-rc.3 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 - github.com/DataDog/datadog-agent/pkg/util/system v0.56.0-rc.3 + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 github.com/stretchr/testify v1.9.0 ) require ( github.com/DataDog/datadog-agent/comp/core/flare/builder v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.56.0-rc.3 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/pkg/collector/corechecks/ebpf/ebpf.go b/pkg/collector/corechecks/ebpf/ebpf.go index c7c2eb17d80a4..934cb5bab4f12 100644 --- a/pkg/collector/corechecks/ebpf/ebpf.go +++ b/pkg/collector/corechecks/ebpf/ebpf.go @@ -3,18 +3,20 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -//go:build cgo && linux +//go:build linux // Package ebpf contains all the ebpf-based checks. package ebpf import ( "fmt" + "net/http" "strings" "github.com/cihub/seelog" "gopkg.in/yaml.v2" + sysprobeclient "github.com/DataDog/datadog-agent/cmd/system-probe/api/client" sysconfig "github.com/DataDog/datadog-agent/cmd/system-probe/config" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" @@ -22,7 +24,6 @@ import ( core "github.com/DataDog/datadog-agent/pkg/collector/corechecks" ebpfcheck "github.com/DataDog/datadog-agent/pkg/collector/corechecks/ebpf/probe/ebpfcheck/model" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" - processnet "github.com/DataDog/datadog-agent/pkg/process/net" "github.com/DataDog/datadog-agent/pkg/util/log" "github.com/DataDog/datadog-agent/pkg/util/optional" ) @@ -38,8 +39,8 @@ type EBPFCheckConfig struct { // EBPFCheck grabs eBPF map/program/perf buffer metrics type EBPFCheck struct { - config *EBPFCheckConfig - sysProbeUtil processnet.SysProbeUtil + config *EBPFCheckConfig + sysProbeClient *http.Client core.CheckBase } @@ -68,26 +69,13 @@ func (m *EBPFCheck) Configure(senderManager sender.SenderManager, _ uint64, conf if err := m.config.Parse(config); err != nil { return fmt.Errorf("ebpf check config: %s", err) } - if err := processnet.CheckPath(pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")); err != nil { - return fmt.Errorf("sysprobe socket: %s", err) - } - + m.sysProbeClient = sysprobeclient.Get(pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")) return nil } // Run executes the check func (m *EBPFCheck) Run() error { - if m.sysProbeUtil == nil { - var err error - m.sysProbeUtil, err = processnet.GetRemoteSystemProbeUtil( - pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket"), - ) - if err != nil { - return fmt.Errorf("sysprobe connection: %s", err) - } - } - - data, err := m.sysProbeUtil.GetCheck(sysconfig.EBPFModule) + stats, err := sysprobeclient.GetCheck[ebpfcheck.EBPFStats](m.sysProbeClient, sysconfig.EBPFModule) if err != nil { return fmt.Errorf("get ebpf check: %s", err) } @@ -97,11 +85,6 @@ func (m *EBPFCheck) Run() error { return fmt.Errorf("get metric sender: %s", err) } - stats, ok := data.(ebpfcheck.EBPFStats) - if !ok { - return log.Errorf("ebpf check raw data has incorrect type: %T", stats) - } - totalMapMaxSize, totalMapRSS := uint64(0), uint64(0) moduleTotalMapMaxSize, moduleTotalMapRSS := make(map[string]uint64), make(map[string]uint64) reportBaseMap := func(mapStats ebpfcheck.EBPFMapStats) { diff --git a/pkg/collector/corechecks/ebpf/oomkill/oom_kill.go b/pkg/collector/corechecks/ebpf/oomkill/oom_kill.go index 5120cd59d6968..8f4261d3f4213 100644 --- a/pkg/collector/corechecks/ebpf/oomkill/oom_kill.go +++ b/pkg/collector/corechecks/ebpf/oomkill/oom_kill.go @@ -3,21 +3,19 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -// FIXME: we require the `cgo` build tag because of this dep relationship: -// github.com/DataDog/datadog-agent/pkg/process/net depends on `github.com/DataDog/agent-payload/v5/process`, -// which has a hard dependency on `github.com/DataDog/zstd_0`, which requires CGO. -// Should be removed once `github.com/DataDog/agent-payload/v5/process` can be imported with CGO disabled. -//go:build cgo && linux +//go:build linux // Package oomkill contains the OOMKill check. package oomkill import ( "fmt" + "net/http" "strings" yaml "gopkg.in/yaml.v2" + sysprobeclient "github.com/DataDog/datadog-agent/cmd/system-probe/api/client" sysconfig "github.com/DataDog/datadog-agent/cmd/system-probe/config" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def" @@ -28,7 +26,6 @@ import ( "github.com/DataDog/datadog-agent/pkg/collector/corechecks/ebpf/probe/oomkill/model" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" "github.com/DataDog/datadog-agent/pkg/metrics/event" - process_net "github.com/DataDog/datadog-agent/pkg/process/net" "github.com/DataDog/datadog-agent/pkg/util/cgroups" "github.com/DataDog/datadog-agent/pkg/util/log" "github.com/DataDog/datadog-agent/pkg/util/optional" @@ -47,8 +44,9 @@ type OOMKillConfig struct { // OOMKillCheck grabs OOM Kill metrics type OOMKillCheck struct { core.CheckBase - instance *OOMKillConfig - tagger tagger.Component + instance *OOMKillConfig + tagger tagger.Component + sysProbeClient *http.Client } // Factory creates a new check factory @@ -80,6 +78,7 @@ func (m *OOMKillCheck) Configure(senderManager sender.SenderManager, _ uint64, c if err != nil { return err } + m.sysProbeClient = sysprobeclient.Get(pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")) return m.instance.Parse(config) } @@ -90,13 +89,7 @@ func (m *OOMKillCheck) Run() error { return nil } - sysProbeUtil, err := process_net.GetRemoteSystemProbeUtil( - pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")) - if err != nil { - return err - } - - data, err := sysProbeUtil.GetCheck(sysconfig.OOMKillProbeModule) + oomkillStats, err := sysprobeclient.GetCheck[[]model.OOMKillStats](m.sysProbeClient, sysconfig.OOMKillProbeModule) if err != nil { return err } @@ -109,10 +102,6 @@ func (m *OOMKillCheck) Run() error { triggerType := "" triggerTypeText := "" - oomkillStats, ok := data.([]model.OOMKillStats) - if !ok { - return log.Errorf("Raw data has incorrect type") - } for _, line := range oomkillStats { containerID, err := cgroups.ContainerFilter("", line.CgroupName) if err != nil || containerID == "" { diff --git a/pkg/collector/corechecks/ebpf/tcpqueuelength/tcp_queue_length.go b/pkg/collector/corechecks/ebpf/tcpqueuelength/tcp_queue_length.go index 18336e67a306b..9644dd511882a 100644 --- a/pkg/collector/corechecks/ebpf/tcpqueuelength/tcp_queue_length.go +++ b/pkg/collector/corechecks/ebpf/tcpqueuelength/tcp_queue_length.go @@ -3,18 +3,17 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. -// FIXME: we require the `cgo` build tag because of this dep relationship: -// github.com/DataDog/datadog-agent/pkg/process/net depends on `github.com/DataDog/agent-payload/v5/process`, -// which has a hard dependency on `github.com/DataDog/zstd_0`, which requires CGO. -// Should be removed once `github.com/DataDog/agent-payload/v5/process` can be imported with CGO disabled. -//go:build cgo && linux +//go:build linux -//nolint:revive // TODO(PLINT) Fix revive linter +// Package tcpqueuelength contains the TCP Queue Length check package tcpqueuelength import ( - yaml "gopkg.in/yaml.v2" + "net/http" + "gopkg.in/yaml.v2" + + sysprobeclient "github.com/DataDog/datadog-agent/cmd/system-probe/api/client" sysconfig "github.com/DataDog/datadog-agent/cmd/system-probe/config" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def" @@ -24,7 +23,6 @@ import ( core "github.com/DataDog/datadog-agent/pkg/collector/corechecks" "github.com/DataDog/datadog-agent/pkg/collector/corechecks/ebpf/probe/tcpqueuelength/model" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" - process_net "github.com/DataDog/datadog-agent/pkg/process/net" "github.com/DataDog/datadog-agent/pkg/util/cgroups" "github.com/DataDog/datadog-agent/pkg/util/log" "github.com/DataDog/datadog-agent/pkg/util/optional" @@ -43,8 +41,9 @@ type TCPQueueLengthConfig struct { // TCPQueueLengthCheck grabs TCP queue length metrics type TCPQueueLengthCheck struct { core.CheckBase - instance *TCPQueueLengthConfig - tagger tagger.Component + instance *TCPQueueLengthConfig + tagger tagger.Component + sysProbeClient *http.Client } // Factory creates a new check factory @@ -76,6 +75,7 @@ func (t *TCPQueueLengthCheck) Configure(senderManager sender.SenderManager, _ ui if err != nil { return err } + t.sysProbeClient = sysprobeclient.Get(pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")) return t.instance.Parse(config) } @@ -86,13 +86,7 @@ func (t *TCPQueueLengthCheck) Run() error { return nil } - sysProbeUtil, err := process_net.GetRemoteSystemProbeUtil( - pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")) - if err != nil { - return err - } - - data, err := sysProbeUtil.GetCheck(sysconfig.TCPQueueLengthTracerModule) + stats, err := sysprobeclient.GetCheck[model.TCPQueueLengthStats](t.sysProbeClient, sysconfig.TCPQueueLengthTracerModule) if err != nil { return err } @@ -102,11 +96,6 @@ func (t *TCPQueueLengthCheck) Run() error { return err } - stats, ok := data.(model.TCPQueueLengthStats) - if !ok { - return log.Errorf("Raw data has incorrect type") - } - for k, v := range stats { containerID, err := cgroups.ContainerFilter("", k) if err != nil || containerID == "" { diff --git a/pkg/collector/corechecks/gpu/gpu.go b/pkg/collector/corechecks/gpu/gpu.go index e52ba27768d3a..1083db30adb78 100644 --- a/pkg/collector/corechecks/gpu/gpu.go +++ b/pkg/collector/corechecks/gpu/gpu.go @@ -9,12 +9,14 @@ package gpu import ( "fmt" + "net/http" "gopkg.in/yaml.v2" "github.com/NVIDIA/go-nvml/pkg/nvml" "github.com/hashicorp/go-multierror" + sysprobeclient "github.com/DataDog/datadog-agent/cmd/system-probe/api/client" sysconfig "github.com/DataDog/datadog-agent/cmd/system-probe/config" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" "github.com/DataDog/datadog-agent/pkg/aggregator/sender" @@ -23,7 +25,6 @@ import ( "github.com/DataDog/datadog-agent/pkg/collector/corechecks/gpu/model" "github.com/DataDog/datadog-agent/pkg/collector/corechecks/gpu/nvidia" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" - processnet "github.com/DataDog/datadog-agent/pkg/process/net" "github.com/DataDog/datadog-agent/pkg/util/log" "github.com/DataDog/datadog-agent/pkg/util/optional" ) @@ -38,11 +39,11 @@ const ( // Check represents the GPU check that will be periodically executed via the Run() function type Check struct { core.CheckBase - config *CheckConfig // config for the check - sysProbeUtil processnet.SysProbeUtil // sysProbeUtil is used to communicate with system probe - activeMetrics map[model.StatsKey]bool // activeMetrics is a set of metrics that have been seen in the current check run - collectors []nvidia.Collector // collectors for NVML metrics - nvmlLib nvml.Interface // NVML library interface + config *CheckConfig // config for the check + sysProbeClient *http.Client // sysProbeClient is used to communicate with system probe + activeMetrics map[model.StatsKey]bool // activeMetrics is a set of metrics that have been seen in the current check run + collectors []nvidia.Collector // collectors for NVML metrics + nvmlLib nvml.Interface // NVML library interface } // Factory creates a new check factory @@ -83,6 +84,7 @@ func (m *Check) Configure(senderManager sender.SenderManager, _ uint64, config, return fmt.Errorf("failed to build NVML collectors: %w", err) } + m.sysProbeClient = sysprobeclient.Get(pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")) return nil } @@ -95,21 +97,6 @@ func (m *Check) Cancel() { m.CheckBase.Cancel() } -func (m *Check) ensureSysprobeUtil() error { - var err error - - if m.sysProbeUtil == nil { - m.sysProbeUtil, err = processnet.GetRemoteSystemProbeUtil( - pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket"), - ) - if err != nil { - return fmt.Errorf("sysprobe connection: %w", err) - } - } - - return nil -} - // Run executes the check func (m *Check) Run() error { snd, err := m.GetSender() @@ -131,20 +118,11 @@ func (m *Check) Run() error { } func (m *Check) emitSysprobeMetrics(snd sender.Sender) error { - if err := m.ensureSysprobeUtil(); err != nil { - return err - } - - sysprobeData, err := m.sysProbeUtil.GetCheck(sysconfig.GPUMonitoringModule) + stats, err := sysprobeclient.GetCheck[model.GPUStats](m.sysProbeClient, sysconfig.GPUMonitoringModule) if err != nil { return fmt.Errorf("cannot get data from system-probe: %w", err) } - stats, ok := sysprobeData.(model.GPUStats) - if !ok { - return fmt.Errorf("gpu check raw data has incorrect type: %T", stats) - } - // Set all metrics to inactive, so we can remove the ones that we don't see // and send the final metrics for key := range m.activeMetrics { diff --git a/pkg/collector/corechecks/system/wincrashdetect/wincrashdetect_windows_test.go b/pkg/collector/corechecks/system/wincrashdetect/wincrashdetect_windows_test.go index c27c5773ae4b6..004a31057f55d 100644 --- a/pkg/collector/corechecks/system/wincrashdetect/wincrashdetect_windows_test.go +++ b/pkg/collector/corechecks/system/wincrashdetect/wincrashdetect_windows_test.go @@ -8,21 +8,21 @@ package wincrashdetect import ( - "net" "net/http" "sync" "testing" "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "golang.org/x/sys/windows/registry" + "github.com/DataDog/datadog-agent/cmd/system-probe/api/server" "github.com/DataDog/datadog-agent/cmd/system-probe/utils" "github.com/DataDog/datadog-agent/pkg/aggregator/mocksender" "github.com/DataDog/datadog-agent/pkg/collector/corechecks/system/wincrashdetect/probe" configmock "github.com/DataDog/datadog-agent/pkg/config/mock" "github.com/DataDog/datadog-agent/pkg/metrics/event" - processNet "github.com/DataDog/datadog-agent/pkg/process/net" ) const ( @@ -30,16 +30,6 @@ const ( systemProbeTestPipeName = `\\.\pipe\dd_system_probe_wincrash_test` ) -func createSystemProbeListener() (l net.Listener, close func()) { - conn, err := processNet.NewSystemProbeListener(systemProbeTestPipeName) - if err != nil { - panic(err) - } - return conn.GetListener(), func() { - _ = conn.GetListener().Close() - } -} - func testSetup(t *testing.T) { // change the hive to hku for the test hive = registry.CURRENT_USER @@ -59,17 +49,15 @@ func TestWinCrashReporting(t *testing.T) { mockSysProbeConfig.SetWithoutSource("system_probe_config.enabled", true) mockSysProbeConfig.SetWithoutSource("system_probe_config.sysprobe_socket", systemProbeTestPipeName) - listener, closefunc := createSystemProbeListener() - defer closefunc() + listener, err := server.NewListener(systemProbeTestPipeName) + require.NoError(t, err) + t.Cleanup(func() { _ = listener.Close() }) mux := http.NewServeMux() - server := http.Server{ + srv := http.Server{ Handler: mux, } - defer server.Close() - - // no socket address is set in config for Windows since system probe - // utilizes a fixed named pipe. + defer srv.Close() /* * the underlying system probe connector is a singleton. Therefore, we can't set up different @@ -87,7 +75,7 @@ func TestWinCrashReporting(t *testing.T) { })) mux.Handle("/debug/stats", http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) - go server.Serve(listener) + go srv.Serve(listener) t.Run("test that no crash detected properly reports", func(t *testing.T) { testSetup(t) @@ -194,14 +182,15 @@ func TestCrashReportingStates(t *testing.T) { var crashStatus *probe.WinCrashStatus - listener, closefunc := createSystemProbeListener() - defer closefunc() + listener, err := server.NewListener(systemProbeTestPipeName) + require.NoError(t, err) + t.Cleanup(func() { _ = listener.Close() }) mux := http.NewServeMux() - server := http.Server{ + srv := http.Server{ Handler: mux, } - defer server.Close() + defer srv.Close() cp, err := probe.NewWinCrashProbe(nil) assert.NotNil(t, cp) @@ -237,7 +226,7 @@ func TestCrashReportingStates(t *testing.T) { })) mux.Handle("/debug/stats", http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { })) - go server.Serve(listener) + go srv.Serve(listener) t.Run("test reporting a crash with a busy intermediate state", func(t *testing.T) { testSetup(t) diff --git a/pkg/collector/python/datadog_agent.go b/pkg/collector/python/datadog_agent.go index b4528fd05966e..95a0b2f69f19d 100644 --- a/pkg/collector/python/datadog_agent.go +++ b/pkg/collector/python/datadog_agent.go @@ -22,6 +22,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/collector/check" "github.com/DataDog/datadog-agent/pkg/collector/externalhost" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" + "github.com/DataDog/datadog-agent/pkg/config/structure" "github.com/DataDog/datadog-agent/pkg/obfuscate" "github.com/DataDog/datadog-agent/pkg/persistentcache" "github.com/DataDog/datadog-agent/pkg/util" @@ -253,7 +254,7 @@ var ( func lazyInitObfuscator() *obfuscate.Obfuscator { obfuscatorLoader.Do(func() { var cfg obfuscate.Config - if err := pkgconfigsetup.Datadog().UnmarshalKey("apm_config.obfuscation", &cfg); err != nil { + if err := structure.UnmarshalKey(pkgconfigsetup.Datadog(), "apm_config.obfuscation", &cfg); err != nil { log.Errorf("Failed to unmarshal apm_config.obfuscation: %s", err.Error()) cfg = obfuscate.Config{} } diff --git a/pkg/config/model/viper_test.go b/pkg/config/model/viper_test.go index c8d4d7de36fc2..7babb3453ffbe 100644 --- a/pkg/config/model/viper_test.go +++ b/pkg/config/model/viper_test.go @@ -61,6 +61,7 @@ func TestConcurrencyUnmarshalling(t *testing.T) { go func() { defer wg.Done() for n := 0; n <= 1000; n++ { + // TODO: This should use pkg/config/structure.UnmarshalKey but that creates a circular dependency. err := config.UnmarshalKey("foo", &s) if err != nil { errs <- fmt.Errorf("unable to decode into struct, %w", err) diff --git a/pkg/config/remote/go.mod b/pkg/config/remote/go.mod index a0ed4243493f6..4a0ed02d3a50c 100644 --- a/pkg/config/remote/go.mod +++ b/pkg/config/remote/go.mod @@ -43,14 +43,14 @@ replace ( ) require ( - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel - github.com/DataDog/datadog-agent/pkg/config/model v0.56.0-rc.3 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 github.com/DataDog/datadog-agent/pkg/proto v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/grpc v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/DataDog/datadog-agent/pkg/util/uuid v0.56.0-rc.3 github.com/Masterminds/semver v1.5.0 github.com/benbjohnson/clock v1.3.0 @@ -65,24 +65,25 @@ require ( require ( github.com/DataDog/appsec-internal-go v1.7.0 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.56.0-rc.3 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/api v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.56.0-rc.3 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/obfuscate v0.48.0 // indirect github.com/DataDog/datadog-agent/pkg/util/cache v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/datadog-go/v5 v5.5.0 // indirect github.com/DataDog/go-libddwaf/v3 v3.3.0 // indirect @@ -116,7 +117,7 @@ require ( ) require ( - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/go-tuf v1.1.0-0.5.2 github.com/DataDog/viper v1.13.5 // indirect github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect @@ -147,3 +148,5 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/DataDog/datadog-agent/pkg/config/structure => ../structure diff --git a/pkg/config/setup/config.go b/pkg/config/setup/config.go index d156d6fec9e9e..ae72d5086ad2b 100644 --- a/pkg/config/setup/config.go +++ b/pkg/config/setup/config.go @@ -1708,6 +1708,7 @@ func LoadProxyFromEnv(config pkgconfigmodel.Config) { var isSet bool p := &pkgconfigmodel.Proxy{} if isSet = config.IsSet("proxy"); isSet { + // TODO: This should use pkg/config/structure.UnmarshalKey but that creates a circular dependency. if err := config.UnmarshalKey("proxy", p); err != nil { isSet = false log.Errorf("Could not load proxy setting from the configuration (ignoring): %s", err) @@ -2469,6 +2470,7 @@ func IsCLCRunner(config pkgconfigmodel.Reader) bool { } var cps []ConfigurationProviders + // TODO: This should use pkg/config/structure.UnmarshalKey but that creates a circular dependency. if err := config.UnmarshalKey("config_providers", &cps); err != nil { return false } diff --git a/pkg/config/structure/go.mod b/pkg/config/structure/go.mod index 7681e588f36c1..16a8d44e24545 100644 --- a/pkg/config/structure/go.mod +++ b/pkg/config/structure/go.mod @@ -34,6 +34,7 @@ require ( github.com/DataDog/datadog-agent/pkg/config/mock v0.0.0-00010101000000-000000000000 github.com/DataDog/datadog-agent/pkg/config/model v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 + github.com/DataDog/viper v1.13.5 github.com/spf13/cast v1.5.1 github.com/stretchr/testify v1.9.0 ) @@ -54,7 +55,6 @@ require ( github.com/DataDog/datadog-agent/pkg/util/system v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/system/socket v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/winutil v0.56.0-rc.3 // indirect - github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/pkg/config/structure/unmarshal.go b/pkg/config/structure/unmarshal.go index 22ebd2f1595bf..a20eb59358df7 100644 --- a/pkg/config/structure/unmarshal.go +++ b/pkg/config/structure/unmarshal.go @@ -16,6 +16,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/config/model" "github.com/DataDog/datadog-agent/pkg/config/nodetreemodel" + "github.com/DataDog/viper" "github.com/spf13/cast" ) @@ -23,6 +24,7 @@ import ( type featureSet struct { allowSquash bool convertEmptyStrNil bool + convertArrayToMap bool } // UnmarshalKeyOption is an option that affects the enabled features in UnmarshalKey @@ -39,6 +41,28 @@ var ConvertEmptyStringToNil UnmarshalKeyOption = func(fs *featureSet) { fs.convertEmptyStrNil = true } +// ImplicitlyConvertArrayToMapSet allows UnmarshalKey to implicitly convert an array of []interface{} to a map[interface{}]bool +var ImplicitlyConvertArrayToMapSet UnmarshalKeyOption = func(fs *featureSet) { + fs.convertArrayToMap = true +} + +// legacyConvertArrayToMap convert array to map when DD_CONF_NODETREEMODEL is disabled +var legacyConvertArrayToMap = viper.DecodeHook( + func(rf reflect.Kind, rt reflect.Kind, data interface{}) (interface{}, error) { + if rf != reflect.Slice { + return data, nil + } + if rt != reflect.Map { + return data, nil + } + newData := map[interface{}]bool{} + for _, i := range data.([]interface{}) { + newData[i] = true + } + return newData, nil + }, +) + // UnmarshalKey retrieves data from the config at the given key and deserializes it // to be stored on the target struct. // @@ -51,6 +75,15 @@ func UnmarshalKey(cfg model.Reader, key string, target interface{}, opts ...Unma if nodetreemodel == "enabled" || nodetreemodel == "unmarshal" { return unmarshalKeyReflection(cfg, key, target, opts...) } + + fs := &featureSet{} + for _, o := range opts { + o(fs) + } + + if fs.convertArrayToMap { + return cfg.UnmarshalKey(key, target, legacyConvertArrayToMap) + } return cfg.UnmarshalKey(key, target) } @@ -163,25 +196,38 @@ func copyStruct(target reflect.Value, source nodetreemodel.Node, fs *featureSet) return nil } -func copyMap(target reflect.Value, source nodetreemodel.Node, _ *featureSet) error { - ktype := reflect.TypeOf("") - vtype := reflect.TypeOf("") - - // TODO: Should handle maps with more complex types in a future PR - // - // For now we only support map[string]string. - if target.Type().Elem() != vtype || target.Type().Key() != ktype { - return fmt.Errorf("only map[string]string are supported, not %s", target.Type()) - } - +func copyMap(target reflect.Value, source nodetreemodel.Node, fs *featureSet) error { + ktype := target.Type().Key() + vtype := target.Type().Elem() mtype := reflect.MapOf(ktype, vtype) results := reflect.MakeMap(mtype) + if fs.convertArrayToMap { + if leaf, ok := source.(nodetreemodel.LeafNode); ok { + thing := leaf.Get() + if arr, ok := thing.([]interface{}); ok { + // convert []interface{} to map[interface{}]bool + create := make(map[interface{}]bool) + for k := range len(arr) { + item := arr[k] + create[fmt.Sprintf("%s", item)] = true + } + converted, err := nodetreemodel.NewNodeTree(create, model.SourceUnknown) + if err != nil { + return err + } + source = converted + } + } + } + inner, ok := source.(nodetreemodel.InnerNode) if !ok { - return fmt.Errorf("can't copy a map into a leaf") + return fmt.Errorf("cannot assign leaf node to a map") } - for _, mkey := range inner.ChildrenKeys() { + + mapKeys := inner.ChildrenKeys() + for _, mkey := range mapKeys { child, err := inner.GetChild(mkey) if err != nil { return err @@ -190,10 +236,12 @@ func copyMap(target reflect.Value, source nodetreemodel.Node, _ *featureSet) err continue } if scalar, ok := child.(nodetreemodel.LeafNode); ok { - if mval, err := cast.ToStringE(scalar.Get()); err == nil { + if mval, err := cast.ToStringE(scalar.Get()); vtype == reflect.TypeOf("") && err == nil { results.SetMapIndex(reflect.ValueOf(mkey), reflect.ValueOf(mval)) + } else if bval, err := cast.ToBoolE(scalar.Get()); vtype == reflect.TypeOf(true) && err == nil { + results.SetMapIndex(reflect.ValueOf(mkey), reflect.ValueOf(bval)) } else { - return fmt.Errorf("TODO: only map[string]string supported currently") + return fmt.Errorf("only map[string]string and map[string]bool supported currently") } } } diff --git a/pkg/config/structure/unmarshal_test.go b/pkg/config/structure/unmarshal_test.go index 79344e2c7d91c..4b1733568f272 100644 --- a/pkg/config/structure/unmarshal_test.go +++ b/pkg/config/structure/unmarshal_test.go @@ -961,22 +961,6 @@ feature: require.Error(t, err) assert.Contains(t, err.Error(), "can't copy into target: scalar required") }) - - t.Run("errors on non-string map", func(t *testing.T) { - confYaml := ` -feature: - enabled: true -` - - mockConfig := mock.NewFromYAML(t, confYaml) - mockConfig.SetKnown("feature") - - feature := make(map[string]bool) - - err := unmarshalKeyReflection(mockConfig, "feature", &feature) - require.Error(t, err) - assert.Equal(t, err.Error(), "only map[string]string are supported, not map[string]bool") - }) } // A flag is provided as a struct tag after a field name separated by a comma that @@ -1231,13 +1215,15 @@ service: }) } -func TestUnmarshalKeysToMap(t *testing.T) { +func TestUnmarshalKeysToMapOfString(t *testing.T) { confYaml := ` service: host: datad0g.com name: intake apikey: abc1 the_great_question: 42 + enabled: true + disabled: f ` mockConfig := mock.NewFromYAML(t, confYaml) mockConfig.SetKnown("service") @@ -1250,6 +1236,31 @@ service: assert.Equal(t, svc["name"], "intake") assert.Equal(t, svc["apikey"], "abc1") assert.Equal(t, svc["the_great_question"], "42") + assert.Equal(t, svc["enabled"], "true") + assert.Equal(t, svc["disabled"], "f") +} + +func TestUnmarshalKeysToMapOfBool(t *testing.T) { + confYaml := ` +service: + enabled: true + disabled: false +` + mockConfig := mock.NewFromYAML(t, confYaml) + mockConfig.SetKnown("service") + var svc = make(map[string]bool) + + err := unmarshalKeyReflection(mockConfig, "service", &svc) + assert.NoError(t, err) + + assert.Equal(t, svc["enabled"], true) + assert.Equal(t, svc["disabled"], false) + + err = UnmarshalKey(mockConfig, "service", &svc) + assert.NoError(t, err) + + assert.Equal(t, svc["enabled"], true) + assert.Equal(t, svc["disabled"], false) } func TestMapGetChildNotFound(t *testing.T) { diff --git a/pkg/config/utils/go.mod b/pkg/config/utils/go.mod index e94371298e41b..fb3ae2aab408b 100644 --- a/pkg/config/utils/go.mod +++ b/pkg/config/utils/go.mod @@ -15,6 +15,7 @@ replace ( github.com/DataDog/datadog-agent/pkg/config/model => ../model/ github.com/DataDog/datadog-agent/pkg/config/nodetreemodel => ../../../pkg/config/nodetreemodel github.com/DataDog/datadog-agent/pkg/config/setup => ../setup/ + github.com/DataDog/datadog-agent/pkg/config/structure => ../../../pkg/config/structure github.com/DataDog/datadog-agent/pkg/config/teeconfig => ../../../pkg/config/teeconfig github.com/DataDog/datadog-agent/pkg/telemetry => ../../telemetry github.com/DataDog/datadog-agent/pkg/util/executable => ../../util/executable @@ -33,29 +34,30 @@ replace ( ) require ( - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel - github.com/DataDog/datadog-agent/pkg/config/model v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/setup v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.56.0-rc.3 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 github.com/stretchr/testify v1.9.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.56.0-rc.3 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect diff --git a/pkg/config/utils/metadata_providers.go b/pkg/config/utils/metadata_providers.go index ca2d3b01e46a8..113611f5e4196 100644 --- a/pkg/config/utils/metadata_providers.go +++ b/pkg/config/utils/metadata_providers.go @@ -9,6 +9,7 @@ import ( "time" pkgconfigmodel "github.com/DataDog/datadog-agent/pkg/config/model" + "github.com/DataDog/datadog-agent/pkg/config/structure" ) // MetadataProviders helps unmarshalling `metadata_providers` config param @@ -20,5 +21,5 @@ type MetadataProviders struct { // GetMetadataProviders returns the "metadata_providers" set in the configuration func GetMetadataProviders(c pkgconfigmodel.Reader) ([]MetadataProviders, error) { var mp []MetadataProviders - return mp, c.UnmarshalKey("metadata_providers", &mp) + return mp, structure.UnmarshalKey(c, "metadata_providers", &mp) } diff --git a/pkg/languagedetection/detector_linux_test.go b/pkg/languagedetection/detector_linux_test.go index bd6ad87f808ae..7b2c7e092507a 100644 --- a/pkg/languagedetection/detector_linux_test.go +++ b/pkg/languagedetection/detector_linux_test.go @@ -15,12 +15,11 @@ import ( "github.com/stretchr/testify/assert" - configmock "github.com/DataDog/datadog-agent/pkg/config/mock" - "github.com/DataDog/datadog-agent/pkg/process/net" - "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" + "github.com/DataDog/datadog-agent/cmd/system-probe/api/server" + configmock "github.com/DataDog/datadog-agent/pkg/config/mock" "github.com/DataDog/datadog-agent/pkg/languagedetection/languagemodels" languagepb "github.com/DataDog/datadog-agent/pkg/proto/pbgo/languagedetection" ) @@ -29,12 +28,12 @@ func startTestUnixServer(t *testing.T, handler http.Handler) string { t.Helper() socketPath := path.Join(t.TempDir(), "test.sock") - listener, err := net.NewSystemProbeListener(socketPath) + listener, err := server.NewListener(socketPath) require.NoError(t, err) - t.Cleanup(listener.Stop) + t.Cleanup(func() { _ = listener.Close() }) srv := httptest.NewUnstartedServer(handler) - srv.Listener = listener.GetListener() + srv.Listener = listener srv.Start() t.Cleanup(srv.Close) diff --git a/pkg/logs/auditor/go.mod b/pkg/logs/auditor/go.mod index 714abc3ee10a3..97112b7a6f7b0 100644 --- a/pkg/logs/auditor/go.mod +++ b/pkg/logs/auditor/go.mod @@ -43,34 +43,34 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 github.com/DataDog/datadog-agent/pkg/logs/message v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/status/health v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/stretchr/testify v1.9.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/pkg/logs/client/go.mod b/pkg/logs/client/go.mod index 033ccf1a1f5e9..2a724520207ce 100644 --- a/pkg/logs/client/go.mod +++ b/pkg/logs/client/go.mod @@ -50,8 +50,8 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 github.com/DataDog/datadog-agent/pkg/logs/message v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/metrics v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 @@ -60,36 +60,36 @@ require ( github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 github.com/stretchr/testify v1.9.0 golang.org/x/net v0.31.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/benbjohnson/clock v1.3.5 // indirect diff --git a/pkg/logs/diagnostic/go.mod b/pkg/logs/diagnostic/go.mod index 3238be81ac26d..871e750da65e8 100644 --- a/pkg/logs/diagnostic/go.mod +++ b/pkg/logs/diagnostic/go.mod @@ -46,35 +46,35 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 github.com/DataDog/datadog-agent/pkg/logs/message v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 github.com/stretchr/testify v1.9.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/pkg/logs/internal/decoder/auto_multiline_detection/user_samples.go b/pkg/logs/internal/decoder/auto_multiline_detection/user_samples.go index 0639c6641cc3e..ee750936c85a8 100644 --- a/pkg/logs/internal/decoder/auto_multiline_detection/user_samples.go +++ b/pkg/logs/internal/decoder/auto_multiline_detection/user_samples.go @@ -10,6 +10,7 @@ import ( "regexp" "github.com/DataDog/datadog-agent/pkg/config/model" + "github.com/DataDog/datadog-agent/pkg/config/structure" "github.com/DataDog/datadog-agent/pkg/logs/internal/decoder/auto_multiline_detection/tokens" "github.com/DataDog/datadog-agent/pkg/util/log" ) @@ -46,7 +47,7 @@ type UserSamples struct { func NewUserSamples(config model.Reader) *UserSamples { tokenizer := NewTokenizer(0) s := make([]*UserSample, 0) - err := config.UnmarshalKey("logs_config.auto_multi_line_detection_custom_samples", &s) + err := structure.UnmarshalKey(config, "logs_config.auto_multi_line_detection_custom_samples", &s) if err != nil { log.Error("Failed to unmarshal custom samples: ", err) diff --git a/pkg/logs/message/go.mod b/pkg/logs/message/go.mod index 69e65223a97e3..59c223b723d2e 100644 --- a/pkg/logs/message/go.mod +++ b/pkg/logs/message/go.mod @@ -42,31 +42,31 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/stretchr/testify v1.9.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/pkg/logs/pipeline/go.mod b/pkg/logs/pipeline/go.mod index 0bfed8fb6ce9a..1f891bb34d799 100644 --- a/pkg/logs/pipeline/go.mod +++ b/pkg/logs/pipeline/go.mod @@ -59,8 +59,8 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 github.com/DataDog/datadog-agent/pkg/logs/auditor v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/client v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/diagnostic v0.56.0-rc.3 @@ -71,7 +71,7 @@ require ( github.com/DataDog/datadog-agent/pkg/logs/sender v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/status/statusinterface v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/status/health v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/DataDog/datadog-agent/pkg/util/startstop v0.56.0-rc.3 github.com/hashicorp/go-multierror v1.1.1 github.com/stretchr/testify v1.9.0 @@ -80,32 +80,32 @@ require ( require ( github.com/DataDog/agent-payload/v5 v5.0.106 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect github.com/DataDog/viper v1.13.5 // indirect diff --git a/pkg/logs/processor/go.mod b/pkg/logs/processor/go.mod index b04bace79d3b6..8893206f0a550 100644 --- a/pkg/logs/processor/go.mod +++ b/pkg/logs/processor/go.mod @@ -51,41 +51,41 @@ require ( github.com/DataDog/agent-payload/v5 v5.0.106 github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 github.com/DataDog/datadog-agent/pkg/logs/diagnostic v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/message v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/metrics v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/sds v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/stretchr/testify v1.9.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect github.com/DataDog/viper v1.13.5 // indirect diff --git a/pkg/logs/sds/go.mod b/pkg/logs/sds/go.mod index 538d2100333e0..b1d5763384e06 100644 --- a/pkg/logs/sds/go.mod +++ b/pkg/logs/sds/go.mod @@ -49,39 +49,39 @@ replace ( ) require ( - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 github.com/DataDog/datadog-agent/pkg/logs/message v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 github.com/stretchr/testify v1.9.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/pkg/logs/sender/go.mod b/pkg/logs/sender/go.mod index e471e3285c000..f3b64ee87a320 100644 --- a/pkg/logs/sender/go.mod +++ b/pkg/logs/sender/go.mod @@ -51,45 +51,45 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 github.com/DataDog/datadog-agent/pkg/logs/client v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/message v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/metrics v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/status/statusinterface v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/benbjohnson/clock v1.3.5 github.com/stretchr/testify v1.9.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/def v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/pkg/logs/sources/go.mod b/pkg/logs/sources/go.mod index 7c0b5b8584a46..05a3f9c7c3223 100644 --- a/pkg/logs/sources/go.mod +++ b/pkg/logs/sources/go.mod @@ -41,30 +41,30 @@ replace ( require ( github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 github.com/stretchr/testify v1.9.0 ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/pkg/logs/util/testutils/go.mod b/pkg/logs/util/testutils/go.mod index 157c9878edab8..c42841ad97fe4 100644 --- a/pkg/logs/util/testutils/go.mod +++ b/pkg/logs/util/testutils/go.mod @@ -44,28 +44,28 @@ replace ( require github.com/DataDog/datadog-agent/pkg/logs/sources v0.56.0-rc.3 require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.0 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/pkg/network/config/replace_rules.go b/pkg/network/config/replace_rules.go index ce8e1654766f0..834e28c3ed388 100644 --- a/pkg/network/config/replace_rules.go +++ b/pkg/network/config/replace_rules.go @@ -12,6 +12,7 @@ import ( "github.com/DataDog/datadog-agent/pkg/config/model" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" + "github.com/DataDog/datadog-agent/pkg/config/structure" ) // ReplaceRule specifies a replace rule. @@ -32,7 +33,7 @@ func parseReplaceRules(cfg model.Config, key string) ([]*ReplaceRule, error) { } rules := make([]*ReplaceRule, 0) - if err := cfg.UnmarshalKey(key, &rules); err != nil { + if err := structure.UnmarshalKey(cfg, key, &rules); err != nil { return nil, fmt.Errorf("rules format should be of the form '[{\"pattern\":\"pattern\",\"repl\":\"replace_str\"}]', error: %w", err) } diff --git a/pkg/network/tracer/connection/ebpfless/tcp_processor_test.go b/pkg/network/tracer/connection/ebpfless/tcp_processor_test.go index 4f3785ed1a8d2..c88bea17c2361 100644 --- a/pkg/network/tracer/connection/ebpfless/tcp_processor_test.go +++ b/pkg/network/tracer/connection/ebpfless/tcp_processor_test.go @@ -77,36 +77,6 @@ type testCapture struct { tcp *layers.TCP } -func (tc testCapture) reverse() testCapture { //nolint:unused // TODO - ret := tc - if tc.pktType == unix.PACKET_HOST { - ret.pktType = unix.PACKET_OUTGOING - } else { - ret.pktType = unix.PACKET_HOST - } - if tc.ipv4 != nil { - ipv4 := *tc.ipv4 - ipv4.SrcIP, ipv4.DstIP = ipv4.DstIP, ipv4.SrcIP - ret.ipv4 = &ipv4 - } - if tc.ipv6 != nil { - ipv6 := *tc.ipv6 - ipv6.SrcIP, ipv6.DstIP = ipv6.DstIP, ipv6.SrcIP - ret.ipv6 = &ipv6 - } - tcp := *tc.tcp - tcp.SrcPort, tcp.DstPort = tcp.DstPort, tcp.SrcPort - ret.tcp = &tcp - return ret -} -func reversePkts(tc []testCapture) []testCapture { //nolint:unused // TODO - var ret []testCapture - for _, t := range tc { - ret = append(ret, t.reverse()) - } - return ret -} - // TODO can this be merged with the logic creating scratchConns in ebpfless tracer? func makeTcpStates(synPkt testCapture) *network.ConnectionStats { //nolint:revive // TODO var family network.ConnectionFamily @@ -151,18 +121,25 @@ func makeTcpStates(synPkt testCapture) *network.ConnectionStats { //nolint:reviv } type tcpTestFixture struct { - t *testing.T - tcp *TCPProcessor - conn *network.ConnectionStats + t *testing.T + tcp *TCPProcessor + conn *network.ConnectionStats +} + +type packetBuilder struct { localSeqBase, remoteSeqBase uint32 } -const TCP_HEADER_SIZE = 20 //nolint:revive // TODO +const tcpHeaderSize = 20 + +func newPacketBuilder(localSeqBase, remoteSeqBase uint32) packetBuilder { + return packetBuilder{localSeqBase: localSeqBase, remoteSeqBase: remoteSeqBase} +} -func (fixture *tcpTestFixture) incoming(payloadLen uint16, relSeq, relAck uint32, flags uint8) testCapture { - ipv4 := ipv4Packet(remoteIP, localhost, minIhl*4+TCP_HEADER_SIZE+payloadLen) - seq := relSeq + fixture.localSeqBase - ack := relAck + fixture.remoteSeqBase +func (pb packetBuilder) incoming(payloadLen uint16, relSeq, relAck uint32, flags uint8) testCapture { + ipv4 := ipv4Packet(remoteIP, localhost, minIhl*4+tcpHeaderSize+payloadLen) + seq := relSeq + pb.localSeqBase + ack := relAck + pb.remoteSeqBase tcp := tcpPacket(defaultRemotePort, defaultLocalPort, seq, ack, flags) return testCapture{ pktType: unix.PACKET_HOST, @@ -172,10 +149,10 @@ func (fixture *tcpTestFixture) incoming(payloadLen uint16, relSeq, relAck uint32 } } -func (fixture *tcpTestFixture) outgoing(payloadLen uint16, relSeq, relAck uint32, flags uint8) testCapture { - ipv4 := ipv4Packet(localhost, remoteIP, minIhl*4+TCP_HEADER_SIZE+payloadLen) - seq := relSeq + fixture.remoteSeqBase - ack := relAck + fixture.localSeqBase +func (pb packetBuilder) outgoing(payloadLen uint16, relSeq, relAck uint32, flags uint8) testCapture { + ipv4 := ipv4Packet(localhost, remoteIP, minIhl*4+tcpHeaderSize+payloadLen) + seq := relSeq + pb.remoteSeqBase + ack := relAck + pb.localSeqBase tcp := tcpPacket(defaultLocalPort, defaultRemotePort, seq, ack, flags) return testCapture{ pktType: unix.PACKET_OUTGOING, @@ -185,13 +162,11 @@ func (fixture *tcpTestFixture) outgoing(payloadLen uint16, relSeq, relAck uint32 } } -func newTcpTestFixture(t *testing.T, localSeqBase, remoteSeqBase uint32) *tcpTestFixture { //nolint:revive // TODO +func newTcpTestFixture(t *testing.T) *tcpTestFixture { //nolint:revive // TODO return &tcpTestFixture{ - t: t, - tcp: NewTCPProcessor(), - conn: nil, - localSeqBase: localSeqBase, - remoteSeqBase: remoteSeqBase, + t: t, + tcp: NewTCPProcessor(), + conn: nil, } } @@ -225,25 +200,24 @@ func (fixture *tcpTestFixture) runAgainstState(packets []testCapture, expected [ require.Equal(fixture.t, expectedStrs, actualStrs) } -func testBasicHandshake(t *testing.T, f *tcpTestFixture) { - +func testBasicHandshake(t *testing.T, pb packetBuilder) { basicHandshake := []testCapture{ - f.outgoing(0, 0, 0, SYN), - f.incoming(0, 0, 1, SYN|ACK), + pb.outgoing(0, 0, 0, SYN), + pb.incoming(0, 0, 1, SYN|ACK), // separate ack and first send of data - f.outgoing(0, 1, 1, ACK), - f.outgoing(123, 1, 1, ACK), + pb.outgoing(0, 1, 1, ACK), + pb.outgoing(123, 1, 1, ACK), // acknowledge data separately - f.incoming(0, 1, 124, ACK), - f.incoming(345, 1, 124, ACK), + pb.incoming(0, 1, 124, ACK), + pb.incoming(345, 1, 124, ACK), // remote FINs separately - f.incoming(0, 346, 124, FIN|ACK), + pb.incoming(0, 346, 124, FIN|ACK), // local acknowledges data, (not the FIN) - f.outgoing(0, 124, 346, ACK), + pb.outgoing(0, 124, 346, ACK), // local acknowledges FIN and sends their own - f.outgoing(0, 124, 347, FIN|ACK), + pb.outgoing(0, 124, 347, FIN|ACK), // remote sends final ACK - f.incoming(0, 347, 125, ACK), + pb.incoming(0, 347, 125, ACK), } expectedClientStates := []ConnStatus{ @@ -262,6 +236,7 @@ func testBasicHandshake(t *testing.T, f *tcpTestFixture) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) require.Empty(t, f.conn.TCPFailures) @@ -284,34 +259,34 @@ var higherSeq uint32 = 2973263073 func TestBasicHandshake(t *testing.T) { t.Run("localSeq lt remoteSeq", func(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - testBasicHandshake(t, f) + pb := newPacketBuilder(lowerSeq, higherSeq) + testBasicHandshake(t, pb) }) t.Run("localSeq gt remoteSeq", func(t *testing.T) { - f := newTcpTestFixture(t, higherSeq, lowerSeq) - testBasicHandshake(t, f) + pb := newPacketBuilder(higherSeq, lowerSeq) + testBasicHandshake(t, pb) }) } -func testReversedBasicHandshake(t *testing.T, f *tcpTestFixture) { +func testReversedBasicHandshake(t *testing.T, pb packetBuilder) { basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 1, SYN|ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 1, SYN|ACK), // separate ack and first send of data - f.incoming(0, 1, 1, ACK), - f.incoming(123, 1, 1, ACK), + pb.incoming(0, 1, 1, ACK), + pb.incoming(123, 1, 1, ACK), // acknowledge data separately - f.outgoing(0, 1, 124, ACK), - f.outgoing(345, 1, 124, ACK), + pb.outgoing(0, 1, 124, ACK), + pb.outgoing(345, 1, 124, ACK), // local FINs separately - f.outgoing(0, 346, 124, FIN|ACK), + pb.outgoing(0, 346, 124, FIN|ACK), // remote acknowledges data, (not the FIN) - f.incoming(0, 124, 346, ACK), + pb.incoming(0, 124, 346, ACK), // remote acknowledges FIN and sends their own - f.incoming(0, 124, 347, FIN|ACK), + pb.incoming(0, 124, 347, FIN|ACK), // local sends final ACK - f.outgoing(0, 347, 125, ACK), + pb.outgoing(0, 347, 125, ACK), } expectedClientStates := []ConnStatus{ @@ -329,6 +304,7 @@ func testReversedBasicHandshake(t *testing.T, f *tcpTestFixture) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) require.Empty(t, f.conn.TCPFailures) @@ -347,37 +323,37 @@ func testReversedBasicHandshake(t *testing.T, f *tcpTestFixture) { func TestReversedBasicHandshake(t *testing.T) { t.Run("localSeq lt remoteSeq", func(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - testReversedBasicHandshake(t, f) + pb := newPacketBuilder(lowerSeq, higherSeq) + testReversedBasicHandshake(t, pb) }) t.Run("localSeq gt remoteSeq", func(t *testing.T) { - f := newTcpTestFixture(t, higherSeq, lowerSeq) - testReversedBasicHandshake(t, f) + pb := newPacketBuilder(higherSeq, lowerSeq) + testReversedBasicHandshake(t, pb) }) } -func testCloseWaitState(t *testing.T, f *tcpTestFixture) { +func testCloseWaitState(t *testing.T, pb packetBuilder) { // test the CloseWait state, which is when the local client still has data left // to send during a passive close basicHandshake := []testCapture{ - f.outgoing(0, 0, 0, SYN), - f.incoming(0, 0, 1, SYN|ACK), + pb.outgoing(0, 0, 0, SYN), + pb.incoming(0, 0, 1, SYN|ACK), // local sends data right out the gate with ACK - f.outgoing(123, 1, 1, ACK), + pb.outgoing(123, 1, 1, ACK), // remote acknowledges and sends data back - f.incoming(345, 1, 124, ACK), + pb.incoming(345, 1, 124, ACK), // remote FINs separately - f.incoming(0, 346, 124, FIN|ACK), + pb.incoming(0, 346, 124, FIN|ACK), // local acknowledges FIN, but keeps sending data for a bit - f.outgoing(100, 124, 347, ACK), + pb.outgoing(100, 124, 347, ACK), // client finally FINACKs - f.outgoing(42, 224, 347, FIN|ACK), + pb.outgoing(42, 224, 347, FIN|ACK), // remote acknowledges data but not including the FIN - f.incoming(0, 347, 224, ACK), + pb.incoming(0, 347, 224, ACK), // server sends final ACK - f.incoming(0, 347, 224+42+1, ACK), + pb.incoming(0, 347, 224+42+1, ACK), } expectedClientStates := []ConnStatus{ @@ -394,6 +370,7 @@ func testCloseWaitState(t *testing.T, f *tcpTestFixture) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) require.Empty(t, f.conn.TCPFailures) @@ -412,39 +389,39 @@ func testCloseWaitState(t *testing.T, f *tcpTestFixture) { func TestCloseWaitState(t *testing.T) { t.Run("localSeq lt remoteSeq", func(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - testCloseWaitState(t, f) + pb := newPacketBuilder(lowerSeq, higherSeq) + testCloseWaitState(t, pb) }) t.Run("localSeq gt remoteSeq", func(t *testing.T) { - f := newTcpTestFixture(t, higherSeq, lowerSeq) + f := newPacketBuilder(higherSeq, lowerSeq) testCloseWaitState(t, f) }) } -func testFinWait2State(t *testing.T, f *tcpTestFixture) { +func testFinWait2State(t *testing.T, pb packetBuilder) { // test the FinWait2 state, which is when the remote still has data left // to send during an active close basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 1, SYN|ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 1, SYN|ACK), // separate ack and first send of data - f.incoming(0, 1, 1, ACK), - f.incoming(123, 1, 1, ACK), + pb.incoming(0, 1, 1, ACK), + pb.incoming(123, 1, 1, ACK), // acknowledge data separately - f.outgoing(0, 1, 124, ACK), - f.outgoing(345, 1, 124, ACK), + pb.outgoing(0, 1, 124, ACK), + pb.outgoing(345, 1, 124, ACK), // local FINs separately - f.outgoing(0, 346, 124, FIN|ACK), + pb.outgoing(0, 346, 124, FIN|ACK), // remote acknowledges the FIN but keeps sending data - f.incoming(100, 124, 347, ACK), + pb.incoming(100, 124, 347, ACK), // local acknowledges this data - f.outgoing(0, 347, 224, ACK), + pb.outgoing(0, 347, 224, ACK), // remote sends their own FIN - f.incoming(0, 224, 347, FIN|ACK), + pb.incoming(0, 224, 347, FIN|ACK), // local sends final ACK - f.outgoing(0, 347, 225, ACK), + pb.outgoing(0, 347, 225, ACK), } expectedClientStates := []ConnStatus{ @@ -463,6 +440,7 @@ func testFinWait2State(t *testing.T, f *tcpTestFixture) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) require.Empty(t, f.conn.TCPFailures) @@ -481,29 +459,28 @@ func testFinWait2State(t *testing.T, f *tcpTestFixture) { func TestFinWait2State(t *testing.T) { t.Run("localSeq lt remoteSeq", func(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - testFinWait2State(t, f) + pb := newPacketBuilder(lowerSeq, higherSeq) + testFinWait2State(t, pb) }) t.Run("localSeq gt remoteSeq", func(t *testing.T) { - f := newTcpTestFixture(t, higherSeq, lowerSeq) - testFinWait2State(t, f) + pb := newPacketBuilder(higherSeq, lowerSeq) + testFinWait2State(t, pb) }) } func TestImmediateFin(t *testing.T) { // originally captured from TestTCPConnsReported which closes connections right as it gets them - f := newTcpTestFixture(t, lowerSeq, higherSeq) - + pb := newPacketBuilder(lowerSeq, higherSeq) basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 1, SYN|ACK), - f.incoming(0, 1, 1, ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 1, SYN|ACK), + pb.incoming(0, 1, 1, ACK), // active close after sending no data - f.outgoing(0, 1, 1, FIN|ACK), - f.incoming(0, 1, 2, FIN|ACK), - f.outgoing(0, 2, 2, ACK), + pb.outgoing(0, 1, 1, FIN|ACK), + pb.incoming(0, 1, 2, FIN|ACK), + pb.outgoing(0, 2, 2, ACK), } expectedClientStates := []ConnStatus{ @@ -516,6 +493,7 @@ func TestImmediateFin(t *testing.T) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) require.Empty(t, f.conn.TCPFailures) @@ -533,11 +511,10 @@ func TestImmediateFin(t *testing.T) { } func TestConnRefusedSyn(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - + pb := newPacketBuilder(lowerSeq, higherSeq) basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 0, RST|ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 0, RST|ACK), } expectedClientStates := []ConnStatus{ @@ -545,11 +522,12 @@ func TestConnRefusedSyn(t *testing.T) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) - require.Equal(t, f.conn.TCPFailures, map[uint16]uint32{ + require.Equal(t, map[uint16]uint32{ uint16(syscall.ECONNREFUSED): 1, - }) + }, f.conn.TCPFailures) expectedStats := network.StatCounters{ SentBytes: 0, @@ -564,12 +542,11 @@ func TestConnRefusedSyn(t *testing.T) { } func TestConnRefusedSynAck(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - + pb := newPacketBuilder(lowerSeq, higherSeq) basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 1, SYN|ACK), - f.outgoing(0, 0, 0, RST|ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 1, SYN|ACK), + pb.outgoing(0, 0, 0, RST|ACK), } expectedClientStates := []ConnStatus{ @@ -578,11 +555,12 @@ func TestConnRefusedSynAck(t *testing.T) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) - require.Equal(t, f.conn.TCPFailures, map[uint16]uint32{ + require.Equal(t, map[uint16]uint32{ uint16(syscall.ECONNREFUSED): 1, - }) + }, f.conn.TCPFailures) expectedStats := network.StatCounters{ SentBytes: 0, @@ -597,14 +575,13 @@ func TestConnRefusedSynAck(t *testing.T) { } func TestConnReset(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - + pb := newPacketBuilder(lowerSeq, higherSeq) basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 1, SYN|ACK), - f.incoming(0, 1, 1, ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 1, SYN|ACK), + pb.incoming(0, 1, 1, ACK), // handshake done, now blow up - f.outgoing(0, 1, 1, RST|ACK), + pb.outgoing(0, 1, 1, RST|ACK), } expectedClientStates := []ConnStatus{ @@ -615,11 +592,12 @@ func TestConnReset(t *testing.T) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) - require.Equal(t, f.conn.TCPFailures, map[uint16]uint32{ + require.Equal(t, map[uint16]uint32{ uint16(syscall.ECONNRESET): 1, - }) + }, f.conn.TCPFailures) expectedStats := network.StatCounters{ SentBytes: 0, @@ -634,15 +612,14 @@ func TestConnReset(t *testing.T) { } func TestRstRetransmit(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - + pb := newPacketBuilder(lowerSeq, higherSeq) basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 1, SYN|ACK), - f.incoming(0, 1, 1, ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 1, SYN|ACK), + pb.incoming(0, 1, 1, ACK), // handshake done, now blow up - f.outgoing(0, 1, 1, RST|ACK), - f.outgoing(0, 1, 1, RST|ACK), + pb.outgoing(0, 1, 1, RST|ACK), + pb.outgoing(0, 1, 1, RST|ACK), } expectedClientStates := []ConnStatus{ @@ -654,12 +631,13 @@ func TestRstRetransmit(t *testing.T) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) // should count as a single failure - require.Equal(t, f.conn.TCPFailures, map[uint16]uint32{ + require.Equal(t, map[uint16]uint32{ uint16(syscall.ECONNRESET): 1, - }) + }, f.conn.TCPFailures) expectedStats := network.StatCounters{ SentBytes: 0, @@ -677,16 +655,15 @@ func TestRstRetransmit(t *testing.T) { func TestConnectTwice(t *testing.T) { // same as TestImmediateFin but everything happens twice - f := newTcpTestFixture(t, lowerSeq, higherSeq) - + pb := newPacketBuilder(lowerSeq, higherSeq) basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 1, SYN|ACK), - f.incoming(0, 1, 1, ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 1, SYN|ACK), + pb.incoming(0, 1, 1, ACK), // active close after sending no data - f.outgoing(0, 1, 1, FIN|ACK), - f.incoming(0, 1, 2, FIN|ACK), - f.outgoing(0, 2, 2, ACK), + pb.outgoing(0, 1, 1, FIN|ACK), + pb.incoming(0, 1, 2, FIN|ACK), + pb.outgoing(0, 2, 2, ACK), } expectedClientStates := []ConnStatus{ @@ -699,6 +676,7 @@ func TestConnectTwice(t *testing.T) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) state := f.tcp.conns[f.conn.ConnectionTuple] @@ -725,17 +703,16 @@ func TestConnectTwice(t *testing.T) { } func TestSimultaneousClose(t *testing.T) { - f := newTcpTestFixture(t, lowerSeq, higherSeq) - + pb := newPacketBuilder(lowerSeq, higherSeq) basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), - f.outgoing(0, 0, 1, SYN|ACK), - f.incoming(0, 1, 1, ACK), + pb.incoming(0, 0, 0, SYN), + pb.outgoing(0, 0, 1, SYN|ACK), + pb.incoming(0, 1, 1, ACK), // active close after sending no data - f.outgoing(0, 1, 1, FIN|ACK), - f.incoming(0, 1, 1, FIN|ACK), - f.outgoing(0, 2, 2, ACK), - f.incoming(0, 2, 2, ACK), + pb.outgoing(0, 1, 1, FIN|ACK), + pb.incoming(0, 1, 1, FIN|ACK), + pb.outgoing(0, 2, 2, ACK), + pb.incoming(0, 2, 2, ACK), } expectedClientStates := []ConnStatus{ @@ -749,6 +726,7 @@ func TestSimultaneousClose(t *testing.T) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) require.Empty(t, f.conn.TCPFailures) @@ -767,18 +745,17 @@ func TestSimultaneousClose(t *testing.T) { func TestUnusualAckSyn(t *testing.T) { // according to zeek, some unusual clients such as ftp.microsoft.com do the ACK and SYN separately - f := newTcpTestFixture(t, lowerSeq, higherSeq) - + pb := newPacketBuilder(lowerSeq, higherSeq) basicHandshake := []testCapture{ - f.incoming(0, 0, 0, SYN), + pb.incoming(0, 0, 0, SYN), // ACK the first SYN before even sending your own SYN - f.outgoing(0, 0, 1, ACK), - f.outgoing(0, 0, 1, SYN), - f.incoming(0, 1, 1, ACK), + pb.outgoing(0, 0, 1, ACK), + pb.outgoing(0, 0, 1, SYN), + pb.incoming(0, 1, 1, ACK), // active close after sending no data - f.outgoing(0, 1, 1, FIN|ACK), - f.incoming(0, 1, 2, FIN|ACK), - f.outgoing(0, 2, 2, ACK), + pb.outgoing(0, 1, 1, FIN|ACK), + pb.incoming(0, 1, 2, FIN|ACK), + pb.outgoing(0, 2, 2, ACK), } expectedClientStates := []ConnStatus{ @@ -792,6 +769,7 @@ func TestUnusualAckSyn(t *testing.T) { ConnStatClosed, } + f := newTcpTestFixture(t) f.runAgainstState(basicHandshake, expectedClientStates) require.Empty(t, f.conn.TCPFailures) diff --git a/pkg/process/net/check.go b/pkg/process/net/check.go deleted file mode 100644 index 748c3dacd52cf..0000000000000 --- a/pkg/process/net/check.go +++ /dev/null @@ -1,81 +0,0 @@ -// Unless explicitly stated otherwise all files in this repository are licensed -// under the Apache License Version 2.0. -// This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2016-present Datadog, Inc. - -//go:build linux - -//nolint:revive // TODO(PROC) Fix revive linter -package net - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - - sysconfig "github.com/DataDog/datadog-agent/cmd/system-probe/config" - sysconfigtypes "github.com/DataDog/datadog-agent/cmd/system-probe/config/types" - ebpfcheck "github.com/DataDog/datadog-agent/pkg/collector/corechecks/ebpf/probe/ebpfcheck/model" - oomkill "github.com/DataDog/datadog-agent/pkg/collector/corechecks/ebpf/probe/oomkill/model" - tcpqueuelength "github.com/DataDog/datadog-agent/pkg/collector/corechecks/ebpf/probe/tcpqueuelength/model" - gpu "github.com/DataDog/datadog-agent/pkg/collector/corechecks/gpu/model" -) - -const ( - checksURL = "http://unix/%s/check" -) - -// GetCheck returns the check output of the specified module -func (r *RemoteSysProbeUtil) GetCheck(module sysconfigtypes.ModuleName) (interface{}, error) { - req, err := http.NewRequest("GET", fmt.Sprintf(checksURL, module), nil) - if err != nil { - return nil, err - } - - resp, err := r.httpClient.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("conn request failed: socket %s, url %s, status code: %d", r.path, fmt.Sprintf(checksURL, module), resp.StatusCode) - } - - body, err := io.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - if module == sysconfig.TCPQueueLengthTracerModule { - var stats tcpqueuelength.TCPQueueLengthStats - err = json.Unmarshal(body, &stats) - if err != nil { - return nil, err - } - return stats, nil - } else if module == sysconfig.OOMKillProbeModule { - var stats []oomkill.OOMKillStats - err = json.Unmarshal(body, &stats) - if err != nil { - return nil, err - } - return stats, nil - } else if module == sysconfig.EBPFModule { - var stats ebpfcheck.EBPFStats - err = json.Unmarshal(body, &stats) - if err != nil { - return nil, err - } - return stats, nil - } else if module == sysconfig.GPUMonitoringModule { - var stats gpu.GPUStats - err = json.Unmarshal(body, &stats) - if err != nil { - return nil, err - } - return stats, nil - } - - return nil, fmt.Errorf("invalid check name: %s", module) -} diff --git a/pkg/process/net/check_windows.go b/pkg/process/net/check_windows.go deleted file mode 100644 index b7cc384e7be3f..0000000000000 --- a/pkg/process/net/check_windows.go +++ /dev/null @@ -1,68 +0,0 @@ -// Unless explicitly stated otherwise all files in this repository are licensed -// under the Apache License Version 2.0. -// This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2016-present Datadog, Inc. - -//go:build windows - -// Package net provides local access to system probe -package net - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - - sysconfig "github.com/DataDog/datadog-agent/cmd/system-probe/config" - sysconfigtypes "github.com/DataDog/datadog-agent/cmd/system-probe/config/types" - "github.com/DataDog/datadog-agent/pkg/collector/corechecks/system/wincrashdetect/probe" -) - -const ( - checksURL = "http://sysprobe/%s/check" -) - -// GetCheck returns the check output of the specified module -func (r *RemoteSysProbeUtil) GetCheck(module sysconfigtypes.ModuleName) (interface{}, error) { - - switch module { - default: - return nil, fmt.Errorf("invalid check name: %s", module) - case sysconfig.WindowsCrashDetectModule: - // don't need to do anything - - // as additional checks are added, simply add case statements for - // newly expected check names. - } - url := fmt.Sprintf(checksURL, module) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, err - } - - resp, err := r.httpClient.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("conn request failed: socket %s, url %s, status code: %d", r.path, req.URL, resp.StatusCode) - } - - body, err := io.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - if module == sysconfig.WindowsCrashDetectModule { - var data probe.WinCrashStatus - err = json.Unmarshal(body, &data) - if err != nil { - return nil, err - } - return data, nil - } - - return nil, fmt.Errorf("invalid check name: %s", module) -} diff --git a/pkg/process/net/common_all.go b/pkg/process/net/common_all.go index 79131b8c7c7f4..9dee717e7b6bb 100644 --- a/pkg/process/net/common_all.go +++ b/pkg/process/net/common_all.go @@ -3,6 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. +// Package net provides local access to system probe package net import "errors" diff --git a/pkg/process/net/common_unsupported.go b/pkg/process/net/common_unsupported.go index 49bdc772284bb..724ce20b15ab4 100644 --- a/pkg/process/net/common_unsupported.go +++ b/pkg/process/net/common_unsupported.go @@ -5,7 +5,6 @@ //go:build !linux && !windows -//nolint:revive // TODO(PROC) Fix revive linter package net import ( @@ -13,7 +12,6 @@ import ( model "github.com/DataDog/agent-payload/v5/process" - sysconfigtypes "github.com/DataDog/datadog-agent/cmd/system-probe/config/types" discoverymodel "github.com/DataDog/datadog-agent/pkg/collector/corechecks/servicediscovery/model" "github.com/DataDog/datadog-agent/pkg/languagedetection/languagemodels" nppayload "github.com/DataDog/datadog-agent/pkg/networkpath/payload" @@ -92,18 +90,17 @@ func (r *RemoteSysProbeUtil) GetConnTrackHost() ([]byte, error) { return nil, Er // GetBTFLoaderInfo is not supported func (r *RemoteSysProbeUtil) GetBTFLoaderInfo() ([]byte, error) { return nil, ErrNotImplemented } +// GetDiscoveryServices is not supported func (r *RemoteSysProbeUtil) GetDiscoveryServices() (*discoverymodel.ServicesResponse, error) { return nil, ErrNotImplemented } -func (r *RemoteSysProbeUtil) GetCheck(module sysconfigtypes.ModuleName) (interface{}, error) { - return nil, ErrNotImplemented -} - -func (r *RemoteSysProbeUtil) GetPing(clientID string, host string, count int, interval time.Duration, timeout time.Duration) ([]byte, error) { +// GetPing is not supported +func (r *RemoteSysProbeUtil) GetPing(_ string, _ string, _ int, _ time.Duration, _ time.Duration) ([]byte, error) { return nil, ErrNotImplemented } -func (r *RemoteSysProbeUtil) GetTraceroute(clientID string, host string, port uint16, protocol nppayload.Protocol, maxTTL uint8, timeout time.Duration) ([]byte, error) { +// GetTraceroute is not supported +func (r *RemoteSysProbeUtil) GetTraceroute(_ string, _ string, _ uint16, _ nppayload.Protocol, _ uint8, _ time.Duration) ([]byte, error) { return nil, ErrNotImplemented } diff --git a/pkg/process/net/mocks/sys_probe_util.go b/pkg/process/net/mocks/sys_probe_util.go index d0a26d64392b7..17363f0c57603 100644 --- a/pkg/process/net/mocks/sys_probe_util.go +++ b/pkg/process/net/mocks/sys_probe_util.go @@ -13,8 +13,6 @@ import ( process "github.com/DataDog/agent-payload/v5/process" time "time" - - types "github.com/DataDog/datadog-agent/cmd/system-probe/config/types" ) // SysProbeUtil is an autogenerated mock type for the SysProbeUtil type @@ -145,64 +143,6 @@ func (_c *SysProbeUtil_GetBTFLoaderInfo_Call) RunAndReturn(run func() ([]byte, e return _c } -// GetCheck provides a mock function with given fields: module -func (_m *SysProbeUtil) GetCheck(module types.ModuleName) (interface{}, error) { - ret := _m.Called(module) - - if len(ret) == 0 { - panic("no return value specified for GetCheck") - } - - var r0 interface{} - var r1 error - if rf, ok := ret.Get(0).(func(types.ModuleName) (interface{}, error)); ok { - return rf(module) - } - if rf, ok := ret.Get(0).(func(types.ModuleName) interface{}); ok { - r0 = rf(module) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(interface{}) - } - } - - if rf, ok := ret.Get(1).(func(types.ModuleName) error); ok { - r1 = rf(module) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SysProbeUtil_GetCheck_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCheck' -type SysProbeUtil_GetCheck_Call struct { - *mock.Call -} - -// GetCheck is a helper method to define mock.On call -// - module types.ModuleName -func (_e *SysProbeUtil_Expecter) GetCheck(module interface{}) *SysProbeUtil_GetCheck_Call { - return &SysProbeUtil_GetCheck_Call{Call: _e.mock.On("GetCheck", module)} -} - -func (_c *SysProbeUtil_GetCheck_Call) Run(run func(module types.ModuleName)) *SysProbeUtil_GetCheck_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(types.ModuleName)) - }) - return _c -} - -func (_c *SysProbeUtil_GetCheck_Call) Return(_a0 interface{}, _a1 error) *SysProbeUtil_GetCheck_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *SysProbeUtil_GetCheck_Call) RunAndReturn(run func(types.ModuleName) (interface{}, error)) *SysProbeUtil_GetCheck_Call { - _c.Call.Return(run) - return _c -} - // GetConnTrackCached provides a mock function with given fields: func (_m *SysProbeUtil) GetConnTrackCached() ([]byte, error) { ret := _m.Called() diff --git a/pkg/process/net/shared.go b/pkg/process/net/shared.go index 3d6bd59f892fc..3c302246382fd 100644 --- a/pkg/process/net/shared.go +++ b/pkg/process/net/shared.go @@ -10,7 +10,6 @@ import ( model "github.com/DataDog/agent-payload/v5/process" - sysconfigtypes "github.com/DataDog/datadog-agent/cmd/system-probe/config/types" discoverymodel "github.com/DataDog/datadog-agent/pkg/collector/corechecks/servicediscovery/model" "github.com/DataDog/datadog-agent/pkg/languagedetection/languagemodels" nppayload "github.com/DataDog/datadog-agent/pkg/networkpath/payload" @@ -34,7 +33,6 @@ type SysProbeUtil interface { DetectLanguage(pids []int32) ([]languagemodels.Language, error) GetPprof(path string) ([]byte, error) GetDiscoveryServices() (*discoverymodel.ServicesResponse, error) - GetCheck(module sysconfigtypes.ModuleName) (interface{}, error) GetPing(clientID string, host string, count int, interval time.Duration, timeout time.Duration) ([]byte, error) GetTraceroute(clientID string, host string, port uint16, protocol nppayload.Protocol, maxTTL uint8, timeout time.Duration) ([]byte, error) } diff --git a/pkg/process/net/uds.go b/pkg/process/net/uds.go deleted file mode 100644 index 85c46b70354c5..0000000000000 --- a/pkg/process/net/uds.go +++ /dev/null @@ -1,99 +0,0 @@ -// Unless explicitly stated otherwise all files in this repository are licensed -// under the Apache License Version 2.0. -// This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2016-present Datadog, Inc. - -//go:build linux || darwin - -package net - -import ( - "fmt" - "net" - "os" - - "github.com/DataDog/datadog-agent/pkg/util/filesystem" - "github.com/DataDog/datadog-agent/pkg/util/log" -) - -// UDSListener (Unix Domain Socket Listener) -type UDSListener struct { - conn net.Listener - socketPath string -} - -// newSocketListener creates a Unix Domain Socket Listener -func newSocketListener(socketAddr string) (*UDSListener, error) { - if len(socketAddr) == 0 { - return nil, fmt.Errorf("uds: empty socket path provided") - } - - addr, err := net.ResolveUnixAddr("unix", socketAddr) - if err != nil { - return nil, fmt.Errorf("uds: can't ResolveUnixAddr: %v", err) - } - - // Check to see if there's a pre-existing system probe socket. - fileInfo, err := os.Stat(socketAddr) - if err == nil { // No error means the socket file already exists - // If it's not a UNIX socket, then this is a problem. - if fileInfo.Mode()&os.ModeSocket == 0 { - return nil, fmt.Errorf("uds: cannot reuse %s socket path: path already exists and it is not a UNIX socket", socketAddr) - } - // Attempt to remove the pre-existing socket - if err = os.Remove(socketAddr); err != nil { - return nil, fmt.Errorf("uds: cannot remove stale UNIX socket: %v", err) - } - } - - conn, err := net.Listen("unix", addr.Name) - if err != nil { - return nil, fmt.Errorf("can't listen: %s", err) - } - - if err := os.Chmod(socketAddr, 0720); err != nil { - return nil, fmt.Errorf("can't set the socket at write only: %s", err) - } - - perms, err := filesystem.NewPermission() - if err != nil { - return nil, err - } - - if err := perms.RestrictAccessToUser(socketAddr); err != nil { - return nil, err - } - - listener := &UDSListener{ - conn: conn, - socketPath: socketAddr, - } - - log.Debugf("uds: %s successfully initialized", conn.Addr()) - return listener, nil -} - -// NewSystemProbeListener returns an idle UDSListener -func NewSystemProbeListener(socketAddr string) (*UDSListener, error) { - var listener, err = newSocketListener(socketAddr) - if err != nil { - return nil, fmt.Errorf("error creating IPC socket: %s", err) - } - - return listener, err -} - -// GetListener will return the underlying Conn's net.Listener -func (l *UDSListener) GetListener() net.Listener { - return l.conn -} - -// Stop closes the UDSListener connection and stops listening -func (l *UDSListener) Stop() { - _ = l.conn.Close() - - // Socket cleanup on exit - above conn.Close() should remove it, but just in case. - if err := os.Remove(l.socketPath); err != nil { - log.Debugf("uds: error removing socket file: %s", err) - } -} diff --git a/pkg/process/net/windows_pipe.go b/pkg/process/net/windows_pipe.go deleted file mode 100644 index 2475511e9a590..0000000000000 --- a/pkg/process/net/windows_pipe.go +++ /dev/null @@ -1,72 +0,0 @@ -// Unless explicitly stated otherwise all files in this repository are licensed -// under the Apache License Version 2.0. -// This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2016-present Datadog, Inc. - -//go:build windows - -package net - -import ( - "fmt" - "net" - - "github.com/Microsoft/go-winio" -) - -const ( - // Buffer sizes for the system probe named pipe. - // The sizes are advisory, Windows can adjust them, but should be small enough to preserve - // the nonpaged pool. - namedPipeInputBufferSize = int32(4096) - namedPipeOutputBufferSize = int32(4096) - - // DACL for the system probe named pipe. - // SE_DACL_PROTECTED (P), SE_DACL_AUTO_INHERITED (AI) - // Allow Everyone (WD) - // nolint:revive // TODO: Hardened DACL and ensure the datadogagent run-as user is allowed. - namedPipeSecurityDescriptor = "D:PAI(A;;FA;;;WD)" -) - -// WindowsPipeListener for communicating with Probe -type WindowsPipeListener struct { - conn net.Listener - pipePath string -} - -// systemProbePipSecurityDescriptor has the effective DACL for the system probe named pipe. -var systemProbePipSecurityDescriptor = namedPipeSecurityDescriptor - -// newPipeListener creates a standardized named pipe server and with hardened ACL -func newPipeListener(namedPipeName string) (net.Listener, error) { - // The DACL must allow the run-as user of datadogagent. - config := winio.PipeConfig{ - SecurityDescriptor: systemProbePipSecurityDescriptor, - InputBufferSize: namedPipeInputBufferSize, - OutputBufferSize: namedPipeOutputBufferSize, - } - - // winio specifies virtually unlimited number of named pipe instances but is limited by - // the nonpaged pool. - return winio.ListenPipe(namedPipeName, &config) -} - -// NewSystemProbeListener sets up a named pipe listener for the system probe service. -func NewSystemProbeListener(namedPipePath string) (*WindowsPipeListener, error) { - namedPipe, err := newPipeListener(namedPipePath) - if err != nil { - return nil, fmt.Errorf("error named pipe %s : %s", namedPipePath, err) - } - - return &WindowsPipeListener{namedPipe, namedPipePath}, nil -} - -// GetListener will return underlying Listener's conn -func (wp *WindowsPipeListener) GetListener() net.Listener { - return wp.conn -} - -// Stop closes the WindowsPipeListener connection and stops listening -func (wp *WindowsPipeListener) Stop() { - wp.conn.Close() -} diff --git a/pkg/security/secl/go.mod b/pkg/security/secl/go.mod index 6140e2523d38d..9e1263fed7d5d 100644 --- a/pkg/security/secl/go.mod +++ b/pkg/security/secl/go.mod @@ -3,7 +3,7 @@ module github.com/DataDog/datadog-agent/pkg/security/secl go 1.22.0 require ( - github.com/Masterminds/semver/v3 v3.3.0 + github.com/Masterminds/semver/v3 v3.3.1 github.com/Masterminds/sprig/v3 v3.3.0 github.com/alecthomas/participle v0.7.1 github.com/davecgh/go-spew v1.1.1 diff --git a/pkg/security/secl/go.sum b/pkg/security/secl/go.sum index d338e78d08387..790ae4a5627db 100644 --- a/pkg/security/secl/go.sum +++ b/pkg/security/secl/go.sum @@ -2,8 +2,8 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= -github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4= +github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/alecthomas/participle v0.7.1 h1:2bN7reTw//5f0cugJcTOnY/NYZcWQOaajW+BwZB5xWs= diff --git a/pkg/serializer/go.mod b/pkg/serializer/go.mod index 35b6c05380658..1ddabf44a07a1 100644 --- a/pkg/serializer/go.mod +++ b/pkg/serializer/go.mod @@ -69,15 +69,15 @@ require ( github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorinterface v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/serializer/compression v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/aggregator/ckey v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 github.com/DataDog/datadog-agent/pkg/metrics v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/process/util/api v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/tagger/types v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/tagset v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/util/json v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/DataDog/datadog-agent/pkg/version v0.57.1 github.com/DataDog/opentelemetry-mapping-go/pkg/quantile v0.21.0 github.com/gogo/protobuf v1.3.2 @@ -92,16 +92,16 @@ require ( github.com/DataDog/datadog-agent/comp/core/flare/builder v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/log/def v0.0.0-00010101000000-000000000000 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/status v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/def v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/api v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/orchestrator/model v0.56.0-rc.3 // indirect @@ -109,18 +109,18 @@ require ( github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/buf v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/common v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/sort v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/mmh3 v0.0.0-20210722141835-012dc69a9e49 // indirect github.com/DataDog/sketches-go v1.4.4 // indirect github.com/DataDog/viper v1.13.5 // indirect diff --git a/pkg/serverless/logs/logs_collector.go b/pkg/serverless/logs/logs_collector.go index 1a9e1ffde1091..22ecaed3fee92 100644 --- a/pkg/serverless/logs/logs_collector.go +++ b/pkg/serverless/logs/logs_collector.go @@ -28,7 +28,7 @@ const ( maxBufferedLogs = 2000 // Bottlecap Failover - bottlecapFailoverReasonEnvVar = "DD_EXTENSION_FAILOVER_REASON" + bottlecapFailoverReasonEnvVar = "DD_EXTENSION_FALLBACK_REASON" ) // Tags contains the actual array of Tags (useful for passing it via reference) diff --git a/pkg/serverless/logs/logs_test.go b/pkg/serverless/logs/logs_test.go index ed0e48336020a..0eb49fd520cd1 100644 --- a/pkg/serverless/logs/logs_test.go +++ b/pkg/serverless/logs/logs_test.go @@ -478,7 +478,7 @@ func TestProcessMessageShouldSendFailoverMetric(t *testing.T) { message := LambdaLogAPIMessage{ logType: logTypeExtension, time: time.Now(), - stringRecord: "{\"DD_EXTENSION_FAILOVER_REASON\":\"test-reason\"}", + stringRecord: "{\"DD_EXTENSION_FALLBACK_REASON\":\"test-reason\"}", } arn := "arn:aws:lambda:us-east-1:123456789012:function:test-function" lastRequestID := "8286a188-ba32-4475-8077-530cd35c09a9" @@ -504,7 +504,7 @@ func TestProcessMessageShouldSendFailoverMetric(t *testing.T) { // even if enhanced metrics are disabled, we should still send the failover metric lc.enhancedMetricsEnabled = false - message.stringRecord = "{\"DD_EXTENSION_FAILOVER_REASON\":\"test-reason\"}" // add again bc processing empties it + message.stringRecord = "{\"DD_EXTENSION_FALLBACK_REASON\":\"test-reason\"}" // add again bc processing empties it lc.processMessage(&message) received, timed = demux.WaitForNumberOfSamples(1, 0, 100*time.Millisecond) diff --git a/pkg/snmp/snmp.go b/pkg/snmp/snmp.go index 6913ae4a866a7..8e63ad76a6d3e 100644 --- a/pkg/snmp/snmp.go +++ b/pkg/snmp/snmp.go @@ -10,15 +10,14 @@ import ( "fmt" "hash/fnv" "net" - "reflect" "sort" "strconv" "time" - "github.com/DataDog/viper" "github.com/gosnmp/gosnmp" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" + "github.com/DataDog/datadog-agent/pkg/config/structure" "github.com/DataDog/datadog-agent/pkg/snmp/gosnmplib" "github.com/DataDog/datadog-agent/pkg/snmp/snmpintegration" @@ -99,33 +98,18 @@ type intOrBoolPtr interface { // NewListenerConfig parses configuration and returns a built ListenerConfig func NewListenerConfig() (ListenerConfig, error) { var snmpConfig ListenerConfig - opt := viper.DecodeHook( - func(rf reflect.Kind, rt reflect.Kind, data interface{}) (interface{}, error) { - // Turn an array into a map for ignored addresses - if rf != reflect.Slice { - return data, nil - } - if rt != reflect.Map { - return data, nil - } - newData := map[interface{}]bool{} - for _, i := range data.([]interface{}) { - newData[i] = true - } - return newData, nil - }, - ) // Set defaults before unmarshalling snmpConfig.CollectDeviceMetadata = true snmpConfig.CollectTopology = true - if pkgconfigsetup.Datadog().IsSet("network_devices.autodiscovery") { - err := pkgconfigsetup.Datadog().UnmarshalKey("network_devices.autodiscovery", &snmpConfig, opt) + ddcfg := pkgconfigsetup.Datadog() + if ddcfg.IsSet("network_devices.autodiscovery") { + err := structure.UnmarshalKey(ddcfg, "network_devices.autodiscovery", &snmpConfig, structure.ImplicitlyConvertArrayToMapSet) if err != nil { return snmpConfig, err } - } else if pkgconfigsetup.Datadog().IsSet("snmp_listener") { - err := pkgconfigsetup.Datadog().UnmarshalKey("snmp_listener", &snmpConfig, opt) + } else if ddcfg.IsSet("snmp_listener") { + err := structure.UnmarshalKey(ddcfg, "snmp_listener", &snmpConfig, structure.ImplicitlyConvertArrayToMapSet) if err != nil { return snmpConfig, err } diff --git a/pkg/snmp/snmpparse/config_snmp.go b/pkg/snmp/snmpparse/config_snmp.go index 13f90a7141e7b..e544f22e9a759 100644 --- a/pkg/snmp/snmpparse/config_snmp.go +++ b/pkg/snmp/snmpparse/config_snmp.go @@ -10,17 +10,15 @@ import ( "encoding/json" "errors" "fmt" - yaml "gopkg.in/yaml.v2" "net" "net/url" - "reflect" - - "github.com/DataDog/viper" - apiutil "github.com/DataDog/datadog-agent/pkg/api/util" + yaml "gopkg.in/yaml.v2" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" "github.com/DataDog/datadog-agent/comp/core/config" + apiutil "github.com/DataDog/datadog-agent/pkg/api/util" + "github.com/DataDog/datadog-agent/pkg/config/structure" snmplistener "github.com/DataDog/datadog-agent/pkg/snmp" ) @@ -81,34 +79,18 @@ func ParseConfigSnmp(c integration.Config) []SNMPConfig { } func parseConfigSnmpMain(conf config.Component) ([]SNMPConfig, error) { - var snmpconfigs []SNMPConfig - var configs []snmplistener.Config - opt := viper.DecodeHook( - func(rf reflect.Kind, rt reflect.Kind, data interface{}) (interface{}, error) { - // Turn an array into a map for ignored addresses - if rf != reflect.Slice { - return data, nil - } - if rt != reflect.Map { - return data, nil - } - newData := map[interface{}]bool{} - for _, i := range data.([]interface{}) { - newData[i] = true - } - return newData, nil - }, - ) - // the UnmarshalKey stores the result in mapstructures while the snmpconfig is in yaml - // so for each result of the Unmarshal key we store the result in a tmp SNMPConfig{} object + snmpconfigs := []SNMPConfig{} + configs := []snmplistener.Config{} + //the UnmarshalKey stores the result in mapstructures while the snmpconfig is in yaml + //so for each result of the Unmarshal key we store the result in a tmp SNMPConfig{} object if conf.IsSet("network_devices.autodiscovery.configs") { - err := conf.UnmarshalKey("network_devices.autodiscovery.configs", &configs, opt) + err := structure.UnmarshalKey(conf, "network_devices.autodiscovery.configs", &configs, structure.ImplicitlyConvertArrayToMapSet) if err != nil { fmt.Printf("unable to get snmp config from network_devices.autodiscovery: %v", err) return nil, err } } else if conf.IsSet("snmp_listener.configs") { - err := conf.UnmarshalKey("snmp_listener.configs", &configs, opt) + err := structure.UnmarshalKey(conf, "snmp_listener.configs", &configs, structure.ImplicitlyConvertArrayToMapSet) if err != nil { fmt.Printf("unable to get snmp config from snmp_listener: %v", err) return nil, err diff --git a/pkg/snmp/snmpparse/config_snmp_test.go b/pkg/snmp/snmpparse/config_snmp_test.go index fc2ec479adaaa..56315ecb45dc5 100644 --- a/pkg/snmp/snmpparse/config_snmp_test.go +++ b/pkg/snmp/snmpparse/config_snmp_test.go @@ -297,7 +297,8 @@ func TestParseConfigSnmpMain(t *testing.T) { fx.Replace(config.MockParams{Overrides: rawConf}), ) - Output, _ := parseConfigSnmpMain(conf) + Output, err := parseConfigSnmpMain(conf) + require.NoError(t, err) Exoutput := []SNMPConfig{ { Version: "1", @@ -337,7 +338,8 @@ network_devices: fx.Replace(config.MockParams{Overrides: rawConf}), ) - Output, _ := parseConfigSnmpMain(conf) + Output, err := parseConfigSnmpMain(conf) + require.NoError(t, err) Exoutput := []SNMPConfig{ { Version: "1", diff --git a/pkg/util/crashreport/crashreport.go b/pkg/util/crashreport/crashreport.go index 8c04cdbb6c11c..563b1cb1adcfb 100644 --- a/pkg/util/crashreport/crashreport.go +++ b/pkg/util/crashreport/crashreport.go @@ -10,11 +10,12 @@ package crashreport import ( "fmt" + "net/http" + sysprobeclient "github.com/DataDog/datadog-agent/cmd/system-probe/api/client" sysconfig "github.com/DataDog/datadog-agent/cmd/system-probe/config" "github.com/DataDog/datadog-agent/pkg/collector/corechecks/system/wincrashdetect/probe" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" - process_net "github.com/DataDog/datadog-agent/pkg/process/net" "github.com/DataDog/datadog-agent/pkg/util/log" "github.com/DataDog/datadog-agent/pkg/util/retry" @@ -27,6 +28,7 @@ type WinCrashReporter struct { baseKey string startupWarnCount int hasRunOnce bool + sysProbeClient *http.Client } const ( @@ -38,8 +40,9 @@ const ( // crash registry keys func NewWinCrashReporter(hive registry.Key, key string) (*WinCrashReporter, error) { wcr := &WinCrashReporter{ - hive: hive, - baseKey: key, + hive: hive, + baseKey: key, + sysProbeClient: sysprobeclient.Get(pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")), } return wcr, nil } @@ -101,20 +104,11 @@ func (wcr *WinCrashReporter) CheckForCrash() (*probe.WinCrashStatus, error) { if wcr.hasRunOnce { return nil, nil } - sysProbeUtil, err := process_net.GetRemoteSystemProbeUtil( - pkgconfigsetup.SystemProbe().GetString("system_probe_config.sysprobe_socket")) - if err != nil { - return nil, wcr.handleStartupError(err) - } - data, err := sysProbeUtil.GetCheck(sysconfig.WindowsCrashDetectModule) + crash, err := sysprobeclient.GetCheck[probe.WinCrashStatus](wcr.sysProbeClient, sysconfig.WindowsCrashDetectModule) if err != nil { return nil, wcr.handleStartupError(err) } - crash, ok := data.(probe.WinCrashStatus) - if !ok { - return nil, fmt.Errorf("Raw data has incorrect type") - } // Crash dump processing is not done yet, nothing to send at the moment. Try later. if crash.StatusCode == probe.WinCrashStatusCodeBusy { diff --git a/pkg/util/fxutil/provide_comp.go b/pkg/util/fxutil/provide_comp.go index 7fd95295a337d..83416ef8815e4 100644 --- a/pkg/util/fxutil/provide_comp.go +++ b/pkg/util/fxutil/provide_comp.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "reflect" + "runtime" "slices" "unicode" "unicode/utf8" @@ -63,16 +64,26 @@ func ProvideComponentConstructor(compCtorFunc interface{}) fx.Option { // type-check the input argument to the constructor ctorFuncType := reflect.TypeOf(compCtorFunc) if ctorFuncType.Kind() != reflect.Func || ctorFuncType.NumIn() > 1 || ctorFuncType.NumOut() == 0 || ctorFuncType.NumOut() > 2 { - return fx.Error(errors.New("argument must be a function with 0 or 1 arguments, and 1 or 2 return values")) + // Caller(1) is the caller of *this* function, which should be a fx.go source file. + // This info lets us show better error messages to developers + _, file, line, _ := runtime.Caller(1) + errtext := fmt.Sprintf("%s:%d: argument must be a function with 0 or 1 arguments, and 1 or 2 return values", file, line) + return fx.Error(errors.New(errtext)) } if ctorFuncType.NumIn() > 0 && ctorFuncType.In(0).Kind() != reflect.Struct { - return fx.Error(errors.New(`constructor must either take 0 arguments, or 1 "requires" struct`)) + // Once we know the Kind == reflect.Func, we can get extra info like the function's name + funcname := runtime.FuncForPC(reflect.ValueOf(compCtorFunc).Pointer()).Name() + _, file, line, _ := runtime.Caller(1) + errmsg := fmt.Sprintf(`constructor %s must either take 0 arguments, or 1 "requires" struct`, funcname) + errtext := fmt.Sprintf("%s:%d: %s", file, line, errmsg) + return fx.Error(errors.New(errtext)) } hasZeroArg := ctorFuncType.NumIn() == 0 ctorTypes, err := getConstructorTypes(ctorFuncType) if err != nil { - return fx.Error(err) + _, file, line, _ := runtime.Caller(1) + return fx.Error(fmt.Errorf("%s:%d: %s", file, line, err)) } // build reflect.Type of the constructor function that will be provided to `fx.Provide` diff --git a/pkg/util/fxutil/provide_comp_test.go b/pkg/util/fxutil/provide_comp_test.go index 32055ce007a1b..3a0fe914124c4 100644 --- a/pkg/util/fxutil/provide_comp_test.go +++ b/pkg/util/fxutil/provide_comp_test.go @@ -10,6 +10,7 @@ import ( "encoding/json" "fmt" "reflect" + "regexp" "sort" "strings" "testing" @@ -43,19 +44,19 @@ func TestValidArgumentAndReturnValue(t *testing.T) { func TestInvalidArgumentOrReturnValue(t *testing.T) { errOpt := ProvideComponentConstructor(1) - assertIsSingleError(t, errOpt, "argument must be a function with 0 or 1 arguments, and 1 or 2 return values") + assertErrorWithSourceInfo(t, errOpt, "argument must be a function with 0 or 1 arguments, and 1 or 2 return values") errOpt = ProvideComponentConstructor(func() {}) - assertIsSingleError(t, errOpt, "argument must be a function with 0 or 1 arguments, and 1 or 2 return values") + assertErrorWithSourceInfo(t, errOpt, "argument must be a function with 0 or 1 arguments, and 1 or 2 return values") errOpt = ProvideComponentConstructor(func(FirstComp) SecondComp { return &secondImpl{} }) - assertIsSingleError(t, errOpt, `constructor must either take 0 arguments, or 1 "requires" struct`) + assertErrorWithSourceInfo(t, errOpt, `must either take 0 arguments, or 1 "requires" struct`) errOpt = ProvideComponentConstructor(func() (FirstComp, SecondComp) { return &firstImpl{}, &secondImpl{} }) - assertIsSingleError(t, errOpt, "second return value must be error, got fxutil.SecondComp") + assertErrorWithSourceInfo(t, errOpt, "second return value must be error, got fxutil.SecondComp") errOpt = ProvideComponentConstructor(func(requires1, requires2) FirstComp { return &firstImpl{} }) - assertIsSingleError(t, errOpt, "argument must be a function with 0 or 1 arguments, and 1 or 2 return values") + assertErrorWithSourceInfo(t, errOpt, "argument must be a function with 0 or 1 arguments, and 1 or 2 return values") } func TestGetConstructorTypes(t *testing.T) { @@ -553,14 +554,20 @@ func assertNoCtorError(t *testing.T, arg fx.Option) { } } -func assertIsSingleError(t *testing.T, arg fx.Option, errMsg string) { +func assertErrorWithSourceInfo(t *testing.T, arg fx.Option, errMsgContained string) { t.Helper() app := fx.New(arg) err := app.Err() if err == nil { t.Fatalf("expected an error, instead got %v of type %T", arg, arg) - } else if err.Error() != errMsg { - t.Fatalf("errror mismatch, expected %v, got %v", errMsg, err.Error()) + } else if !strings.Contains(err.Error(), errMsgContained) { + t.Fatalf(`error mismatch, expected to contain "%v", got "%v"`, errMsgContained, err.Error()) + } + // Assert that the callsite shows up in the error, with source file and line number + re := regexp.MustCompile(`pkg/util/fxutil/provide_comp_test.go:\d+:`) + match := re.FindString(err.Error()) + if match == "" { + t.Fatalf(`error expected to contain source file and line number, got "%v"`, err.Error()) } } diff --git a/pkg/util/grpc/go.mod b/pkg/util/grpc/go.mod index 023e84c3c7828..d4f475022ff4c 100644 --- a/pkg/util/grpc/go.mod +++ b/pkg/util/grpc/go.mod @@ -37,7 +37,7 @@ replace ( require ( github.com/DataDog/datadog-agent/pkg/api v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/proto v0.56.0-rc.3 - github.com/DataDog/datadog-agent/pkg/util/log v0.57.1 + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 github.com/stretchr/testify v1.9.0 @@ -46,23 +46,24 @@ require ( ) require ( - github.com/DataDog/datadog-agent/comp/core/secrets v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/model v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/setup v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.56.0-rc.3 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect github.com/DataDog/viper v1.13.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect @@ -106,3 +107,5 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/DataDog/datadog-agent/pkg/config/structure => ../../config/structure diff --git a/test/otel/go.mod b/test/otel/go.mod index 326e90ea51055..ea718cbe70eed 100644 --- a/test/otel/go.mod +++ b/test/otel/go.mod @@ -102,8 +102,8 @@ require ( github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/metricsclient v0.56.0-rc.3 github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/statsprocessor v0.56.0-rc.1 - github.com/DataDog/datadog-agent/pkg/config/model v0.57.1 - github.com/DataDog/datadog-agent/pkg/config/setup v0.57.1 + github.com/DataDog/datadog-agent/pkg/config/model v0.59.0 + github.com/DataDog/datadog-agent/pkg/config/setup v0.59.0 github.com/DataDog/datadog-agent/pkg/proto v0.56.0-rc.3 github.com/DataDog/datadog-agent/pkg/trace v0.56.0-rc.3 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog v0.113.0 @@ -119,17 +119,17 @@ require ( github.com/DataDog/agent-payload/v5 v5.0.119 // indirect github.com/DataDog/datadog-agent/comp/core/flare/builder v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/core/flare/types v0.57.1 // indirect - github.com/DataDog/datadog-agent/comp/core/secrets v0.57.1 // indirect + github.com/DataDog/datadog-agent/comp/core/secrets v0.59.0 // indirect github.com/DataDog/datadog-agent/comp/core/telemetry v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/def v0.57.1 // indirect github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/trace/compression/def v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/comp/trace/compression/impl-gzip v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/env v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect + github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/env v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/config/mock v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/nodetreemodel v0.60.0-devel // indirect - github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000 // indirect + github.com/DataDog/datadog-agent/pkg/config/structure v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.60.0-devel // indirect github.com/DataDog/datadog-agent/pkg/config/utils v0.57.1 // indirect github.com/DataDog/datadog-agent/pkg/logs/auditor v0.56.0-rc.3 // indirect @@ -150,21 +150,21 @@ require ( github.com/DataDog/datadog-agent/pkg/telemetry v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/backoff v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/cgroups v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/executable v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/filesystem v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/executable v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/filesystem v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/fxutil v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.58.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/http v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/log v0.58.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/optional v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/pointer v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/scrubber v0.58.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/log v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/optional v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/pointer v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/startstop v0.56.0-rc.3 // indirect github.com/DataDog/datadog-agent/pkg/util/statstracker v0.56.0-rc.3 // indirect - github.com/DataDog/datadog-agent/pkg/util/system v0.57.1 // indirect - github.com/DataDog/datadog-agent/pkg/util/system/socket v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/system v0.59.0 // indirect + github.com/DataDog/datadog-agent/pkg/util/system/socket v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0 // indirect - github.com/DataDog/datadog-agent/pkg/util/winutil v0.57.1 // indirect + github.com/DataDog/datadog-agent/pkg/util/winutil v0.59.0 // indirect github.com/DataDog/datadog-agent/pkg/version v0.57.1 // indirect github.com/DataDog/datadog-api-client-go/v2 v2.26.0 // indirect github.com/DataDog/datadog-go/v5 v5.5.0 // indirect