Class: Dradis::Plugins::Qualys::Asset::Importer
- Inherits:
-
Upload::Importer
- Object
- Upload::Importer
- Dradis::Plugins::Qualys::Asset::Importer
- Defined in:
- lib/dradis/plugins/qualys/asset/importer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#import(params = {}) ⇒ Object
The framework will call this function if the user selects this plugin from the dropdown list and uploads a file.
-
#initialize(args = {}) ⇒ Importer
constructor
A new instance of Importer.
Constructor Details
Class Method Details
.templates ⇒ Object
15 16 17 |
# File 'lib/dradis/plugins/qualys/asset/importer.rb', line 15 def self.templates { evidence: 'asset_evidence', issue: 'asset_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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dradis/plugins/qualys/asset/importer.rb', line 29 def import(params={}) file_content = File.read( params[:file] ) logger.info { 'Parsing Qualys ASSET XML output file...' } doc = Nokogiri::XML(file_content) logger.info { 'Done.' } if doc.root.name != ROOT_PATH_NAME error = 'No scan results were detected in the uploaded file. Ensure you uploaded a Qualys ASSET XML file.' logger.fatal { error } content_service.create_note text: error return false end doc.xpath('ASSET_DATA_REPORT/GLOSSARY/VULN_DETAILS_LIST/VULN_DETAILS').each do |xml_issue| process_issue(xml_issue) end doc.xpath('ASSET_DATA_REPORT/HOST_LIST/HOST').each do |xml_node| process_node(xml_node) end true end |