class Qualys::Report
Qualys
reports
Constants
- TIMEOUT
accepted timeout in seconds
Attributes
appendices[RW]
glossary[RW]
header[RW]
host_list[RW]
Public Class Methods
create_global_report()
click to toggle source
returns the id of the report
# File lib/qualys/report.rb, line 40 def create_global_report scan_template = templates.detect { |template| template['TITLE'] == 'Technical Report' } response = api_post('/report/', query: { action: 'launch', report_title: 'Generated_by_Ruby_Qualys_gem', report_type: 'Scan', output_format: 'xml', template_id: scan_template['ID'] }) response.parsed_response['SIMPLE_RETURN']['RESPONSE']['ITEM_LIST']['ITEM']['VALUE'] end
delete(id)
click to toggle source
# File lib/qualys/report.rb, line 32 def delete(id) api_post('/report/', query: { action: 'delete', id: id }) end
find_by_id(id)
click to toggle source
# File lib/qualys/report.rb, line 12 def find_by_id(id) response = api_get('/report/', query: { action: 'fetch', id: id }) # check if report exist return unless response.parsed_response.keys.include?('ASSET_DATA_REPORT') Report.new(response.parsed_response) end
global_report()
click to toggle source
returns a report global report object. This method can be time consuming and times out after 64 s
# File lib/qualys/report.rb, line 55 def global_report report_id = create_global_report report = find_by_id(report_id) 10.times do sleep(TIMEOUT / 10) report = find_by_id(report_id) break unless report.nil? end raise Qualys::Report::Exception, 'Report generation timed out' if report.nil? delete(report_id) report end
new(report)
click to toggle source
# File lib/qualys/report.rb, line 72 def initialize(report) @header = report['ASSET_DATA_REPORT']['HEADER'] @host_list = report['ASSET_DATA_REPORT']['HOST_LIST']['HOST'] @glossary = report['ASSET_DATA_REPORT']['GLOSSARY']['VULN_DETAILS_LIST']['VULN_DETAILS'] @appendices = report['ASSET_DATA_REPORT']['APPENDICES'] end
templates()
click to toggle source
returns the list of the templates
# File lib/qualys/report.rb, line 25 def templates auth = { username: Qualys::Config.username, password: Qualys::Config.password } response = HTTParty.get('https://qualysapi.qualys.eu/msp/report_template_list.php', basic_auth: auth) response.parsed_response['REPORT_TEMPLATE_LIST']['REPORT_TEMPLATE'] end
Public Instance Methods
hosts()
click to toggle source
# File lib/qualys/report.rb, line 79 def hosts hosts ||= host_list.map do |xml_host| vulnerabilities = xml_host['VULN_INFO_LIST']['VULN_INFO'].map do |vuln| Qualys::Vulnerability.new(vuln, @glossary) end Qualys::Host.new(xml_host, vulnerabilities) end hosts end