@@ -19,16 +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 ()
34
+ answers ['kind' ] = answers ['detection_kind' ]
31
35
answers ['search' ] = answers ['detection_search' ] + ' | `' + file_name + '_filter`'
36
+ del answers ['detection_search' ]
32
37
answers ['how_to_implement' ] = 'UPDATE_HOW_TO_IMPLEMENT'
33
38
answers ['known_false_positives' ] = 'UPDATE_KNOWN_FALSE_POSITIVES'
34
39
answers ['references' ] = ['REFERENCE' ]
@@ -52,7 +57,7 @@ def buildDetection(self)->dict[str,Any]:
52
57
'name' : "True Positive Test" ,
53
58
'attack_data' : [
54
59
{
55
- 'data' : "Enter URL for Dataset Here. This may also be a relative or absolute path on your local system for testing. " ,
60
+ 'data' : "https://github.com/splunk/contentctl/wiki " ,
56
61
"sourcetype" : "UPDATE SOURCETYPE" ,
57
62
"source" : "UPDATE SOURCE"
58
63
}
@@ -65,32 +70,35 @@ def buildStory(self)->dict[str,Any]:
65
70
questions = NewContentQuestions .get_questions_story ()
66
71
answers = questionary .prompt (questions )
67
72
answers ['name' ] = answers ['story_name' ]
73
+ del answers ['story_name' ]
68
74
answers ['id' ] = str (uuid .uuid4 ())
69
75
answers ['version' ] = 1
70
76
answers ['date' ] = datetime .today ().strftime ('%Y-%m-%d' )
71
77
answers ['author' ] = answers ['story_author' ]
78
+ del answers ['story_author' ]
72
79
answers ['description' ] = 'UPDATE_DESCRIPTION'
73
80
answers ['narrative' ] = 'UPDATE_NARRATIVE'
74
81
answers ['references' ] = []
75
82
answers ['tags' ] = dict ()
76
- answers ['tags' ]['analytic_story' ] = answers ['name' ]
77
83
answers ['tags' ]['category' ] = answers ['category' ]
84
+ del answers ['category' ]
78
85
answers ['tags' ]['product' ] = ['Splunk Enterprise' ,'Splunk Enterprise Security' ,'Splunk Cloud' ]
79
86
answers ['tags' ]['usecase' ] = answers ['usecase' ]
87
+ del answers ['usecase' ]
80
88
answers ['tags' ]['cve' ] = ['UPDATE WITH CVE(S) IF APPLICABLE' ]
81
89
return answers
82
90
83
91
84
92
def execute (self , input_dto : new ) -> None :
85
93
if input_dto .type == NewContentType .detection :
86
94
content_dict = self .buildDetection ()
87
- subdirectory = pathlib .Path ('detections' ) / content_dict .get ( 'type ' )
95
+ subdirectory = pathlib .Path ('detections' ) / content_dict .pop ( 'detection_kind ' )
88
96
elif input_dto .type == NewContentType .story :
89
97
content_dict = self .buildStory ()
90
98
subdirectory = pathlib .Path ('stories' )
91
99
else :
92
100
raise Exception (f"Unsupported new content type: [{ input_dto .type } ]" )
93
-
101
+
94
102
full_output_path = input_dto .path / subdirectory / SecurityContentObject_Abstract .contentNameToFileName (content_dict .get ('name' ))
95
103
YmlWriter .writeYmlFile (str (full_output_path ), content_dict )
96
104
0 commit comments