Created
May 17, 2022 01:15
-
-
Save sfowl/b080ce94c973959c1c9186e621849eb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import csv | |
import sys | |
import rhsda | |
client = rhsda.ApiClient(logLevel="DEBUG") | |
params = { | |
"after": "2017-05-02", | |
"product": "Enterprise Linux", | |
"severity": "critical", | |
} | |
cves = client.cve_search_query(params, outFormat="list") | |
data = client.mget_cves( | |
cves=cves, numThreads=16, outFormat="json", product="Enterprise Linux" | |
) | |
advisory_to_cve_map = dict() | |
for cve in data: | |
for advisory in cve.get("affected_release", []): | |
if advisory["product_name"].startswith("Red Hat Enterprise Linux"): | |
advisory_id = advisory["advisory"] | |
try: | |
advisory_to_cve_map[advisory_id]["cves"].append(cve) | |
except KeyError: | |
advisory_info = { | |
"cves": [cve], | |
} | |
advisory_info.update(advisory) | |
advisory_to_cve_map[advisory_id] = advisory_info | |
items = [] | |
for i, a in sorted(advisory_to_cve_map.items()): | |
items.append([i, a["product_name"], a["cpe"], a["package"], a["release_date"]]) | |
writer = csv.writer(sys.stdout) | |
writer.writerow(["Advisory ID", "Product Name", "CPE", "Package", "Release Date"]) | |
writer.writerows(sorted(items)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rhsda
module comes from here: https://github.com/RedHatProductSecurity/cve-pylib#working-with-backend-rhsda-library