Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
chore: update tools (#1020)
Browse files Browse the repository at this point in the history
* chore: update tools

* fix: goconst lint error

* test: use gomega insted of testify

* refactor: use strconv.Iota to cast int to string
  • Loading branch information
chrisgacsal authored Dec 8, 2023
1 parent 22f72c3 commit 1c2719f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion api/models/containerimageinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package models

import (
"fmt"
"strconv"
"strings"
)

Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions makefile.d/20-tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 $<) $@
Expand All @@ -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 $<) $@
Expand Down
11 changes: 8 additions & 3 deletions pkg/shared/families/malware/yara/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
})
}
}
39 changes: 19 additions & 20 deletions pkg/uibackend/rest/dashboard_riskiest_assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package rest
import (
"fmt"
"reflect"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -491,23 +492,23 @@ func Test_toAPIRiskyAssets(t *testing.T) {
}
}

const SummaryQueryTemplate = "summary/%s/%s desc"

func Test_getOrderByOdataForVulnerabilities(t *testing.T) {
tests := []struct {
name string
want string
}{
{
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 {
Expand All @@ -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",
Expand Down

0 comments on commit 1c2719f

Please sign in to comment.