Skip to content

Commit 48bb4a8

Browse files
committed
wip
1 parent dada07b commit 48bb4a8

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

.golangci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,29 @@ linters-settings:
204204
- docStub
205205
- preferFprint
206206

207+
unused:
208+
# Mark all struct fields that have been written to as used.
209+
# Default: true
210+
field-writes-are-uses: false
211+
# Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write.
212+
# Default: false
213+
post-statements-are-reads: true
214+
# Mark all exported identifiers as used.
215+
# Default: true
216+
# exported-is-used: false
217+
# Mark all exported fields as used.
218+
# default: true
219+
exported-fields-are-used: false
220+
# Mark all function parameters as used.
221+
# default: true
222+
parameters-are-used: true
223+
# Mark all local variables as used.
224+
# default: true
225+
local-variables-are-used: false
226+
# Mark all identifiers inside generated files as used.
227+
# Default: true
228+
generated-is-used: false
229+
207230
linters:
208231
enable-all: true
209232
disable:

pkg/acquisition/acquisition_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,9 @@ func TestLoadAcquisitionFromFile(t *testing.T) {
304304

305305
type MockCat struct {
306306
configuration.DataSourceCommonCfg `yaml:",inline"`
307-
logger *log.Entry
308307
}
309308

310309
func (f *MockCat) Configure(cfg []byte, logger *log.Entry, metricsLevel int) error {
311-
f.logger = logger
312310
if f.Mode == "" {
313311
f.Mode = configuration.CAT_MODE
314312
}
@@ -349,11 +347,9 @@ func (f *MockCat) GetUuid() string { return "" }
349347

350348
type MockTail struct {
351349
configuration.DataSourceCommonCfg `yaml:",inline"`
352-
logger *log.Entry
353350
}
354351

355352
func (f *MockTail) Configure(cfg []byte, logger *log.Entry, metricsLevel int) error {
356-
f.logger = logger
357353
if f.Mode == "" {
358354
f.Mode = configuration.TAIL_MODE
359355
}

pkg/acquisition/modules/appsec/appsec.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ type AppsecSourceConfig struct {
4949

5050
// runtime structure of AppsecSourceConfig
5151
type AppsecSource struct {
52-
metricsLevel int
5352
config AppsecSourceConfig
5453
logger *log.Entry
5554
mux *http.ServeMux
5655
server *http.Server
57-
outChan chan types.Event
5856
InChan chan appsec.ParsedRequest
5957
AppsecRuntime *appsec.AppsecRuntimeConfig
6058
AppsecConfigs map[string]appsec.AppsecConfig
@@ -162,7 +160,6 @@ func (w *AppsecSource) Configure(yamlConfig []byte, logger *log.Entry, MetricsLe
162160
}
163161

164162
w.logger = logger
165-
w.metricsLevel = MetricsLevel
166163
w.logger.Tracef("Appsec configuration: %+v", w.config)
167164

168165
if w.config.AuthCacheDuration == nil {
@@ -266,8 +263,6 @@ func (w *AppsecSource) OneShotAcquisition(_ context.Context, _ chan types.Event,
266263
}
267264

268265
func (w *AppsecSource) StreamingAcquisition(ctx context.Context, out chan types.Event, t *tomb.Tomb) error {
269-
w.outChan = out
270-
271266
t.Go(func() error {
272267
defer trace.CatchPanic("crowdsec/acquis/appsec/live")
273268

pkg/apiserver/apic.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ type apic struct {
6464
pullTomb tomb.Tomb
6565
metricsTomb tomb.Tomb
6666
startup bool
67-
credentials *csconfig.ApiCredentialsCfg
6867
scenarioList []string
6968
consoleConfig *csconfig.ConsoleConfig
7069
isPulling chan bool
@@ -186,7 +185,6 @@ func NewAPIC(ctx context.Context, config *csconfig.OnlineApiClientCfg, dbClient
186185
dbClient: dbClient,
187186
mu: sync.Mutex{},
188187
startup: true,
189-
credentials: config.Credentials,
190188
pullTomb: tomb.Tomb{},
191189
pushTomb: tomb.Tomb{},
192190
metricsTomb: tomb.Tomb{},

pkg/apiserver/apiserver.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type APIServer struct {
3535
UnixSocket string
3636
TLS *csconfig.TLSCfg
3737
dbClient *database.Client
38-
logFile string
3938
controller *controllers.Controller
4039
flushScheduler *gocron.Scheduler
4140
router *gin.Engine
@@ -200,7 +199,7 @@ func NewServer(ctx context.Context, config *csconfig.LocalApiServerCfg) (*APISer
200199
}
201200

202201
// The logger that will be used by handlers
203-
clog, logFile, err := newGinLogger(config)
202+
clog, _, err := newGinLogger(config)
204203
if err != nil {
205204
return nil, err
206205
}
@@ -284,7 +283,6 @@ func NewServer(ctx context.Context, config *csconfig.LocalApiServerCfg) (*APISer
284283
URL: config.ListenURI,
285284
UnixSocket: config.ListenSocket,
286285
TLS: config.TLS,
287-
logFile: logFile,
288286
dbClient: dbClient,
289287
controller: controller,
290288
flushScheduler: flushScheduler,

pkg/csplugin/broker.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ type PluginBroker struct {
4444
profileConfigs []*csconfig.ProfileCfg
4545
pluginConfigByName map[string]PluginConfig
4646
pluginMap map[string]plugin.Plugin
47-
notificationConfigsByPluginType map[string][][]byte // "slack" -> []{config1, config2}
4847
notificationPluginByName map[string]protobufs.NotifierServer
4948
watcher PluginWatcher
5049
pluginKillMethods []func()
@@ -74,7 +73,6 @@ type ProfileAlert struct {
7473

7574
func (pb *PluginBroker) Init(ctx context.Context, pluginCfg *csconfig.PluginCfg, profileConfigs []*csconfig.ProfileCfg, configPaths *csconfig.ConfigurationPaths) error {
7675
pb.PluginChannel = make(chan ProfileAlert)
77-
pb.notificationConfigsByPluginType = make(map[string][][]byte)
7876
pb.notificationPluginByName = make(map[string]protobufs.NotifierServer)
7977
pb.pluginMap = make(map[string]plugin.Plugin)
8078
pb.pluginConfigByName = make(map[string]PluginConfig)

pkg/leakybucket/manager_load.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ type BucketFactory struct {
6666
duration time.Duration // internal representation of `Duration`
6767
ret chan types.Event // the bucket-specific output chan for overflows
6868
processors []Processor // processors is the list of hooks for pour/overflow/create (cf. uniq, blackhole etc.)
69-
output bool // ??
7069
ScenarioVersion string `yaml:"version,omitempty"`
7170
hash string
7271
Simulated bool `yaml:"simulated"` // Set to true if the scenario instantiating the bucket was in the exclusion list
@@ -474,7 +473,6 @@ func LoadBucket(bucketFactory *BucketFactory, tomb *tomb.Tomb) error {
474473
}
475474
}
476475

477-
bucketFactory.output = false
478476
if err := ValidateFactory(bucketFactory); err != nil {
479477
return fmt.Errorf("invalid bucket from %s: %w", bucketFactory.Filename, err)
480478
}

pkg/leakybucket/manager_run.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,12 @@ func GarbageCollectBuckets(deadline time.Time, buckets *Buckets) error {
3333
buckets.wgDumpState.Add(1)
3434
defer buckets.wgDumpState.Done()
3535

36-
total := 0
37-
discard := 0
3836
toflush := []string{}
3937
buckets.Bucket_map.Range(func(rkey, rvalue interface{}) bool {
4038
key := rkey.(string)
4139
val := rvalue.(*Leaky)
42-
total += 1
4340
//bucket already overflowed, we can kill it
4441
if !val.Ovflw_ts.IsZero() {
45-
discard += 1
4642
val.logger.Debugf("overflowed at %s.", val.Ovflw_ts)
4743
toflush = append(toflush, key)
4844
val.tomb.Kill(nil)
@@ -97,12 +93,10 @@ func DumpBucketsStateAt(deadline time.Time, outputdir string, buckets *Buckets)
9793
tmpFileName := tmpFd.Name()
9894
serialized = make(map[string]Leaky)
9995
log.Printf("Dumping buckets state at %s", deadline)
100-
total := 0
10196
discard := 0
10297
buckets.Bucket_map.Range(func(rkey, rvalue interface{}) bool {
10398
key := rkey.(string)
10499
val := rvalue.(*Leaky)
105-
total += 1
106100
if !val.Ovflw_ts.IsZero() {
107101
discard += 1
108102
val.logger.Debugf("overflowed at %s.", val.Ovflw_ts)

0 commit comments

Comments
 (0)