File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
abstract_security_content_objects Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1055,3 +1055,30 @@ def get_summary(
1055
1055
# Return the summary
1056
1056
1057
1057
return summary_dict
1058
+
1059
+ @model_validator (mode = "after" )
1060
+ def validate_data_source_output_fields (self ):
1061
+ # Skip validation for Hunting and Correlation types, or non-production detections
1062
+ if (self .status != DetectionStatus .production or
1063
+ self .type in {AnalyticsType .Hunting , AnalyticsType .Correlation } or
1064
+ len (self .data_source ) <= 1 ):
1065
+ return self
1066
+
1067
+ # Validate that all required output fields are present in the search
1068
+ for data_source in self .data_source_objects :
1069
+ if not data_source .output_fields :
1070
+ continue
1071
+
1072
+ missing_fields = [
1073
+ field for field in data_source .output_fields
1074
+ if field not in self .search
1075
+ ]
1076
+
1077
+ if missing_fields :
1078
+ raise ValueError (
1079
+ f"Data source '{ data_source .name } ' has output fields "
1080
+ f"{ missing_fields } that are not present in the search "
1081
+ f"for detection '{ self .name } '"
1082
+ )
1083
+
1084
+ return self
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class DataSource(SecurityContentObject):
23
23
field_mappings : None | list = None
24
24
convert_to_log_source : None | list = None
25
25
example_log : None | str = None
26
- output_fields : list [ str ] = []
26
+ output_fields : None | list = None
27
27
28
28
@model_serializer
29
29
def serialize_model (self ):
You can’t perform that action at this time.
0 commit comments