Class: Dradis::Plugins::Nexpose::Simple::Importer

Inherits:
Upload::Importer
  • Object
show all
Defined in:
lib/dradis/plugins/nexpose/simple/importer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Importer

Returns a new instance of Importer.



17
18
19
20
# File 'lib/dradis/plugins/nexpose/simple/importer.rb', line 17

def initialize(args = {})
  args[:plugin] = Dradis::Plugins::Nexpose
  super(args)
end

Class Method Details

.templatesObject



13
14
15
# File 'lib/dradis/plugins/nexpose/simple/importer.rb', line 13

def self.templates
  {}
end

Instance Method Details

#import(params = {}) ⇒ Object

The framework will call this function if the user selects this plugin from the dropdown list and uploads a file.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dradis/plugins/nexpose/simple/importer.rb', line 25

def import(params = {})
  file_content = File.read( params[:file] )

  logger.info { 'Parsing NeXpose output file...' }
  doc = Nokogiri::XML(file_content)
  logger.info { 'Done.' }

  unless doc.root.name == 'NeXposeSimpleXML'
    error = "The document doesn't seem to be in either NeXpose-Simple or NeXpose-Full XML format. Ensure you uploaded a Nexpose XML report."
    logger.fatal{ error }
    content_service.create_note text: error
    return false
  end

  process_simple(doc)

  logger.info { 'NeXpose-Simple format uploaded successfully' }
  true
end