MCPcopy
hub / github.com/crowdsecurity/crowdsec / LoadBuckets

Function LoadBuckets

pkg/leakybucket/manager_load.go:184–211  ·  view source on GitHub ↗
(
	cscfg *csconfig.CrowdsecServiceCfg,
	hub *cwhub.Hub,
	scenarios []*cwhub.Item,
	orderEvent bool,
)

Source from the content-addressed store, hash-verified

182}
183
184func LoadBuckets(
185 cscfg *csconfig.CrowdsecServiceCfg,
186 hub *cwhub.Hub,
187 scenarios []*cwhub.Item,
188 orderEvent bool,
189) ([]BucketFactory, chan pipeline.Event, error) {
190 allFactories := []BucketFactory{}
191 response := make(chan pipeline.Event, 1)
192
193 for _, item := range scenarios {
194 log.Debugf("Loading '%s'", item.State.LocalPath)
195
196 factories, err := loadBucketFactoriesFromFile(item, hub, response, orderEvent, &cscfg.SimulationConfig)
197 if err != nil {
198 return nil, nil, err
199 }
200
201 allFactories = append(allFactories, factories...)
202 }
203
204 if err := alertcontext.NewAlertContext(cscfg.ContextToSend, cscfg.ConsoleContextValueLength); err != nil {
205 return nil, nil, fmt.Errorf("unable to load alert context: %w", err)
206 }
207
208 log.Infof("Loaded %d scenarios", len(allFactories))
209
210 return allFactories, response, nil
211}
212
213func bucketLogger(f *BucketFactory) *log.Entry {
214 fields := log.Fields{"cfg": f.BucketName, "name": f.Spec.Name}

Callers 2

LoadBucketsFunction · 0.92
testOneBucketFunction · 0.70

Calls 2

NewAlertContextFunction · 0.92

Tested by 1

testOneBucketFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…