Sha256: b745611d7a26b2d97cb3fbd115bb00508d38849c09675b7c496a120186f6d8a6

Contents?: true

Size: 1.89 KB

Versions: 11

Compression:

Stored size: 1.89 KB

Contents

module Dradis
  module Plugins
    module Qualys
      class FieldProcessor < Dradis::Plugins::Upload::FieldProcessor

        def post_initialize(args={})
          case data.name
          when 'CAT'
            @cat_object = data
            @qualys_object = ::Qualys::Element.new(data.elements.first)
          when 'QID'
            @qualys_object = ::Qualys::WAS::QID.new(data)
          when 'VULNERABILITY'
            @qualys_object = ::Qualys::WAS::Vulnerability.new(data)
          when 'VULN_DETAILS'
            @qualys_object = ::Qualys::Asset::Vulnerability.new(data)
          when 'VULN_INFO'
            @qualys_object = ::Qualys::Asset::Evidence.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).
          # However we can use it to identify the type of scan we're processing.
          type, name = field.split('.')

          %{element evidence}.include?(type) ? value_network(name) : value_was(name)
        end

        private
        def value_network(name)
          if %w{cat_fqdn cat_misc cat_port cat_protocol cat_value}.include?(name)
            attribute = name[4..-1]
            @cat_object[attribute] || 'n/a'
          else

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

        def value_was(name)
          @qualys_object.try(name) || 'n/a'
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dradis-qualys-4.14.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.13.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.11.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.10.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.9.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.8.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.7.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.6.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.5.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.4.0 lib/dradis/plugins/qualys/field_processor.rb
dradis-qualys-4.3.0 lib/dradis/plugins/qualys/field_processor.rb