5
5
from contentctl .objects .security_content_object import SecurityContentObject
6
6
from contentctl .objects .enums import DataModel
7
7
from contentctl .objects .investigation_tags import InvestigationTags
8
-
9
- from contentctl .objects .constants import CONTENTCTL_MAX_SEARCH_NAME_LENGTH
8
+ from contentctl .objects .constants import (
9
+ CONTENTCTL_MAX_SEARCH_NAME_LENGTH ,
10
+ CONTENTCTL_RESPONSE_TASK_NAME_FORMAT_TEMPLATE ,
11
+ CONTENTCTL_MAX_STANZA_LENGTH
12
+ )
13
+ from contentctl .objects .config import CustomApp
10
14
11
15
# TODO (#266): disable the use_enum_values configuration
12
16
class Investigation (SecurityContentObject ):
@@ -39,6 +43,16 @@ def inputs(self)->List[str]:
39
43
def lowercase_name (self )-> str :
40
44
return self .name .replace (' ' , '_' ).replace ('-' ,'_' ).replace ('.' ,'_' ).replace ('/' ,'_' ).lower ().replace (' ' , '_' ).replace ('-' ,'_' ).replace ('.' ,'_' ).replace ('/' ,'_' ).lower ()
41
45
46
+
47
+ # This is a slightly modified version of the get_conf_stanza_name function from
48
+ # SecurityContentObject_Abstract
49
+ def get_response_task_name (self , app :CustomApp , max_stanza_length :int = CONTENTCTL_MAX_STANZA_LENGTH )-> str :
50
+ stanza_name = CONTENTCTL_RESPONSE_TASK_NAME_FORMAT_TEMPLATE .format (app_label = app .label , detection_name = self .name )
51
+ if len (stanza_name ) > max_stanza_length :
52
+ raise ValueError (f"conf stanza may only be { max_stanza_length } characters, "
53
+ f"but stanza was actually { len (stanza_name )} characters: '{ stanza_name } ' " )
54
+ return stanza_name
55
+
42
56
43
57
@model_serializer
44
58
def serialize_model (self ):
@@ -69,6 +83,3 @@ def model_post_init(self, ctx:dict[str,Any]):
69
83
# back to itself
70
84
for story in self .tags .analytic_story :
71
85
story .investigations .append (self )
72
-
73
-
74
-
0 commit comments