class Threatinator::Plugins::Output::Json

Public Class Methods

new(config) click to toggle source
# File lib/threatinator/plugins/output/json.rb, line 12
def initialize(config)
  @output_file = config.file
  @first = true
  puts "{"
end

Public Instance Methods

finish() click to toggle source
# File lib/threatinator/plugins/output/json.rb, line 44
def finish
  puts "]}"
end
handle_event(event) click to toggle source
# File lib/threatinator/plugins/output/json.rb, line 18
def handle_event(event)
  if @first
    puts "\"header\" : #{MultiJson.dump(event.header.to_h)}"
    puts ",\"items\" : ["
    puts "{"
    @first = false
  else
    puts ",{"
  end
  delim = ""
  if event.ipv4s.size > 0
    puts "#{delim}\"ipv4s\" : #{MultiJson.dump(event.ipv4s.list)}"
    delim = ","
  end
  if event.fqdns.size > 0
    puts "#{delim}\"fqdns\" : #{MultiJson.dump(event.fqdns.list)}"
    delim = ","
  end
  if event.urls.size > 0
    puts "#{delim}\"urls\" : #{MultiJson.dump(event.urls.list)}"
    delim = ","
  end
  puts "}"

end