File tree Expand file tree Collapse file tree
vulnerabilities/importers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
109from pathlib import Path
1110from typing import Set
1211
1817from vulnerabilities .importer import AffectedPackage
1918from vulnerabilities .importer import Importer
2019from vulnerabilities .importer import Reference
20+ from vulnerabilities .utils import is_cve
2121from vulnerabilities .utils import load_yaml
2222
23- logger = logging .getLogger (__name__ )
24-
2523
2624class 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 ],
You can’t perform that action at this time.
0 commit comments