Skip to content

Commit c0cff81

Browse files
committed
Switch drilldowns to dump in json format so
we can support and arbitrary number of them
1 parent 7bde9d7 commit c0cff81

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

contentctl/objects/abstract_security_content_objects/detection_abstract.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ def model_post_init(self, __context: Any) -> None:
573573
print("adding default drilldown?")
574574
self.drilldown_searches.extend(Drilldown.constructDrilldownsFromDetection(self))
575575

576+
@property
577+
def drilldownsInJSON(self) -> list[dict[str,str]]:
578+
return [drilldown.model_dump() for drilldown in self.drilldown_searches]
579+
576580
@field_validator('lookups', mode="before")
577581
@classmethod
578582
def getDetectionLookups(cls, v:list[str], info:ValidationInfo) -> list[Lookup]:

contentctl/objects/drilldown.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,4 @@ def perform_search_substitutions(self, detection:Detection)->None:
5050
f"drilldown search '{self.search}' for Detection {detection.file_path}.\n"
5151
"If this was intentional, then please ignore this warning.\n")
5252
self.search = self.search.replace(SEARCH_PLACEHOLDER, detection.search)
53-
54-
55-
53+

contentctl/output/templates/savedsearches_detections.j2

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,7 @@ alert.suppress.fields = {{ detection.tags.throttling.conf_formatted_fields() }}
112112
alert.suppress.period = {{ detection.tags.throttling.period }}
113113
{% endif %}
114114
search = {{ detection.search | escapeNewlines() }}
115-
{% for drilldown_search in detection.drilldown_searches%}
116-
action.notable.param.drilldown_name = {{ drilldown_search.name }}
117-
action.notable.param.drilldown_search = {{ drilldown_search.search | escapeNewlines()}}
118-
action.notable.param.drilldown_earliest_offset = {{ drilldown_search.earliest_offset }}
119-
action.notable.param.drilldown_latest_offset = {{ drilldown_search.latest_offset }}
120-
{% endfor %}
115+
action.notable.param.drilldown_searches = {{ detection.drilldownsInJSON | tojson | escapeNewlines() }}
121116
{% endif %}
122117

123118
{% endfor %}

0 commit comments

Comments
 (0)