Class: Dradis::Plugins::Saint::FieldProcessor

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

Constant Summary collapse

ALLOWED_DATA_NAMES =
%w{evidence vulnerability host}

Instance Method Summary collapse

Instance Method Details

#post_initialize(args = {}) ⇒ Object



8
9
10
11
12
# File 'lib/dradis/plugins/saint/field_processor.rb', line 8

def post_initialize(args={})
  raise 'Unhandled data name!' unless ALLOWED_DATA_NAMES.include?(data.name)
  @saint_object =
    "::Saint::#{data.name.capitalize}".constantize.new(data)
end

#value(args = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dradis/plugins/saint/field_processor.rb', line 14

def value(args={})
  field = args[:field]
  _, name = field.split('.')

  # We cannot send the message 'class' to the saint_object because it
  # evaluates to the object's Ruby class. We temporarily rename the
  # field to 'vuln_class' and switch it back later when needed.
  if name == 'class'
    name = 'vuln_class'
  end

  @saint_object.try(name) || 'n/a'
end