can pull exploitability index now in the client

This commit is contained in:
Brendan McDevitt 2022-09-20 09:24:07 -05:00
parent e400ddc258
commit dadf386eb5

View file

@ -38,27 +38,33 @@ class MicrosoftCvrfClient
puts "Exception when calling DefaultApi->cvrf_id_get: #{e}"
end
# THREAT STRING SPECIFIC METHODS
# response from get_id()
def cves_and_threat_strings(response)
def cves_threat_strs(response)
response.vulnerability.map do |vuln|
threat_string = get_threat_string_for_vuln(vuln)
split_t_string = split_threat_string(threat_string)
#hashed_string = split_threat_string_to_hash(split_t_string)
[ vuln.cve, split_t_string ]
threat_str = get_threat_str_for_vuln(vuln)
split_t_str_arr = split_threat_str(threat_str)
hashed_t_str = threat_str_arr_to_hash(split_t_str_arr)
{ vuln.cve => hashed_t_str }
end
end
def get_threat_string_for_vuln(vuln)
def get_threat_str_for_vuln(vuln)
vuln.threats.select { |t| t.type == 1 }.first.description.value
end
def split_threat_string(threat_string)
threat_string.split(";")
def split_threat_str(threat_str)
threat_str.split(";")
end
# doesnt work
def split_threat_string_to_hash(split_threat_string)
Hash[*split_threat_string.flatten]
def threat_str_arr_to_hash(split_threat_str_arr)
arr_of_hash = split_threat_str_arr.map do |e|
spl_str = e.split(":")
k = spl_str[0]
v = spl_str[1]
{ k => v }
end
arr_of_hash.reduce Hash.new, :merge
end
end