Skip to content

Commit 7bde9d7

Browse files
committed
Update template and drilldown object
1 parent a849e34 commit 7bde9d7

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

contentctl/objects/drilldown.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ class Drilldown(BaseModel):
2525

2626
@classmethod
2727
def constructDrilldownsFromDetection(cls, detection: Detection) -> list[Drilldown]:
28-
if len([f"${o.name}$" for o in detection.tags.observable if o.role[0] == "Victim"]) == 0 and detection.type != AnalyticsType.Hunting:
29-
print("no victim!")
30-
# print(detection.tags.observable)
31-
# print(detection.file_path)
28+
victim_observables = [o for o in detection.tags.observable if o.role[0] == "Victim"]
29+
if len(victim_observables) == 0 or detection.type == AnalyticsType.Hunting:
30+
# No victims, so no drilldowns
31+
return []
3232

33-
variableNamesString = ' and'.join([f"${o.name}$" for o in detection.tags.observable if o.type[0] == "Victim"])
34-
nameField = "View the detection results for }" + variableNamesString
35-
appendedSearch = " | search " + ' '.join([f"o.name = ${o.name}$" for o in detection.tags.observable])
33+
variableNamesString = ' and '.join([f"${o.name}$" for o in victim_observables])
34+
nameField = f"View the detection results for {variableNamesString}"
35+
appendedSearch = " | search " + ' '.join([f"{o.name} = ${o.name}$" for o in victim_observables])
3636
search_field = f"{detection.search}{appendedSearch}"
3737
detection_results = cls(name=nameField, earliest_offset=EARLIEST_OFFSET, latest_offset=LATEST_OFFSET, search=search_field)
3838

contentctl/output/templates/savedsearches_detections.j2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ 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-
{% if detection.tags.drilldown%}
116-
action.notable.param.drilldown_name = {{ detection.tags.drilldown.name }}
117-
action.notable.param.drilldown_search = {{ detection.tags.drilldown.search | escapeNewlines()}}
118-
action.notable.param.drilldown_earliest_offset = {{ detection.tags.drilldown.earliest_offset }}
119-
action.notable.param.drilldown_latest_offset = {{ detection.tags.drilldown.latest_offset }}
120-
{% endif %}
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 %}
121121
{% endif %}
122122

123123
{% endfor %}

0 commit comments

Comments
 (0)