Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ linters:

maintidx:
# raise this after refactoring
under: 18
under: 20

misspell:
locale: US
Expand Down Expand Up @@ -220,7 +220,7 @@ linters:
- name: cyclomatic
arguments:
# lower this after refactoring
- 39
- 37
- name: empty-block
disabled: true
- name: empty-lines
Expand Down Expand Up @@ -287,16 +287,12 @@ linters:
- fmt.Printf
- fmt.Println
disabled: true
- name: unnecessary-format
disabled: true
- name: unnecessary-stmt
disabled: true
- name: unsecure-url-scheme
disabled: true
- name: unused-parameter
disabled: true
- name: unused-receiver
disabled: true
- name: use-any
disabled: true
- name: use-waitgroup-go
Expand All @@ -313,6 +309,11 @@ linters:
- -QF1003 # could use tagged switch on ...
- -QF1012 # QF1012: Use fmt.Fprintf(...) instead of ...

usetesting:
os-temp-dir: false
context-background: true
context-todo: true

exclusions:
presets:
- comments
Expand Down
4 changes: 2 additions & 2 deletions cmd/crowdsec-cli/clialert/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (cli *cliAlerts) displayOneAlert(alert *models.Alert, withDetail bool) erro
alertDecisionsTable(color.Output, cfg.Cscli.Color, alert)

if len(alert.Meta) > 0 {
fmt.Fprintf(os.Stdout, "\n - Context :\n")
fmt.Fprintln(os.Stdout, "\n - Context :")
sort.Slice(alert.Meta, func(i, j int) bool {
return alert.Meta[i].Key < alert.Meta[j].Key
})
Expand All @@ -183,7 +183,7 @@ func (cli *cliAlerts) displayOneAlert(alert *models.Alert, withDetail bool) erro
}

if withDetail {
fmt.Fprintf(os.Stdout, "\n - Events :\n")
fmt.Fprintln(os.Stdout, "\n - Events :")

for _, event := range alert.Events {
alertEventTable(color.Output, cfg.Cscli.Color, event)
Expand Down
2 changes: 1 addition & 1 deletion cmd/crowdsec-cli/clilapi/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (cli *cliLapi) register(ctx context.Context, apiURL string, outputFile stri
return fmt.Errorf("api client register: %w", err)
}

log.Printf("Successfully registered to Local API (LAPI)")
log.Info("Successfully registered to Local API (LAPI)")

var dumpFile string

Expand Down
2 changes: 1 addition & 1 deletion cmd/crowdsec-cli/clilapi/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (cli *cliLapi) Status(ctx context.Context, out io.Writer, hub *cwhub.Hub) e
return fmt.Errorf("failed to authenticate to Local API (LAPI): %w", err)
}

fmt.Fprintf(out, "You can successfully interact with Local API (LAPI)\n")
fmt.Fprintln(out, "You can successfully interact with Local API (LAPI)")

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crowdsec-cli/dashboard_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewCLIDashboard(cfg configGetter) *cliDashboard {
}
}

