Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pyvulnerabilitylookup/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def get_vendor_product_vulnerabilities(self, vendor: str, product: str,
return r.json()

def get_vendor_product_vulnerabilities_iter(self, vendor: str, product: str,
*, since: date | datetime) -> Generator[dict[str, Any]]:
*, since: date | datetime | None=None) -> Generator[dict[str, Any]]:
'''Iterate over the vulnerabilities per vendor and a specific product

:param vendor: A vendor owning products (must be in the known vendor list)
Expand All @@ -215,12 +215,14 @@ def get_vendor_product_vulnerabilities_iter(self, vendor: str, product: str,
per_page = 10
while True:
r = self.get_vendor_product_vulnerabilities(vendor, product, since=since, page=page, per_page=per_page)
# The format i the response is a dict with the source as key,
# The format in the response is a dict with the source as key,
# that contains a list [[ID, vulnerability], ...]
# we yield that last part
# we yield that last part appended with the source as a third element.
if not any(r.values()):
break
for vulnerabilities in r.values():
for origin, vulnerabilities in r.items():
for vulnerability in vulnerabilities:
vulnerability.append(origin)
yield from vulnerabilities
page += 1

Expand Down
Loading