Class: Dradis::Plugins::Veracode::FieldProcessor

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

Instance Method Summary collapse

Instance Method Details

#post_initialize(args = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dradis/plugins/veracode/field_processor.rb', line 5

def post_initialize(args = {})
  @record =
    if data.is_a?(::Veracode::Flaw) || data.is_a?(::Veracode::Evidence) || data.is_a?(::Veracode::Vulnerability)
      data
    # Note: The evidence and flaw samples are the same but they need to
    # be differentiated in the plugins manager preview. In that case,
    # we're adding a "dradis_type" attribute in the evidence.sample file
    elsif data['dradis_type'] == 'evidence'
      ::Veracode::Evidence.new(data.at_xpath('./staticflaws/flaw'))
    elsif data.name == 'component'
      ::Veracode::Vulnerability.new(data.at_xpath('./vulnerabilities/vulnerability'))
    else
      ::Veracode::Flaw.new(data.at_xpath('./staticflaws/flaw'))
    end
end

#value(args = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/dradis/plugins/veracode/field_processor.rb', line 21

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

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

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