Skip to content

Commit 5fcf2b7

Browse files
committed
Format code
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 0853bdb commit 5fcf2b7

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

vulnerabilities/importers/elixir_security.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from vulnerabilities.importer import Importer
2020
from vulnerabilities.importer import Reference
2121
from vulnerabilities.utils import load_yaml
22+
from vulnerabilities.utils import is_cve
2223

2324
logger = logging.getLogger(__name__)
2425

@@ -46,15 +47,18 @@ def process_file(self, path):
4647
cve_id = ""
4748
summary = yaml_file.get("description") or ""
4849
pkg_name = yaml_file.get("package") or ""
49-
if not pkg_name:
50-
return []
5150

5251
cve = yaml_file.get("cve") or ""
5352

5453
if cve and not cve.startswith("CVE-"):
55-
cve = yaml_file["cve"]
5654
cve_id = f"CVE-{cve}"
5755

56+
if not cve_id:
57+
return []
58+
59+
if not is_cve(cve_id):
60+
return []
61+
5862
references = []
5963
link = yaml_file.get("link") or ""
6064
if link:
@@ -82,18 +86,16 @@ def process_file(self, path):
8286
VersionConstraint.from_string(version_class=vrc, string=version).invert()
8387
)
8488

85-
affected_packages.append(
86-
AffectedPackage(
87-
package=PackageURL(
88-
type="hex",
89-
name=pkg_name,
90-
),
91-
affected_version_range=HexVersionRange(constraints=constraints),
89+
if pkg_name:
90+
affected_packages.append(
91+
AffectedPackage(
92+
package=PackageURL(
93+
type="hex",
94+
name=pkg_name,
95+
),
96+
affected_version_range=HexVersionRange(constraints=constraints),
97+
)
9298
)
93-
)
94-
95-
if not cve_id:
96-
return []
9799

98100
yield AdvisoryData(
99101
aliases=[cve_id],

0 commit comments

Comments
 (0)