Class: Dradis::Plugins::Netsparker::Importer

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.templatesObject



3
4
5
# File 'lib/dradis/plugins/netsparker/importer.rb', line 3

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



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dradis/plugins/netsparker/importer.rb', line 10

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

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

  if @doc.xpath('/netsparker').empty?
    error = 'No scan results were detected in the uploaded file (/netsparker). Ensure you uploaded an Netsparker XML report.'
    logger.fatal { error }
    content_service.create_note text: error
    return false
  end

  @doc.xpath('/netsparker/target').each do |xml_host|
    process_report_host(xml_host)
  end

  return true
end