mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2026-10-12 02:12:31 +00:00
refact: remove unused struct fields (#3633)
This commit is contained in:
@@ -316,11 +316,9 @@ func TestLoadAcquisitionFromFiles(t *testing.T) {
|
||||
|
||||
type MockCat struct {
|
||||
configuration.DataSourceCommonCfg `yaml:",inline"`
|
||||
logger *log.Entry
|
||||
}
|
||||
|
||||
func (f *MockCat) Configure(_ []byte, logger *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
|
||||
f.logger = logger
|
||||
func (f *MockCat) Configure(_ []byte, _ *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
|
||||
if f.Mode == "" {
|
||||
f.Mode = configuration.CAT_MODE
|
||||
}
|
||||
@@ -353,11 +351,9 @@ func (*MockCat) GetUuid() string { return "" }
|
||||
|
||||
type MockTail struct {
|
||||
configuration.DataSourceCommonCfg `yaml:",inline"`
|
||||
logger *log.Entry
|
||||
}
|
||||
|
||||
func (f *MockTail) Configure(_ []byte, logger *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
|
||||
f.logger = logger
|
||||
func (f *MockTail) Configure(_ []byte, _ *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
|
||||
if f.Mode == "" {
|
||||
f.Mode = configuration.TAIL_MODE
|
||||
}
|
||||
@@ -574,9 +570,12 @@ func (*TailModeNoTailer) CanRun() error { return nil }
|
||||
func TestStartAcquisition_MissingTailer(t *testing.T) {
|
||||
ctx := t.Context()
|
||||
out := make(chan types.Event)
|
||||
var tb tomb.Tomb
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
var tb tomb.Tomb
|
||||
|
||||
go func() { errCh <- StartAcquisition(ctx, []DataSource{&TailModeNoTailer{}}, out, &tb) }()
|
||||
|
||||
require.ErrorContains(t, <-errCh, "tail_no_tailer: tail mode is set but StreamingAcquisition is not supported")
|
||||
}
|
||||
|
||||
@@ -594,8 +593,11 @@ func (*CatModeNoFetcher) CanRun() error { return nil }
|
||||
func TestStartAcquisition_MissingFetcher(t *testing.T) {
|
||||
ctx := t.Context()
|
||||
out := make(chan types.Event)
|
||||
var tb tomb.Tomb
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
var tb tomb.Tomb
|
||||
|
||||
go func() { errCh <- StartAcquisition(ctx, []DataSource{&CatModeNoFetcher{}}, out, &tb) }()
|
||||
|
||||
require.ErrorContains(t, <-errCh, "cat_no_fetcher: cat mode is set but OneShotAcquisition is not supported")
|
||||
}
|
||||
|
||||
@@ -62,12 +62,10 @@ type AppsecSourceConfig struct {
|
||||
|
||||
// runtime structure of AppsecSourceConfig
|
||||
type AppsecSource struct {
|
||||
metricsLevel metrics.AcquisitionMetricsLevel
|
||||
config AppsecSourceConfig
|
||||
logger *log.Entry
|
||||
mux *http.ServeMux
|
||||
server *http.Server
|
||||
outChan chan types.Event
|
||||
InChan chan appsec.ParsedRequest
|
||||
AppsecRuntime *appsec.AppsecRuntimeConfig
|
||||
AppsecConfigs map[string]appsec.AppsecConfig
|
||||
@@ -209,7 +207,6 @@ func (w *AppsecSource) Configure(yamlConfig []byte, logger *log.Entry, metricsLe
|
||||
}
|
||||
|
||||
w.logger = logger
|
||||
w.metricsLevel = metricsLevel
|
||||
w.logger.Tracef("Appsec configuration: %+v", w.config)
|
||||
|
||||
if w.config.AuthCacheDuration == nil {
|
||||
@@ -433,8 +430,6 @@ func (w *AppsecSource) listenAndServe(ctx context.Context, t *tomb.Tomb) error {
|
||||
}
|
||||
|
||||
func (w *AppsecSource) StreamingAcquisition(ctx context.Context, out chan types.Event, t *tomb.Tomb) error {
|
||||
w.outChan = out
|
||||
|
||||
apiClient, err := apiclient.GetLAPIClient()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get authenticated LAPI client: %w", err)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -14,8 +13,6 @@ type APIKeyTransport struct {
|
||||
// Transport is the underlying HTTP transport to use when making requests.
|
||||
// It will default to http.DefaultTransport if nil.
|
||||
Transport http.RoundTripper
|
||||
URL *url.URL
|
||||
VersionPrefix string
|
||||
UserAgent string
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ type apic struct {
|
||||
pullTomb tomb.Tomb
|
||||
metricsTomb tomb.Tomb
|
||||
startup bool
|
||||
credentials *csconfig.ApiCredentialsCfg
|
||||
consoleConfig *csconfig.ConsoleConfig
|
||||
isPulling chan bool
|
||||
whitelists *csconfig.CapiWhitelist
|
||||
@@ -195,7 +194,6 @@ func NewAPIC(ctx context.Context, config *csconfig.OnlineApiClientCfg, dbClient
|
||||
dbClient: dbClient,
|
||||
mu: sync.Mutex{},
|
||||
startup: true,
|
||||
credentials: config.Credentials,
|
||||
pullTomb: tomb.Tomb{},
|
||||
pushTomb: tomb.Tomb{},
|
||||
metricsTomb: tomb.Tomb{},
|
||||
|
||||
@@ -38,7 +38,6 @@ type APIServer struct {
|
||||
UnixSocket string
|
||||
TLS *csconfig.TLSCfg
|
||||
dbClient *database.Client
|
||||
logFile string
|
||||
controller *controllers.Controller
|
||||
flushScheduler *gocron.Scheduler
|
||||
router *gin.Engine
|
||||
@@ -204,7 +203,7 @@ func NewServer(ctx context.Context, config *csconfig.LocalApiServerCfg) (*APISer
|
||||
}
|
||||
|
||||
// The logger that will be used by handlers
|
||||
clog, logFile, err := newGinLogger(config)
|
||||
clog, _, err := newGinLogger(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -286,7 +285,6 @@ func NewServer(ctx context.Context, config *csconfig.LocalApiServerCfg) (*APISer
|
||||
URL: config.ListenURI,
|
||||
UnixSocket: config.ListenSocket,
|
||||
TLS: config.TLS,
|
||||
logFile: logFile,
|
||||
dbClient: dbClient,
|
||||
controller: controller,
|
||||
flushScheduler: flushScheduler,
|
||||
|
||||
Reference in New Issue
Block a user