Class: Dradis::Plugins::OpenVAS::Importer

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.templatesObject



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

def self.templates
  { evidence: 'evidence', issue: 'result' }
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
30
31
32
33
34
# File 'lib/dradis/plugins/openvas/importer.rb', line 10

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

  # Parse contents
  logger.info{'Parsing OpenVAS output file...'}
  @doc = Nokogiri::XML(file_content)
  logger.info{'Done'}


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


  @doc.xpath('/report/report/results/result').each do |xml_result|
    process_result(xml_result)
  end

  logger.info{ "Report processed." }
  return true
end