Class: Threatinator::Plugins::Output::Csv

Inherits:
FileBasedOutput show all
Defined in:
lib/threatinator/plugins/output/csv.rb

Defined Under Namespace

Classes: Config

Instance Method Summary collapse

Methods inherited from FileBasedOutput

#finish

Methods inherited from Output

#finish

Constructor Details

#initialize(config) ⇒ Csv

Returns a new instance of Csv.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/threatinator/plugins/output/csv.rb', line 10

def initialize(config)
  super(config)
  @csv = ::CSV.new(self.output_io, 
                   :write_headers => true,
                   :headers => [
                     :provider,
                     :feed_name,
                     :type,
                     :ipv4_1,
                     :ipv4_2,
                     :ipv4_3,
                     :ipv4_4,
                     :fqdn_1,
                     :fqdn_2,
                     :fqdn_3,
                     :fqdn_4
                   ])
end

Instance Method Details

#handle_event(event) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/threatinator/plugins/output/csv.rb', line 29

def handle_event(event)
  @csv.add_row([
    event.feed_provider,
    event.feed_name,
    event.type,
    event.ipv4s[0],
    event.ipv4s[1],
    event.ipv4s[2],
    event.ipv4s[3],
    event.fqdns[0],
    event.fqdns[1],
    event.fqdns[2],
    event.fqdns[3]
  ])
end