From b17127486f21bf756b75fdfd8b14e7db1faf29da Mon Sep 17 00:00:00 2001 From: Michel Osswald Date: Wed, 10 Jun 2026 11:05:55 +0200 Subject: [PATCH] fix(guard): cache enabled policy categories --- internal/guard/policy/engine.go | 3 ++- internal/guard/policy/profiles.go | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/guard/policy/engine.go b/internal/guard/policy/engine.go index 8432c815..ae46d843 100644 --- a/internal/guard/policy/engine.go +++ b/internal/guard/policy/engine.go @@ -21,9 +21,10 @@ func (e Engine) Evaluate(event risk.RiskEvent, cfg Config) Result { if cfg.RulePack == "" { cfg.RulePack = e.pack.ID } + enabledCategories := enabledCategories(cfg.Profile) for _, rule := range e.pack.Rules { - if !categoryEnabled(cfg.Profile, rule.Category) || !rule.When(event) { + if !enabledCategories[rule.Category] || !rule.When(event) { continue } return Result{ diff --git a/internal/guard/policy/profiles.go b/internal/guard/policy/profiles.go index 5a84e76c..e1788e7b 100644 --- a/internal/guard/policy/profiles.go +++ b/internal/guard/policy/profiles.go @@ -29,7 +29,3 @@ func enabledCategories(profile Profile) map[RuleCategory]bool { } return categories } - -func categoryEnabled(profile Profile, category RuleCategory) bool { - return enabledCategories(profile)[category] -}