diff --git a/cmd/crowdsec-cli/alerts.go b/cmd/crowdsec-cli/alerts.go index bc17c728f..2bc0d524f 100644 --- a/cmd/crowdsec-cli/alerts.go +++ b/cmd/crowdsec-cli/alerts.go @@ -3,7 +3,6 @@ package main import ( "context" "encoding/csv" - json "github.com/goccy/go-json" "fmt" "net/url" "os" @@ -15,18 +14,18 @@ import ( "github.com/fatih/color" "github.com/go-openapi/strfmt" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "gopkg.in/yaml.v2" "github.com/crowdsecurity/go-cs-lib/version" + "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" "github.com/crowdsecurity/crowdsec/pkg/apiclient" "github.com/crowdsecurity/crowdsec/pkg/database" "github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/types" - - "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" ) func DecisionsFromAlert(alert *models.Alert) string { diff --git a/cmd/crowdsec-cli/bouncers.go b/cmd/crowdsec-cli/bouncers.go index a70c676ad..fe871aa20 100644 --- a/cmd/crowdsec-cli/bouncers.go +++ b/cmd/crowdsec-cli/bouncers.go @@ -2,7 +2,6 @@ package main import ( "encoding/csv" - json "github.com/goccy/go-json" "fmt" "io" "strings" @@ -10,15 +9,15 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/fatih/color" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "golang.org/x/exp/slices" + "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" middlewares "github.com/crowdsecurity/crowdsec/pkg/apiserver/middlewares/v1" "github.com/crowdsecurity/crowdsec/pkg/database" "github.com/crowdsecurity/crowdsec/pkg/types" - - "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" ) func getBouncers(out io.Writer, dbClient *database.Client) error { diff --git a/cmd/crowdsec-cli/config_restore.go b/cmd/crowdsec-cli/config_restore.go index 6c4b7636a..5bddf751e 100644 --- a/cmd/crowdsec-cli/config_restore.go +++ b/cmd/crowdsec-cli/config_restore.go @@ -1,12 +1,12 @@ package main import ( - json "github.com/goccy/go-json" "fmt" "io" "os" "path/filepath" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "gopkg.in/yaml.v2" @@ -20,7 +20,8 @@ type OldAPICfg struct { Password string `json:"password"` } -/* Restore crowdsec configurations to directory : +/* + Restore crowdsec configurations to directory : - Main config (config.yaml) - Profiles config (profiles.yaml) diff --git a/cmd/crowdsec-cli/config_show.go b/cmd/crowdsec-cli/config_show.go index 146ba9c7c..b2add28c3 100644 --- a/cmd/crowdsec-cli/config_show.go +++ b/cmd/crowdsec-cli/config_show.go @@ -1,12 +1,12 @@ package main import ( - json "github.com/goccy/go-json" "fmt" "os" "text/template" "github.com/antonmedv/expr" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "gopkg.in/yaml.v2" @@ -204,7 +204,7 @@ func runConfigShow(cmd *cobra.Command, args []string) error { // pointers in boolean tests. Prefix notation is the cherry on top. funcs := template.FuncMap{ // can't use generics here - "ValueBool": func(b *bool) bool { return b!=nil && *b }, + "ValueBool": func(b *bool) bool { return b != nil && *b }, } tmp, err := template.New("config").Funcs(funcs).Parse(configShowTemplate) diff --git a/cmd/crowdsec-cli/console.go b/cmd/crowdsec-cli/console.go index b364bf90e..c387d23c5 100644 --- a/cmd/crowdsec-cli/console.go +++ b/cmd/crowdsec-cli/console.go @@ -3,13 +3,13 @@ package main import ( "context" "encoding/csv" - json "github.com/goccy/go-json" "fmt" "net/url" "os" "github.com/fatih/color" "github.com/go-openapi/strfmt" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "gopkg.in/yaml.v3" @@ -17,13 +17,12 @@ import ( "github.com/crowdsecurity/go-cs-lib/ptr" "github.com/crowdsecurity/go-cs-lib/version" + "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" "github.com/crowdsecurity/crowdsec/pkg/apiclient" "github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/cwhub" "github.com/crowdsecurity/crowdsec/pkg/fflag" "github.com/crowdsecurity/crowdsec/pkg/types" - - "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" ) func NewConsoleCmd() *cobra.Command { @@ -193,11 +192,11 @@ Disable given information push to the central API.`, case "json": c := csConfig.API.Server.ConsoleConfig out := map[string](*bool){ - csconfig.SEND_MANUAL_SCENARIOS: c.ShareManualDecisions, - csconfig.SEND_CUSTOM_SCENARIOS: c.ShareCustomScenarios, + csconfig.SEND_MANUAL_SCENARIOS: c.ShareManualDecisions, + csconfig.SEND_CUSTOM_SCENARIOS: c.ShareCustomScenarios, csconfig.SEND_TAINTED_SCENARIOS: c.ShareTaintedScenarios, - csconfig.SEND_CONTEXT: c.ShareContext, - csconfig.CONSOLE_MANAGEMENT: c.ConsoleManagement, + csconfig.SEND_CONTEXT: c.ShareContext, + csconfig.CONSOLE_MANAGEMENT: c.ConsoleManagement, } data, err := json.MarshalIndent(out, "", " ") if err != nil { diff --git a/cmd/crowdsec-cli/decisions.go b/cmd/crowdsec-cli/decisions.go index c86797496..47ec1810f 100644 --- a/cmd/crowdsec-cli/decisions.go +++ b/cmd/crowdsec-cli/decisions.go @@ -3,7 +3,6 @@ package main import ( "context" "encoding/csv" - json "github.com/goccy/go-json" "fmt" "net/url" "os" @@ -13,6 +12,7 @@ import ( "github.com/fatih/color" "github.com/go-openapi/strfmt" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/cmd/crowdsec-cli/decisions_import.go b/cmd/crowdsec-cli/decisions_import.go index 0dd50ee8c..ca05077cf 100644 --- a/cmd/crowdsec-cli/decisions_import.go +++ b/cmd/crowdsec-cli/decisions_import.go @@ -4,13 +4,13 @@ import ( "bufio" "bytes" "context" - json "github.com/goccy/go-json" "fmt" "io" "os" "strings" "time" + json "github.com/goccy/go-json" "github.com/jszwec/csvutil" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -62,8 +62,7 @@ func parseDecisionList(content []byte, format string) ([]decisionRaw, error) { return ret, nil } - -func runDecisionsImport(cmd *cobra.Command, args []string) error { +func runDecisionsImport(cmd *cobra.Command, args []string) error { flags := cmd.Flags() input, err := flags.GetString("input") @@ -115,7 +114,7 @@ func runDecisionsImport(cmd *cobra.Command, args []string) error { var ( content []byte - fin *os.File + fin *os.File ) // set format if the file has a json or csv extension @@ -225,7 +224,6 @@ func runDecisionsImport(cmd *cobra.Command, args []string) error { return nil } - func NewDecisionsImportCmd() *cobra.Command { var cmdDecisionsImport = &cobra.Command{ Use: "import [options]", diff --git a/cmd/crowdsec-cli/hubtest.go b/cmd/crowdsec-cli/hubtest.go index 201bde702..9764f533a 100644 --- a/cmd/crowdsec-cli/hubtest.go +++ b/cmd/crowdsec-cli/hubtest.go @@ -1,7 +1,6 @@ package main import ( - json "github.com/goccy/go-json" "fmt" "math" "os" @@ -11,6 +10,7 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/enescakir/emoji" "github.com/fatih/color" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "gopkg.in/yaml.v2" @@ -59,7 +59,6 @@ func NewHubTestCmd() *cobra.Command { return cmdHubTest } - func NewHubTestCreateCmd() *cobra.Command { parsers := []string{} postoverflows := []string{} @@ -173,7 +172,6 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios return cmdHubTestCreate } - func NewHubTestRunCmd() *cobra.Command { var noClean bool var runAll bool @@ -327,7 +325,6 @@ func NewHubTestRunCmd() *cobra.Command { return cmdHubTestRun } - func NewHubTestCleanCmd() *cobra.Command { var cmdHubTestClean = &cobra.Command{ Use: "clean", @@ -352,7 +349,6 @@ func NewHubTestCleanCmd() *cobra.Command { return cmdHubTestClean } - func NewHubTestInfoCmd() *cobra.Command { var cmdHubTestInfo = &cobra.Command{ Use: "info", @@ -381,7 +377,6 @@ func NewHubTestInfoCmd() *cobra.Command { return cmdHubTestInfo } - func NewHubTestListCmd() *cobra.Command { var cmdHubTestList = &cobra.Command{ Use: "list", @@ -412,7 +407,6 @@ func NewHubTestListCmd() *cobra.Command { return cmdHubTestList } - func NewHubTestCoverageCmd() *cobra.Command { var showParserCov bool var showScenarioCov bool @@ -514,7 +508,6 @@ func NewHubTestCoverageCmd() *cobra.Command { return cmdHubTestCoverage } - func NewHubTestEvalCmd() *cobra.Command { var evalExpression string var cmdHubTestEval = &cobra.Command{ @@ -547,7 +540,6 @@ func NewHubTestEvalCmd() *cobra.Command { return cmdHubTestEval } - func NewHubTestExplainCmd() *cobra.Command { var cmdHubTestExplain = &cobra.Command{ Use: "explain", diff --git a/cmd/crowdsec-cli/machines.go b/cmd/crowdsec-cli/machines.go index 022e53292..6e14d7739 100644 --- a/cmd/crowdsec-cli/machines.go +++ b/cmd/crowdsec-cli/machines.go @@ -3,7 +3,6 @@ package main import ( saferand "crypto/rand" "encoding/csv" - json "github.com/goccy/go-json" "fmt" "io" "math/big" @@ -14,6 +13,7 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/fatih/color" "github.com/go-openapi/strfmt" + json "github.com/goccy/go-json" "github.com/google/uuid" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -22,12 +22,11 @@ import ( "github.com/crowdsecurity/machineid" + "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" "github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/database" "github.com/crowdsecurity/crowdsec/pkg/database/ent" "github.com/crowdsecurity/crowdsec/pkg/types" - - "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" ) var ( diff --git a/cmd/crowdsec-cli/metrics.go b/cmd/crowdsec-cli/metrics.go index 585cb1ec4..5cea43f01 100644 --- a/cmd/crowdsec-cli/metrics.go +++ b/cmd/crowdsec-cli/metrics.go @@ -1,7 +1,6 @@ package main import ( - json "github.com/goccy/go-json" "fmt" "io" "net/http" @@ -10,6 +9,7 @@ import ( "time" "github.com/fatih/color" + json "github.com/goccy/go-json" dto "github.com/prometheus/client_model/go" "github.com/prometheus/prom2json" log "github.com/sirupsen/logrus" @@ -282,7 +282,6 @@ func FormatPrometheusMetrics(out io.Writer, url string, formatType string) error var noUnit bool - func runMetrics(cmd *cobra.Command, args []string) error { if err := csConfig.LoadPrometheus(); err != nil { return fmt.Errorf("failed to load prometheus config: %w", err) @@ -311,7 +310,6 @@ func runMetrics(cmd *cobra.Command, args []string) error { return nil } - func NewMetricsCmd() *cobra.Command { cmdMetrics := &cobra.Command{ Use: "metrics", @@ -319,7 +317,7 @@ func NewMetricsCmd() *cobra.Command { Long: `Fetch metrics from the prometheus server and display them in a human-friendly way`, Args: cobra.ExactArgs(0), DisableAutoGenTag: true, - RunE: runMetrics, + RunE: runMetrics, } cmdMetrics.PersistentFlags().StringVarP(&prometheusURL, "url", "u", "", "Prometheus url (http://:/metrics)") cmdMetrics.PersistentFlags().BoolVar(&noUnit, "no-unit", false, "Show the real number instead of formatted with units") diff --git a/cmd/crowdsec-cli/notifications.go b/cmd/crowdsec-cli/notifications.go index be4d9598d..b79387ba6 100644 --- a/cmd/crowdsec-cli/notifications.go +++ b/cmd/crowdsec-cli/notifications.go @@ -3,7 +3,6 @@ package main import ( "context" "encoding/csv" - json "github.com/goccy/go-json" "fmt" "io/fs" "net/url" @@ -15,18 +14,18 @@ import ( "github.com/fatih/color" "github.com/go-openapi/strfmt" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "gopkg.in/tomb.v2" "github.com/crowdsecurity/go-cs-lib/version" + "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" "github.com/crowdsecurity/crowdsec/pkg/apiclient" "github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/csplugin" "github.com/crowdsecurity/crowdsec/pkg/csprofiles" - - "github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require" ) type NotificationsCfg struct { diff --git a/cmd/crowdsec-cli/utils.go b/cmd/crowdsec-cli/utils.go index e1b65a793..b5084a4a3 100644 --- a/cmd/crowdsec-cli/utils.go +++ b/cmd/crowdsec-cli/utils.go @@ -2,7 +2,6 @@ package main import ( "encoding/csv" - json "github.com/goccy/go-json" "fmt" "io" "math" @@ -13,12 +12,13 @@ import ( "strings" "time" + "github.com/agext/levenshtein" "github.com/fatih/color" + json "github.com/goccy/go-json" dto "github.com/prometheus/client_model/go" "github.com/prometheus/prom2json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "github.com/agext/levenshtein" "golang.org/x/exp/slices" "gopkg.in/yaml.v2" @@ -688,10 +688,10 @@ var ranges = []unit{ {value: 1e18, symbol: "E"}, {value: 1e15, symbol: "P"}, {value: 1e12, symbol: "T"}, - {value: 1e9, symbol: "G"}, - {value: 1e6, symbol: "M"}, - {value: 1e3, symbol: "k"}, - {value: 1, symbol: ""}, + {value: 1e9, symbol: "G"}, + {value: 1e6, symbol: "M"}, + {value: 1e3, symbol: "k"}, + {value: 1, symbol: ""}, } func formatNumber(num int) string { diff --git a/cmd/notification-splunk/main.go b/cmd/notification-splunk/main.go index 42b39418b..50e6f3933 100644 --- a/cmd/notification-splunk/main.go +++ b/cmd/notification-splunk/main.go @@ -3,18 +3,18 @@ package main import ( "context" "crypto/tls" - json "github.com/goccy/go-json" "fmt" "io" "net/http" "os" "strings" - "github.com/crowdsecurity/crowdsec/pkg/protobufs" + json "github.com/goccy/go-json" "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" - "gopkg.in/yaml.v2" + + "github.com/crowdsecurity/crowdsec/pkg/protobufs" ) var logger hclog.Logger = hclog.New(&hclog.LoggerOptions{ diff --git a/go.mod b/go.mod index 4565e816c..5a9aeb443 100644 --- a/go.mod +++ b/go.mod @@ -38,6 +38,7 @@ require ( github.com/go-openapi/swag v0.22.3 github.com/go-openapi/validate v0.20.0 github.com/go-sql-driver/mysql v1.6.0 + github.com/goccy/go-json v0.10.2 github.com/goccy/go-yaml v1.11.0 github.com/gofrs/uuid v4.0.0+incompatible github.com/golang-jwt/jwt/v4 v4.4.2 @@ -117,7 +118,6 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.14.0 // indirect github.com/go-stack/stack v1.8.0 // indirect - github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.1.0 // indirect github.com/golang/protobuf v1.5.3 // indirect diff --git a/pkg/acquisition/modules/kinesis/kinesis.go b/pkg/acquisition/modules/kinesis/kinesis.go index 08eb4e9f5..31bfd4a80 100644 --- a/pkg/acquisition/modules/kinesis/kinesis.go +++ b/pkg/acquisition/modules/kinesis/kinesis.go @@ -3,7 +3,6 @@ package kinesisacquisition import ( "bytes" "compress/gzip" - json "github.com/goccy/go-json" "fmt" "io" "strings" @@ -13,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/kinesis" + json "github.com/goccy/go-json" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" "gopkg.in/tomb.v2" diff --git a/pkg/acquisition/modules/kinesis/kinesis_test.go b/pkg/acquisition/modules/kinesis/kinesis_test.go index 39e500b54..cf891ec59 100644 --- a/pkg/acquisition/modules/kinesis/kinesis_test.go +++ b/pkg/acquisition/modules/kinesis/kinesis_test.go @@ -3,7 +3,6 @@ package kinesisacquisition import ( "bytes" "compress/gzip" - json "github.com/goccy/go-json" "fmt" "net" "os" @@ -12,15 +11,17 @@ import ( "testing" "time" - "github.com/crowdsecurity/go-cs-lib/cstest" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/kinesis" - "github.com/crowdsecurity/crowdsec/pkg/types" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "gopkg.in/tomb.v2" + + "github.com/crowdsecurity/go-cs-lib/cstest" + + "github.com/crowdsecurity/crowdsec/pkg/types" ) func getLocalStackEndpoint() (string, error) { diff --git a/pkg/acquisition/modules/kubernetesaudit/k8s_audit.go b/pkg/acquisition/modules/kubernetesaudit/k8s_audit.go index 7d4bb07a6..b9a7724c6 100644 --- a/pkg/acquisition/modules/kubernetesaudit/k8s_audit.go +++ b/pkg/acquisition/modules/kubernetesaudit/k8s_audit.go @@ -2,12 +2,12 @@ package kubernetesauditacquisition import ( "context" - json "github.com/goccy/go-json" "fmt" "io" "net/http" "strings" + json "github.com/goccy/go-json" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" "gopkg.in/tomb.v2" diff --git a/pkg/acquisition/modules/s3/s3.go b/pkg/acquisition/modules/s3/s3.go index 93551f814..57a968dc5 100644 --- a/pkg/acquisition/modules/s3/s3.go +++ b/pkg/acquisition/modules/s3/s3.go @@ -5,7 +5,6 @@ import ( "bytes" "compress/gzip" "context" - json "github.com/goccy/go-json" "errors" "fmt" "io" @@ -22,6 +21,7 @@ import ( "github.com/aws/aws-sdk-go/service/s3/s3iface" "github.com/aws/aws-sdk-go/service/sqs" "github.com/aws/aws-sdk-go/service/sqs/sqsiface" + json "github.com/goccy/go-json" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" "gopkg.in/tomb.v2" diff --git a/pkg/alertcontext/alertcontext.go b/pkg/alertcontext/alertcontext.go index 5270efe2d..e331a602d 100644 --- a/pkg/alertcontext/alertcontext.go +++ b/pkg/alertcontext/alertcontext.go @@ -1,12 +1,12 @@ package alertcontext import ( - json "github.com/goccy/go-json" "fmt" "strconv" "github.com/antonmedv/expr" "github.com/antonmedv/expr/vm" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "golang.org/x/exp/slices" diff --git a/pkg/apiclient/auth.go b/pkg/apiclient/auth.go index b6e1e5629..1e9e998d7 100644 --- a/pkg/apiclient/auth.go +++ b/pkg/apiclient/auth.go @@ -2,7 +2,6 @@ package apiclient import ( "bytes" - json "github.com/goccy/go-json" "fmt" "io" "math/rand" @@ -13,6 +12,7 @@ import ( "time" "github.com/go-openapi/strfmt" + json "github.com/goccy/go-json" "github.com/pkg/errors" log "github.com/sirupsen/logrus" diff --git a/pkg/apiclient/auth_service_test.go b/pkg/apiclient/auth_service_test.go index cc33117c5..19a2685a0 100644 --- a/pkg/apiclient/auth_service_test.go +++ b/pkg/apiclient/auth_service_test.go @@ -3,13 +3,13 @@ package apiclient import ( "bytes" "context" - json "github.com/goccy/go-json" "fmt" "io" "net/http" "net/url" "testing" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" diff --git a/pkg/apiclient/client.go b/pkg/apiclient/client.go index 2d8afb78d..07b4d5427 100644 --- a/pkg/apiclient/client.go +++ b/pkg/apiclient/client.go @@ -4,12 +4,13 @@ import ( "context" "crypto/tls" "crypto/x509" - json "github.com/goccy/go-json" "fmt" "io" "net/http" "net/url" + json "github.com/goccy/go-json" + "github.com/crowdsecurity/crowdsec/pkg/models" ) diff --git a/pkg/apiclient/client_http.go b/pkg/apiclient/client_http.go index 1091f863a..11fcfb20a 100644 --- a/pkg/apiclient/client_http.go +++ b/pkg/apiclient/client_http.go @@ -3,7 +3,6 @@ package apiclient import ( "bytes" "context" - json "github.com/goccy/go-json" "errors" "fmt" "io" @@ -12,6 +11,7 @@ import ( "net/url" "strings" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" ) diff --git a/pkg/apiserver/alerts_test.go b/pkg/apiserver/alerts_test.go index 3fc990457..c6ccaa6ff 100644 --- a/pkg/apiserver/alerts_test.go +++ b/pkg/apiserver/alerts_test.go @@ -1,7 +1,6 @@ package apiserver import ( - json "github.com/goccy/go-json" "fmt" "net/http" "net/http/httptest" @@ -9,13 +8,14 @@ import ( "sync" "testing" + "github.com/gin-gonic/gin" + json "github.com/goccy/go-json" + log "github.com/sirupsen/logrus" + "github.com/stretchr/testify/assert" + "github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/csplugin" "github.com/crowdsecurity/crowdsec/pkg/models" - "github.com/gin-gonic/gin" - - log "github.com/sirupsen/logrus" - "github.com/stretchr/testify/assert" ) type LAPI struct { diff --git a/pkg/apiserver/apic_test.go b/pkg/apiserver/apic_test.go index 50695818b..92b1ab270 100644 --- a/pkg/apiserver/apic_test.go +++ b/pkg/apiserver/apic_test.go @@ -3,7 +3,6 @@ package apiserver import ( "bytes" "context" - json "github.com/goccy/go-json" "fmt" "net" "net/http" @@ -14,6 +13,7 @@ import ( "testing" "time" + json "github.com/goccy/go-json" "github.com/jarcoal/httpmock" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index bb0473baf..3b6de182f 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -1,7 +1,6 @@ package apiserver import ( - json "github.com/goccy/go-json" "fmt" "net/http" "net/http/httptest" @@ -11,20 +10,20 @@ import ( "testing" "time" + "github.com/gin-gonic/gin" + "github.com/go-openapi/strfmt" + json "github.com/goccy/go-json" + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" + "github.com/stretchr/testify/assert" + "github.com/crowdsecurity/go-cs-lib/version" middlewares "github.com/crowdsecurity/crowdsec/pkg/apiserver/middlewares/v1" - "github.com/crowdsecurity/crowdsec/pkg/models" - "github.com/crowdsecurity/crowdsec/pkg/types" - "github.com/go-openapi/strfmt" - "github.com/pkg/errors" - "github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/database" - "github.com/gin-gonic/gin" - - log "github.com/sirupsen/logrus" - "github.com/stretchr/testify/assert" + "github.com/crowdsecurity/crowdsec/pkg/models" + "github.com/crowdsecurity/crowdsec/pkg/types" ) var testMachineID = "test" diff --git a/pkg/apiserver/controllers/v1/alerts.go b/pkg/apiserver/controllers/v1/alerts.go index aa2e3e4f7..871c06a75 100644 --- a/pkg/apiserver/controllers/v1/alerts.go +++ b/pkg/apiserver/controllers/v1/alerts.go @@ -1,7 +1,6 @@ package v1 import ( - json "github.com/goccy/go-json" "fmt" "net" "net/http" @@ -10,15 +9,16 @@ import ( "time" jwt "github.com/appleboy/gin-jwt/v2" + "github.com/gin-gonic/gin" + "github.com/go-openapi/strfmt" + json "github.com/goccy/go-json" "github.com/google/uuid" + log "github.com/sirupsen/logrus" "github.com/crowdsecurity/crowdsec/pkg/csplugin" "github.com/crowdsecurity/crowdsec/pkg/database/ent" "github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/types" - "github.com/gin-gonic/gin" - "github.com/go-openapi/strfmt" - log "github.com/sirupsen/logrus" ) func FormatOneAlert(alert *ent.Alert) *models.Alert { diff --git a/pkg/apiserver/controllers/v1/decisions.go b/pkg/apiserver/controllers/v1/decisions.go index e5f74f6a5..a8a921729 100644 --- a/pkg/apiserver/controllers/v1/decisions.go +++ b/pkg/apiserver/controllers/v1/decisions.go @@ -1,17 +1,18 @@ package v1 import ( - json "github.com/goccy/go-json" "fmt" "net/http" "strconv" "time" + "github.com/gin-gonic/gin" + json "github.com/goccy/go-json" + log "github.com/sirupsen/logrus" + "github.com/crowdsecurity/crowdsec/pkg/database/ent" "github.com/crowdsecurity/crowdsec/pkg/fflag" "github.com/crowdsecurity/crowdsec/pkg/models" - "github.com/gin-gonic/gin" - log "github.com/sirupsen/logrus" ) // Format decisions for the bouncers diff --git a/pkg/apiserver/machines_test.go b/pkg/apiserver/machines_test.go index 8b86476ad..853b64e09 100644 --- a/pkg/apiserver/machines_test.go +++ b/pkg/apiserver/machines_test.go @@ -1,12 +1,12 @@ package apiserver import ( - json "github.com/goccy/go-json" "net/http" "net/http/httptest" "strings" "testing" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" ) diff --git a/pkg/apiserver/papi.go b/pkg/apiserver/papi.go index 4d9a53719..f96a5c98b 100644 --- a/pkg/apiserver/papi.go +++ b/pkg/apiserver/papi.go @@ -2,12 +2,12 @@ package apiserver import ( "context" - json "github.com/goccy/go-json" "fmt" "net/http" "sync" "time" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "gopkg.in/tomb.v2" diff --git a/pkg/apiserver/papi_cmd.go b/pkg/apiserver/papi_cmd.go index 7d60931be..c3331611f 100644 --- a/pkg/apiserver/papi_cmd.go +++ b/pkg/apiserver/papi_cmd.go @@ -1,10 +1,10 @@ package apiserver import ( - json "github.com/goccy/go-json" "fmt" "time" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/crowdsecurity/go-cs-lib/ptr" diff --git a/pkg/csplugin/broker_test.go b/pkg/csplugin/broker_test.go index 7aae7145b..a8ef01fe5 100644 --- a/pkg/csplugin/broker_test.go +++ b/pkg/csplugin/broker_test.go @@ -4,12 +4,12 @@ package csplugin import ( "bytes" - json "github.com/goccy/go-json" "io" "os" "testing" "time" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/csplugin/broker_win_test.go b/pkg/csplugin/broker_win_test.go index 1f3e74a38..47b5a068c 100644 --- a/pkg/csplugin/broker_win_test.go +++ b/pkg/csplugin/broker_win_test.go @@ -4,12 +4,12 @@ package csplugin import ( "bytes" - json "github.com/goccy/go-json" "io" "os" "testing" "time" + json "github.com/goccy/go-json" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/tomb.v2" diff --git a/pkg/cticlient/client.go b/pkg/cticlient/client.go index 74efc4142..73d685914 100644 --- a/pkg/cticlient/client.go +++ b/pkg/cticlient/client.go @@ -1,13 +1,13 @@ package cticlient import ( - json "github.com/goccy/go-json" "errors" "fmt" "io" "net/http" "strings" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" ) diff --git a/pkg/cwhub/loader.go b/pkg/cwhub/loader.go index fe8e3a3c1..6c6bfb1ee 100644 --- a/pkg/cwhub/loader.go +++ b/pkg/cwhub/loader.go @@ -1,7 +1,6 @@ package cwhub import ( - json "github.com/goccy/go-json" "errors" "fmt" "os" @@ -9,6 +8,7 @@ import ( "sort" "strings" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" "golang.org/x/mod/semver" diff --git a/pkg/cwversion/version.go b/pkg/cwversion/version.go index 17801cb0b..7c809f844 100644 --- a/pkg/cwversion/version.go +++ b/pkg/cwversion/version.go @@ -1,21 +1,21 @@ package cwversion import ( - json "github.com/goccy/go-json" "fmt" "log" "net/http" "runtime" "strings" + json "github.com/goccy/go-json" goversion "github.com/hashicorp/go-version" - + "github.com/crowdsecurity/go-cs-lib/version" ) var ( - Codename string // = "SoumSoum" - System = runtime.GOOS // = "linux" + Codename string // = "SoumSoum" + System = runtime.GOOS // = "linux" Constraint_parser = ">= 1.0, <= 2.0" Constraint_scenario = ">= 1.0, < 3.0" Constraint_api = "v1" diff --git a/pkg/database/alerts.go b/pkg/database/alerts.go index 07b60132f..692d12cf4 100644 --- a/pkg/database/alerts.go +++ b/pkg/database/alerts.go @@ -2,16 +2,15 @@ package database import ( "context" - json "github.com/goccy/go-json" "fmt" "sort" "strconv" "strings" "time" - "github.com/mattn/go-sqlite3" - "github.com/davecgh/go-spew/spew" + json "github.com/goccy/go-json" + "github.com/mattn/go-sqlite3" "github.com/pkg/errors" log "github.com/sirupsen/logrus" diff --git a/pkg/exprhelpers/crowdsec_cti_test.go b/pkg/exprhelpers/crowdsec_cti_test.go index 378075008..f0f1c896d 100644 --- a/pkg/exprhelpers/crowdsec_cti_test.go +++ b/pkg/exprhelpers/crowdsec_cti_test.go @@ -2,13 +2,13 @@ package exprhelpers import ( "bytes" - json "github.com/goccy/go-json" "io" "net/http" "strings" "testing" "time" + json "github.com/goccy/go-json" "github.com/stretchr/testify/assert" "github.com/crowdsecurity/go-cs-lib/ptr" diff --git a/pkg/exprhelpers/jsonextract.go b/pkg/exprhelpers/jsonextract.go index b159ed6ea..e353d7e3e 100644 --- a/pkg/exprhelpers/jsonextract.go +++ b/pkg/exprhelpers/jsonextract.go @@ -1,13 +1,12 @@ package exprhelpers import ( - json "github.com/goccy/go-json" "errors" "fmt" "strings" "github.com/buger/jsonparser" - + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" ) diff --git a/pkg/leakybucket/buckets_test.go b/pkg/leakybucket/buckets_test.go index 13dfb6897..0c606cc4d 100644 --- a/pkg/leakybucket/buckets_test.go +++ b/pkg/leakybucket/buckets_test.go @@ -2,7 +2,6 @@ package leakybucket import ( "bytes" - json "github.com/goccy/go-json" "errors" "fmt" "html/template" @@ -13,14 +12,16 @@ import ( "testing" "time" + "github.com/davecgh/go-spew/spew" + json "github.com/goccy/go-json" + log "github.com/sirupsen/logrus" + "gopkg.in/tomb.v2" + yaml "gopkg.in/yaml.v2" + "github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/exprhelpers" "github.com/crowdsecurity/crowdsec/pkg/parser" "github.com/crowdsecurity/crowdsec/pkg/types" - "github.com/davecgh/go-spew/spew" - log "github.com/sirupsen/logrus" - "gopkg.in/tomb.v2" - yaml "gopkg.in/yaml.v2" ) type TestFile struct { diff --git a/pkg/leakybucket/manager_load.go b/pkg/leakybucket/manager_load.go index 94ca7d495..1cf6a8c6d 100644 --- a/pkg/leakybucket/manager_load.go +++ b/pkg/leakybucket/manager_load.go @@ -1,7 +1,6 @@ package leakybucket import ( - json "github.com/goccy/go-json" "errors" "fmt" "io" @@ -14,6 +13,7 @@ import ( "github.com/antonmedv/expr" "github.com/antonmedv/expr/vm" "github.com/davecgh/go-spew/spew" + json "github.com/goccy/go-json" "github.com/goombaio/namegenerator" log "github.com/sirupsen/logrus" "gopkg.in/tomb.v2" diff --git a/pkg/leakybucket/manager_run.go b/pkg/leakybucket/manager_run.go index 2573446a9..ee7107a43 100644 --- a/pkg/leakybucket/manager_run.go +++ b/pkg/leakybucket/manager_run.go @@ -1,7 +1,6 @@ package leakybucket import ( - json "github.com/goccy/go-json" "errors" "fmt" "math" @@ -10,6 +9,7 @@ import ( "time" "github.com/antonmedv/expr" + json "github.com/goccy/go-json" "github.com/mohae/deepcopy" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" diff --git a/pkg/longpollclient/client.go b/pkg/longpollclient/client.go index 9570a9291..eb1bafa67 100644 --- a/pkg/longpollclient/client.go +++ b/pkg/longpollclient/client.go @@ -1,13 +1,13 @@ package longpollclient import ( - json "github.com/goccy/go-json" "fmt" "io" "net/http" "net/url" "time" + json "github.com/goccy/go-json" "github.com/gofrs/uuid" log "github.com/sirupsen/logrus" "gopkg.in/tomb.v2" diff --git a/pkg/metabase/api.go b/pkg/metabase/api.go index 5d504556f..e0fe20bb9 100644 --- a/pkg/metabase/api.go +++ b/pkg/metabase/api.go @@ -1,15 +1,15 @@ package metabase import ( - json "github.com/goccy/go-json" "fmt" "net/http" "time" - "github.com/crowdsecurity/go-cs-lib/version" - "github.com/dghubble/sling" + json "github.com/goccy/go-json" log "github.com/sirupsen/logrus" + + "github.com/crowdsecurity/go-cs-lib/version" ) type MBClient struct { diff --git a/pkg/metabase/database.go b/pkg/metabase/database.go index ebded25db..b9ebe1493 100644 --- a/pkg/metabase/database.go +++ b/pkg/metabase/database.go @@ -1,11 +1,12 @@ package metabase import ( - json "github.com/goccy/go-json" "fmt" "path/filepath" "strings" + json "github.com/goccy/go-json" + "github.com/crowdsecurity/crowdsec/pkg/csconfig" ) diff --git a/pkg/parser/enrich_unmarshal.go b/pkg/parser/enrich_unmarshal.go index fa04eed8e..6366fbb69 100644 --- a/pkg/parser/enrich_unmarshal.go +++ b/pkg/parser/enrich_unmarshal.go @@ -2,7 +2,6 @@ package parser import ( json "github.com/goccy/go-json" - log "github.com/sirupsen/logrus" "github.com/crowdsecurity/crowdsec/pkg/types"