added a way to fetch advisory too
This commit is contained in:
parent
a3a8fb0c1e
commit
204eba3321
1 changed files with 18 additions and 5 deletions
|
@ -41,14 +41,18 @@ parserr = OptionParser.new do |parser|
|
|||
'Refresh rpm-to-cve.xml file with latest pkgs and cves') do |_refresh|
|
||||
options[:refresh] = true
|
||||
end
|
||||
parser.on('-c', '--cve CVE_ID',
|
||||
parser.on('-c', '--cve CVE-2020-1234',
|
||||
'Takes a cve id and returns cve json from redhats security API.') do |cve|
|
||||
options[:cve] = cve
|
||||
end
|
||||
parser.on('-f', '--cves-from-file CVE_FILE',
|
||||
parser.on('-f', '--cves-from-file cves.txt',
|
||||
'Takes a file one cve id per line and sends a batch request to redhat security API') do |file|
|
||||
options[:file] = file
|
||||
end
|
||||
parser.on('-a', '--advisory RHSA-2019:0997',
|
||||
'Takes a RHSA advisory and sends an API request to redhat RHSA-2015:2155') do |advisory|
|
||||
options[:advisory] = advisory
|
||||
end
|
||||
end
|
||||
|
||||
parserr.parse!
|
||||
|
@ -63,20 +67,29 @@ if options[:xmlpkg_name]
|
|||
elsif options[:pkg]
|
||||
pkg = options[:pkg]
|
||||
params = { params: { package: pkg } }
|
||||
json = rhel_api_client.request('/cve.json', params)
|
||||
cve_pkgs_and_adv = rhel_api_client.cve_pkg_adv(json)
|
||||
json_pp(cve_pkgs_and_adv)
|
||||
response = rhel_api_client.request('/cve.json', params)
|
||||
|
||||
json = rhel_api_client.cve_pkg_adv(response)
|
||||
json_pp(json)
|
||||
elsif options[:refresh]
|
||||
rpm_auditer.refresh_rpm_to_cve_file('./data/rpm-to-cve.xml')
|
||||
elsif options[:cve]
|
||||
id = options[:cve]
|
||||
|
||||
json = rhel_api_client.cve_id(id)
|
||||
json_pp(json)
|
||||
elsif options[:file]
|
||||
filepath = options[:file]
|
||||
cve_ids = read_cves_file(filepath)
|
||||
|
||||
json = rhel_api_client.cve_ids(cve_ids)
|
||||
json_pp(json)
|
||||
elsif options[:list]
|
||||
puts rpm_auditer.list_pkg_names.sort
|
||||
elsif options[:advisory]
|
||||
advisory = options[:advisory]
|
||||
params = { params: { advisory: advisory } }
|
||||
|
||||
json = rhel_api_client.request('/cve.json', params)
|
||||
json_pp(json)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue