From 108c6b35ad097db7d861b5a6489c06fe58833e5a Mon Sep 17 00:00:00 2001 From: Artur Ribeiro Date: Thu, 12 Sep 2024 10:23:30 +0100 Subject: [PATCH] fix lint problems and add new go version to docs --- .../20f14e1a-a899-4e79-9f09-b6a84cd4649b.md | 4 ++-- internal/console/analyze.go | 2 +- pkg/engine/secrets/inspector.go | 10 +++++----- pkg/printer/printer.go | 10 +++++----- pkg/scan/preview_secrets_mask.go | 10 +++++----- pkg/scan/utils.go | 2 +- pkg/utils/random.go | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/queries/cicd-queries/20f14e1a-a899-4e79-9f09-b6a84cd4649b.md b/docs/queries/cicd-queries/20f14e1a-a899-4e79-9f09-b6a84cd4649b.md index ef3f681e084..9dea0defeb5 100644 --- a/docs/queries/cicd-queries/20f14e1a-a899-4e79-9f09-b6a84cd4649b.md +++ b/docs/queries/cicd-queries/20f14e1a-a899-4e79-9f09-b6a84cd4649b.md @@ -205,10 +205,10 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Go 1.22.x + - name: Set up Go 1.23.x uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.23.x - name: Run test metrics script id: testcov run: | diff --git a/internal/console/analyze.go b/internal/console/analyze.go index ecd9e2ec8ee..2069b871923 100644 --- a/internal/console/analyze.go +++ b/internal/console/analyze.go @@ -77,7 +77,7 @@ func executeAnalyze(analyzeParams *analyzer.Parameters) error { log.Debug().Msg("console.scan()") for _, warn := range warnings { - log.Warn().Msgf(warn) + log.Warn().Msgf("%s", warn) } console := newConsole() diff --git a/pkg/engine/secrets/inspector.go b/pkg/engine/secrets/inspector.go index e01191f3f82..3ee708190b8 100644 --- a/pkg/engine/secrets/inspector.go +++ b/pkg/engine/secrets/inspector.go @@ -316,18 +316,18 @@ func (c *Inspector) isSecret(s string, query *RegexQuery) (isSecretRet bool, gro for _, group := range groups { splitedText := strings.Split(s, "\n") - max := -1 + maxSplit := -1 for i, splited := range splitedText { if len(groups) < query.Multiline.DetectLineGroup { - if strings.Contains(splited, group[query.Multiline.DetectLineGroup]) && i > max { - max = i + if strings.Contains(splited, group[query.Multiline.DetectLineGroup]) && i > maxSplit { + maxSplit = i } } } - if max == -1 { + if maxSplit == -1 { continue } - secret, newGroups := c.isSecret(strings.Join(append(splitedText[:max], splitedText[max+1:]...), "\n"), query) + secret, newGroups := c.isSecret(strings.Join(append(splitedText[:maxSplit], splitedText[maxSplit+1:]...), "\n"), query) if !secret { continue } diff --git a/pkg/printer/printer.go b/pkg/printer/printer.go index 0ca05454280..96ef66e9104 100644 --- a/pkg/printer/printer.go +++ b/pkg/printer/printer.go @@ -280,15 +280,15 @@ func NewPrinter(minimal bool) *Printer { func (p *Printer) PrintBySev(content, sev string) string { switch strings.ToUpper(sev) { case model.SeverityCritical: - return p.Critical.Sprintf(content) + return p.Critical.Sprintf("%s", content) case model.SeverityHigh: - return p.High.Sprintf(content) + return p.High.Sprintf("%s", content) case model.SeverityMedium: - return p.Medium.Sprintf(content) + return p.Medium.Sprintf("%s", content) case model.SeverityLow: - return p.Low.Sprintf(content) + return p.Low.Sprintf("%s", content) case model.SeverityInfo: - return p.Info.Sprintf(content) + return p.Info.Sprintf("%s", content) } return content } diff --git a/pkg/scan/preview_secrets_mask.go b/pkg/scan/preview_secrets_mask.go index 417d8d3e7b6..6a9f9851727 100644 --- a/pkg/scan/preview_secrets_mask.go +++ b/pkg/scan/preview_secrets_mask.go @@ -126,18 +126,18 @@ func isSecret(line string, rule *secrets.RegexQuery, allowRules *[]secrets.Allow for _, group := range groups { splitedText := strings.Split(line, "\n") - max := -1 + maxSplit := -1 for i, splited := range splitedText { if len(groups) < rule.Multiline.DetectLineGroup { - if strings.Contains(splited, group[rule.Multiline.DetectLineGroup]) && i > max { - max = i + if strings.Contains(splited, group[rule.Multiline.DetectLineGroup]) && i > maxSplit { + maxSplit = i } } } - if max == -1 { + if maxSplit == -1 { continue } - secret, newGroups := isSecret(strings.Join(append(splitedText[:max], splitedText[max+1:]...), "\n"), rule, allowRules) + secret, newGroups := isSecret(strings.Join(append(splitedText[:maxSplit], splitedText[maxSplit+1:]...), "\n"), rule, allowRules) if !secret { continue } diff --git a/pkg/scan/utils.go b/pkg/scan/utils.go index 59aab45644f..16a470512b1 100644 --- a/pkg/scan/utils.go +++ b/pkg/scan/utils.go @@ -241,7 +241,7 @@ func printVersionCheck(customPrint *consolePrinter.Printer, s *model.Summary) { message := fmt.Sprintf("A new version 'v%s' of KICS is available, please consider updating", s.LatestVersion.LatestVersionTag) fmt.Println(customPrint.VersionMessage.Sprintf(message)) - log.Warn().Msgf(message) + log.Warn().Msgf("%s", message) } } diff --git a/pkg/utils/random.go b/pkg/utils/random.go index fb524a38a6d..d9a45a1e425 100644 --- a/pkg/utils/random.go +++ b/pkg/utils/random.go @@ -14,7 +14,7 @@ var randmu sync.Mutex const tempDirFormat = 1e9 func reseed() uint32 { - return uint32(time.Now().UnixNano() + int64(os.Getpid())) + return uint32(int32(time.Now().UnixNano()) + int32(os.Getpid())) } // NextRandom returns a random number