Class: Dradis::Plugins::Qualys::Vuln::Importer

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Importer

Returns a new instance of Importer.



20
21
22
23
# File 'lib/dradis/plugins/qualys/vuln/importer.rb', line 20

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

Instance Attribute Details

#host_nodeObject

Returns the value of attribute host_node.



14
15
16
# File 'lib/dradis/plugins/qualys/vuln/importer.rb', line 14

def host_node
  @host_node
end

Class Method Details

.templatesObject



16
17
18
# File 'lib/dradis/plugins/qualys/vuln/importer.rb', line 16

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



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dradis/plugins/qualys/vuln/importer.rb', line 28

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

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

  if @doc.root.name != 'SCAN'
    error = "No scan results were detected in the uploaded file. Ensure you uploaded a Qualys XML file."
    logger.fatal{ error }
    content_service.create_note text: error
    return false
  end

  @doc.xpath('SCAN/IP').each do |xml_host|
    process_ip(xml_host)
  end

  logger.info { 'Qualys Vuln file successfully imported' }
  return true
end