Sha256: ba9f6a826a548b0bef03f99533951ed1197a73310f44f3ed61cd6c1e45e4f1fe

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

module Dradis
  module Plugins
    module Nessus

      class FieldProcessor < Dradis::Plugins::Upload::FieldProcessor

        def post_initialize(args={})
          @nessus_object = (data.name == 'ReportHost') ? ::Nessus::Host.new(data) : ::Nessus::ReportItem.new(data)
        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('.')

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

            if field == 'report_item.description' && output =~ /^  -/
              format_bullet_point_lists(output)
            else
              output
            end
          end
        end

        private
        def format_bullet_point_lists(input)
          input.split("\n").map do |paragraph|
            if paragraph =~ /^  - (.*)$/m
              '* ' + $1.gsub(/    /, '').gsub(/\n/, ' ')
            else
              paragraph
            end
          end.join("\n\n")
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dradis-nessus-3.14.0 lib/dradis/plugins/nessus/field_processor.rb
dradis-nessus-3.13.0 lib/dradis/plugins/nessus/field_processor.rb
dradis-nessus-3.12.0 lib/dradis/plugins/nessus/field_processor.rb
dradis-nessus-3.11.0 lib/dradis/plugins/nessus/field_processor.rb
dradis-nessus-3.10.1 lib/dradis/plugins/nessus/field_processor.rb
dradis-nessus-3.9.0 lib/dradis/plugins/nessus/field_processor.rb