feat(rules): add priority field and configurable evaluation mode (#1460) #1497
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements #1460 - Improve rule ordering logic
This PR adds explicit rule ordering and configurable evaluation modes, addressing the feature request for more intuitive rule management.
New Features
1. Priority Field for Rules
Rules now have an explicit
priorityfield (integer, default 0):Example rule:
{ "name": "block-malware-domains", "priority": -100, "action": "deny", "operator": { ... } }2. Configurable Evaluation Modes
New config option
Rules.EvaluationMode:deny-priorityfirst-matchExample config:
How It Works
deny-priority mode (default):
first-match mode:
Backwards Compatibility
deny-priority(current behavior)Files Changed
daemon/rule/rule.go- Added Priority field and EvaluationMode typedaemon/rule/loader.go- Updated sorting and matching logicdaemon/ui/config/config.go- Added EvaluationMode to config structdaemon/ui/config_utils.go- Apply evaluation mode from configdaemon/data/default-config.json- Added EvaluationMode defaultTest Plan
deny-prioritymode: confirm deny rules still win over allowfirst-matchmode: confirm first matching rule wins regardless of actionReviewers
@savchenko - Original requester
@Danny3 - Commented on the feature request