diff --git a/.golangci.yaml b/.golangci.yaml index 021ce48abd..45e2760742 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -8,7 +8,7 @@ linters: - containedctx - contextcheck - exhaustruct - - exportloopref + - copyloopvar - fatcontext - gci - gocritic diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca84f8d04f..ac290c6c8f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -77,7 +77,7 @@ repos: files: deploy/cloudformation/.*yml - repo: https://github.com/aws-cloudformation/cfn-lint - rev: v1.18.3 + rev: v1.18.4 hooks: - id: cfn-python-lint files: deploy/cloudformation/.*.yml diff --git a/bin/.awscli-2.19.1.pkg b/bin/.awscli-2.19.4.pkg similarity index 100% rename from bin/.awscli-2.19.1.pkg rename to bin/.awscli-2.19.4.pkg diff --git a/bin/.gcloud-499.0.0.pkg b/bin/.gcloud-500.0.0.pkg similarity index 100% rename from bin/.gcloud-499.0.0.pkg rename to bin/.gcloud-500.0.0.pkg diff --git a/bin/.gh-2.60.1.pkg b/bin/.gh-2.61.0.pkg similarity index 100% rename from bin/.gh-2.60.1.pkg rename to bin/.gh-2.61.0.pkg diff --git a/bin/.golangci-lint-1.61.0.pkg b/bin/.golangci-lint-1.62.0.pkg similarity index 100% rename from bin/.golangci-lint-1.61.0.pkg rename to bin/.golangci-lint-1.62.0.pkg diff --git a/bin/.kind-0.24.0.pkg b/bin/.kind-0.25.0.pkg similarity index 100% rename from bin/.kind-0.24.0.pkg rename to bin/.kind-0.25.0.pkg diff --git a/bin/aws b/bin/aws index b00571dbec..e4213c3f5e 120000 --- a/bin/aws +++ b/bin/aws @@ -1 +1 @@ -.awscli-2.19.1.pkg \ No newline at end of file +.awscli-2.19.4.pkg \ No newline at end of file diff --git a/bin/aws_completer b/bin/aws_completer index b00571dbec..e4213c3f5e 120000 --- a/bin/aws_completer +++ b/bin/aws_completer @@ -1 +1 @@ -.awscli-2.19.1.pkg \ No newline at end of file +.awscli-2.19.4.pkg \ No newline at end of file diff --git a/bin/bq b/bin/bq index 0bd7ad7dea..d57458febf 120000 --- a/bin/bq +++ b/bin/bq @@ -1 +1 @@ -.gcloud-499.0.0.pkg \ No newline at end of file +.gcloud-500.0.0.pkg \ No newline at end of file diff --git a/bin/docker-credential-gcloud b/bin/docker-credential-gcloud index 0bd7ad7dea..d57458febf 120000 --- a/bin/docker-credential-gcloud +++ b/bin/docker-credential-gcloud @@ -1 +1 @@ -.gcloud-499.0.0.pkg \ No newline at end of file +.gcloud-500.0.0.pkg \ No newline at end of file diff --git a/bin/gcloud b/bin/gcloud index 0bd7ad7dea..d57458febf 120000 --- a/bin/gcloud +++ b/bin/gcloud @@ -1 +1 @@ -.gcloud-499.0.0.pkg \ No newline at end of file +.gcloud-500.0.0.pkg \ No newline at end of file diff --git a/bin/gh b/bin/gh index ee6c814240..d347aa1894 120000 --- a/bin/gh +++ b/bin/gh @@ -1 +1 @@ -.gh-2.60.1.pkg \ No newline at end of file +.gh-2.61.0.pkg \ No newline at end of file diff --git a/bin/git-credential-gcloud.sh b/bin/git-credential-gcloud.sh index 0bd7ad7dea..d57458febf 120000 --- a/bin/git-credential-gcloud.sh +++ b/bin/git-credential-gcloud.sh @@ -1 +1 @@ -.gcloud-499.0.0.pkg \ No newline at end of file +.gcloud-500.0.0.pkg \ No newline at end of file diff --git a/bin/golangci-lint b/bin/golangci-lint index 79bb386e3c..1997017ab9 120000 --- a/bin/golangci-lint +++ b/bin/golangci-lint @@ -1 +1 @@ -.golangci-lint-1.61.0.pkg \ No newline at end of file +.golangci-lint-1.62.0.pkg \ No newline at end of file diff --git a/bin/gsutil b/bin/gsutil index 0bd7ad7dea..d57458febf 120000 --- a/bin/gsutil +++ b/bin/gsutil @@ -1 +1 @@ -.gcloud-499.0.0.pkg \ No newline at end of file +.gcloud-500.0.0.pkg \ No newline at end of file diff --git a/bin/kind b/bin/kind index 21bbc22a2e..283ee865f5 120000 --- a/bin/kind +++ b/bin/kind @@ -1 +1 @@ -.kind-0.24.0.pkg \ No newline at end of file +.kind-0.25.0.pkg \ No newline at end of file diff --git a/internal/flavors/benchmark/aws_org_test.go b/internal/flavors/benchmark/aws_org_test.go index 24f1d7ea51..96d94ce1c0 100644 --- a/internal/flavors/benchmark/aws_org_test.go +++ b/internal/flavors/benchmark/aws_org_test.go @@ -103,7 +103,6 @@ func TestAWSOrg_Initialize(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/flavors/benchmark/aws_test.go b/internal/flavors/benchmark/aws_test.go index 5bc22c1d2a..dd581fca71 100644 --- a/internal/flavors/benchmark/aws_test.go +++ b/internal/flavors/benchmark/aws_test.go @@ -62,7 +62,6 @@ func TestAWS_Initialize(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/flavors/benchmark/azure.go b/internal/flavors/benchmark/azure.go index eea58f4749..b3952f32ab 100644 --- a/internal/flavors/benchmark/azure.go +++ b/internal/flavors/benchmark/azure.go @@ -102,9 +102,9 @@ func calculateFetcherTimeout(period time.Duration) time.Duration { roundedHours := math.Round(period.Hours() * 0.7) to := time.Duration(roundedHours) * time.Hour - const min = 3 * time.Hour - if to < min { - return min + const minTimeout = 3 * time.Hour + if to < minTimeout { + return minTimeout } return to diff --git a/internal/flavors/benchmark/azure_test.go b/internal/flavors/benchmark/azure_test.go index 7da5ef8fb1..50249a7ea1 100644 --- a/internal/flavors/benchmark/azure_test.go +++ b/internal/flavors/benchmark/azure_test.go @@ -88,7 +88,6 @@ func TestAzure_Initialize(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tt := tt t.Parallel() testInitialize(t, &Azure{ diff --git a/internal/flavors/benchmark/eks_test.go b/internal/flavors/benchmark/eks_test.go index 89fcdb1a0b..9776bcd0d3 100644 --- a/internal/flavors/benchmark/eks_test.go +++ b/internal/flavors/benchmark/eks_test.go @@ -106,7 +106,6 @@ func TestEKS_Initialize(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/flavors/benchmark/gcp_test.go b/internal/flavors/benchmark/gcp_test.go index 6eaa13c0de..1ac9cd733d 100644 --- a/internal/flavors/benchmark/gcp_test.go +++ b/internal/flavors/benchmark/gcp_test.go @@ -104,7 +104,6 @@ func TestGCP_Initialize(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tt := tt t.Parallel() testInitialize(t, &GCP{ diff --git a/internal/flavors/benchmark/k8s_test.go b/internal/flavors/benchmark/k8s_test.go index 5b971856a8..749ff778bc 100644 --- a/internal/flavors/benchmark/k8s_test.go +++ b/internal/flavors/benchmark/k8s_test.go @@ -58,7 +58,6 @@ func TestK8S_Initialize(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/launcher/launcher_test.go b/internal/launcher/launcher_test.go index 00fe653f31..c72f1d0379 100644 --- a/internal/launcher/launcher_test.go +++ b/internal/launcher/launcher_test.go @@ -289,7 +289,6 @@ func (s *LauncherTestSuite) TestWaitForUpdates() { } for _, tt := range testcases { - tt := tt s.Run(tt.name, func() { mocks := s.initMocks() sut := s.newLauncher(mocks, beaterMockCreator) diff --git a/internal/resources/fetching/fetchers/azure/assets_enricher_keyvault_test.go b/internal/resources/fetching/fetchers/azure/assets_enricher_keyvault_test.go index c1387b844c..1698d4f38e 100644 --- a/internal/resources/fetching/fetchers/azure/assets_enricher_keyvault_test.go +++ b/internal/resources/fetching/fetchers/azure/assets_enricher_keyvault_test.go @@ -123,7 +123,6 @@ func TestKeyVaultEnricher(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { mockProvider := azurelib.NewMockProviderAPI(t) diff --git a/internal/resources/fetching/fetchers/azure/assets_enricher_storage_account_test.go b/internal/resources/fetching/fetchers/azure/assets_enricher_storage_account_test.go index a4a992c305..ab0c19e99c 100644 --- a/internal/resources/fetching/fetchers/azure/assets_enricher_storage_account_test.go +++ b/internal/resources/fetching/fetchers/azure/assets_enricher_storage_account_test.go @@ -377,7 +377,6 @@ func TestStorageAccountEnricher(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { cmd := cycle.Metadata{} diff --git a/internal/resources/fetching/fetchers/azure/insights_batch_fetcher_test.go b/internal/resources/fetching/fetchers/azure/insights_batch_fetcher_test.go index 8bc07460e0..0734367658 100644 --- a/internal/resources/fetching/fetchers/azure/insights_batch_fetcher_test.go +++ b/internal/resources/fetching/fetchers/azure/insights_batch_fetcher_test.go @@ -184,7 +184,6 @@ func TestAzureInsightsBatchAssetFetcher(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { m := azurelib.NewMockProviderAPI(t) diff --git a/internal/resources/fetching/fetchers/azure/locations_network_watcher_batch_fetcher_test.go b/internal/resources/fetching/fetchers/azure/locations_network_watcher_batch_fetcher_test.go index 8ac3143963..cb9c22aab4 100644 --- a/internal/resources/fetching/fetchers/azure/locations_network_watcher_batch_fetcher_test.go +++ b/internal/resources/fetching/fetchers/azure/locations_network_watcher_batch_fetcher_test.go @@ -261,7 +261,6 @@ func TestAzureLocationsNetworkWatcherAssetBatchFetcher_Fetch(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { m := azurelib.NewMockProviderAPI(t) diff --git a/internal/resources/fetching/fetchers/azure/security_fetcher_test.go b/internal/resources/fetching/fetchers/azure/security_fetcher_test.go index c486eac17f..08d938a905 100644 --- a/internal/resources/fetching/fetchers/azure/security_fetcher_test.go +++ b/internal/resources/fetching/fetchers/azure/security_fetcher_test.go @@ -307,7 +307,6 @@ func TestAzureSecurityAssetFetcher(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { // tear up m := azurelib.NewMockProviderAPI(t) diff --git a/internal/resources/fetching/fetchers/k8s/process_fetcher_test.go b/internal/resources/fetching/fetchers/k8s/process_fetcher_test.go index f395cc5e86..3d18070618 100644 --- a/internal/resources/fetching/fetchers/k8s/process_fetcher_test.go +++ b/internal/resources/fetching/fetchers/k8s/process_fetcher_test.go @@ -275,7 +275,6 @@ func TestExtractCommandName(t *testing.T) { } for _, tc := range tests { - tc := tc name := strings.ReplaceAll(tc.cmd, "/", "|") // For readability, because tests are also hierarchical with '/'. t.Run(name, func(t *testing.T) { got := extractCommandName(tc.cmd) diff --git a/internal/resources/providers/awslib/kms/provider_test.go b/internal/resources/providers/awslib/kms/provider_test.go index 06751a4433..b52ea6741b 100644 --- a/internal/resources/providers/awslib/kms/provider_test.go +++ b/internal/resources/providers/awslib/kms/provider_test.go @@ -20,7 +20,6 @@ package kms import ( "context" "errors" - "fmt" "testing" kmsClient "github.com/aws/aws-sdk-go-v2/service/kms" @@ -35,8 +34,10 @@ import ( type ProviderTestSuite struct { suite.Suite } -type mocks [2][]any -type kmsClientMockReturnVals map[string][]mocks +type ( + mocks [2][]any + kmsClientMockReturnVals map[string][]mocks +) func TestProviderTestSuite(t *testing.T) { s := new(ProviderTestSuite) @@ -47,11 +48,13 @@ func (s *ProviderTestSuite) SetupTest() {} func (s *ProviderTestSuite) TearDownTest() {} -var keyId1 = "21c0ba99-3a6c-4f72-8ef8-8118d4804710" -var keyId2 = "21c0ba99-3a6c-4f72-8ef8-8118d4804711" +var ( + keyId1 = "21c0ba99-3a6c-4f72-8ef8-8118d4804710" + keyId2 = "21c0ba99-3a6c-4f72-8ef8-8118d4804711" +) func (s *ProviderTestSuite) TestProvider_DescribeSymmetricKeys() { - var tests = []struct { + tests := []struct { name string regions []string kmsClientMockReturnVals kmsClientMockReturnVals @@ -181,7 +184,7 @@ func (s *ProviderTestSuite) TestProvider_DescribeSymmetricKeys() { // Using `ElementsMatch` instead of the usual `Equals` since iterating over the regions map does not produce a // guaranteed order - s.ElementsMatch(test.expected, results, fmt.Sprintf("Test '%s' failed, elements do not match", test.name)) + s.ElementsMatch(test.expected, results, "Test '%s' failed, elements do not match", test.name) } } diff --git a/internal/resources/providers/awslib/s3/provider_test.go b/internal/resources/providers/awslib/s3/provider_test.go index 0624ff3b9c..74ac0d6ac8 100644 --- a/internal/resources/providers/awslib/s3/provider_test.go +++ b/internal/resources/providers/awslib/s3/provider_test.go @@ -20,7 +20,6 @@ package s3 import ( "context" "errors" - "fmt" "testing" "github.com/aws/aws-sdk-go-v2/aws" @@ -39,9 +38,11 @@ import ( type ProviderTestSuite struct { suite.Suite } -type mocks [2][]any -type s3ClientMockReturnVals map[string][]mocks -type s3ControlClientMockReturnVals map[string]mocks +type ( + mocks [2][]any + s3ClientMockReturnVals map[string][]mocks + s3ControlClientMockReturnVals map[string]mocks +) func TestProviderTestSuite(t *testing.T) { s := new(ProviderTestSuite) @@ -52,14 +53,16 @@ func (s *ProviderTestSuite) SetupTest() {} func (s *ProviderTestSuite) TearDownTest() {} -var bucketName = "MyBucket" -var secondBucketName = "MyAnotherBucket" -var region types.BucketLocationConstraint = "eu-west-1" -var bucketPolicy BucketPolicy = map[string]any{"foo": "bar"} -var bucketPolicyString = "{\"foo\": \"bar\"}" +var ( + bucketName = "MyBucket" + secondBucketName = "MyAnotherBucket" + region types.BucketLocationConstraint = "eu-west-1" + bucketPolicy BucketPolicy = map[string]any{"foo": "bar"} + bucketPolicyString = "{\"foo\": \"bar\"}" +) func (s *ProviderTestSuite) TestProvider_DescribeBuckets() { - var tests = []struct { + tests := []struct { name string regions []string s3ClientMockReturnVals s3ClientMockReturnVals @@ -526,6 +529,6 @@ func (s *ProviderTestSuite) TestProvider_DescribeBuckets() { // Using `ElementsMatch` instead of the usual `Equals` since iterating over the regions map does not produce a // guaranteed order - s.ElementsMatch(test.expected, results, fmt.Sprintf("Test '%s' failed, elements do not match", test.name)) + s.ElementsMatch(test.expected, results, "Test '%s' failed, elements do not match", test.name) } } diff --git a/internal/resources/providers/azurelib/inventory/app_service_provider_test.go b/internal/resources/providers/azurelib/inventory/app_service_provider_test.go index 31bf9b2a41..fa49a57bc9 100644 --- a/internal/resources/providers/azurelib/inventory/app_service_provider_test.go +++ b/internal/resources/providers/azurelib/inventory/app_service_provider_test.go @@ -139,7 +139,6 @@ func TestGetAppServiceAuthSettings(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { mockWrapper := &mockAzureAppServiceWrapper{} mockWrapper.Test(t) @@ -284,7 +283,6 @@ func TestGetAppServiceSiteConfig(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { mockWrapper := &mockAzureAppServiceWrapper{} mockWrapper.Test(t) diff --git a/internal/resources/providers/azurelib/inventory/keyvault_provider_test.go b/internal/resources/providers/azurelib/inventory/keyvault_provider_test.go index b32d3248cc..6ae916f815 100644 --- a/internal/resources/providers/azurelib/inventory/keyvault_provider_test.go +++ b/internal/resources/providers/azurelib/inventory/keyvault_provider_test.go @@ -169,7 +169,6 @@ func TestListKeyVaultDiagnosticSettings(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { mockWrapper := &mockAzureKeyVaultWrapper{} mockWrapper.Test(t) @@ -283,7 +282,6 @@ func TestListKeyVaultKeys(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { mockWrapper := &mockAzureKeyVaultWrapper{} mockWrapper.Test(t) @@ -403,7 +401,6 @@ func TestListKeyVaultSecrets(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { mockWrapper := &mockAzureKeyVaultWrapper{} mockWrapper.Test(t) diff --git a/internal/resources/providers/azurelib/inventory/resource_graph_provider_test.go b/internal/resources/providers/azurelib/inventory/resource_graph_provider_test.go index 63b396494b..5f6fc4cffa 100644 --- a/internal/resources/providers/azurelib/inventory/resource_graph_provider_test.go +++ b/internal/resources/providers/azurelib/inventory/resource_graph_provider_test.go @@ -255,7 +255,6 @@ func TestReadPager(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { pagerHandlerMock := runtime.PagingHandler[int]{ More: tc.moreFn, diff --git a/internal/resources/providers/azurelib/inventory/security_provider_test.go b/internal/resources/providers/azurelib/inventory/security_provider_test.go index e7c8d1ae08..615362d00a 100644 --- a/internal/resources/providers/azurelib/inventory/security_provider_test.go +++ b/internal/resources/providers/azurelib/inventory/security_provider_test.go @@ -136,7 +136,6 @@ func TestListSecurityContacts(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { log := testhelper.NewLogger(t) @@ -258,7 +257,6 @@ func TestListAutoProvisioningSettings(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { log := testhelper.NewLogger(t) diff --git a/internal/resources/providers/azurelib/inventory/sql_server_provider_test.go b/internal/resources/providers/azurelib/inventory/sql_server_provider_test.go index 45935e2a98..96268248ee 100644 --- a/internal/resources/providers/azurelib/inventory/sql_server_provider_test.go +++ b/internal/resources/providers/azurelib/inventory/sql_server_provider_test.go @@ -635,7 +635,6 @@ func TestListSQLFirewallRules(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { fakeSrv := &fake.FirewallRulesServer{} fakeSrv.NewListByServerPager = func(_, _ string, _ *armsql.FirewallRulesClientListByServerOptions) azfake.PagerResponder[armsql.FirewallRulesClientListByServerResponse] { diff --git a/internal/resources/providers/azurelib/inventory/storage_provider_test.go b/internal/resources/providers/azurelib/inventory/storage_provider_test.go index 1980c0861c..13240c7c66 100644 --- a/internal/resources/providers/azurelib/inventory/storage_provider_test.go +++ b/internal/resources/providers/azurelib/inventory/storage_provider_test.go @@ -94,7 +94,6 @@ func TestTransformStorageAccounts(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { got, err := transformStorageAccounts(tc.inputServicesPages, tc.inputSubscriptionId) if tc.expectError { @@ -152,7 +151,6 @@ func TestTransformBlobServices(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { got, err := transformBlobServices(tc.inputServicesPages, tc.inputStorageAccount) if tc.expectError { @@ -694,7 +692,6 @@ func TestListDiagnosticSettingsAssetTypes(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() provider := &storageAccountProvider{ diff --git a/internal/resources/utils/strings/strings_test.go b/internal/resources/utils/strings/strings_test.go index 620cee7a56..7017e2525b 100644 --- a/internal/resources/utils/strings/strings_test.go +++ b/internal/resources/utils/strings/strings_test.go @@ -98,7 +98,6 @@ func TestFromMap(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { got := FromMap(tc.input, tc.inputKey) require.Equal(t, tc.expected, got) diff --git a/internal/transformer/events_creator_test.go b/internal/transformer/events_creator_test.go index 6372238798..a7f21ad175 100644 --- a/internal/transformer/events_creator_test.go +++ b/internal/transformer/events_creator_test.go @@ -22,7 +22,6 @@ import ( "encoding/json" "io" "os" - "regexp" "testing" "github.com/elastic/beats/v7/libbeat/beat" @@ -188,7 +187,7 @@ func (s *EventsCreatorTestSuite) TestTransformer_ProcessAggregatedResources() { s.NotEmpty(event.Fields["event"], "resource event is missing") s.Equal(event.Fields["cloudbeat"], versionInfo) s.Equal(enrichedValue, event.Fields[enrichedKey]) - s.Regexp(regexp.MustCompile("^Rule \".*\": (passed|failed)$"), event.Fields["message"], "event message is not correct") + s.Regexp("^Rule \".*\": (passed|failed)$", event.Fields["message"], "event message is not correct") } }) }