added a script to pull down threat strings from a given bulletin-id
This commit is contained in:
parent
f8b79d06bb
commit
e400ddc258
2 changed files with 51 additions and 5 deletions
26
tools/microsoft/bin/get_cves_and_threat_strings_from_bulletin.rb
Executable file
26
tools/microsoft/bin/get_cves_and_threat_strings_from_bulletin.rb
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require '../microsoft_cvrf_client.rb'
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
|
@options = {}
|
||||||
|
|
||||||
|
OptionParser.new do |opts|
|
||||||
|
opts.on("-id", "--id", "Bulletin ID") do |id|
|
||||||
|
@options[:id] = id
|
||||||
|
end
|
||||||
|
end.parse!
|
||||||
|
|
||||||
|
bulletin_id = @options[:id]
|
||||||
|
api_client = MicrosoftCvrfClient.new
|
||||||
|
|
||||||
|
bulletin_response = api_client.get_id(bulletin_id)
|
||||||
|
|
||||||
|
cves_and_threat_strings = api_client.cves_and_threat_strings(bulletin_response)
|
||||||
|
|
||||||
|
cves_and_threat_strings.each do |cve, threat_strings|
|
||||||
|
puts "CVE: #{cve}"
|
||||||
|
puts "-------------------"
|
||||||
|
puts "THREAT_STRINGS: #{threat_strings}"
|
||||||
|
puts "-------------------"
|
||||||
|
end
|
|
@ -33,13 +33,33 @@ class MicrosoftCvrfClient
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_id(id)
|
def get_id(id)
|
||||||
p "Now checking #{id}"
|
api_instance.cvrf_id_get(api_version, api_key, id)
|
||||||
p "------------------"
|
|
||||||
result = api_instance.cvrf_id_get(api_version, api_key, id)
|
|
||||||
p result
|
|
||||||
rescue OpenapiClient::ApiError => e
|
rescue OpenapiClient::ApiError => e
|
||||||
puts "Exception when calling DefaultApi->cvrf_id_get: #{e}"
|
puts "Exception when calling DefaultApi->cvrf_id_get: #{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# response from get_id()
|
||||||
|
def cves_and_threat_strings(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 ]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_threat_string_for_vuln(vuln)
|
||||||
|
vuln.threats.select { |t| t.type == 1 }.first.description.value
|
||||||
|
end
|
||||||
|
|
||||||
|
def split_threat_string(threat_string)
|
||||||
|
threat_string.split(";")
|
||||||
|
end
|
||||||
|
|
||||||
|
# doesnt work
|
||||||
|
def split_threat_string_to_hash(split_threat_string)
|
||||||
|
Hash[*split_threat_string.flatten]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
c = MicrosoftCvrfClient.new
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue