Class: LogStash::Filters::Naxsi

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/filters/naxsi.rb

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



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()

  # Get all of your idN keys from the event
  ids = event_hash.keys.select { |a| /id\d+/ =~ a }

  ids.each do |id|

    new_event = LogStash::Event.new()

    # Copy all the keys that are not tied to the exceptions
    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

    # Add the properties for the exception
    ["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

    # Create the new event
    yield new_event
  end

  # Cancel the original event
  event.cancel

  # filter_matched should go in the last line of our successful code
  filter_matched(event)
end

#registerObject



17
18
19
# File 'lib/logstash/filters/naxsi.rb', line 17

def register
  # Add instance variables
end