Sha256: 31f1f37a139efb8e7d2a7969516a5b8f00dfa77cd25d797714a973f0a2a8e34f

Contents?: true

Size: 1.39 KB

Versions: 31

Compression:

Stored size: 1.39 KB

Contents

module Dradis::Plugins::OpenVAS

  # This processor defers to ::OpenVAS::Result class to extract all the
  # relevant information exposed through the :result template.
  class FieldProcessor < Dradis::Plugins::Upload::FieldProcessor

    def post_initialize(args={})

      # Figure out if v6 or v7
      @openvas_object = case detect_version(data)
                        when :v6
                          ::OpenVAS::V6::Result.new(data)
                        when :v7
                          ::OpenVAS::V7::Result.new(data)
                        end
    end

    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('.')

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

    private
    # There is no clear-cut way to determine the version of the file from the
    # contents (see thread below) so we have to do some guess work.
    #
    # See:
    #   http://lists.wald.intevation.org/pipermail/openvas-discuss/2014-October/006907.html
    #   http://lists.wald.intevation.org/pipermail/openvas-discuss/2014-November/007092.html
    def detect_version(xml_data)
      # Gross over simplification. May need to smarten in the future.
      xml_data.at_xpath('./description[contains(text(), "Summary:")]') ? :v6 : :v7
    end

  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
dradis-openvas-4.14.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.13.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.11.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.10.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.9.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.8.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.7.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.6.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.5.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.4.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.3.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.2.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.1.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-4.0.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-3.22.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-3.21.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-3.20.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-3.19.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-3.18.0 lib/dradis/plugins/openvas/field_processor.rb
dradis-openvas-3.17.0 lib/dradis/plugins/openvas/field_processor.rb