class Qualys::Vulnerability

Qualys vulnerabilities from a report xml

Attributes

category[RW]
correlation[RW]
cve_code_list[RW]
details[RW]
first_found[RW]
impact[RW]
last_found[RW]
last_update[RW]
pci_flag[RW]
port[RW]
protocol[RW]
qid[RW]
result[RW]
service[RW]
severity[RW]
solution[RW]
ssl[RW]
status[RW]
threat[RW]
times_found[RW]
title[RW]
type[RW]
url[RW]
vendor_reference_list[RW]

Public Class Methods

new(vuln, glossary) click to toggle source
# File lib/qualys/vulnerability.rb, line 12
def initialize(vuln, glossary)
  parse_vuln vuln

  match_details glossary

  parse_cve if @details['CVE_ID_LIST']
  parse_details
  # gives the url to the qualys knowledge base for this vulnerabitlty
  parse_url
end

Public Instance Methods

to_s() click to toggle source
# File lib/qualys/vulnerability.rb, line 23
def to_s
  "#{qid}, #{title}, severity : #{severity}, cves: #{cve_code_list&.join(', ') || 'no cve'}"
end

Private Instance Methods

match_details(glossary) click to toggle source

this methods finds the details for this qid in the report's glossary

# File lib/qualys/vulnerability.rb, line 39
def match_details(glossary)
  @details = glossary.select { |detail| detail['id'] == @qid }[0]
end
parse_cve() click to toggle source
# File lib/qualys/vulnerability.rb, line 29
def parse_cve
  cve_xlm_array = if @details['CVE_ID_LIST']['CVE_ID'].is_a?(Array)
                    @details['CVE_ID_LIST']['CVE_ID']
                  else
                    [@details['CVE_ID_LIST']['CVE_ID']]
                  end
  @cve_code_list = cve_xlm_array.map { |cve| cve['ID'] }
end
parse_details() click to toggle source
# File lib/qualys/vulnerability.rb, line 43
def parse_details
  @title = @details['TITLE']
  @severity = @details['SEVERITY']
  @category = @details['CATEGORY']
  @threat = @details['THREAT']
  @impact = @details['IMPACT']
  @solution = @details['SOLUTION']
  @pci_flag = @details['PCI_FLAG']
  @correlation = @details['CORRELATION']
  @vendor_reference_list = @details['VENDOR_REFERENCE_LIST']
  @last_update = @details['BUGTRAQ_ID_LIST']
end
parse_url() click to toggle source
# File lib/qualys/vulnerability.rb, line 56
def parse_url
  @url = 'https://qualysguard.qualys.eu/fo/common/vuln_info.php?id=' + @qid[4..-1]
end
parse_vuln(vuln) click to toggle source
# File lib/qualys/vulnerability.rb, line 60
def parse_vuln(vuln)
  @qid = vuln['QID']['id']
  @type = vuln['TYPE']
  @port = vuln['PORT']
  @service = vuln['SERVICE']
  @protocol = vuln['PROTOCOL']
  @ssl = vuln['SSL']
  @result = vuln['RESULT']
  @first_found = vuln['FIRST_FOUND']
  @last_found = vuln['LAST_FOUND']
  @times_found = vuln['TIMES_FOUND']
  @status = vuln['VULN_STATUS']
end