Compare commits

...

2 commits

Author SHA1 Message Date
Marco Mariani
0acf483aa1 lint imports 2023-09-24 23:39:07 +02:00
Marco Mariani
1a1c421386 replace encoding/json with goccy/go-json 2023-09-24 23:30:42 +02:00
47 changed files with 104 additions and 119 deletions

View file

@ -3,7 +3,6 @@ package main
import ( import (
"context" "context"
"encoding/csv" "encoding/csv"
"encoding/json"
"fmt" "fmt"
"net/url" "net/url"
"os" "os"
@ -15,18 +14,18 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"github.com/crowdsecurity/go-cs-lib/version" "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/apiclient"
"github.com/crowdsecurity/crowdsec/pkg/database" "github.com/crowdsecurity/crowdsec/pkg/database"
"github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/models"
"github.com/crowdsecurity/crowdsec/pkg/types" "github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
) )
func DecisionsFromAlert(alert *models.Alert) string { func DecisionsFromAlert(alert *models.Alert) string {

View file

@ -2,7 +2,6 @@ package main
import ( import (
"encoding/csv" "encoding/csv"
"encoding/json"
"fmt" "fmt"
"io" "io"
"strings" "strings"
@ -10,15 +9,15 @@ import (
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
"github.com/fatih/color" "github.com/fatih/color"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
middlewares "github.com/crowdsecurity/crowdsec/pkg/apiserver/middlewares/v1" middlewares "github.com/crowdsecurity/crowdsec/pkg/apiserver/middlewares/v1"
"github.com/crowdsecurity/crowdsec/pkg/database" "github.com/crowdsecurity/crowdsec/pkg/database"
"github.com/crowdsecurity/crowdsec/pkg/types" "github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
) )
func getBouncers(out io.Writer, dbClient *database.Client) error { func getBouncers(out io.Writer, dbClient *database.Client) error {

View file

@ -1,12 +1,12 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
@ -20,7 +20,8 @@ type OldAPICfg struct {
Password string `json:"password"` Password string `json:"password"`
} }
/* Restore crowdsec configurations to directory <dirPath> : /*
Restore crowdsec configurations to directory <dirPath> :
- Main config (config.yaml) - Main config (config.yaml)
- Profiles config (profiles.yaml) - Profiles config (profiles.yaml)

View file

@ -1,12 +1,12 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"os" "os"
"text/template" "text/template"
"github.com/antonmedv/expr" "github.com/antonmedv/expr"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "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. // pointers in boolean tests. Prefix notation is the cherry on top.
funcs := template.FuncMap{ funcs := template.FuncMap{
// can't use generics here // 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) tmp, err := template.New("config").Funcs(funcs).Parse(configShowTemplate)

View file

@ -3,13 +3,13 @@ package main
import ( import (
"context" "context"
"encoding/csv" "encoding/csv"
"encoding/json"
"fmt" "fmt"
"net/url" "net/url"
"os" "os"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
@ -17,13 +17,12 @@ import (
"github.com/crowdsecurity/go-cs-lib/ptr" "github.com/crowdsecurity/go-cs-lib/ptr"
"github.com/crowdsecurity/go-cs-lib/version" "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/apiclient"
"github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/cwhub" "github.com/crowdsecurity/crowdsec/pkg/cwhub"
"github.com/crowdsecurity/crowdsec/pkg/fflag" "github.com/crowdsecurity/crowdsec/pkg/fflag"
"github.com/crowdsecurity/crowdsec/pkg/types" "github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
) )
func NewConsoleCmd() *cobra.Command { func NewConsoleCmd() *cobra.Command {
@ -193,11 +192,11 @@ Disable given information push to the central API.`,
case "json": case "json":
c := csConfig.API.Server.ConsoleConfig c := csConfig.API.Server.ConsoleConfig
out := map[string](*bool){ out := map[string](*bool){
csconfig.SEND_MANUAL_SCENARIOS: c.ShareManualDecisions, csconfig.SEND_MANUAL_SCENARIOS: c.ShareManualDecisions,
csconfig.SEND_CUSTOM_SCENARIOS: c.ShareCustomScenarios, csconfig.SEND_CUSTOM_SCENARIOS: c.ShareCustomScenarios,
csconfig.SEND_TAINTED_SCENARIOS: c.ShareTaintedScenarios, csconfig.SEND_TAINTED_SCENARIOS: c.ShareTaintedScenarios,
csconfig.SEND_CONTEXT: c.ShareContext, csconfig.SEND_CONTEXT: c.ShareContext,
csconfig.CONSOLE_MANAGEMENT: c.ConsoleManagement, csconfig.CONSOLE_MANAGEMENT: c.ConsoleManagement,
} }
data, err := json.MarshalIndent(out, "", " ") data, err := json.MarshalIndent(out, "", " ")
if err != nil { if err != nil {

View file

@ -3,7 +3,6 @@ package main
import ( import (
"context" "context"
"encoding/csv" "encoding/csv"
"encoding/json"
"fmt" "fmt"
"net/url" "net/url"
"os" "os"
@ -13,6 +12,7 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"

View file

@ -4,13 +4,13 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"context" "context"
"encoding/json"
"fmt" "fmt"
"io" "io"
"os" "os"
"strings" "strings"
"time" "time"
json "github.com/goccy/go-json"
"github.com/jszwec/csvutil" "github.com/jszwec/csvutil"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -62,8 +62,7 @@ func parseDecisionList(content []byte, format string) ([]decisionRaw, error) {
return ret, nil return ret, nil
} }
func runDecisionsImport(cmd *cobra.Command, args []string) error {
func runDecisionsImport(cmd *cobra.Command, args []string) error {
flags := cmd.Flags() flags := cmd.Flags()
input, err := flags.GetString("input") input, err := flags.GetString("input")
@ -115,7 +114,7 @@ func runDecisionsImport(cmd *cobra.Command, args []string) error {
var ( var (
content []byte content []byte
fin *os.File fin *os.File
) )
// set format if the file has a json or csv extension // 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 return nil
} }
func NewDecisionsImportCmd() *cobra.Command { func NewDecisionsImportCmd() *cobra.Command {
var cmdDecisionsImport = &cobra.Command{ var cmdDecisionsImport = &cobra.Command{
Use: "import [options]", Use: "import [options]",

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"math" "math"
"os" "os"
@ -11,6 +10,7 @@ import (
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
"github.com/enescakir/emoji" "github.com/enescakir/emoji"
"github.com/fatih/color" "github.com/fatih/color"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
@ -59,7 +59,6 @@ func NewHubTestCmd() *cobra.Command {
return cmdHubTest return cmdHubTest
} }
func NewHubTestCreateCmd() *cobra.Command { func NewHubTestCreateCmd() *cobra.Command {
parsers := []string{} parsers := []string{}
postoverflows := []string{} postoverflows := []string{}
@ -173,7 +172,6 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios
return cmdHubTestCreate return cmdHubTestCreate
} }
func NewHubTestRunCmd() *cobra.Command { func NewHubTestRunCmd() *cobra.Command {
var noClean bool var noClean bool
var runAll bool var runAll bool
@ -327,7 +325,6 @@ func NewHubTestRunCmd() *cobra.Command {
return cmdHubTestRun return cmdHubTestRun
} }
func NewHubTestCleanCmd() *cobra.Command { func NewHubTestCleanCmd() *cobra.Command {
var cmdHubTestClean = &cobra.Command{ var cmdHubTestClean = &cobra.Command{
Use: "clean", Use: "clean",
@ -352,7 +349,6 @@ func NewHubTestCleanCmd() *cobra.Command {
return cmdHubTestClean return cmdHubTestClean
} }
func NewHubTestInfoCmd() *cobra.Command { func NewHubTestInfoCmd() *cobra.Command {
var cmdHubTestInfo = &cobra.Command{ var cmdHubTestInfo = &cobra.Command{
Use: "info", Use: "info",
@ -381,7 +377,6 @@ func NewHubTestInfoCmd() *cobra.Command {
return cmdHubTestInfo return cmdHubTestInfo
} }
func NewHubTestListCmd() *cobra.Command { func NewHubTestListCmd() *cobra.Command {
var cmdHubTestList = &cobra.Command{ var cmdHubTestList = &cobra.Command{
Use: "list", Use: "list",
@ -412,7 +407,6 @@ func NewHubTestListCmd() *cobra.Command {
return cmdHubTestList return cmdHubTestList
} }
func NewHubTestCoverageCmd() *cobra.Command { func NewHubTestCoverageCmd() *cobra.Command {
var showParserCov bool var showParserCov bool
var showScenarioCov bool var showScenarioCov bool
@ -514,7 +508,6 @@ func NewHubTestCoverageCmd() *cobra.Command {
return cmdHubTestCoverage return cmdHubTestCoverage
} }
func NewHubTestEvalCmd() *cobra.Command { func NewHubTestEvalCmd() *cobra.Command {
var evalExpression string var evalExpression string
var cmdHubTestEval = &cobra.Command{ var cmdHubTestEval = &cobra.Command{
@ -547,7 +540,6 @@ func NewHubTestEvalCmd() *cobra.Command {
return cmdHubTestEval return cmdHubTestEval
} }
func NewHubTestExplainCmd() *cobra.Command { func NewHubTestExplainCmd() *cobra.Command {
var cmdHubTestExplain = &cobra.Command{ var cmdHubTestExplain = &cobra.Command{
Use: "explain", Use: "explain",

View file

@ -3,7 +3,6 @@ package main
import ( import (
saferand "crypto/rand" saferand "crypto/rand"
"encoding/csv" "encoding/csv"
"encoding/json"
"fmt" "fmt"
"io" "io"
"math/big" "math/big"
@ -14,6 +13,7 @@ import (
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
json "github.com/goccy/go-json"
"github.com/google/uuid" "github.com/google/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -22,12 +22,11 @@ import (
"github.com/crowdsecurity/machineid" "github.com/crowdsecurity/machineid"
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
"github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/database" "github.com/crowdsecurity/crowdsec/pkg/database"
"github.com/crowdsecurity/crowdsec/pkg/database/ent" "github.com/crowdsecurity/crowdsec/pkg/database/ent"
"github.com/crowdsecurity/crowdsec/pkg/types" "github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
) )
var ( var (

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -10,6 +9,7 @@ import (
"time" "time"
"github.com/fatih/color" "github.com/fatih/color"
json "github.com/goccy/go-json"
dto "github.com/prometheus/client_model/go" dto "github.com/prometheus/client_model/go"
"github.com/prometheus/prom2json" "github.com/prometheus/prom2json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -282,7 +282,6 @@ func FormatPrometheusMetrics(out io.Writer, url string, formatType string) error
var noUnit bool var noUnit bool
func runMetrics(cmd *cobra.Command, args []string) error { func runMetrics(cmd *cobra.Command, args []string) error {
if err := csConfig.LoadPrometheus(); err != nil { if err := csConfig.LoadPrometheus(); err != nil {
return fmt.Errorf("failed to load prometheus config: %w", err) return fmt.Errorf("failed to load prometheus config: %w", err)
@ -311,7 +310,6 @@ func runMetrics(cmd *cobra.Command, args []string) error {
return nil return nil
} }
func NewMetricsCmd() *cobra.Command { func NewMetricsCmd() *cobra.Command {
cmdMetrics := &cobra.Command{ cmdMetrics := &cobra.Command{
Use: "metrics", 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`, Long: `Fetch metrics from the prometheus server and display them in a human-friendly way`,
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
DisableAutoGenTag: true, DisableAutoGenTag: true,
RunE: runMetrics, RunE: runMetrics,
} }
cmdMetrics.PersistentFlags().StringVarP(&prometheusURL, "url", "u", "", "Prometheus url (http://<ip>:<port>/metrics)") cmdMetrics.PersistentFlags().StringVarP(&prometheusURL, "url", "u", "", "Prometheus url (http://<ip>:<port>/metrics)")
cmdMetrics.PersistentFlags().BoolVar(&noUnit, "no-unit", false, "Show the real number instead of formatted with units") cmdMetrics.PersistentFlags().BoolVar(&noUnit, "no-unit", false, "Show the real number instead of formatted with units")

View file

@ -3,7 +3,6 @@ package main
import ( import (
"context" "context"
"encoding/csv" "encoding/csv"
"encoding/json"
"fmt" "fmt"
"io/fs" "io/fs"
"net/url" "net/url"
@ -15,18 +14,18 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"
"github.com/crowdsecurity/go-cs-lib/version" "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/apiclient"
"github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/csplugin" "github.com/crowdsecurity/crowdsec/pkg/csplugin"
"github.com/crowdsecurity/crowdsec/pkg/csprofiles" "github.com/crowdsecurity/crowdsec/pkg/csprofiles"
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
) )
type NotificationsCfg struct { type NotificationsCfg struct {

View file

@ -2,7 +2,6 @@ package main
import ( import (
"encoding/csv" "encoding/csv"
"encoding/json"
"fmt" "fmt"
"io" "io"
"math" "math"
@ -13,12 +12,13 @@ import (
"strings" "strings"
"time" "time"
"github.com/agext/levenshtein"
"github.com/fatih/color" "github.com/fatih/color"
json "github.com/goccy/go-json"
dto "github.com/prometheus/client_model/go" dto "github.com/prometheus/client_model/go"
"github.com/prometheus/prom2json" "github.com/prometheus/prom2json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/agext/levenshtein"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
@ -688,10 +688,10 @@ var ranges = []unit{
{value: 1e18, symbol: "E"}, {value: 1e18, symbol: "E"},
{value: 1e15, symbol: "P"}, {value: 1e15, symbol: "P"},
{value: 1e12, symbol: "T"}, {value: 1e12, symbol: "T"},
{value: 1e9, symbol: "G"}, {value: 1e9, symbol: "G"},
{value: 1e6, symbol: "M"}, {value: 1e6, symbol: "M"},
{value: 1e3, symbol: "k"}, {value: 1e3, symbol: "k"},
{value: 1, symbol: ""}, {value: 1, symbol: ""},
} }
func formatNumber(num int) string { func formatNumber(num int) string {

View file

@ -3,18 +3,18 @@ package main
import ( import (
"context" "context"
"crypto/tls" "crypto/tls"
"encoding/json"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"os" "os"
"strings" "strings"
"github.com/crowdsecurity/crowdsec/pkg/protobufs" json "github.com/goccy/go-json"
"github.com/hashicorp/go-hclog" "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin" plugin "github.com/hashicorp/go-plugin"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"github.com/crowdsecurity/crowdsec/pkg/protobufs"
) )
var logger hclog.Logger = hclog.New(&hclog.LoggerOptions{ var logger hclog.Logger = hclog.New(&hclog.LoggerOptions{

2
go.mod
View file

@ -38,6 +38,7 @@ require (
github.com/go-openapi/swag v0.22.3 github.com/go-openapi/swag v0.22.3
github.com/go-openapi/validate v0.20.0 github.com/go-openapi/validate v0.20.0
github.com/go-sql-driver/mysql v1.6.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/goccy/go-yaml v1.11.0
github.com/gofrs/uuid v4.0.0+incompatible github.com/gofrs/uuid v4.0.0+incompatible
github.com/golang-jwt/jwt/v4 v4.4.2 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/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/go-stack/stack v1.8.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/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.1.0 // indirect github.com/golang/glog v1.1.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect github.com/golang/protobuf v1.5.3 // indirect

View file

@ -3,7 +3,6 @@ package kinesisacquisition
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"encoding/json"
"fmt" "fmt"
"io" "io"
"strings" "strings"
@ -13,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kinesis" "github.com/aws/aws-sdk-go/service/kinesis"
json "github.com/goccy/go-json"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"

View file

@ -3,7 +3,6 @@ package kinesisacquisition
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"encoding/json"
"fmt" "fmt"
"net" "net"
"os" "os"
@ -12,15 +11,17 @@ import (
"testing" "testing"
"time" "time"
"github.com/crowdsecurity/go-cs-lib/cstest"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kinesis" "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" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"
"github.com/crowdsecurity/go-cs-lib/cstest"
"github.com/crowdsecurity/crowdsec/pkg/types"
) )
func getLocalStackEndpoint() (string, error) { func getLocalStackEndpoint() (string, error) {

View file

@ -2,12 +2,12 @@ package kubernetesauditacquisition
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"strings" "strings"
json "github.com/goccy/go-json"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"

View file

@ -5,7 +5,6 @@ import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"context" "context"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -22,6 +21,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3/s3iface" "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"
"github.com/aws/aws-sdk-go/service/sqs/sqsiface" "github.com/aws/aws-sdk-go/service/sqs/sqsiface"
json "github.com/goccy/go-json"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"

View file

@ -1,12 +1,12 @@
package alertcontext package alertcontext
import ( import (
"encoding/json"
"fmt" "fmt"
"strconv" "strconv"
"github.com/antonmedv/expr" "github.com/antonmedv/expr"
"github.com/antonmedv/expr/vm" "github.com/antonmedv/expr/vm"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"

View file

@ -2,7 +2,6 @@ package apiclient
import ( import (
"bytes" "bytes"
"encoding/json"
"fmt" "fmt"
"io" "io"
"math/rand" "math/rand"
@ -13,6 +12,7 @@ import (
"time" "time"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
json "github.com/goccy/go-json"
"github.com/pkg/errors" "github.com/pkg/errors"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"

View file

@ -3,13 +3,13 @@ package apiclient
import ( import (
"bytes" "bytes"
"context" "context"
"encoding/json"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"testing" "testing"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

View file

@ -4,12 +4,13 @@ import (
"context" "context"
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"encoding/json"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
json "github.com/goccy/go-json"
"github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/models"
) )

View file

@ -3,7 +3,6 @@ package apiclient
import ( import (
"bytes" "bytes"
"context" "context"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -12,6 +11,7 @@ import (
"net/url" "net/url"
"strings" "strings"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )

View file

@ -1,7 +1,6 @@
package apiserver package apiserver
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -9,13 +8,14 @@ import (
"sync" "sync"
"testing" "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/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/csplugin" "github.com/crowdsecurity/crowdsec/pkg/csplugin"
"github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/models"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
) )
type LAPI struct { type LAPI struct {

View file

@ -3,7 +3,6 @@ package apiserver
import ( import (
"bytes" "bytes"
"context" "context"
"encoding/json"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -14,6 +13,7 @@ import (
"testing" "testing"
"time" "time"
json "github.com/goccy/go-json"
"github.com/jarcoal/httpmock" "github.com/jarcoal/httpmock"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

View file

@ -1,7 +1,6 @@
package apiserver package apiserver
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -11,20 +10,20 @@ import (
"testing" "testing"
"time" "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" "github.com/crowdsecurity/go-cs-lib/version"
middlewares "github.com/crowdsecurity/crowdsec/pkg/apiserver/middlewares/v1" 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/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/database" "github.com/crowdsecurity/crowdsec/pkg/database"
"github.com/gin-gonic/gin" "github.com/crowdsecurity/crowdsec/pkg/models"
"github.com/crowdsecurity/crowdsec/pkg/types"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
) )
var testMachineID = "test" var testMachineID = "test"

View file

@ -1,7 +1,6 @@
package v1 package v1
import ( import (
"encoding/json"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -10,15 +9,16 @@ import (
"time" "time"
jwt "github.com/appleboy/gin-jwt/v2" 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" "github.com/google/uuid"
log "github.com/sirupsen/logrus"
"github.com/crowdsecurity/crowdsec/pkg/csplugin" "github.com/crowdsecurity/crowdsec/pkg/csplugin"
"github.com/crowdsecurity/crowdsec/pkg/database/ent" "github.com/crowdsecurity/crowdsec/pkg/database/ent"
"github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/models"
"github.com/crowdsecurity/crowdsec/pkg/types" "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 { func FormatOneAlert(alert *ent.Alert) *models.Alert {

View file

@ -1,17 +1,18 @@
package v1 package v1
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"strconv" "strconv"
"time" "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/database/ent"
"github.com/crowdsecurity/crowdsec/pkg/fflag" "github.com/crowdsecurity/crowdsec/pkg/fflag"
"github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/models"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
) )
// Format decisions for the bouncers // Format decisions for the bouncers

View file

@ -1,12 +1,12 @@
package apiserver package apiserver
import ( import (
"encoding/json"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings" "strings"
"testing" "testing"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View file

@ -2,12 +2,12 @@ package apiserver
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"sync" "sync"
"time" "time"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"

View file

@ -1,10 +1,10 @@
package apiserver package apiserver
import ( import (
"encoding/json"
"fmt" "fmt"
"time" "time"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/crowdsecurity/go-cs-lib/ptr" "github.com/crowdsecurity/go-cs-lib/ptr"

View file

@ -4,12 +4,12 @@ package csplugin
import ( import (
"bytes" "bytes"
"encoding/json"
"io" "io"
"os" "os"
"testing" "testing"
"time" "time"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"

View file

@ -4,12 +4,12 @@ package csplugin
import ( import (
"bytes" "bytes"
"encoding/json"
"io" "io"
"os" "os"
"testing" "testing"
"time" "time"
json "github.com/goccy/go-json"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"

View file

@ -1,13 +1,13 @@
package cticlient package cticlient
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"strings" "strings"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )

View file

@ -1,7 +1,7 @@
package cticlient package cticlient
// import ( // import (
// "encoding/json" // json "github.com/goccy/go-json"
// "net/http" // "net/http"
// "net/http/httptest" // "net/http/httptest"
// "net/url" // "net/url"

View file

@ -1,7 +1,6 @@
package cwhub package cwhub
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"os" "os"
@ -9,6 +8,7 @@ import (
"sort" "sort"
"strings" "strings"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"golang.org/x/mod/semver" "golang.org/x/mod/semver"

View file

@ -1,21 +1,21 @@
package cwversion package cwversion
import ( import (
"encoding/json"
"fmt" "fmt"
"log" "log"
"net/http" "net/http"
"runtime" "runtime"
"strings" "strings"
json "github.com/goccy/go-json"
goversion "github.com/hashicorp/go-version" goversion "github.com/hashicorp/go-version"
"github.com/crowdsecurity/go-cs-lib/version" "github.com/crowdsecurity/go-cs-lib/version"
) )
var ( var (
Codename string // = "SoumSoum" Codename string // = "SoumSoum"
System = runtime.GOOS // = "linux" System = runtime.GOOS // = "linux"
Constraint_parser = ">= 1.0, <= 2.0" Constraint_parser = ">= 1.0, <= 2.0"
Constraint_scenario = ">= 1.0, < 3.0" Constraint_scenario = ">= 1.0, < 3.0"
Constraint_api = "v1" Constraint_api = "v1"

View file

@ -2,16 +2,15 @@ package database
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/mattn/go-sqlite3"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
json "github.com/goccy/go-json"
"github.com/mattn/go-sqlite3"
"github.com/pkg/errors" "github.com/pkg/errors"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"

View file

@ -2,13 +2,13 @@ package exprhelpers
import ( import (
"bytes" "bytes"
"encoding/json"
"io" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
"time" "time"
json "github.com/goccy/go-json"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/crowdsecurity/go-cs-lib/ptr" "github.com/crowdsecurity/go-cs-lib/ptr"

View file

@ -1,13 +1,12 @@
package exprhelpers package exprhelpers
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"strings" "strings"
"github.com/buger/jsonparser" "github.com/buger/jsonparser"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )

View file

@ -2,7 +2,6 @@ package leakybucket
import ( import (
"bytes" "bytes"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"html/template" "html/template"
@ -13,14 +12,16 @@ import (
"testing" "testing"
"time" "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/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/exprhelpers" "github.com/crowdsecurity/crowdsec/pkg/exprhelpers"
"github.com/crowdsecurity/crowdsec/pkg/parser" "github.com/crowdsecurity/crowdsec/pkg/parser"
"github.com/crowdsecurity/crowdsec/pkg/types" "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 { type TestFile struct {

View file

@ -1,7 +1,6 @@
package leakybucket package leakybucket
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -14,6 +13,7 @@ import (
"github.com/antonmedv/expr" "github.com/antonmedv/expr"
"github.com/antonmedv/expr/vm" "github.com/antonmedv/expr/vm"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
json "github.com/goccy/go-json"
"github.com/goombaio/namegenerator" "github.com/goombaio/namegenerator"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"

View file

@ -1,7 +1,6 @@
package leakybucket package leakybucket
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"math" "math"
@ -10,6 +9,7 @@ import (
"time" "time"
"github.com/antonmedv/expr" "github.com/antonmedv/expr"
json "github.com/goccy/go-json"
"github.com/mohae/deepcopy" "github.com/mohae/deepcopy"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"

View file

@ -1,13 +1,13 @@
package longpollclient package longpollclient
import ( import (
"encoding/json"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"time" "time"
json "github.com/goccy/go-json"
"github.com/gofrs/uuid" "github.com/gofrs/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/tomb.v2" "gopkg.in/tomb.v2"

View file

@ -1,15 +1,15 @@
package metabase package metabase
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
"github.com/crowdsecurity/go-cs-lib/version"
"github.com/dghubble/sling" "github.com/dghubble/sling"
json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/crowdsecurity/go-cs-lib/version"
) )
type MBClient struct { type MBClient struct {

View file

@ -1,11 +1,12 @@
package metabase package metabase
import ( import (
"encoding/json"
"fmt" "fmt"
"path/filepath" "path/filepath"
"strings" "strings"
json "github.com/goccy/go-json"
"github.com/crowdsecurity/crowdsec/pkg/csconfig" "github.com/crowdsecurity/crowdsec/pkg/csconfig"
) )

View file

@ -1,8 +1,7 @@
package parser package parser
import ( import (
"encoding/json" json "github.com/goccy/go-json"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/crowdsecurity/crowdsec/pkg/types" "github.com/crowdsecurity/crowdsec/pkg/types"