Class: Dradis::Plugins::Nexpose::Full::Importer

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Importer

Returns a new instance of Importer.



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

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

Class Method Details

.templatesObject



14
15
16
# File 'lib/dradis/plugins/nexpose/full/importer.rb', line 14

def self.templates
  { evidence: 'full_evidence', issue: 'full_vulnerability' }
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.



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

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

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

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

  process_full(doc)

  logger.info { 'NeXpose-Full format successfully imported' }
  true
end