1
- from sigma .pipelines .common import \
2
- logsource_windows , \
3
- logsource_windows_process_creation , \
4
- logsource_windows_registry_add , \
5
- logsource_windows_registry_delete , \
6
- logsource_windows_registry_event , \
7
- logsource_windows_registry_set , \
8
- logsource_windows_file_event , \
9
- logsource_linux_process_creation , \
10
- generate_windows_logsource_items
11
- from sigma .processing .transformations import AddConditionTransformation , FieldMappingTransformation , DetectionItemFailureTransformation , RuleFailureTransformation , SetStateTransformation
12
- from sigma .processing .conditions import LogsourceCondition , ExcludeFieldCondition , RuleProcessingItemAppliedCondition
1
+ from sigma .pipelines .common import (
2
+ logsource_windows ,
3
+ logsource_windows_process_creation ,
4
+ logsource_windows_registry_add ,
5
+ logsource_windows_registry_delete ,
6
+ logsource_windows_registry_event ,
7
+ logsource_windows_registry_set ,
8
+ logsource_windows_file_event ,
9
+ logsource_linux_process_creation ,
10
+ generate_windows_logsource_items ,
11
+ )
12
+ from sigma .processing .transformations import (
13
+ AddConditionTransformation ,
14
+ FieldMappingTransformation ,
15
+ DetectionItemFailureTransformation ,
16
+ RuleFailureTransformation ,
17
+ SetStateTransformation ,
18
+ )
19
+ from sigma .processing .conditions import (
20
+ LogsourceCondition ,
21
+ ExcludeFieldCondition ,
22
+ RuleProcessingItemAppliedCondition ,
23
+ )
13
24
from sigma .processing .pipeline import ProcessingItem , ProcessingPipeline
14
25
15
- windows_sysmon_acceleration_keywords = { # Map Sysmon event sources and keywords that are added to search for Sysmon optimization pipeline
16
- "process_creation" : "ParentProcessGuid" ,
17
- "file_event" : "TargetFilename" ,
26
+ windows_sysmon_acceleration_keywords = { # Map Sysmon event sources and keywords that are added to search for Sysmon optimization pipeline
27
+ "process_creation" : "ParentProcessGuid" ,
28
+ "file_event" : "TargetFilename" ,
18
29
}
19
30
20
31
splunk_sysmon_process_creation_cim_mapping = {
36
47
splunk_windows_registry_cim_mapping = {
37
48
"Computer" : "Registry.dest" ,
38
49
"Details" : "Registry.registry_value_data" ,
39
- "EventType" : "Registry.action" , # EventType: DeleteKey is parsed to action: deleted
50
+ "EventType" : "Registry.action" , # EventType: DeleteKey is parsed to action: deleted
40
51
"Image" : "Registry.process_path" ,
41
52
"ProcessGuid" : "Registry.process_guid" ,
42
53
"ProcessId" : "Registry.process_id" ,
52
63
"TargetFilename" : "Filesystem.file_path" ,
53
64
}
54
65
66
+
55
67
def splunk_windows_pipeline ():
56
68
return ProcessingPipeline (
57
69
name = "Splunk Windows log source conditions" ,
58
70
allowed_backends = {"splunk" },
59
71
priority = 20 ,
60
- items = generate_windows_logsource_items ("source" , "WinEventLog:{source}" ) + [
61
- ProcessingItem ( # Field mappings
72
+ items = generate_windows_logsource_items ("source" , "WinEventLog:{source}" )
73
+ + [
74
+ ProcessingItem ( # Field mappings
62
75
identifier = "splunk_windows_field_mapping" ,
63
- transformation = FieldMappingTransformation ({
64
- "EventID" : "EventCode" ,
65
- })
76
+ transformation = FieldMappingTransformation (
77
+ {
78
+ "EventID" : "EventCode" ,
79
+ }
80
+ ),
66
81
)
67
82
],
68
83
)
69
84
85
+
70
86
def splunk_windows_sysmon_acceleration_keywords ():
71
87
return ProcessingPipeline (
72
88
name = "Splunk Windows Sysmon search acceleration keywords" ,
73
89
allowed_backends = {"splunk" },
74
90
priority = 25 ,
75
91
items = [
76
- ProcessingItem ( # Some optimizations searching for characteristic keyword for specific log sources
92
+ ProcessingItem ( # Some optimizations searching for characteristic keyword for specific log sources
77
93
identifier = "splunk_windows_sysmon_process_creation" ,
78
- transformation = AddConditionTransformation ({
79
- None : keyword ,
80
- }),
94
+ transformation = AddConditionTransformation (
95
+ {
96
+ None : keyword ,
97
+ }
98
+ ),
81
99
rule_conditions = [
82
100
LogsourceCondition (
83
101
category = sysmon_category ,
84
102
product = "windows" ,
85
103
service = "sysmon" ,
86
104
)
87
- ]
105
+ ],
88
106
)
89
107
for sysmon_category , keyword in windows_sysmon_acceleration_keywords .items ()
90
- ]
108
+ ],
91
109
)
92
110
111
+
93
112
def splunk_cim_data_model ():
94
113
return ProcessingPipeline (
95
114
name = "Splunk CIM Data Model Mapping" ,
@@ -98,21 +117,26 @@ def splunk_cim_data_model():
98
117
items = [
99
118
ProcessingItem (
100
119
identifier = "splunk_dm_mapping_sysmon_process_creation_unsupported_fields" ,
101
- transformation = DetectionItemFailureTransformation ("The Splunk Data Model Sigma backend supports only the following fields for process_creation log source: " + "," .join (splunk_sysmon_process_creation_cim_mapping .keys ())),
120
+ transformation = DetectionItemFailureTransformation (
121
+ "The Splunk Data Model Sigma backend supports only the following fields for process_creation log source: "
122
+ + "," .join (splunk_sysmon_process_creation_cim_mapping .keys ())
123
+ ),
102
124
rule_conditions = [
103
125
logsource_windows_process_creation (),
104
126
logsource_linux_process_creation (),
105
127
],
106
128
rule_condition_linking = any ,
107
129
field_name_conditions = [
108
130
ExcludeFieldCondition (
109
- fields = splunk_sysmon_process_creation_cim_mapping .keys ()
131
+ fields = splunk_sysmon_process_creation_cim_mapping .keys ()
110
132
)
111
- ]
133
+ ],
112
134
),
113
135
ProcessingItem (
114
136
identifier = "splunk_dm_mapping_sysmon_process_creation" ,
115
- transformation = FieldMappingTransformation (splunk_sysmon_process_creation_cim_mapping ),
137
+ transformation = FieldMappingTransformation (
138
+ splunk_sysmon_process_creation_cim_mapping
139
+ ),
116
140
rule_conditions = [
117
141
logsource_windows_process_creation (),
118
142
logsource_linux_process_creation (),
@@ -121,7 +145,9 @@ def splunk_cim_data_model():
121
145
),
122
146
ProcessingItem (
123
147
identifier = "splunk_dm_fields_sysmon_process_creation" ,
124
- transformation = SetStateTransformation ("fields" , splunk_sysmon_process_creation_cim_mapping .values ()),
148
+ transformation = SetStateTransformation (
149
+ "fields" , splunk_sysmon_process_creation_cim_mapping .values ()
150
+ ),
125
151
rule_conditions = [
126
152
logsource_windows_process_creation (),
127
153
logsource_linux_process_creation (),
@@ -130,7 +156,9 @@ def splunk_cim_data_model():
130
156
),
131
157
ProcessingItem (
132
158
identifier = "splunk_dm_sysmon_process_creation_data_model_set" ,
133
- transformation = SetStateTransformation ("data_model_set" , "Endpoint.Processes" ),
159
+ transformation = SetStateTransformation (
160
+ "data_model_set" , "Endpoint.Processes"
161
+ ),
134
162
rule_conditions = [
135
163
logsource_windows_process_creation (),
136
164
logsource_linux_process_creation (),
@@ -139,7 +167,10 @@ def splunk_cim_data_model():
139
167
),
140
168
ProcessingItem (
141
169
identifier = "splunk_dm_mapping_sysmon_registry_unsupported_fields" ,
142
- transformation = DetectionItemFailureTransformation ("The Splunk Data Model Sigma backend supports only the following fields for registry log source: " + "," .join (splunk_windows_registry_cim_mapping .keys ())),
170
+ transformation = DetectionItemFailureTransformation (
171
+ "The Splunk Data Model Sigma backend supports only the following fields for registry log source: "
172
+ + "," .join (splunk_windows_registry_cim_mapping .keys ())
173
+ ),
143
174
rule_conditions = [
144
175
logsource_windows_registry_add (),
145
176
logsource_windows_registry_delete (),
@@ -149,13 +180,15 @@ def splunk_cim_data_model():
149
180
rule_condition_linking = any ,
150
181
field_name_conditions = [
151
182
ExcludeFieldCondition (
152
- fields = splunk_windows_registry_cim_mapping .keys ()
183
+ fields = splunk_windows_registry_cim_mapping .keys ()
153
184
)
154
- ]
185
+ ],
155
186
),
156
187
ProcessingItem (
157
188
identifier = "splunk_dm_mapping_sysmon_registry" ,
158
- transformation = FieldMappingTransformation (splunk_windows_registry_cim_mapping ),
189
+ transformation = FieldMappingTransformation (
190
+ splunk_windows_registry_cim_mapping
191
+ ),
159
192
rule_conditions = [
160
193
logsource_windows_registry_add (),
161
194
logsource_windows_registry_delete (),
@@ -166,7 +199,9 @@ def splunk_cim_data_model():
166
199
),
167
200
ProcessingItem (
168
201
identifier = "splunk_dm_fields_sysmon_registry" ,
169
- transformation = SetStateTransformation ("fields" , splunk_windows_registry_cim_mapping .values ()),
202
+ transformation = SetStateTransformation (
203
+ "fields" , splunk_windows_registry_cim_mapping .values ()
204
+ ),
170
205
rule_conditions = [
171
206
logsource_windows_registry_add (),
172
207
logsource_windows_registry_delete (),
@@ -177,7 +212,9 @@ def splunk_cim_data_model():
177
212
),
178
213
ProcessingItem (
179
214
identifier = "splunk_dm_sysmon_registry_data_model_set" ,
180
- transformation = SetStateTransformation ("data_model_set" , "Endpoint.Registry" ),
215
+ transformation = SetStateTransformation (
216
+ "data_model_set" , "Endpoint.Registry"
217
+ ),
181
218
rule_conditions = [
182
219
logsource_windows_registry_add (),
183
220
logsource_windows_registry_delete (),
@@ -188,48 +225,64 @@ def splunk_cim_data_model():
188
225
),
189
226
ProcessingItem (
190
227
identifier = "splunk_dm_mapping_sysmon_file_event_unsupported_fields" ,
191
- transformation = DetectionItemFailureTransformation ("The Splunk Data Model Sigma backend supports only the following fields for file_event log source: " + "," .join (splunk_windows_file_event_cim_mapping .keys ())),
228
+ transformation = DetectionItemFailureTransformation (
229
+ "The Splunk Data Model Sigma backend supports only the following fields for file_event log source: "
230
+ + "," .join (splunk_windows_file_event_cim_mapping .keys ())
231
+ ),
192
232
rule_conditions = [
193
233
logsource_windows_file_event (),
194
234
],
195
235
field_name_conditions = [
196
236
ExcludeFieldCondition (
197
- fields = splunk_windows_file_event_cim_mapping .keys ()
237
+ fields = splunk_windows_file_event_cim_mapping .keys ()
198
238
)
199
- ]
239
+ ],
200
240
),
201
241
ProcessingItem (
202
242
identifier = "splunk_dm_mapping_sysmon_file_event" ,
203
- transformation = FieldMappingTransformation (splunk_windows_file_event_cim_mapping ),
243
+ transformation = FieldMappingTransformation (
244
+ splunk_windows_file_event_cim_mapping
245
+ ),
204
246
rule_conditions = [
205
247
logsource_windows_file_event (),
206
- ]
248
+ ],
207
249
),
208
250
ProcessingItem (
209
251
identifier = "splunk_dm_fields_sysmon_file_event" ,
210
- transformation = SetStateTransformation ("fields" , splunk_windows_file_event_cim_mapping .values ()),
252
+ transformation = SetStateTransformation (
253
+ "fields" , splunk_windows_file_event_cim_mapping .values ()
254
+ ),
211
255
rule_conditions = [
212
256
logsource_windows_file_event (),
213
- ]
257
+ ],
214
258
),
215
259
ProcessingItem (
216
260
identifier = "splunk_dm_mapping_sysmon_file_event_data_model_set" ,
217
- transformation = SetStateTransformation ("data_model_set" , "Endpoint.Filesystem" ),
261
+ transformation = SetStateTransformation (
262
+ "data_model_set" , "Endpoint.Filesystem"
263
+ ),
218
264
rule_conditions = [
219
265
logsource_windows_file_event (),
220
- ]
266
+ ],
221
267
),
222
268
ProcessingItem (
223
269
identifier = "splunk_dm_mapping_log_source_not_supported" ,
224
270
rule_condition_linking = any ,
225
- transformation = RuleFailureTransformation ("Rule type not yet supported by the Splunk data model CIM pipeline!" ),
271
+ transformation = RuleFailureTransformation (
272
+ "Rule type not yet supported by the Splunk data model CIM pipeline!"
273
+ ),
226
274
rule_condition_negation = True ,
227
275
rule_conditions = [
228
- RuleProcessingItemAppliedCondition ("splunk_dm_mapping_sysmon_process_creation" ),
229
- RuleProcessingItemAppliedCondition ("splunk_dm_mapping_sysmon_registry" ),
230
- RuleProcessingItemAppliedCondition ("splunk_dm_mapping_sysmon_file_event" ),
276
+ RuleProcessingItemAppliedCondition (
277
+ "splunk_dm_mapping_sysmon_process_creation"
278
+ ),
279
+ RuleProcessingItemAppliedCondition (
280
+ "splunk_dm_mapping_sysmon_registry"
281
+ ),
282
+ RuleProcessingItemAppliedCondition (
283
+ "splunk_dm_mapping_sysmon_file_event"
284
+ ),
231
285
],
232
286
),
233
- ]
287
+ ],
234
288
)
235
-
0 commit comments