Skip to content

Commit

Permalink
fix lint problems and add new go version to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturRibeiro-CX committed Sep 12, 2024
1 parent 77b537a commit 108c6b3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion internal/console/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions pkg/engine/secrets/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/scan/preview_secrets_mask.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scan/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Check failure on line 243 in pkg/scan/utils.go

View workflow job for this annotation

GitHub Actions / lint

printf: non-constant format string in call to (github.com/gookit/color.RGBColor).Sprintf (govet)
log.Warn().Msgf(message)
log.Warn().Msgf("%s", message)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Check failure on line 17 in pkg/utils/random.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion int64 -> int32 (gosec)
}

// NextRandom returns a random number
Expand Down

0 comments on commit 108c6b3

Please sign in to comment.