Skip to content

Commit c1031de

Browse files
Added Schema Check for Data View ID and Index (#3830)
(cherry picked from commit ec6038b)
1 parent db43a34 commit c1031de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

detection_rules/rule.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,12 @@ def get_required_fields(self, index: str) -> List[dict]:
708708
if validator is not None:
709709
return validator.get_required_fields(index or [])
710710

711+
@validates_schema
712+
def validates_index_and_data_view_id(self, data, **kwargs):
713+
"""Validate that either index or data_view_id is set, but not both."""
714+
if data.get('index') and data.get('data_view_id'):
715+
raise ValidationError("Only one of index or data_view_id should be set.")
716+
711717
@validates_schema
712718
def validates_query_data(self, data, **kwargs):
713719
"""Custom validation for query rule type and subclasses."""

0 commit comments

Comments
 (0)