make private methods and put query_cve method as main public method
This commit is contained in:
parent
0d49f92dbe
commit
fa13eeab27
1 changed files with 23 additions and 19 deletions
|
@ -64,6 +64,28 @@ class MicrosoftKbChecker
|
|||
'Windows Server 2012 R2',
|
||||
'Windows Server 2012 R2 (Server Core installation)'
|
||||
].freeze
|
||||
|
||||
def query_cve
|
||||
#TODO: handle error msg better
|
||||
if os_available?
|
||||
response = make_request
|
||||
if response.code == 200
|
||||
json = parse_json(response)
|
||||
os_results = select_os(json)
|
||||
if os_results.nil?
|
||||
'Product not found in response data.'
|
||||
else
|
||||
kbs_for_os(os_results)
|
||||
end
|
||||
else
|
||||
'Problem with HTTP response data.'
|
||||
end
|
||||
else
|
||||
'Operating system not found.'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def cve_url
|
||||
cve = options[:cve_id]
|
||||
|
@ -86,25 +108,7 @@ class MicrosoftKbChecker
|
|||
AVAILABLE_OS.include?(options[:os_name])
|
||||
end
|
||||
|
||||
def query_cve
|
||||
#TODO: handle error msg better
|
||||
if os_available?
|
||||
response = make_request
|
||||
if response.code == 200
|
||||
json = parse_json(response)
|
||||
os_results = select_os(json)
|
||||
if os_results.nil?
|
||||
'Product not found in response data.'
|
||||
else
|
||||
kbs_for_os(os_results)
|
||||
end
|
||||
else
|
||||
'Problem with HTTP response data.'
|
||||
end
|
||||
else
|
||||
'Operating system not found.'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def select_os(json)
|
||||
json.dig('affectedProducts').select do |os|
|
||||
|
|
Loading…
Add table
Reference in a new issue