From 3e2c0f8189af7c1bfe7a3bac58519cbef35e9390 Mon Sep 17 00:00:00 2001 From: Hritik Vijay Date: Sat, 27 Mar 2021 03:39:13 +0530 Subject: [PATCH] Use the canonical way of splitting name, version Mozilla website uses rsplit to extract the name and version so it should be better in any case. https://github.com/mozilla/bedrock/blob/765a60450235d810cf941676e4a29f012a9eaaba/bedrock/security/models.py#L29 Based on discussion here https://github.com/mozilla/foundation-security-advisories/issues/76 Signed-off-by: Hritik Vijay --- vulnerabilities/importers/mozilla.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vulnerabilities/importers/mozilla.py b/vulnerabilities/importers/mozilla.py index 4d45f9e78..1bca201b5 100644 --- a/vulnerabilities/importers/mozilla.py +++ b/vulnerabilities/importers/mozilla.py @@ -130,10 +130,9 @@ def get_package_urls(self, pkgs: List[str]) -> List[PackageURL]: package_urls = [ PackageURL( type="mozilla", - # TODO: Improve after https://github.com/mozilla/foundation-security-advisories/issues/76#issuecomment-803082182 # pkg is of the form "Firefox ESR 1.21" or "Thunderbird 2.21" - name=" ".join(pkg.split(" ")[0:-1]), - version=pkg.split(" ")[-1], + name=pkg.rsplit(None, 1)[0], + version=pkg.rsplit(None, 1)[1], ) for pkg in pkgs ]