Class: Dradis::Plugins::Nessus::FieldProcessor

Inherits:
Upload::FieldProcessor
  • Object
show all
Defined in:
lib/dradis/plugins/nessus/field_processor.rb

Instance Method Summary collapse

Instance Method Details

#post_initialize(args = {}) ⇒ Object



7
8
9
# File 'lib/dradis/plugins/nessus/field_processor.rb', line 7

def post_initialize(args={})
  @nessus_object = (data.name == 'ReportHost') ? ::Nessus::Host.new(data) : ::Nessus::ReportItem.new(data)
end

#value(args = {}) ⇒ Object



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
# File 'lib/dradis/plugins/nessus/field_processor.rb', line 11

def value(args={})
  field = args[:field]

  # fields in the template are of the form <foo>.<field>, where <foo>
  # is common across all fields for a given template (and meaningless).
  _, name = field.split('.')

  if name.end_with?('entries')
    # report_item.bid_entries
    # report_item.cve_entries
    # report_item.xref_entries
    entries = @nessus_object.try(name)
    if entries.any?
      entries.to_a.join("\n")
    else
      'n/a'
    end
  else
    output = @nessus_object.try(name) || 'n/a'

    if field == 'report_item.description' && output =~ /^\s+-/
      format_bullet_point_lists(output)
    else
      output
    end
  end
end