Skip to content

Commit d93865a

Browse files
committed
Require at least 1 analytic story
per detection. Significant cleanup of the savedstories_detections.j2 template to make other changes easier. The changes in this template still generate an identical savedsearches.conf file before the changes.
1 parent 8411908 commit d93865a

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

contentctl/objects/detection_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class DetectionTags(BaseModel):
4343
# detection spec
4444

4545
model_config = ConfigDict(validate_default=False, extra="forbid")
46-
analytic_story: list[Story] = Field(...)
46+
analytic_story: list[Story] = Field(min_length=1)
4747
asset_type: AssetType = Field(...)
4848
group: list[str] = []
4949

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
### {{app.label}} DETECTIONS ###
22

33
{% for detection in objects %}
4-
{% if (detection.type == 'TTP' or detection.type == 'Anomaly' or detection.type == 'Hunting' or detection.type == 'Correlation') %}
54
[{{ detection.get_conf_stanza_name(app) }}]
65
action.escu = 0
76
action.escu.enabled = 1
87
description = {{ detection.status_aware_description | escapeNewlines() }}
98
action.escu.mappings = {{ detection.mappings | tojson }}
109
action.escu.data_models = {{ detection.datamodel | tojson }}
1110
action.escu.eli5 = {{ detection.status_aware_description | escapeNewlines() }}
12-
{% if detection.how_to_implement %}
1311
action.escu.how_to_implement = {{ detection.how_to_implement | escapeNewlines() }}
14-
{% else %}
15-
action.escu.how_to_implement = none
16-
{% endif %}
17-
{% if detection.known_false_positives %}
1812
action.escu.known_false_positives = {{ detection.known_false_positives | escapeNewlines() }}
19-
{% else %}
20-
action.escu.known_false_positives = None
21-
{% endif %}
2213
action.escu.creation_date = {{ detection.date }}
2314
action.escu.modification_date = {{ detection.date }}
2415
action.escu.confidence = high
2516
action.escu.search_type = detection
26-
{% if detection.tags.product is defined %}
2717
action.escu.product = {{ detection.tags.product | tojson }}
28-
{% endif %}
2918
{% if detection.tags.atomic_guid %}
3019
action.escu.atomic_red_team_guids = {{ detection.tags.getAtomicGuidStringArray() | tojson }}
3120
{% endif %}
@@ -34,7 +23,6 @@ action.escu.providing_technologies = {{ detection.providing_technologies | tojso
3423
{% else %}
3524
action.escu.providing_technologies = null
3625
{% endif %}
37-
{% if detection.tags.analytic_story %}
3826
action.escu.analytic_story = {{ objectListToNameList(detection.tags.analytic_story) | tojson }}
3927
{% if detection.deployment.alert_action.rba.enabled%}
4028
action.risk = 1
@@ -43,25 +31,17 @@ action.risk.param._risk = {{ detection.risk | tojson }}
4331
action.risk.param._risk_score = 0
4432
action.risk.param.verbose = 0
4533
{% endif %}
46-
{% else %}
47-
action.escu.analytic_story = []
48-
{% endif %}
4934
cron_schedule = {{ detection.deployment.scheduling.cron_schedule }}
5035
dispatch.earliest_time = {{ detection.deployment.scheduling.earliest_time }}
5136
dispatch.latest_time = {{ detection.deployment.scheduling.latest_time }}
5237
action.correlationsearch.enabled = 1
5338
action.correlationsearch.label = {{ detection.get_action_dot_correlationsearch_dot_label(app) }}
5439
action.correlationsearch.annotations = {{ detection.annotations | tojson }}
5540
action.correlationsearch.metadata = {{ detection.metadata | tojson }}
56-
{% if detection.deployment.scheduling.schedule_window is defined %}
5741
schedule_window = {{ detection.deployment.scheduling.schedule_window }}
58-
{% endif %}
59-
{% if detection.deployment is defined %}
6042
{% if detection.deployment.alert_action.notable %}
6143
action.notable = 1
62-
{% if detection.nes_fields %}
6344
action.notable.param.nes_fields = {{ detection.nes_fields }}
64-
{% endif %}
6545
action.notable.param.rule_description = {{ detection.deployment.alert_action.notable.rule_description | custom_jinja2_enrichment_filter(detection) | escapeNewlines()}}
6646
action.notable.param.rule_title = {% if detection.type | lower == "correlation" %}RBA: {{ detection.deployment.alert_action.notable.rule_title | custom_jinja2_enrichment_filter(detection) }}{% else %}{{ detection.deployment.alert_action.notable.rule_title | custom_jinja2_enrichment_filter(detection) }}{% endif +%}
6747
action.notable.param.security_domain = {{ detection.tags.security_domain }}
@@ -87,13 +67,8 @@ action.sendtophantom.param.phantom_server = {{ detection.deployment.alert_action
8767
action.sendtophantom.param.sensitivity = {{ detection.deployment.alert_action.phantom.sensitivity | custom_jinja2_enrichment_filter(detection) }}
8868
action.sendtophantom.param.severity = {{ detection.deployment.alert_action.phantom.severity | custom_jinja2_enrichment_filter(detection) }}
8969
{% endif %}
90-
{% endif %}
9170
alert.digest_mode = 1
92-
{% if detection.enabled_by_default %}
93-
disabled = false
94-
{% else %}
95-
disabled = true
96-
{% endif %}
71+
disabled = {{ (not detection.enabled_by_default) | lower }}
9772
enableSched = 1
9873
allow_skew = 100%
9974
counttype = number of events
@@ -108,7 +83,6 @@ alert.suppress.period = {{ detection.tags.throttling.period }}
10883
{% endif %}
10984
search = {{ detection.search | escapeNewlines() }}
11085
action.notable.param.drilldown_searches = {{ detection.drilldowns_in_JSON | tojson | escapeNewlines() }}
111-
{% endif %}
11286

11387
{% endfor %}
11488
### END {{ app.label }} DETECTIONS ###

0 commit comments

Comments
 (0)