diff --git a/.golangci.yml b/.golangci.yml index b5e2e6b51..c47e71fdd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -78,6 +78,8 @@ linters: - gci # imports still has gci lint errors after run `gci write --skip-generated -s standard -s default -s "prefix(github.com/openclarity/vmclarity)"` - depguard # NOTE(chrisgacsal): need discussion before enabling it - tagalign # NOTE(chrisgacsal): does not seem to provide much value + - protogetter # FIXME(chrisgacsal): needs code changes to enable + - inamedparam # FIXME(chrisgacsal): needs code changes to enable issues: # Excluding configuration per-path, per-linter, per-text and per-source diff --git a/api/models/containerimageinfo.go b/api/models/containerimageinfo.go index a0d2dc89b..05649f4cf 100644 --- a/api/models/containerimageinfo.go +++ b/api/models/containerimageinfo.go @@ -17,6 +17,7 @@ package models import ( "fmt" + "strconv" "strings" ) @@ -101,7 +102,7 @@ const nilString = "nil" func (c ContainerImageInfo) String() string { size := nilString if c.Size != nil { - size = fmt.Sprintf("%d", *c.Size) + size = strconv.Itoa(*c.Size) } labels := nilString diff --git a/makefile.d/20-tools.mk b/makefile.d/20-tools.mk index a57e7223e..b6957c8ae 100644 --- a/makefile.d/20-tools.mk +++ b/makefile.d/20-tools.mk @@ -32,7 +32,7 @@ bin/actionlint-$(ACTIONLINT_VERSION): | $(BIN_DIR) #### AZURECLI_BIN := $(BIN_DIR)/az -AZURECLI_VERSION := 2.53.0 +AZURECLI_VERSION := 2.55.0 AZURECLI_VENV := $(AZURECLI_BIN)-$(AZURECLI_VERSION) bin/az: $(AZURECLI_VENV)/bin/az @@ -48,7 +48,7 @@ $(AZURECLI_VENV)/bin/az: | $(BIN_DIR) #### BICEP_BIN := $(BIN_DIR)/bicep -BICEP_VERSION := 0.22.6 +BICEP_VERSION := 0.23.1 BICEP_OSTYPE := $(OSTYPE) BICEP_ARCH := $(ARCHTYPE) @@ -75,7 +75,7 @@ bin/bicep-$(BICEP_VERSION): | $(BIN_DIR) #### CFNLINT_BIN := $(BIN_DIR)/cfn-lint -CFNLINT_VERSION := 0.82.2 +CFNLINT_VERSION := 0.83.4 CFNLINT_VENV := $(CFNLINT_BIN)-$(CFNLINT_VERSION) bin/cfn-lint: $(CFNLINT_VENV)/bin/cfn-lint @@ -92,7 +92,7 @@ $(CFNLINT_VENV)/bin/cfn-lint: | $(BIN_DIR) GOLANGCI_BIN := $(BIN_DIR)/golangci-lint GOLANGCI_CONFIG := $(ROOT_DIR)/.golangci.yml -GOLANGCI_VERSION := 1.54.2 +GOLANGCI_VERSION := 1.55.2 bin/golangci-lint: bin/golangci-lint-$(GOLANGCI_VERSION) @ln -sf golangci-lint-$(GOLANGCI_VERSION) bin/golangci-lint @@ -106,7 +106,7 @@ bin/golangci-lint-$(GOLANGCI_VERSION): | $(BIN_DIR) #### YQ_BIN := $(BIN_DIR)/yq -YQ_VERSION := 4.35.2 +YQ_VERSION := 4.40.4 bin/yq: bin/yq-$(YQ_VERSION) @ln -sf $(notdir $<) $@ @@ -121,7 +121,7 @@ bin/yq-$(YQ_VERSION): | $(BIN_DIR) #### HELM_BIN := $(BIN_DIR)/helm -HELM_VERSION := 3.13.1 +HELM_VERSION := 3.13.2 bin/helm: bin/helm-$(HELM_VERSION) @ln -sf $(notdir $<) $@ diff --git a/pkg/shared/families/malware/yara/util/util_test.go b/pkg/shared/families/malware/yara/util/util_test.go index f618ebbac..22a49eb64 100644 --- a/pkg/shared/families/malware/yara/util/util_test.go +++ b/pkg/shared/families/malware/yara/util/util_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - "github.com/stretchr/testify/assert" + . "github.com/onsi/gomega" "github.com/openclarity/vmclarity/pkg/shared/families/malware/common" ) @@ -236,9 +236,11 @@ func TestParseYaraScanOutput(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + g := NewGomegaWithT(t) + got, err := ParseYaraScanOutput(tt.args.line) if err != nil { - assert.EqualErrorf(t, err, tt.expectedErr.Error(), "Error should be: %v, got: %v", tt.expectedErr, err) + g.Expect(err.Error()).Should(BeEquivalentTo(tt.expectedErr.Error())) return } if err == nil && tt.expectedErr != nil { @@ -288,7 +290,10 @@ func TestIsErrorThresholdReached(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.Equalf(t, tt.want, IsErrorThresholdReached(tt.args.errorCount, tt.args.allCount), "IsErrorThresholdReached(%v, %v)", tt.args.errorCount, tt.args.allCount) + g := NewGomegaWithT(t) + + actual := IsErrorThresholdReached(tt.args.errorCount, tt.args.allCount) + g.Expect(actual).Should(BeEquivalentTo(tt.want)) }) } } diff --git a/pkg/uibackend/rest/dashboard_riskiest_assets_test.go b/pkg/uibackend/rest/dashboard_riskiest_assets_test.go index 2bb06ce05..9a36386fa 100644 --- a/pkg/uibackend/rest/dashboard_riskiest_assets_test.go +++ b/pkg/uibackend/rest/dashboard_riskiest_assets_test.go @@ -18,6 +18,7 @@ package rest import ( "fmt" "reflect" + "strings" "testing" "github.com/google/go-cmp/cmp" @@ -491,6 +492,8 @@ func Test_toAPIRiskyAssets(t *testing.T) { } } +const SummaryQueryTemplate = "summary/%s/%s desc" + func Test_getOrderByOdataForVulnerabilities(t *testing.T) { tests := []struct { name string @@ -498,16 +501,14 @@ func Test_getOrderByOdataForVulnerabilities(t *testing.T) { }{ { name: "sanity", - want: fmt.Sprintf("summary/%s/%s desc,"+ - "summary/%s/%s desc,"+ - "summary/%s/%s desc,"+ - "summary/%s/%s desc,"+ - "summary/%s/%s desc", - totalVulnerabilitiesSummaryFieldName, totalCriticalVulnerabilitiesSummaryFieldName, - totalVulnerabilitiesSummaryFieldName, totalHighVulnerabilitiesSummaryFieldName, - totalVulnerabilitiesSummaryFieldName, totalMediumVulnerabilitiesSummaryFieldName, - totalVulnerabilitiesSummaryFieldName, totalLowVulnerabilitiesFieldName, - totalVulnerabilitiesSummaryFieldName, totalNegligibleVulnerabilitiesFieldName), + want: strings.Join( + []string{ + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalCriticalVulnerabilitiesSummaryFieldName), + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalHighVulnerabilitiesSummaryFieldName), + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalMediumVulnerabilitiesSummaryFieldName), + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalLowVulnerabilitiesFieldName), + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalNegligibleVulnerabilitiesFieldName), + }, ","), }, } for _, tt := range tests { @@ -533,16 +534,14 @@ func Test_getOrderByOData(t *testing.T) { args: args{ totalFindingField: totalVulnerabilitiesSummaryFieldName, }, - want: fmt.Sprintf("summary/%s/%s desc,"+ - "summary/%s/%s desc,"+ - "summary/%s/%s desc,"+ - "summary/%s/%s desc,"+ - "summary/%s/%s desc", - totalVulnerabilitiesSummaryFieldName, totalCriticalVulnerabilitiesSummaryFieldName, - totalVulnerabilitiesSummaryFieldName, totalHighVulnerabilitiesSummaryFieldName, - totalVulnerabilitiesSummaryFieldName, totalMediumVulnerabilitiesSummaryFieldName, - totalVulnerabilitiesSummaryFieldName, totalLowVulnerabilitiesFieldName, - totalVulnerabilitiesSummaryFieldName, totalNegligibleVulnerabilitiesFieldName), + want: strings.Join( + []string{ + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalCriticalVulnerabilitiesSummaryFieldName), + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalHighVulnerabilitiesSummaryFieldName), + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalMediumVulnerabilitiesSummaryFieldName), + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalLowVulnerabilitiesFieldName), + fmt.Sprintf(SummaryQueryTemplate, totalVulnerabilitiesSummaryFieldName, totalNegligibleVulnerabilitiesFieldName), + }, ","), }, { name: "not vulnerabilities",