Skip to content

Commit 4933778

Browse files
committed
Adapt to github upstream data bug
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
1 parent 259bacb commit 4933778

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

vulnerabilities/importers/github.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ def process_name(ecosystem: str, pkg_name: str) -> Optional[Tuple[Optional[str],
155155
return ns, name
156156

157157
if ecosystem == "COMPOSER":
158-
vendor, name = pkg_name.split("/")
158+
try:
159+
vendor, name = pkg_name.split("/")
160+
except ValueError:
161+
# TODO log this
162+
return None
159163
return vendor, name
160164

161165
if ecosystem == "NUGET" or ecosystem == "PIP" or ecosystem == "RUBYGEMS":

vulnerabilities/package_managers.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,18 @@ async def load_api(self, pkg_set):
309309

310310
async def fetch(self, pkg, session) -> None:
311311
endpoint = self.composer_url(pkg)
312-
resp = await session.request(method="GET", url=endpoint)
313-
resp = await resp.json()
314-
self.cache[pkg] = self.extract_versions(resp, pkg)
312+
if endpoint:
313+
resp = await session.request(method="GET", url=endpoint)
314+
resp = await resp.json()
315+
self.cache[pkg] = self.extract_versions(resp, pkg)
315316

316317
@staticmethod
317318
def composer_url(pkg_name: str) -> str:
318-
vendor, name = pkg_name.split("/")
319+
try:
320+
vendor, name = pkg_name.split("/")
321+
except ValueError:
322+
# TODO Log this
323+
return None
319324
return f"https://repo.packagist.org/p/{vendor}/{name}.json"
320325

321326
@staticmethod

0 commit comments

Comments
 (0)