@@ -19,17 +19,21 @@ def buildDetection(self)->dict[str,Any]:
19
19
answers = questionary .prompt (questions )
20
20
answers .update (answers )
21
21
answers ['name' ] = answers ['detection_name' ]
22
+ del answers ['detection_name' ]
22
23
answers ['id' ] = str (uuid .uuid4 ())
23
24
answers ['version' ] = 1
24
25
answers ['date' ] = datetime .today ().strftime ('%Y-%m-%d' )
25
26
answers ['author' ] = answers ['detection_author' ]
27
+ del answers ['detection_author' ]
26
28
answers ['data_source' ] = answers ['data_source' ]
27
29
answers ['type' ] = answers ['detection_type' ]
30
+ del answers ['detection_type' ]
28
31
answers ['status' ] = "production" #start everything as production since that's what we INTEND the content to become
29
32
answers ['description' ] = 'UPDATE_DESCRIPTION'
30
33
file_name = answers ['name' ].replace (' ' , '_' ).replace ('-' ,'_' ).replace ('.' ,'_' ).replace ('/' ,'_' ).lower ()
31
34
answers ['kind' ] = answers ['detection_kind' ]
32
35
answers ['search' ] = answers ['detection_search' ] + ' | `' + file_name + '_filter`'
36
+ del answers ['detection_search' ]
33
37
answers ['how_to_implement' ] = 'UPDATE_HOW_TO_IMPLEMENT'
34
38
answers ['known_false_positives' ] = 'UPDATE_KNOWN_FALSE_POSITIVES'
35
39
answers ['references' ] = ['REFERENCE' ]
@@ -66,32 +70,37 @@ def buildStory(self)->dict[str,Any]:
66
70
questions = NewContentQuestions .get_questions_story ()
67
71
answers = questionary .prompt (questions )
68
72
answers ['name' ] = answers ['story_name' ]
73
+ del answers ['story_name' ]
69
74
answers ['id' ] = str (uuid .uuid4 ())
70
75
answers ['version' ] = 1
71
76
answers ['date' ] = datetime .today ().strftime ('%Y-%m-%d' )
72
77
answers ['author' ] = answers ['story_author' ]
78
+ del answers ['story_author' ]
73
79
answers ['description' ] = 'UPDATE_DESCRIPTION'
74
80
answers ['narrative' ] = 'UPDATE_NARRATIVE'
75
81
answers ['references' ] = []
76
82
answers ['tags' ] = dict ()
77
83
answers ['tags' ]['analytic_story' ] = answers ['name' ]
78
84
answers ['tags' ]['category' ] = answers ['category' ]
85
+ del answers ['category' ]
79
86
answers ['tags' ]['product' ] = ['Splunk Enterprise' ,'Splunk Enterprise Security' ,'Splunk Cloud' ]
80
87
answers ['tags' ]['usecase' ] = answers ['usecase' ]
88
+ del answers ['usecase' ]
81
89
answers ['tags' ]['cve' ] = ['UPDATE WITH CVE(S) IF APPLICABLE' ]
90
+ del answers ['detection_kind' ]
82
91
return answers
83
92
84
93
85
94
def execute (self , input_dto : new ) -> None :
86
95
if input_dto .type == NewContentType .detection :
87
96
content_dict = self .buildDetection ()
88
- subdirectory = pathlib .Path ('detections' ) / content_dict .get ('detection_kind' )
97
+ subdirectory = pathlib .Path ('detections' ) / content_dict .pop ('detection_kind' )
89
98
elif input_dto .type == NewContentType .story :
90
99
content_dict = self .buildStory ()
91
100
subdirectory = pathlib .Path ('stories' )
92
101
else :
93
102
raise Exception (f"Unsupported new content type: [{ input_dto .type } ]" )
94
-
103
+
95
104
full_output_path = input_dto .path / subdirectory / SecurityContentObject_Abstract .contentNameToFileName (content_dict .get ('name' ))
96
105
YmlWriter .writeYmlFile (str (full_output_path ), content_dict )
97
106
0 commit comments