Sha256: e067995480ecf7a002f65b790dd45535fd8565cac1c8dddfa031831404bad0cd

Contents?: true

Size: 1.5 KB

Versions: 22

Compression:

Stored size: 1.5 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 =~ /^\s+-/
              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 =~ /(.*)\s+:\s*$/m
              $1 + ':'
            elsif paragraph =~ /^\s+-\s+(.*)$/m
              '* ' + $1.gsub(/\s{3,}/, ' ').gsub(/\n/, ' ')
            else
              paragraph
            end
          end.join("\n")
        end
      end

    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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