Skip to content

Commit ac074dd

Browse files
authored
Merge pull request #377 from splunk/data_source_output_fields_validation
Data source output fields validation
2 parents a64d879 + ea8ec90 commit ac074dd

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class DetectionTestingManagerOutputDto:
8989
start_time: Union[datetime.datetime, None] = None
9090
replay_index: str = "contentctl_testing_index"
9191
replay_host: str = "CONTENTCTL_HOST"
92-
timeout_seconds: int = 60
92+
timeout_seconds: int = 120
9393
terminate: bool = False
9494

9595

contentctl/objects/abstract_security_content_objects/detection_abstract.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,3 +1055,30 @@ def get_summary(
10551055
# Return the summary
10561056

10571057
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 self.type in {
1063+
AnalyticsType.Hunting,
1064+
AnalyticsType.Correlation,
1065+
}:
1066+
return self
1067+
1068+
# Validate that all required output fields are present in the search
1069+
for data_source in self.data_source_objects:
1070+
if not data_source.output_fields:
1071+
continue
1072+
1073+
missing_fields = [
1074+
field for field in data_source.output_fields 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

0 commit comments

Comments
 (0)