From 0c4a80d37919930b08728bd35bcda8f3666d173c Mon Sep 17 00:00:00 2001 From: Nicolas Schweitzer Date: Mon, 11 Nov 2024 19:16:43 +0100 Subject: [PATCH] fix revive errors --- .../api/v1/languagedetection/util.go | 6 ++-- pkg/clusteragent/languagedetection/patcher.go | 6 ++-- .../corechecks/ebpf/probe/ebpfcheck/prog.go | 4 +-- .../snmp/internal/checkconfig/config_test.go | 36 +++++++++---------- .../snmp/internal/profile/profile.go | 2 +- .../snmp/internal/profile/testing_utils.go | 4 +-- pkg/databasemonitoring/aws/aurora_test.go | 27 +++++++------- .../profiledefinition/profile_definition.go | 2 +- .../profiledefinition/yaml_utils_test.go | 6 ++-- pkg/security/secl/rules/opts.go | 4 +-- 10 files changed, 49 insertions(+), 48 deletions(-) diff --git a/cmd/cluster-agent/api/v1/languagedetection/util.go b/cmd/cluster-agent/api/v1/languagedetection/util.go index 904d0366ca249..eb2442558c5f4 100644 --- a/cmd/cluster-agent/api/v1/languagedetection/util.go +++ b/cmd/cluster-agent/api/v1/languagedetection/util.go @@ -171,9 +171,9 @@ func (ownersLanguages *OwnersLanguages) handleKubeAPIServerUnsetEvents(events [] case workloadmeta.KindKubernetesDeployment: // extract deployment name and namespace from entity id deployment := event.Entity.(*workloadmeta.KubernetesDeployment) - deploymentIds := strings.Split(deployment.GetID().ID, "/") - namespace := deploymentIds[0] - deploymentName := deploymentIds[1] + deploymentIDs := strings.Split(deployment.GetID().ID, "/") + namespace := deploymentIDs[0] + deploymentName := deploymentIDs[1] delete(ownersLanguages.containersLanguages, langUtil.NewNamespacedOwnerReference("apps/v1", langUtil.KindDeployment, deploymentName, namespace)) _ = wlm.Push(workloadmeta.SourceLanguageDetectionServer, workloadmeta.Event{ Type: workloadmeta.EventTypeUnset, diff --git a/pkg/clusteragent/languagedetection/patcher.go b/pkg/clusteragent/languagedetection/patcher.go index 778d69a385f8f..0db562ef67609 100644 --- a/pkg/clusteragent/languagedetection/patcher.go +++ b/pkg/clusteragent/languagedetection/patcher.go @@ -179,9 +179,9 @@ func (lp *languagePatcher) handleDeploymentEvent(event workloadmeta.Event) { deploymentID := event.Entity.(*workloadmeta.KubernetesDeployment).ID // extract deployment name and namespace from entity id - deploymentIds := strings.Split(deploymentID, "/") - namespace := deploymentIds[0] - deploymentName := deploymentIds[1] + deploymentIDs := strings.Split(deploymentID, "/") + namespace := deploymentIDs[0] + deploymentName := deploymentIDs[1] // get the complete entity deployment, err := lp.store.GetKubernetesDeployment(deploymentID) diff --git a/pkg/collector/corechecks/ebpf/probe/ebpfcheck/prog.go b/pkg/collector/corechecks/ebpf/probe/ebpfcheck/prog.go index 26873926fe0b5..2dccb7f0b2a7f 100644 --- a/pkg/collector/corechecks/ebpf/probe/ebpfcheck/prog.go +++ b/pkg/collector/corechecks/ebpf/probe/ebpfcheck/prog.go @@ -67,8 +67,8 @@ type ProgInfo struct { XlatedProgInsns Pointer LoadTime uint64 CreatedByUID uint32 - NrMapIds uint32 - MapIds Pointer + NrMapIDs uint32 + MapIDs Pointer Name ObjName Ifindex uint32 _ [4]byte /* unsupported bitfield */ diff --git a/pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go b/pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go index ce9fbfe8d65e8..86921a64c3b07 100644 --- a/pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go +++ b/pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go @@ -708,7 +708,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"}, }, }, "profile2": profile.ProfileConfig{ @@ -716,7 +716,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.10"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.10"}, }, }, "profile3": profile.ProfileConfig{ @@ -724,7 +724,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.5.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.5.*"}, }, }, } @@ -734,7 +734,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.***.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.***.*"}, }, }, } @@ -744,7 +744,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.[.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.[.*"}, }, }, } @@ -754,7 +754,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, }, }, "profile2": profile.ProfileConfig{ @@ -762,7 +762,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, }, }, "profile3": profile.ProfileConfig{ @@ -770,7 +770,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.4"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.4"}, }, }, } @@ -780,7 +780,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "userMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, }, IsUserProfile: true, }, @@ -789,7 +789,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "defaultMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, }, }, } @@ -799,7 +799,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "defaultMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, }, }, "user-profile": profile.ProfileConfig{ @@ -807,7 +807,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "userMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, }, IsUserProfile: true, }, @@ -818,7 +818,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "defaultMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.*"}, }, }, "user-profile": profile.ProfileConfig{ @@ -826,7 +826,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "userMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.*"}, }, IsUserProfile: true, }, @@ -837,7 +837,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, }, IsUserProfile: true, }, @@ -846,7 +846,7 @@ func Test_getProfileForSysObjectID(t *testing.T) { Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}}, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"}, }, IsUserProfile: true, }, @@ -1120,7 +1120,7 @@ func Test_snmpConfig_setProfile(t *testing.T) { }, }, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"}, } profile2 := profiledefinition.ProfileDefinition{ Device: profiledefinition.DeviceMeta{Vendor: "b-vendor"}, @@ -1171,7 +1171,7 @@ func Test_snmpConfig_setProfile(t *testing.T) { }, }, }, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"}, } mockProfiles := profile.ProfileConfigMap{ diff --git a/pkg/collector/corechecks/snmp/internal/profile/profile.go b/pkg/collector/corechecks/snmp/internal/profile/profile.go index 031d9f945c3f8..2640b177d0b97 100644 --- a/pkg/collector/corechecks/snmp/internal/profile/profile.go +++ b/pkg/collector/corechecks/snmp/internal/profile/profile.go @@ -55,7 +55,7 @@ func GetProfileForSysObjectID(profiles ProfileConfigMap, sysObjectID string) (st var matchedOids []string for profile, profConfig := range profiles { - for _, oidPattern := range profConfig.Definition.SysObjectIds { + for _, oidPattern := range profConfig.Definition.SysObjectIDs { found, err := filepath.Match(oidPattern, sysObjectID) if err != nil { log.Debugf("pattern error: %s", err) diff --git a/pkg/collector/corechecks/snmp/internal/profile/testing_utils.go b/pkg/collector/corechecks/snmp/internal/profile/testing_utils.go index f1d68debaf046..d86bd9e40379c 100644 --- a/pkg/collector/corechecks/snmp/internal/profile/testing_utils.go +++ b/pkg/collector/corechecks/snmp/internal/profile/testing_utils.go @@ -74,7 +74,7 @@ func FixtureProfileDefinitionMap() ProfileConfigMap { Metrics: metrics, Extends: []string{"_base.yaml", "_generic-if.yaml"}, Device: profiledefinition.DeviceMeta{Vendor: "f5"}, - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"}, StaticTags: []string{"static_tag:from_profile_root", "static_tag:from_base_profile"}, MetricTags: []profiledefinition.MetricTagConfig{ { @@ -190,7 +190,7 @@ func FixtureProfileDefinitionMap() ProfileConfigMap { }, "another_profile": ProfileConfig{ Definition: profiledefinition.ProfileDefinition{ - SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.32473.1.1"}, + SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.32473.1.1"}, Metrics: []profiledefinition.MetricsConfig{ {Symbol: profiledefinition.SymbolConfig{OID: "1.3.6.1.2.1.1.999.0", Name: "anotherMetric"}, MetricType: ""}, }, diff --git a/pkg/databasemonitoring/aws/aurora_test.go b/pkg/databasemonitoring/aws/aurora_test.go index 27d5a7e92a04a..208054921686d 100644 --- a/pkg/databasemonitoring/aws/aurora_test.go +++ b/pkg/databasemonitoring/aws/aurora_test.go @@ -10,12 +10,13 @@ package aws import ( "context" "errors" + "testing" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/rds/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" - "testing" ) type mockrdsServiceConfigurer func(k *MockrdsService) @@ -24,14 +25,14 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { testCases := []struct { name string configureClient mockrdsServiceConfigurer - clusterIds []string + clusterIDs []string expectedAuroraClusterEndpoints map[string]*AuroraCluster expectedErr error }{ { name: "no cluster ids given", configureClient: func(k *MockrdsService) {}, - clusterIds: nil, + clusterIDs: nil, expectedErr: errors.New("at least one database cluster identifier is required"), }, { @@ -39,7 +40,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { configureClient: func(k *MockrdsService) { k.EXPECT().DescribeDBInstances(gomock.Any(), gomock.Any()).Return(&rds.DescribeDBInstancesOutput{}, nil).Times(1) }, - clusterIds: []string{"test-cluster"}, + clusterIDs: []string{"test-cluster"}, expectedAuroraClusterEndpoints: nil, expectedErr: errors.New("no endpoints found for aurora clusters with id(s): test-cluster"), }, @@ -48,7 +49,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { configureClient: func(k *MockrdsService) { k.EXPECT().DescribeDBInstances(gomock.Any(), gomock.Any()).Return(nil, errors.New("big time error")).Times(1) }, - clusterIds: []string{"test-cluster"}, + clusterIDs: []string{"test-cluster"}, expectedAuroraClusterEndpoints: nil, expectedErr: errors.New("error running GetAuroraClusterEndpoints big time error"), }, @@ -71,7 +72,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { }, }, nil).Times(1) }, - clusterIds: []string{"test-cluster"}, + clusterIDs: []string{"test-cluster"}, expectedAuroraClusterEndpoints: map[string]*AuroraCluster{ "test-cluster": { Instances: []*Instance{ @@ -126,7 +127,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { }, }, nil).Times(1) }, - clusterIds: []string{"test-cluster"}, + clusterIDs: []string{"test-cluster"}, expectedAuroraClusterEndpoints: map[string]*AuroraCluster{ "test-cluster": { Instances: []*Instance{ @@ -193,7 +194,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { }, }, nil).Times(1) }, - clusterIds: []string{"test-cluster"}, + clusterIDs: []string{"test-cluster"}, expectedAuroraClusterEndpoints: map[string]*AuroraCluster{ "test-cluster": { Instances: []*Instance{ @@ -226,7 +227,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { }, }, nil).Times(1) }, - clusterIds: []string{"test-cluster", "test-cluster-2"}, + clusterIDs: []string{"test-cluster", "test-cluster-2"}, expectedAuroraClusterEndpoints: map[string]*AuroraCluster{ "test-cluster": { Instances: []*Instance{ @@ -281,7 +282,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { }, }, nil).Times(1) }, - clusterIds: []string{"test-cluster", "test-cluster-2"}, + clusterIDs: []string{"test-cluster", "test-cluster-2"}, expectedAuroraClusterEndpoints: map[string]*AuroraCluster{ "test-cluster": { Instances: []*Instance{ @@ -319,7 +320,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) { mockClient := NewMockrdsService(ctrl) tt.configureClient(mockClient) client := &Client{client: mockClient} - clusters, err := client.GetAuroraClusterEndpoints(context.Background(), tt.clusterIds) + clusters, err := client.GetAuroraClusterEndpoints(context.Background(), tt.clusterIDs) if tt.expectedErr != nil { assert.EqualError(t, err, tt.expectedErr.Error()) return @@ -598,12 +599,12 @@ func TestGetAuroraClustersFromTags(t *testing.T) { } } -func createDescribeDBInstancesRequest(clusterIds []string) *rds.DescribeDBInstancesInput { +func createDescribeDBInstancesRequest(clusterIDs []string) *rds.DescribeDBInstancesInput { return &rds.DescribeDBInstancesInput{ Filters: []types.Filter{ { Name: aws.String("db-cluster-id"), - Values: clusterIds, + Values: clusterIDs, }, }, } diff --git a/pkg/networkdevice/profile/profiledefinition/profile_definition.go b/pkg/networkdevice/profile/profiledefinition/profile_definition.go index c58d27c1ae9ea..3aa2c2ec1bcb2 100644 --- a/pkg/networkdevice/profile/profiledefinition/profile_definition.go +++ b/pkg/networkdevice/profile/profiledefinition/profile_definition.go @@ -20,7 +20,7 @@ type DeviceMeta struct { type ProfileDefinition struct { Name string `yaml:"name" json:"name"` Description string `yaml:"description,omitempty" json:"description,omitempty"` - SysObjectIds StringArray `yaml:"sysobjectid,omitempty" json:"sysobjectid,omitempty"` + SysObjectIDs StringArray `yaml:"sysobjectid,omitempty" json:"sysobjectid,omitempty"` Extends []string `yaml:"extends,omitempty" json:"extends,omitempty"` Metadata MetadataConfig `yaml:"metadata,omitempty" json:"metadata,omitempty" jsonschema:"-"` MetricTags []MetricTagConfig `yaml:"metric_tags,omitempty" json:"metric_tags,omitempty"` diff --git a/pkg/networkdevice/profile/profiledefinition/yaml_utils_test.go b/pkg/networkdevice/profile/profiledefinition/yaml_utils_test.go index c54fae528ddca..a33102ed28f56 100644 --- a/pkg/networkdevice/profile/profiledefinition/yaml_utils_test.go +++ b/pkg/networkdevice/profile/profiledefinition/yaml_utils_test.go @@ -14,7 +14,7 @@ import ( ) type MyStringArray struct { - SomeIds StringArray `yaml:"my_field"` + SomeIDs StringArray `yaml:"my_field"` } type MySymbolStruct struct { @@ -47,7 +47,7 @@ metric_tags: func TestStringArray_UnmarshalYAML_array(t *testing.T) { myStruct := MyStringArray{} - expected := MyStringArray{SomeIds: StringArray{"aaa", "bbb"}} + expected := MyStringArray{SomeIDs: StringArray{"aaa", "bbb"}} yaml.Unmarshal([]byte(` my_field: @@ -60,7 +60,7 @@ my_field: func TestStringArray_UnmarshalYAML_string(t *testing.T) { myStruct := MyStringArray{} - expected := MyStringArray{SomeIds: StringArray{"aaa"}} + expected := MyStringArray{SomeIDs: StringArray{"aaa"}} yaml.Unmarshal([]byte(` my_field: aaa diff --git a/pkg/security/secl/rules/opts.go b/pkg/security/secl/rules/opts.go index 8ded8a1331dce..cc4ee53cc284a 100644 --- a/pkg/security/secl/rules/opts.go +++ b/pkg/security/secl/rules/opts.go @@ -52,8 +52,8 @@ func (o *Opts) WithEventTypeEnabled(eventTypes map[eval.EventType]bool) *Opts { } // WithReservedRuleIDs set reserved rule ids -func (o *Opts) WithReservedRuleIDs(ruleIds []RuleID) *Opts { - o.ReservedRuleIDs = ruleIds +func (o *Opts) WithReservedRuleIDs(ruleIDs []RuleID) *Opts { + o.ReservedRuleIDs = ruleIDs return o }