diff --git a/internal/guard/policy/engine.go b/internal/guard/policy/engine.go index 8432c81..89b80fd 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 } + enabled := enabledCategories(cfg.Profile) for _, rule := range e.pack.Rules { - if !categoryEnabled(cfg.Profile, rule.Category) || !rule.When(event) { + if !enabled[rule.Category] || !rule.When(event) { continue } return Result{ diff --git a/internal/guard/policy/profiles.go b/internal/guard/policy/profiles.go index 5a84e76..e1788e7 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] -}