2020-05-15 09:39:16 +00:00
|
|
|
package leakybucket
|
|
|
|
|
|
|
|
import "github.com/crowdsecurity/crowdsec/pkg/types"
|
|
|
|
|
|
|
|
type Processor interface {
|
|
|
|
OnBucketInit(Bucket *BucketFactory) error
|
|
|
|
OnBucketPour(Bucket *BucketFactory) func(types.Event, *Leaky) *types.Event
|
2023-11-24 10:10:54 +00:00
|
|
|
OnBucketOverflow(Bucket *BucketFactory) func(*Leaky, types.RuntimeAlert, *types.Queue) (types.RuntimeAlert, *types.Queue)
|
2023-01-06 08:26:16 +00:00
|
|
|
|
|
|
|
AfterBucketPour(Bucket *BucketFactory) func(types.Event, *Leaky) *types.Event
|
2020-05-15 09:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type DumbProcessor struct {
|
|
|
|
}
|
|
|
|
|
2020-11-30 09:37:17 +00:00
|
|
|
func (d *DumbProcessor) OnBucketInit(bucketFactory *BucketFactory) error {
|
2020-05-15 09:39:16 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-30 09:37:17 +00:00
|
|
|
func (d *DumbProcessor) OnBucketPour(bucketFactory *BucketFactory) func(types.Event, *Leaky) *types.Event {
|
|
|
|
return func(msg types.Event, leaky *Leaky) *types.Event {
|
2020-05-15 09:39:16 +00:00
|
|
|
return &msg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-24 10:10:54 +00:00
|
|
|
func (d *DumbProcessor) OnBucketOverflow(b *BucketFactory) func(*Leaky, types.RuntimeAlert, *types.Queue) (types.RuntimeAlert, *types.Queue) {
|
|
|
|
return func(leaky *Leaky, alert types.RuntimeAlert, queue *types.Queue) (types.RuntimeAlert, *types.Queue) {
|
2020-11-30 09:37:17 +00:00
|
|
|
return alert, queue
|
2020-05-15 09:39:16 +00:00
|
|
|
}
|
2023-01-06 08:26:16 +00:00
|
|
|
}
|
2020-05-15 09:39:16 +00:00
|
|
|
|
2023-01-06 08:26:16 +00:00
|
|
|
func (d *DumbProcessor) AfterBucketPour(bucketFactory *BucketFactory) func(types.Event, *Leaky) *types.Event {
|
|
|
|
return func(msg types.Event, leaky *Leaky) *types.Event {
|
|
|
|
return &msg
|
|
|
|
}
|
2020-05-15 09:39:16 +00:00
|
|
|
}
|