Skip to content

Commit eedd07e

Browse files
committed
Added some documentation and
updated the jinja2 template. escapeNewlines() was ONLY being applied to the detection.description before, but it MUST be applied to the explanation as well. This bug was confirmed by generating some conf files with description and/or explanations, with spaces, defined. Now, whichever value is used to populate that field is properly escaped.
1 parent 8c21622 commit eedd07e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

contentctl/objects/abstract_security_content_objects/detection_abstract.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,16 @@ class Detection_Abstract(SecurityContentObject):
6767
search: str = Field(...)
6868
how_to_implement: str = Field(..., min_length=4)
6969
known_false_positives: str = Field(..., min_length=4)
70-
explanation: Optional[str] = None
70+
explanation: None | str = Field(
71+
default=None,
72+
exclude=True, #Don't serialize this value when dumping the object
73+
description="Provide an explanation to be included "
74+
"in the 'Explanation' field of the Detection in "
75+
"the Use Case Library. If this field is not "
76+
"defined in the YML, it will default to the "
77+
"value of the 'description' field when "
78+
"serialized in analyticstories_detections.j2",
79+
)
7180

7281
enabled_by_default: bool = False
7382
file_path: FilePath = Field(...)

contentctl/output/templates/analyticstories_detections.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
type = detection
88
asset_type = {{ detection.tags.asset_type.value }}
99
confidence = medium
10-
explanation = {{ detection.explanation if detection.explanation else detection.description | escapeNewlines() }}
10+
explanation = {{ (detection.explanation if detection.explanation else detection.description) | escapeNewlines() }}
1111
{% if detection.how_to_implement is defined %}
1212
how_to_implement = {{ detection.how_to_implement | escapeNewlines() }}
1313
{% else %}

0 commit comments

Comments
 (0)