From fa19c2a9411d44779958bd486ce8dedcd1e5814c Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 22 May 2024 10:48:05 +0200 Subject: [PATCH 1/4] comment fix --- cmd/crowdsec-cli/support.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/crowdsec-cli/support.go b/cmd/crowdsec-cli/support.go index 3b0f53cd6e1..061733ef8d3 100644 --- a/cmd/crowdsec-cli/support.go +++ b/cmd/crowdsec-cli/support.go @@ -427,7 +427,7 @@ func (cli *cliSupport) writeToZip(zipWriter *zip.Writer, filename string, mtime } } -// writeToZip adds a file to the zip archive, from a file, and retains the mtime +// writeFileToZip adds a file to the zip archive, from a file, and retains the mtime func (cli *cliSupport) writeFileToZip(zw *zip.Writer, filename string, fromFile string) { mtime := time.Now() From acd4adc8c69293755063ca8e53b6f93535540a2d Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 22 May 2024 11:30:33 +0200 Subject: [PATCH 2/4] redundancy --- pkg/apiserver/apiserver_test.go | 2 +- pkg/database/flush.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index 20c48337833..26531a592da 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -294,7 +294,7 @@ func TestWithWrongFlushConfig(t *testing.T) { config.API.Server.DbConfig.Flush.MaxItems = &maxItems apiServer, err := NewServer(config.API.Server) - cstest.RequireErrorContains(t, err, "max_items can't be zero or negative number") + cstest.RequireErrorContains(t, err, "max_items can't be zero or negative") assert.Nil(t, apiServer) } diff --git a/pkg/database/flush.go b/pkg/database/flush.go index 56e42715b2c..5a1f0bea5bf 100644 --- a/pkg/database/flush.go +++ b/pkg/database/flush.go @@ -22,7 +22,7 @@ func (c *Client) StartFlushScheduler(config *csconfig.FlushDBCfg) (*gocron.Sched maxAge := "" if config.MaxItems != nil && *config.MaxItems <= 0 { - return nil, errors.New("max_items can't be zero or negative number") + return nil, errors.New("max_items can't be zero or negative") } if config.MaxItems != nil { From bccd8694ddfb6925e57c3a16c8561ff44c55c81a Mon Sep 17 00:00:00 2001 From: marco Date: Fri, 17 May 2024 09:12:24 +0200 Subject: [PATCH 3/4] typo nill -> nil --- pkg/exprhelpers/crowdsec_cti_test.go | 2 +- pkg/exprhelpers/debugger_test.go | 10 +++++----- pkg/parser/runtime.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/exprhelpers/crowdsec_cti_test.go b/pkg/exprhelpers/crowdsec_cti_test.go index 4c0346e447c..9f78b932d6d 100644 --- a/pkg/exprhelpers/crowdsec_cti_test.go +++ b/pkg/exprhelpers/crowdsec_cti_test.go @@ -109,7 +109,7 @@ func smokeHandler(req *http.Request) *http.Response { } } -func TestNillClient(t *testing.T) { +func TestNilClient(t *testing.T) { defer ShutdownCrowdsecCTI() if err := InitCrowdsecCTI(ptr.Of(""), nil, nil, nil); !errors.Is(err, cticlient.ErrDisabled) { diff --git a/pkg/exprhelpers/debugger_test.go b/pkg/exprhelpers/debugger_test.go index 9c713a8d4f5..6832b4efaa8 100644 --- a/pkg/exprhelpers/debugger_test.go +++ b/pkg/exprhelpers/debugger_test.go @@ -59,7 +59,7 @@ func TestBaseDbg(t *testing.T) { "base_string": "hello world", "base_int": 42, "base_float": 42.42, - "nillvar": &teststruct{}, + "nilvar": &teststruct{}, "base_struct": struct { Foo string Bar int @@ -79,8 +79,8 @@ func TestBaseDbg(t *testing.T) { //Missing multi parametes function tests := []ExprDbgTest{ { - Name: "nill deref", - Expr: "Upper('1') == '1' && nillvar.Foo == '42'", + Name: "nil deref", + Expr: "Upper('1') == '1' && nilvar.Foo == '42'", Env: defaultEnv, ExpectedFailRuntime: true, ExpectedOutputs: []OpOutput{ @@ -307,8 +307,8 @@ func TestBaseDbg(t *testing.T) { t.Fatalf("test %s : unexpected compile error : %s", test.Name, err) } } - if test.Name == "nill deref" { - test.Env["nillvar"] = nil + if test.Name == "nil deref" { + test.Env["nilvar"] = nil } outdbg, ret, err := RunWithDebug(prog, test.Env, logger) if test.ExpectedFailRuntime { diff --git a/pkg/parser/runtime.go b/pkg/parser/runtime.go index 1596ef5ffd9..8068690b68f 100644 --- a/pkg/parser/runtime.go +++ b/pkg/parser/runtime.go @@ -42,8 +42,8 @@ func SetTargetByName(target string, value string, evt *types.Event) bool { iter := reflect.ValueOf(evt).Elem() if (iter == reflect.Value{}) || iter.IsZero() { - log.Tracef("event is nill") - //event is nill + log.Tracef("event is nil") + //event is nil return false } for _, f := range strings.Split(target, ".") { From 890fd1d8aaec363a52e6b572dc2d75852f50c214 Mon Sep 17 00:00:00 2001 From: marco Date: Sat, 18 May 2024 22:20:06 +0200 Subject: [PATCH 4/4] remove extra newline from log --- cmd/crowdsec/parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/crowdsec/parse.go b/cmd/crowdsec/parse.go index 39eedfc858e..26eae66be2b 100644 --- a/cmd/crowdsec/parse.go +++ b/cmd/crowdsec/parse.go @@ -37,7 +37,7 @@ func runParse(input chan types.Event, output chan types.Event, parserCTX parser. /* parse the log using magic */ parsed, err := parser.Parse(parserCTX, event, nodes) if err != nil { - log.Errorf("failed parsing : %v\n", err) + log.Errorf("failed parsing: %v", err) } elapsed := time.Since(startParsing) globalParsingHistogram.With(prometheus.Labels{"source": event.Line.Src, "type": event.Line.Module}).Observe(elapsed.Seconds())