Skip to content

Commit 60e49f4

Browse files
committed
Add pipeline for adding advisory ID and tests
Signed-off-by: Tushar Goel <[email protected]>
1 parent 89770c8 commit 60e49f4

35 files changed

+331
-4
lines changed

vulnerabilities/importer.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,21 @@ class Importer:
377377
# It needs to be unique and immutable
378378
importer_name = ""
379379

380+
def get_advisory_id(self, aliases: list[str]) -> str:
381+
"""
382+
Return the Advisory ID for the given aliases.
383+
"""
384+
raise NotImplementedError
385+
386+
def get_cve_id(self, aliases: list[str]) -> str:
387+
"""
388+
Return the CVE ID for the given aliases.
389+
"""
390+
for alias in aliases:
391+
if alias.startswith("CVE-"):
392+
return alias
393+
return None
394+
380395
def __init__(self):
381396
if not self.spdx_license_expression:
382397
raise Exception(f"Cannot run importer {self!r} without a license")

vulnerabilities/importers/apache_httpd.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class ApacheHTTPDImporter(Importer):
3838
license_url = "https://www.apache.org/licenses/LICENSE-2.0"
3939
importer_name = "Apache HTTPD Importer"
4040

41+
def get_advisory_id(self, aliases: list[str]) -> str:
42+
"""
43+
Return the Advisory ID for the given aliases.
44+
"""
45+
return self.get_cve_id(aliases)
46+
4147
def advisory_data(self):
4248
links = fetch_links(self.base_url)
4349
for link in links:

vulnerabilities/importers/apache_kafka.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ def fetch_advisory_page(self):
102102
page = requests.get(self.GH_PAGE_URL)
103103
return page.content
104104

105+
def get_advisory_id(self, aliases: list[str]) -> str:
106+
"""
107+
Return the Advisory ID for the given aliases.
108+
"""
109+
return self.get_cve_id(aliases)
110+
105111
def advisory_data(self):
106112
advisory_page = self.fetch_advisory_page(self)
107113

vulnerabilities/importers/apache_tomcat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ class ApacheTomcatImporter(Importer):
120120
license_url = "https://www.apache.org/licenses/LICENSE-2.0"
121121
importer_name = "Apache Tomcat Importer"
122122

123+
def get_advisory_id(self, aliases: list[str]) -> str:
124+
"""
125+
Return the Advisory ID for the given aliases.
126+
"""
127+
return self.get_cve_id(aliases)
128+
123129
def fetch_advisory_pages(self):
124130
"""
125131
Yield the content of each HTML page containing version-related security data.

vulnerabilities/importers/archlinux.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class ArchlinuxImporter(Importer):
3030
license_url = "https://github.com/archlinux/arch-security-tracker/blob/master/LICENSE"
3131
importer_name = "Arch Linux Importer"
3232

33+
def get_advisory_id(self, aliases: list[str]) -> str:
34+
"""
35+
Return the Advisory ID for the given aliases.
36+
"""
37+
return self.get_cve_id(aliases)
38+
3339
def fetch(self) -> Iterable[Mapping]:
3440
response = fetch_response(self.url)
3541
return response.json()

vulnerabilities/importers/curl.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class CurlImporter(Importer):
3939
importer_name = "Curl Importer"
4040
api_url = "https://curl.se/docs/vuln.json"
4141

42+
def get_advisory_id(self, aliases: list[str]) -> str:
43+
"""
44+
Return the Advisory ID for the given aliases.
45+
"""
46+
return self.get_cve_id(aliases)
47+
4248
def fetch(self) -> Iterable[Mapping]:
4349
response = fetch_response(self.api_url)
4450
return response.json()

vulnerabilities/importers/debian.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class DebianImporter(Importer):
8282
api_url = "https://security-tracker.debian.org/tracker/data/json"
8383
importer_name = "Debian Importer"
8484

85+
def get_advisory_id(self, aliases: list[str]) -> str:
86+
"""
87+
Return the Advisory ID for the given aliases.
88+
"""
89+
return self.get_cve_id(aliases)
90+
8591
def get_response(self):
8692
response = requests.get(self.api_url)
8793
if response.status_code == 200:

vulnerabilities/importers/debian_oval.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class DebianOvalImporter(OvalImporter):
5656
"""
5757
importer_name = "Debian Oval Importer"
5858

59+
def get_advisory_id(self, aliases: list[str]) -> str:
60+
"""
61+
Return the Advisory ID for the given aliases.
62+
"""
63+
return self.get_cve_id(aliases)
64+
5965
def __init__(self, *args, **kwargs):
6066
super().__init__(*args, **kwargs)
6167
# we could avoid setting translations, and have it

vulnerabilities/importers/elixir_security.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ def advisory_data(self) -> Set[AdvisoryData]:
4141
if self.vcs_response:
4242
self.vcs_response.delete()
4343

44+
def get_advisory_id(self, aliases: list[str]) -> str:
45+
"""
46+
Return the Advisory ID for the given aliases.
47+
"""
48+
return self.get_cve_id(aliases)
49+
4450
def process_file(self, file, base_path):
4551
relative_path = str(file.relative_to(base_path)).strip("/")
4652
advisory_url = (

vulnerabilities/importers/epss.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ class EPSSImporter(Importer):
2929
spdx_license_expression = "unknown"
3030
importer_name = "EPSS Importer"
3131

32+
def get_advisory_id(self, aliases: list[str]) -> str:
33+
"""
34+
Return the Advisory ID for the given aliases.
35+
"""
36+
return self.get_cve_id(aliases)
37+
3238
def advisory_data(self) -> Iterable[AdvisoryData]:
3339
response = urllib.request.urlopen(self.advisory_url)
3440
with gzip.open(response, "rb") as f:

0 commit comments

Comments
 (0)