func (cli cliDashboard) NewCommand() *cobra.Command {
func (cliDashboard) NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "dashboard",
DisableAutoGenTag: true,
Expand Down
4 changes: 2 additions & 2 deletions pkg/acquisition/modules/appsec/appsec_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type AppsecRunner struct {
appsecAllowlistsClient *allowlists.AppsecAllowlist
}

func (r *AppsecRunner) MergeDedupRules(collections []appsec.AppsecCollection, logger *log.Entry) string {
func (*AppsecRunner) MergeDedupRules(collections []appsec.AppsecCollection, logger *log.Entry) string {
var rulesArr []string
dedupRules := make(map[string]struct{})
discarded := 0
Expand Down Expand Up @@ -265,7 +265,7 @@ func (r *AppsecRunner) handleInBandInterrupt(request *appsec.ParsedRequest) {
}

for tag, remediation := range r.AppsecRuntime.RemediationByTag {
if slices.Contains[[]string, string](in.Tags, tag) {
if slices.Contains(in.Tags, tag) {
r.AppsecRuntime.Response.Action = remediation
}
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/acquisition/modules/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (f *FileSource) GetMode() string {
}

// SupportedModes returns the supported modes by the acquisition module
func (f *FileSource) SupportedModes() []string {
func (*FileSource) SupportedModes() []string {
return []string{configuration.TAIL_MODE, configuration.CAT_MODE}
}

Expand Down Expand Up @@ -291,19 +291,19 @@ func (f *FileSource) OneShotAcquisition(_ context.Context, out chan types.Event,
return nil
}

func (f *FileSource) GetMetrics() []prometheus.Collector {
func (*FileSource) GetMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.FileDatasourceLinesRead}
}

func (f *FileSource) GetAggregMetrics() []prometheus.Collector {
func (*FileSource) GetAggregMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.FileDatasourceLinesRead}
}

func (f *FileSource) GetName() string {
func (*FileSource) GetName() string {
return "file"
}

func (f *FileSource) CanRun() error {
func (*FileSource) CanRun() error {
return nil
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/acquisition/modules/kubernetesaudit/k8s_audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func (ka *KubernetesAuditSource) GetUuid() string {
return ka.config.UniqueId
}

func (ka *KubernetesAuditSource) GetMetrics() []prometheus.Collector {
func (*KubernetesAuditSource) GetMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.K8SAuditDataSourceEventCount, metrics.K8SAuditDataSourceRequestCount}
}

func (ka *KubernetesAuditSource) GetAggregMetrics() []prometheus.Collector {
func (*KubernetesAuditSource) GetAggregMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.K8SAuditDataSourceEventCount, metrics.K8SAuditDataSourceRequestCount}
}

Expand Down Expand Up @@ -118,7 +118,7 @@ func (ka *KubernetesAuditSource) GetMode() string {
return ka.config.Mode
}

func (ka *KubernetesAuditSource) GetName() string {
func (*KubernetesAuditSource) GetName() string {
return "k8s-audit"
}

Expand Down Expand Up @@ -149,11 +149,11 @@ func (ka *KubernetesAuditSource) StreamingAcquisition(ctx context.Context, out c
return nil
}

func (ka *KubernetesAuditSource) CanRun() error {
func (*KubernetesAuditSource) CanRun() error {
return nil
}

func (ka *KubernetesAuditSource) Dump() interface{} {
func (ka *KubernetesAuditSource) Dump() any {
return ka
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/acquisition/modules/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ type LokiSource struct {
lokiWebsocket string
}

func (l *LokiSource) GetMetrics() []prometheus.Collector {
func (*LokiSource) GetMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.LokiDataSourceLinesRead}
}

func (l *LokiSource) GetAggregMetrics() []prometheus.Collector {
func (*LokiSource) GetAggregMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.LokiDataSourceLinesRead}
}

Expand Down Expand Up @@ -259,7 +259,7 @@ func (l *LokiSource) GetMode() string {
return l.Config.Mode
}

func (l *LokiSource) GetName() string {
func (*LokiSource) GetName() string {
return "loki"
}

Expand Down Expand Up @@ -353,19 +353,19 @@ func (l *LokiSource) StreamingAcquisition(ctx context.Context, out chan types.Ev
return nil
}

func (l *LokiSource) CanRun() error {
func (*LokiSource) CanRun() error {
return nil
}

func (l *LokiSource) GetUuid() string {
return l.Config.UniqueId
}

func (l *LokiSource) Dump() interface{} {
func (l *LokiSource) Dump() any {
return l
}

// SupportedModes returns the supported modes by the acquisition module
func (l *LokiSource) SupportedModes() []string {
func (*LokiSource) SupportedModes() []string {
return []string{configuration.TAIL_MODE, configuration.CAT_MODE}
}
10 changes: 5 additions & 5 deletions pkg/acquisition/modules/syslog/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,27 @@ func (s *SyslogSource) GetUuid() string {
return s.config.UniqueId
}

func (s *SyslogSource) GetName() string {
func (*SyslogSource) GetName() string {
return "syslog"
}

func (s *SyslogSource) GetMode() string {
return s.config.Mode
}

func (s *SyslogSource) Dump() interface{} {
func (s *SyslogSource) Dump() any {
return s
}

func (s *SyslogSource) CanRun() error {
func (*SyslogSource) CanRun() error {
return nil
}

func (s *SyslogSource) GetMetrics() []prometheus.Collector {
func (*SyslogSource) GetMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.SyslogDataSourceLinesReceived, metrics.SyslogDataSourceLinesParsed}
}

func (s *SyslogSource) GetAggregMetrics() []prometheus.Collector {
func (*SyslogSource) GetAggregMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.SyslogDataSourceLinesReceived, metrics.SyslogDataSourceLinesParsed}
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/acquisition/modules/victorialogs/victorialogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ type VLSource struct {
logger *log.Entry
}

func (l *VLSource) GetMetrics() []prometheus.Collector {
func (*VLSource) GetMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.VictorialogsDataSourceLinesRead}
}

func (l *VLSource) GetAggregMetrics() []prometheus.Collector {
func (*VLSource) GetAggregMetrics() []prometheus.Collector {
return []prometheus.Collector{metrics.VictorialogsDataSourceLinesRead}
}

Expand Down Expand Up @@ -226,7 +226,7 @@ func (l *VLSource) GetMode() string {
return l.Config.Mode
}

func (l *VLSource) GetName() string {
func (*VLSource) GetName() string {
return "victorialogs"
}

Expand Down Expand Up @@ -349,19 +349,19 @@ func (l *VLSource) getResponseChan(ctx context.Context, infinite bool) (chan *vl
return respChan, err
}

func (l *VLSource) CanRun() error {
func (*VLSource) CanRun() error {
return nil
}

func (l *VLSource) GetUuid() string {
return l.Config.UniqueId
}

func (l *VLSource) Dump() interface{} {
func (l *VLSource) Dump() any {
return l
}

// SupportedModes returns the supported modes by the acquisition module
func (l *VLSource) SupportedModes() []string {
func (*VLSource) SupportedModes() []string {
return []string{configuration.TAIL_MODE, configuration.CAT_MODE}
}
26 changes: 13 additions & 13 deletions pkg/acquisition/modules/wineventlog/wineventlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,54 @@ import (

type WinEventLogSource struct{}

func (w *WinEventLogSource) GetUuid() string {
func (*WinEventLogSource) GetUuid() string {
return ""
}

func (w *WinEventLogSource) UnmarshalConfig(_ []byte) error {
func (*WinEventLogSource) UnmarshalConfig(_ []byte) error {
return nil
}

func (w *WinEventLogSource) Configure(_ context.Context, _ []byte, _ *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
func (*WinEventLogSource) Configure(_ context.Context, _ []byte, _ *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
return nil
}

func (w *WinEventLogSource) ConfigureByDSN(_ context.Context, _ string, _ map[string]string, _ *log.Entry, _ string) error {
func (*WinEventLogSource) ConfigureByDSN(_ context.Context, _ string, _ map[string]string, _ *log.Entry, _ string) error {
return nil
}

func (w *WinEventLogSource) GetMode() string {
func (*WinEventLogSource) GetMode() string {
return ""
}

func (w *WinEventLogSource) SupportedModes() []string {
func (*WinEventLogSource) SupportedModes() []string {
return []string{configuration.TAIL_MODE, configuration.CAT_MODE}
}

func (w *WinEventLogSource) OneShotAcquisition(_ context.Context, _ chan types.Event, _ *tomb.Tomb) error {
func (*WinEventLogSource) OneShotAcquisition(_ context.Context, _ chan types.Event, _ *tomb.Tomb) error {
return nil
}

func (w *WinEventLogSource) GetMetrics() []prometheus.Collector {
func (*WinEventLogSource) GetMetrics() []prometheus.Collector {
return nil
}

func (w *WinEventLogSource) GetAggregMetrics() []prometheus.Collector {
func (*WinEventLogSource) GetAggregMetrics() []prometheus.Collector {
return nil
}

func (w *WinEventLogSource) GetName() string {
func (*WinEventLogSource) GetName() string {
return "wineventlog"
}

func (w *WinEventLogSource) CanRun() error {
func (*WinEventLogSource) CanRun() error {
return errors.New("windows event log acquisition is only supported on Windows")
}

func (w *WinEventLogSource) StreamingAcquisition(_ context.Context, _ chan types.Event, _ *tomb.Tomb) error {
func (*WinEventLogSource) StreamingAcquisition(_ context.Context, _ chan types.Event, _ *tomb.Tomb) error {
return nil
}

func (w *WinEventLogSource) Dump() interface{} {
func (w *WinEventLogSource) Dump() any {
return w
}
Loading