-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsyspce_engine_filter.py
More file actions
57 lines (43 loc) · 1.77 KB
/
syspce_engine_filter.py
File metadata and controls
57 lines (43 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import logging
from syspce_engine import Engine
from syspce_message import *
log = logging.getLogger('sysmoncorrelator')
class FilterEngine(Engine):
def __init__(self, data_buffer_in,
data_condition_in, src,
search_filter,
filter_attribute,
events, daemon):
Engine.__init__(self, data_buffer_in,
data_condition_in,
src, daemon)
self.events = events
self.search_filter = search_filter
self.filter_attribute = filter_attribute
self.name = 'Filter Engine'
self.module_id = Module.FILTER_ENGINE
def do_action(self):
for event in self.events:
try:
match = True
for search_filter in self.search_filter:
#special case for filter attribute idEvent becouse
# it's an int not string
if search_filter == 'idEvent':
if self.search_filter[search_filter] != \
event[search_filter]:
match = False
break
else:
if self.search_filter[search_filter].lower() not in \
event[search_filter].lower():
match = False
break
if match:
if self.filter_attribute:
self.send_message(event[self.filter_attribute])
else:
self.send_message(event)
except Exception, e:
pass
self.terminate()