clean it up
This commit is contained in:
parent
5ae8c85c7f
commit
5cdf3b0704
2 changed files with 15 additions and 1 deletions
|
@ -41,4 +41,9 @@ class RhelSecurityApiClient
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cve_id(cve_id)
|
||||||
|
params = {}
|
||||||
|
request("/cve/#{cve_id}.json", params)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ require 'optparse'
|
||||||
require 'json'
|
require 'json'
|
||||||
require './rhel_rpm_to_cve'
|
require './rhel_rpm_to_cve'
|
||||||
require './rhel_security_api_client'
|
require './rhel_security_api_client'
|
||||||
|
require 'pry'
|
||||||
|
|
||||||
ARGV << '-h' if ARGV.empty?
|
ARGV << '-h' if ARGV.empty?
|
||||||
|
|
||||||
|
@ -26,6 +27,9 @@ parser = OptionParser.new do |parser|
|
||||||
parser.on('-r', '--refresh', 'Refresh rpm-to-cve.xml file with latest pkgs and cves') do |_refresh|
|
parser.on('-r', '--refresh', 'Refresh rpm-to-cve.xml file with latest pkgs and cves') do |_refresh|
|
||||||
options[:refresh] = true
|
options[:refresh] = true
|
||||||
end
|
end
|
||||||
|
parser.on('-c', '--cve CVE_ID', 'Takes a cve id and returns cve json from redhats security API.') do |cve|
|
||||||
|
options[:cve] = cve
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.parse!
|
parser.parse!
|
||||||
|
@ -39,6 +43,7 @@ end
|
||||||
rpm_auditer = RhelRpmToCve.new(filepath: data_file)
|
rpm_auditer = RhelRpmToCve.new(filepath: data_file)
|
||||||
rhel_api_client = RhelSecurityApiClient.new
|
rhel_api_client = RhelSecurityApiClient.new
|
||||||
|
|
||||||
|
# this is getting long and nasty probably change this to a case statment
|
||||||
if xmlpkg_name
|
if xmlpkg_name
|
||||||
json = rpm_auditer.cves_per_pkg_name(xmlpkg_name).to_json
|
json = rpm_auditer.cves_per_pkg_name(xmlpkg_name).to_json
|
||||||
puts JSON.pretty_generate(JSON.parse(json))
|
puts JSON.pretty_generate(JSON.parse(json))
|
||||||
|
@ -49,6 +54,10 @@ elsif pkg_name
|
||||||
puts JSON.pretty_generate(cve_pkgs_and_adv)
|
puts JSON.pretty_generate(cve_pkgs_and_adv)
|
||||||
elsif options[:refresh]
|
elsif options[:refresh]
|
||||||
rpm_auditer.refresh_rpm_to_cve_file('./rpm-to-cve.xml')
|
rpm_auditer.refresh_rpm_to_cve_file('./rpm-to-cve.xml')
|
||||||
|
elsif options[:cve]
|
||||||
|
cve = options[:cve]
|
||||||
|
r = rhel_api_client.cve_id(cve)
|
||||||
|
puts JSON.pretty_generate(r)
|
||||||
else options.key?(:list)
|
else options.key?(:list)
|
||||||
puts rpm_auditer.list_pkg_names.sort
|
puts rpm_auditer.list_pkg_names.sort
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue