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
58
|
# File 'lib/logstash/filters/naxsi.rb', line 22
def filter(event)
event_hash = event.to_hash()
ids = event_hash.keys.select { |a| /id\d+/ =~ a }
ids.each do |id|
new_event = LogStash::Event.new()
event_hash.keys.each do |key|
next if /id\d+|score\d+|var_name\d+|zone\d+|cscore\d+/ =~ key
new_event[key] = event[key]
end
exception_num = id[-1,1]
new_event["exception_num"] = exception_num
["id","score","var_name","zone","cscore"].each do |prop|
next unless event_hash.has_key?(prop + exception_num)
new_event[prop] = event_hash[prop + exception_num]
end
yield new_event
end
event.cancel
filter_matched(event)
end
|