Added an RPM to CVE parser for RHEL
This commit is contained in:
parent
f5687cecbb
commit
40a745361e
3 changed files with 205908 additions and 0 deletions
43
rpm_to_cve_parser/rhel_rpm_to_cve.rb
Executable file
43
rpm_to_cve_parser/rhel_rpm_to_cve.rb
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
require 'ox'
|
||||||
|
|
||||||
|
class RhelRpmToCve
|
||||||
|
# filepath == /path/to/rpm-to-cve.xml
|
||||||
|
attr_accessor :filepath, :file, :xml
|
||||||
|
|
||||||
|
def initialize(filepath)
|
||||||
|
@filepath = filepath
|
||||||
|
@file = File.read(filepath)
|
||||||
|
@xml = Ox.load(file, mode: :hash)
|
||||||
|
end
|
||||||
|
|
||||||
|
def list_pkg_names
|
||||||
|
xml[:rpms][:rpm].map do |key|
|
||||||
|
key.first[:rpm]
|
||||||
|
end.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
def pkg_exists?(pkg_name)
|
||||||
|
list_pkg_names.include? pkg_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def cves_per_pkg_name(pkg_name)
|
||||||
|
if pkg_exists? pkg_name
|
||||||
|
results = find_pkg(pkg_name).map do |r|
|
||||||
|
r[:cve]
|
||||||
|
end.compact
|
||||||
|
|
||||||
|
{
|
||||||
|
:rhel_package_name => pkg_name,
|
||||||
|
:cves => results.map {|cve| cve}
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_pkg(pkg_name)
|
||||||
|
xml[:rpms][:rpm].select do |results|
|
||||||
|
results if results.first[:rpm] == pkg_name
|
||||||
|
end.first
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
205861
rpm_to_cve_parser/rpm-to-cve.xml
Normal file
205861
rpm_to_cve_parser/rpm-to-cve.xml
Normal file
File diff suppressed because it is too large
Load diff
4
rpm_to_cve_parser/update_rpms_to_cve_xml.sh
Executable file
4
rpm_to_cve_parser/update_rpms_to_cve_xml.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# refresh the latest rpm to cve xml mapping file from redhat security page
|
||||||
|
|
||||||
|
wget https://www.redhat.com/security/data/metrics/rpm-to-cve.xml .
|
Loading…
Add table
Reference in a new issue