From 021ffb2eb52310e6da1d95ea14e5a63821b47a3c Mon Sep 17 00:00:00 2001 From: Maxime mouial Date: Thu, 24 Nov 2022 16:41:09 +0100 Subject: [PATCH] WIP --- .golangci.yml | 2 +- pkg/flare/archive.go | 10 +--------- pkg/flare/archive_dca.go | 12 ++++++------ pkg/flare/archive_security.go | 18 +++++++++--------- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c4ebfcccc37bfa..a9019040a482da 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -74,7 +74,7 @@ linters-settings: errcheck: # Disable warnings for `fmt` and `log` packages. Also ignore `Write` functions from `net/http` package. # Disable warnings for select Windows functions - ignore: fmt:.*,github.com/DataDog/datadog-agent/pkg/util/log:.*,github.com/DataDog/datadog-agent/comp/core/log:.*,net/http:Write,github.com/DataDog/datadog-agent/pkg/trace/metrics:.*,github.com/DataDog/datadog-agent/pkg/collector/corechecks:Warnf?,golang.org/x/sys/windows:(CloseHandle|FreeLibrary|FreeSid|RegCloseKey|SetEvent),syscall:CloseHandle,golang.org/x/sys/windows/svc/mgr:Disconnect,golang.org/x/sys/windows/svc/debug:(Close|Error|Info|Warning),github.com/lxn/walk:Dispose + ignore: fmt:.*,github.com/DataDog/datadog-agent/pkg/util/log:.*,github.com/DataDog/datadog-agent/comp/core/log:.*,net/http:Write,github.com/DataDog/datadog-agent/pkg/trace/metrics:.*,github.com/DataDog/datadog-agent/pkg/collector/corechecks:Warnf?,golang.org/x/sys/windows:(CloseHandle|FreeLibrary|FreeSid|RegCloseKey|SetEvent),syscall:CloseHandle,golang.org/x/sys/windows/svc/mgr:Disconnect,golang.org/x/sys/windows/svc/debug:(Close|Error|Info|Warning),github.com/lxn/walk:Dispose,github.com/DataDog/datadog-agent/comp/core/flare/helpers:(AddFile.*|CopyDir.*|CopyFile.*) staticcheck: go: "1.17" checks: ["all", diff --git a/pkg/flare/archive.go b/pkg/flare/archive.go index 1cb1b73f0e1a8c..d8053702f8c7ab 100644 --- a/pkg/flare/archive.go +++ b/pkg/flare/archive.go @@ -38,11 +38,6 @@ import ( "gopkg.in/yaml.v2" ) -const ( - // Maximum size for the root directory name - directoryNameMaxSize = 32 -) - var ( pprofURL = fmt.Sprintf("http://127.0.0.1:%s/debug/pprof/goroutine?debug=2", config.Datadog.GetString("expvar_port")) @@ -51,9 +46,6 @@ var ( // Match .yaml and .yml to ship configuration files in the flare. cnfFileExtRx = regexp.MustCompile(`(?i)\.ya?ml`) - - // Filter to clean the directory name from invalid file name characters - directoryNameFilter = regexp.MustCompile(`[^a-zA-Z0-9_-]+`) ) // SearchPaths is just an alias for a map of strings @@ -188,7 +180,7 @@ func createArchive(fb flarehelpers.FlareBuilder, confSearchPaths SearchPaths, lo fb.CopyFile(filepath.Join(config.FileUsedDir(), "install_info")) getConfigFiles(fb, confSearchPaths) - getExpVar(fb) + getExpVar(fb) //nolint:errcheck getWindowsData(fb) if config.Datadog.GetBool("telemetry.enabled") { diff --git a/pkg/flare/archive_dca.go b/pkg/flare/archive_dca.go index 6f20a29c8644e1..0ab1107cabf7c8 100644 --- a/pkg/flare/archive_dca.go +++ b/pkg/flare/archive_dca.go @@ -55,16 +55,16 @@ func createDCAArchive(fb flarehelpers.FlareBuilder, local bool, confSearchPaths getLogFiles(fb, logFilePath) getConfigFiles(fb, confSearchPaths) - getClusterAgentConfigCheck(fb) - getExpVar(fb) - getMetadataMap(fb) - getClusterAgentClusterChecks(fb) - getClusterAgentDiagnose(fb) + getClusterAgentConfigCheck(fb) //nolint:errcheck + getExpVar(fb) //nolint:errcheck + getMetadataMap(fb) //nolint:errcheck + getClusterAgentClusterChecks(fb) //nolint:errcheck + getClusterAgentDiagnose(fb) //nolint:errcheck fb.AddFileFromFunc("envvars.log", getEnvVars) fb.AddFileFromFunc("telemetry.log", QueryDCAMetrics) if config.Datadog.GetBool("external_metrics_provider.enabled") { - getHPAStatus(fb) + getHPAStatus(fb) //nolint:errcheck } } diff --git a/pkg/flare/archive_security.go b/pkg/flare/archive_security.go index c73806d962297b..65fc835f4d36de 100644 --- a/pkg/flare/archive_security.go +++ b/pkg/flare/archive_security.go @@ -44,16 +44,16 @@ func createSecurityAgentArchive(fb flarehelpers.FlareBuilder, local bool, logFil getLogFiles(fb, logFilePath) getConfigFiles(fb, SearchPaths{}) - getComplianceFiles(fb) - getRuntimeFiles(fb) - getExpVar(fb) + getComplianceFiles(fb) //nolint:errcheck + getRuntimeFiles(fb) //nolint:errcheck + getExpVar(fb) //nolint:errcheck fb.AddFileFromFunc("envvars.log", getEnvVars) - getLinuxKernelSymbols(fb) - getLinuxPid1MountInfo(fb) - getLinuxDmesg(fb) - getLinuxKprobeEvents(fb) - getLinuxTracingAvailableEvents(fb) - getLinuxTracingAvailableFilterFunctions(fb) + getLinuxKernelSymbols(fb) //nolint:errcheck + getLinuxPid1MountInfo(fb) //nolint:errcheck + getLinuxDmesg(fb) //nolint:errcheck + getLinuxKprobeEvents(fb) //nolint:errcheck + getLinuxTracingAvailableEvents(fb) //nolint:errcheck + getLinuxTracingAvailableFilterFunctions(fb) //nolint:errcheck } func getComplianceFiles(fb flarehelpers.FlareBuilder) error {