Skip to content

Commit

Permalink
[CWS] make sure rate limiters are reset on ruleset changes (#30228)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux authored Oct 17, 2024
1 parent f7b3b58 commit 0faebd9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/security/events/rate_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ const (
)

var (
defaultPerRuleLimiters = map[eval.RuleID]Limiter{
RulesetLoadedRuleID: NewStdLimiter(rate.Inf, 1), // No limit on ruleset loaded
HeartbeatRuleID: NewStdLimiter(rate.Inf, 1), // No limit on heartbeat
AbnormalPathRuleID: NewStdLimiter(rate.Every(30*time.Second), 1),
NoProcessContextErrorRuleID: NewStdLimiter(rate.Every(30*time.Second), 1),
BrokenProcessLineageErrorRuleID: NewStdLimiter(rate.Every(30*time.Second), 1),
EBPFLessHelloMessageRuleID: NewStdLimiter(rate.Inf, 1), // No limit on hello message
InternalCoreDumpRuleID: NewStdLimiter(rate.Every(30*time.Second), 1),
defaultPerRuleLimiters = map[eval.RuleID]rate.Limit{
RulesetLoadedRuleID: rate.Inf, // No limit on ruleset loaded
HeartbeatRuleID: rate.Inf, // No limit on heartbeat
AbnormalPathRuleID: rate.Every(30 * time.Second),
NoProcessContextErrorRuleID: rate.Every(30 * time.Second),
BrokenProcessLineageErrorRuleID: rate.Every(30 * time.Second),
EBPFLessHelloMessageRuleID: rate.Inf, // No limit on hello message
InternalCoreDumpRuleID: rate.Every(30 * time.Second),
}
)

Expand Down Expand Up @@ -72,8 +72,8 @@ func NewRateLimiter(config *config.RuntimeSecurityConfig, client statsd.ClientIn
}

func (rl *RateLimiter) applyBaseLimitersFromDefault(limiters map[string]Limiter) {
for id, limiter := range defaultPerRuleLimiters {
limiters[id] = limiter
for id, rate := range defaultPerRuleLimiters {
limiters[id] = NewStdLimiter(rate, 1)
}

limiter, err := NewAnomalyDetectionLimiter(rl.config.AnomalyDetectionRateLimiterNumKeys, rl.config.AnomalyDetectionRateLimiterNumEventsAllowed, rl.config.AnomalyDetectionRateLimiterPeriod)
Expand Down

0 comments on commit 0faebd9

Please sign in to comment.