Skip to content

Commit 3a74be0

Browse files
committed
Format code
Signed-off-by: Tushar Goel <[email protected]>
1 parent 4b7b32a commit 3a74be0

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

vulnerabilities/importers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from vulnerabilities.importers import archlinux
1313
from vulnerabilities.importers import debian
1414
from vulnerabilities.importers import debian_oval
15-
from vulnerabilities.importers import gentoo
1615
from vulnerabilities.importers import elixir_security
16+
from vulnerabilities.importers import gentoo
1717
from vulnerabilities.importers import github
1818
from vulnerabilities.importers import gitlab
1919
from vulnerabilities.importers import istio

vulnerabilities/importers/elixir_security.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# See https://github.com/nexB/vulnerablecode for support or download.
77
# See https://aboutcode.org for more information about nexB OSS projects.
88
#
9-
import logging
109
from pathlib import Path
1110
from typing import Set
1211

@@ -18,10 +17,9 @@
1817
from vulnerabilities.importer import AffectedPackage
1918
from vulnerabilities.importer import Importer
2019
from vulnerabilities.importer import Reference
20+
from vulnerabilities.utils import is_cve
2121
from vulnerabilities.utils import load_yaml
2222

23-
logger = logging.getLogger(__name__)
24-
2523

2624
class ElixirSecurityImporter(Importer):
2725

@@ -46,15 +44,18 @@ def process_file(self, path):
4644
cve_id = ""
4745
summary = yaml_file.get("description") or ""
4846
pkg_name = yaml_file.get("package") or ""
49-
if not pkg_name:
50-
return []
5147

5248
cve = yaml_file.get("cve") or ""
5349

5450
if cve and not cve.startswith("CVE-"):
55-
cve = yaml_file["cve"]
5651
cve_id = f"CVE-{cve}"
5752

53+
if not cve_id:
54+
return []
55+
56+
if not is_cve(cve_id):
57+
return []
58+
5859
references = []
5960
link = yaml_file.get("link") or ""
6061
if link:
@@ -82,18 +83,16 @@ def process_file(self, path):
8283
VersionConstraint.from_string(version_class=vrc, string=version).invert()
8384
)
8485

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

9897
yield AdvisoryData(
9998
aliases=[cve_id],

0 commit comments

Comments
 (0)