Skip to content

Instantly share code, notes, and snippets.

@sfowl
Created May 17, 2022 01:15
Show Gist options
  • Save sfowl/b080ce94c973959c1c9186e621849eb9 to your computer and use it in GitHub Desktop.
Save sfowl/b080ce94c973959c1c9186e621849eb9 to your computer and use it in GitHub Desktop.
#!/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))
@sfowl
Copy link
Author

sfowl commented May 17, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment