Sha256: e7df276767bc3c8e02f47ed7e95330428d34fc48ac46912e1a6603c6422ac000

Contents?: true

Size: 1.77 KB

Versions: 19

Compression:

Stored size: 1.77 KB

Contents

module OpenVAS::V7

  # The format is given by the OMPv5 :get_reports call (OpenVASv7 uses OMPv5).
  #
  # See:
  #   http://www.openvas.org/omp-5-0.html#command_get_reports
  class Result < ::OpenVAS::Result


    private
    # This method parses the <tags> tag of the <result> entry and extracts the
    # available fields. Previous versions of the format (e.g. OpenVAS v6)
    # included these embedded fields in the <description> tag instead of the
    # <tags> tag, hence the not-so-intuitive name.
    def description_fields
      if @tag_fields.nil?
        delimiters = {
          # Not supported via .fields
          'cvss_base_vector=' => :cvss_base_vector,
          'impact=' => :impact,
          'solution_type=' => :solution_type,

          # Not supported via .fields
          'affected=' => :affected_software,
          'insight=' => :insight,
          'solution=' => :solution,
          'summary=' => :summary,
          'vuldetect=' => :vuldetect

          # Missing fields, these used to be available under <description> but it
          # doesn't look like they are under <tags>
          # 'Impact Level:' => :impact_level,
          # 'Information that was gathered:' => :info_gathered,
        }

        @tag_fields = {}
        current_field = nil
        buffer = ''
        clean_line = nil

        @xml.at_xpath('./nvt/tags').text().split('|').each do |tag_line|
          clean_line = tag_line.lstrip

          if clean_line.empty?
            buffer << "\n"
            next
          end

          delimiters.keys.each do |tag_name|
            if tag_line.starts_with?(tag_name)
              @tag_fields[delimiters[tag_name]] = clean_line[tag_name.length..-1]
              next
            end
          end
        end
      end

      @tag_fields
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
dradis-openvas-4.15.0 lib/openvas/v7/result.rb
dradis-openvas-4.14.0 lib/openvas/v7/result.rb
dradis-openvas-4.13.0 lib/openvas/v7/result.rb
dradis-openvas-4.11.0 lib/openvas/v7/result.rb
dradis-openvas-4.10.0 lib/openvas/v7/result.rb
dradis-openvas-4.9.0 lib/openvas/v7/result.rb
dradis-openvas-4.8.0 lib/openvas/v7/result.rb
dradis-openvas-4.7.0 lib/openvas/v7/result.rb
dradis-openvas-4.6.0 lib/openvas/v7/result.rb
dradis-openvas-4.5.0 lib/openvas/v7/result.rb
dradis-openvas-4.4.0 lib/openvas/v7/result.rb
dradis-openvas-4.3.0 lib/openvas/v7/result.rb
dradis-openvas-4.2.0 lib/openvas/v7/result.rb
dradis-openvas-4.1.0 lib/openvas/v7/result.rb
dradis-openvas-4.0.0 lib/openvas/v7/result.rb
dradis-openvas-3.22.0 lib/openvas/v7/result.rb
dradis-openvas-3.21.0 lib/openvas/v7/result.rb
dradis-openvas-3.20.0 lib/openvas/v7/result.rb
dradis-openvas-3.19.0 lib/openvas/v7/result.rb