From d17398b56f2a052b934a6ab4631a9c43022c7f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Mon, 22 Apr 2024 10:56:01 +0200 Subject: [PATCH] new: [workers] Get recent CVEs for a product and a vendor by querying a vulnerability-lookup instance. --- freshermeat/workers/fetch_cve.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/freshermeat/workers/fetch_cve.py b/freshermeat/workers/fetch_cve.py index 3a48d16..a1bbf74 100644 --- a/freshermeat/workers/fetch_cve.py +++ b/freshermeat/workers/fetch_cve.py @@ -52,6 +52,30 @@ async def get_cve(*args, **kwargs): raise e +async def get_cve_vulnerability_lookup(*args, **kwargs): + """ + Get recent CVEs for a product and a vendor by querying a vulnerability-lookup instance: + https://vulnerability.circl.lu + """ + try: + request_kwargs = { + "verify": True, + "allow_redirects": True, + "timeout": 15, + "headers": {"User-Agent": "https://github.com/cedricbonhomme/freshermeat"}, + } + result = requests.get( + f"https://vulnerability.circl.lu/api/search/{args[0]}/{args[1]}", + **request_kwargs, + ) + logger.info(f"CVE for {args[2]} retrieved") + if result.status_code == 200: + return result.json()["cvelistv5"] + return [] + except Exception as e: + raise e + + async def insert_database(project): async with sem: logger.info(f"Retrieving CVE for {project.name}") -- 2.45.2