mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
lint: github.com/pkg/errors -> errors (#3091)
This commit is contained in:
parent
4b988701ed
commit
0e93f98cad
4 changed files with 15 additions and 18 deletions
|
@ -52,8 +52,6 @@ linters-settings:
|
|||
desc: "errors.Wrap() is deprecated in favor of fmt.Errorf()"
|
||||
files:
|
||||
- "!**/pkg/database/*.go"
|
||||
- "!**/pkg/exprhelpers/*.go"
|
||||
- "!**/pkg/acquisition/modules/appsec/appsec.go"
|
||||
- "!**/pkg/apiserver/controllers/v1/errors.go"
|
||||
yaml:
|
||||
files:
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||
"github.com/crowdsecurity/go-cs-lib/trace"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/tomb.v2"
|
||||
|
@ -98,7 +97,7 @@ func (w *AppsecSource) UnmarshalConfig(yamlConfig []byte) error {
|
|||
|
||||
err := yaml.UnmarshalStrict(yamlConfig, &w.config)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Cannot parse appsec configuration")
|
||||
return fmt.Errorf("Cannot parse appsec configuration: %w", err)
|
||||
}
|
||||
|
||||
if w.config.ListenAddr == "" && w.config.ListenSocket == "" {
|
||||
|
@ -153,7 +152,7 @@ func (w *AppsecSource) GetAggregMetrics() []prometheus.Collector {
|
|||
func (w *AppsecSource) Configure(yamlConfig []byte, logger *log.Entry, MetricsLevel int) error {
|
||||
err := w.UnmarshalConfig(yamlConfig)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to parse appsec configuration")
|
||||
return fmt.Errorf("unable to parse appsec configuration: %w", err)
|
||||
}
|
||||
w.logger = logger
|
||||
w.metricsLevel = MetricsLevel
|
||||
|
@ -263,7 +262,7 @@ func (w *AppsecSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb)
|
|||
_ = os.RemoveAll(w.config.ListenSocket)
|
||||
listener, err := net.Listen("unix", w.config.ListenSocket)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Appsec server failed")
|
||||
return fmt.Errorf("Appsec server failed: %w", err)
|
||||
}
|
||||
defer listener.Close()
|
||||
if w.config.CertFilePath != "" && w.config.KeyFilePath != "" {
|
||||
|
@ -272,7 +271,7 @@ func (w *AppsecSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb)
|
|||
err = w.server.Serve(listener)
|
||||
}
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
return errors.Wrap(err, "Appsec server failed")
|
||||
return fmt.Errorf("Appsec server failed: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -288,7 +287,7 @@ func (w *AppsecSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb)
|
|||
}
|
||||
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
return errors.Wrap(err, "Appsec server failed")
|
||||
return fmt.Errorf("Appsec server failed: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package exprhelpers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/bluele/gcache"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/cticlient"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -40,7 +40,7 @@ func InitCrowdsecCTI(Key *string, TTL *time.Duration, Size *int, LogLevel *log.L
|
|||
}
|
||||
clog := log.New()
|
||||
if err := types.ConfigureLogger(clog); err != nil {
|
||||
return errors.Wrap(err, "while configuring datasource logger")
|
||||
return fmt.Errorf("while configuring datasource logger: %w", err)
|
||||
}
|
||||
if LogLevel != nil {
|
||||
clog.SetLevel(*LogLevel)
|
||||
|
|
|
@ -2,12 +2,12 @@ package exprhelpers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/antonmedv/expr"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -936,7 +936,7 @@ func TestGetDecisionsCount(t *testing.T) {
|
|||
SaveX(context.Background())
|
||||
|
||||
if decision == nil {
|
||||
require.Error(t, errors.Errorf("Failed to create sample decision"))
|
||||
require.Error(t, errors.New("Failed to create sample decision"))
|
||||
}
|
||||
|
||||
err = Init(dbClient)
|
||||
|
@ -1022,7 +1022,7 @@ func TestGetDecisionsSinceCount(t *testing.T) {
|
|||
SetOrigin("CAPI").
|
||||
SaveX(context.Background())
|
||||
if decision == nil {
|
||||
require.Error(t, errors.Errorf("Failed to create sample decision"))
|
||||
require.Error(t, errors.New("Failed to create sample decision"))
|
||||
}
|
||||
|
||||
decision2 := dbClient.Ent.Decision.Create().
|
||||
|
@ -1041,7 +1041,7 @@ func TestGetDecisionsSinceCount(t *testing.T) {
|
|||
SaveX(context.Background())
|
||||
|
||||
if decision2 == nil {
|
||||
require.Error(t, errors.Errorf("Failed to create sample decision"))
|
||||
require.Error(t, errors.New("Failed to create sample decision"))
|
||||
}
|
||||
|
||||
err = Init(dbClient)
|
||||
|
@ -1147,7 +1147,7 @@ func TestGetActiveDecisionsCount(t *testing.T) {
|
|||
SaveX(context.Background())
|
||||
|
||||
if decision == nil {
|
||||
require.Error(t, errors.Errorf("Failed to create sample decision"))
|
||||
require.Error(t, errors.New("Failed to create sample decision"))
|
||||
}
|
||||
|
||||
expiredDecision := dbClient.Ent.Decision.Create().
|
||||
|
@ -1165,7 +1165,7 @@ func TestGetActiveDecisionsCount(t *testing.T) {
|
|||
SaveX(context.Background())
|
||||
|
||||
if expiredDecision == nil {
|
||||
require.Error(t, errors.Errorf("Failed to create sample decision"))
|
||||
require.Error(t, errors.New("Failed to create sample decision"))
|
||||
}
|
||||
|
||||
err = Init(dbClient)
|
||||
|
@ -1253,7 +1253,7 @@ func TestGetActiveDecisionsTimeLeft(t *testing.T) {
|
|||
SaveX(context.Background())
|
||||
|
||||
if decision == nil {
|
||||
require.Error(t, errors.Errorf("Failed to create sample decision"))
|
||||
require.Error(t, errors.New("Failed to create sample decision"))
|
||||
}
|
||||
|
||||
longerDecision := dbClient.Ent.Decision.Create().
|
||||
|
@ -1271,7 +1271,7 @@ func TestGetActiveDecisionsTimeLeft(t *testing.T) {
|
|||
SaveX(context.Background())
|
||||
|
||||
if longerDecision == nil {
|
||||
require.Error(t, errors.Errorf("Failed to create sample decision"))
|
||||
require.Error(t, errors.New("Failed to create sample decision"))
|
||||
}
|
||||
|
||||
err = Init(dbClient)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue