Skip to content

Commit 4e862d3

Browse files
committed
Remove build_ssa from the config.
Change typing of the detection_abstract search field from dict | str to str. dict | str WAS in place to support sigma searches, but that functionality has since been removed.
1 parent ba19a6a commit 4e862d3

File tree

2 files changed

+29
-39
lines changed

2 files changed

+29
-39
lines changed

contentctl/objects/abstract_security_content_objects/detection_abstract.py

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from contentctl.objects.unit_test import UnitTest
2323
from contentctl.objects.test_group import TestGroup
2424
from contentctl.objects.integration_test import IntegrationTest
25-
from contentctl.objects.event_source import EventSource
2625
from contentctl.objects.data_source import DataSource
2726

2827
#from contentctl.objects.playbook import Playbook
@@ -39,7 +38,7 @@ class Detection_Abstract(SecurityContentObject):
3938
status: DetectionStatus = Field(...)
4039
data_source: list[str] = []
4140
tags: DetectionTags = Field(...)
42-
search: Union[str, dict[str,Any]] = Field(...)
41+
search: str = Field(...)
4342
how_to_implement: str = Field(..., min_length=4)
4443
known_false_positives: str = Field(..., min_length=4)
4544

@@ -136,10 +135,9 @@ def validate_test_groups(cls, value:Union[None, List[TestGroup]], info:Validatio
136135
@computed_field
137136
@property
138137
def datamodel(self)->List[DataModel]:
139-
if isinstance(self.search, str):
140-
return [dm for dm in DataModel if dm.value in self.search]
141-
else:
142-
return []
138+
return [dm for dm in DataModel if dm.value in self.search]
139+
140+
143141

144142

145143
@computed_field
@@ -238,11 +236,8 @@ def nes_fields(self)->Optional[str]:
238236
@computed_field
239237
@property
240238
def providing_technologies(self)->List[ProvidingTechnology]:
241-
if isinstance(self.search, str):
242-
return ProvidingTechnology.getProvidingTechFromSearch(self.search)
243-
else:
244-
#Dict-formatted searches (sigma) will not have providing technologies
245-
return []
239+
return ProvidingTechnology.getProvidingTechFromSearch(self.search)
240+
246241

247242
@computed_field
248243
@property
@@ -599,35 +594,32 @@ def ensureProperObservablesExist(self):
599594

600595
@model_validator(mode="after")
601596
def search_observables_exist_validate(self):
597+
observable_fields = [ob.name.lower() for ob in self.tags.observable]
598+
599+
#All $field$ fields from the message must appear in the search
600+
field_match_regex = r"\$([^\s.]*)\$"
601+
602+
603+
if self.tags.message:
604+
message_fields = [match.replace("$", "").lower() for match in re.findall(field_match_regex, self.tags.message.lower())]
605+
missing_fields = set([field for field in observable_fields if field not in self.search.lower()])
606+
else:
607+
message_fields = []
608+
missing_fields = set()
602609

603-
if isinstance(self.search, str):
604-
605-
observable_fields = [ob.name.lower() for ob in self.tags.observable]
606-
607-
#All $field$ fields from the message must appear in the search
608-
field_match_regex = r"\$([^\s.]*)\$"
609-
610-
611-
if self.tags.message:
612-
message_fields = [match.replace("$", "").lower() for match in re.findall(field_match_regex, self.tags.message.lower())]
613-
missing_fields = set([field for field in observable_fields if field not in self.search.lower()])
614-
else:
615-
message_fields = []
616-
missing_fields = set()
617-
618610

619-
error_messages = []
620-
if len(missing_fields) > 0:
621-
error_messages.append(f"The following fields are declared as observables, but do not exist in the search: {missing_fields}")
611+
error_messages = []
612+
if len(missing_fields) > 0:
613+
error_messages.append(f"The following fields are declared as observables, but do not exist in the search: {missing_fields}")
622614

623-
624-
missing_fields = set([field for field in message_fields if field not in self.search.lower()])
625-
if len(missing_fields) > 0:
626-
error_messages.append(f"The following fields are used as fields in the message, but do not exist in the search: {missing_fields}")
627-
628-
if len(error_messages) > 0 and self.status == DetectionStatus.production.value:
629-
msg = "Use of fields in observables/messages that do not appear in search:\n\t- "+ "\n\t- ".join(error_messages)
630-
raise(ValueError(msg))
615+
616+
missing_fields = set([field for field in message_fields if field not in self.search.lower()])
617+
if len(missing_fields) > 0:
618+
error_messages.append(f"The following fields are used as fields in the message, but do not exist in the search: {missing_fields}")
619+
620+
if len(error_messages) > 0 and self.status == DetectionStatus.production.value:
621+
msg = "Use of fields in observables/messages that do not appear in search:\n\t- "+ "\n\t- ".join(error_messages)
622+
raise(ValueError(msg))
631623

632624
# Found everything
633625
return self

contentctl/objects/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class validate(Config_Base):
175175
"be avoided for performance reasons.")
176176
build_app: bool = Field(default=True, description="Should an app be built and output in the build_path?")
177177
build_api: bool = Field(default=False, description="Should api objects be built and output in the build_path?")
178-
build_ssa: bool = Field(default=False, description="Should ssa objects be built and output in the build_path?")
179178
data_source_TA_validation: bool = Field(default=False, description="Validate latest TA information from Splunkbase")
180179

181180
def getAtomicRedTeamRepoPath(self, atomic_red_team_repo_name:str = "atomic-red-team"):
@@ -577,7 +576,6 @@ def dumpCICDPlanAndQuit(self, githash: str, detections:List[Detection]):
577576
# output to dist. We have already built it!
578577
self.build_app = False
579578
self.build_api = False
580-
self.build_ssa = False
581579
self.enrichments = False
582580

583581
self.enable_integration_testing = True

0 commit comments

Comments
 (0)