diff --git a/.golangci.yml b/.golangci.yml index 7997c9e7e..dc379b3b2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -295,10 +295,6 @@ issues: - nosprintfhostport text: "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf" - - linters: - - wastedassign - text: "assigned to .*, but reassigned without using the value" - # https://github.com/timakin/bodyclose - linters: - bodyclose diff --git a/cmd/crowdsec-cli/alerts.go b/cmd/crowdsec-cli/alerts.go index a3736abd1..15824d2d0 100644 --- a/cmd/crowdsec-cli/alerts.go +++ b/cmd/crowdsec-cli/alerts.go @@ -71,8 +71,7 @@ func SourceFromAlert(alert *models.Alert) string { //try to compose a human friendly version if *alert.Source.Value != "" && *alert.Source.Scope != "" { - scope := "" - scope = fmt.Sprintf("%s:%s", *alert.Source.Scope, *alert.Source.Value) + scope := fmt.Sprintf("%s:%s", *alert.Source.Scope, *alert.Source.Value) extra := "" if alert.Source.Cn != "" { extra = alert.Source.Cn diff --git a/cmd/crowdsec-cli/explain.go b/cmd/crowdsec-cli/explain.go index e6dd3598f..d21c17049 100644 --- a/cmd/crowdsec-cli/explain.go +++ b/cmd/crowdsec-cli/explain.go @@ -188,10 +188,9 @@ func (cli cliExplain) run(cmd *cobra.Command, args []string) error { } } }() - tmpFile := "" // we create a temporary log file if a log line/stdin has been provided if logLine != "" || logFile == "-" { - tmpFile = filepath.Join(dir, "cscli_test_tmp.log") + tmpFile := filepath.Join(dir, "cscli_test_tmp.log") f, err = os.Create(tmpFile) if err != nil { return err diff --git a/pkg/acquisition/modules/appsec/utils.go b/pkg/acquisition/modules/appsec/utils.go index 84d2fcecf..760061796 100644 --- a/pkg/acquisition/modules/appsec/utils.go +++ b/pkg/acquisition/modules/appsec/utils.go @@ -179,11 +179,9 @@ func (r *AppsecRunner) AccumulateTxToEvent(evt *types.Event, req *appsec.ParsedR req.Tx.Variables().All(func(v variables.RuleVariable, col collection.Collection) bool { for _, variable := range col.FindAll() { - key := "" - if variable.Key() == "" { - key = variable.Variable().Name() - } else { - key = variable.Variable().Name() + "." + variable.Key() + key := variable.Variable().Name() + if variable.Key() != "" { + key += "." + variable.Key() } if variable.Value() == "" { continue @@ -214,7 +212,7 @@ func (r *AppsecRunner) AccumulateTxToEvent(evt *types.Event, req *appsec.ParsedR evt.Appsec.HasOutBandMatches = true } - name := "" + var name string version := "" hash := "" ruleNameProm := fmt.Sprintf("%d", rule.Rule().ID()) diff --git a/pkg/database/alerts.go b/pkg/database/alerts.go index 8524884d7..0502c2531 100644 --- a/pkg/database/alerts.go +++ b/pkg/database/alerts.go @@ -77,14 +77,11 @@ func formatAlertSource(alert *models.Alert) string { func formatAlertAsString(machineID string, alert *models.Alert) []string { src := formatAlertSource(alert) - /**/ - msg := "" + msg := "empty scenario" if alert.Scenario != nil && *alert.Scenario != "" { msg = *alert.Scenario } else if alert.Message != nil && *alert.Message != "" { msg = *alert.Message - } else { - msg = "empty scenario" } reason := fmt.Sprintf("%s by %s", msg, src) @@ -116,7 +113,7 @@ func formatAlertAsString(machineID string, alert *models.Alert) []string { reason = fmt.Sprintf("%s for %d/%d decisions", msg, i+1, len(alert.Decisions)) } - machineIDOrigin := "" + var machineIDOrigin string if machineID == "" { machineIDOrigin = *decisionItem.Origin } else { diff --git a/pkg/hubtest/parser_assert.go b/pkg/hubtest/parser_assert.go index db27f710e..7eec8e535 100644 --- a/pkg/hubtest/parser_assert.go +++ b/pkg/hubtest/parser_assert.go @@ -107,7 +107,7 @@ func (p *ParserAssert) AssertFile(testFile string) error { } match := variableRE.FindStringSubmatch(scanner.Text()) - variable := "" + var variable string if len(match) == 0 { log.Infof("Couldn't get variable of line '%s'", scanner.Text()) diff --git a/pkg/parser/runtime.go b/pkg/parser/runtime.go index 693fb1e7d..4f4f6a0f3 100644 --- a/pkg/parser/runtime.go +++ b/pkg/parser/runtime.go @@ -319,7 +319,7 @@ func Parse(ctx UnixParserCtx, xp types.Event, nodes []Node) (types.Event, error) } clog.Tracef("node (%s) ret : %v", node.rn, ret) if ParseDump { - parserIdxInStage := 0 + var parserIdxInStage int StageParseMutex.Lock() if len(StageParseCache[stage][node.Name]) == 0 { StageParseCache[stage][node.Name] = make([]dumps.ParserResult, 0)