From 5fcf2b79b23c6e122e8bc44aae09bb58cab89b19 Mon Sep 17 00:00:00 2001 From: Tushar Goel Date: Thu, 5 Jan 2023 12:36:01 +0530 Subject: [PATCH] Format code Signed-off-by: Tushar Goel --- vulnerabilities/importers/elixir_security.py | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/vulnerabilities/importers/elixir_security.py b/vulnerabilities/importers/elixir_security.py index b9f069813..024db1920 100644 --- a/vulnerabilities/importers/elixir_security.py +++ b/vulnerabilities/importers/elixir_security.py @@ -19,6 +19,7 @@ from vulnerabilities.importer import Importer from vulnerabilities.importer import Reference from vulnerabilities.utils import load_yaml +from vulnerabilities.utils import is_cve logger = logging.getLogger(__name__) @@ -46,15 +47,18 @@ def process_file(self, path): cve_id = "" summary = yaml_file.get("description") or "" pkg_name = yaml_file.get("package") or "" - if not pkg_name: - return [] cve = yaml_file.get("cve") or "" if cve and not cve.startswith("CVE-"): - cve = yaml_file["cve"] cve_id = f"CVE-{cve}" + if not cve_id: + return [] + + if not is_cve(cve_id): + return [] + references = [] link = yaml_file.get("link") or "" if link: @@ -82,18 +86,16 @@ def process_file(self, path): VersionConstraint.from_string(version_class=vrc, string=version).invert() ) - affected_packages.append( - AffectedPackage( - package=PackageURL( - type="hex", - name=pkg_name, - ), - affected_version_range=HexVersionRange(constraints=constraints), + if pkg_name: + affected_packages.append( + AffectedPackage( + package=PackageURL( + type="hex", + name=pkg_name, + ), + affected_version_range=HexVersionRange(constraints=constraints), + ) ) - ) - - if not cve_id: - return [] yield AdvisoryData( aliases=[cve_id],