2323from vulnerabilities .importer import AffectedPackageV2
2424from vulnerabilities .importer import ReferenceV2
2525from vulnerabilities .importer import VulnerabilitySeverity
26- from vulnerabilities .management .commands .commit_export import logger
2726from vulnerabilities .pipelines import VulnerableCodeBaseImporterPipelineV2
2827from vulnerabilities .severity_systems import GENERIC
2928
@@ -84,7 +83,7 @@ def process_file(self, file):
8483 affected_packages = []
8584 seen_packages = set ()
8685
87- for purl , constraint in get_affected_and_safe_purls (child ):
86+ for purl , constraint in get_affected_and_safe_purls (child , logger = self . log ):
8887 signature = (purl .to_string (), str (constraint ))
8988
9089 if signature not in seen_packages :
@@ -134,7 +133,7 @@ def cves_from_reference(reference):
134133 return cves
135134
136135
137- def extract_purls_and_constraints (pkg_name , pkg_ns , constraints , invert ):
136+ def extract_purls_and_constraints (pkg_name , pkg_ns , constraints , invert , logger ):
138137 for comparator , version , slot_value in constraints :
139138 qualifiers = {"slot" : slot_value } if slot_value else {}
140139 purl = PackageURL (type = "ebuild" , name = pkg_name , namespace = pkg_ns , qualifiers = qualifiers )
@@ -147,10 +146,10 @@ def extract_purls_and_constraints(pkg_name, pkg_ns, constraints, invert):
147146
148147 yield purl , constraint
149148 except InvalidVersion as e :
150- logger . error (f"InvalidVersion constraints version: { version } error:{ e } " )
149+ logger (f"InvalidVersion constraints version: { version } error:{ e } " )
151150
152151
153- def get_affected_and_safe_purls (affected_elem ):
152+ def get_affected_and_safe_purls (affected_elem , logger ):
154153 for pkg in affected_elem :
155154 name = pkg .attrib .get ("name" )
156155 if not name :
@@ -160,9 +159,11 @@ def get_affected_and_safe_purls(affected_elem):
160159 safe_constraints , affected_constraints = get_safe_and_affected_constraints (pkg )
161160
162161 yield from extract_purls_and_constraints (
163- pkg_name , pkg_ns , affected_constraints , invert = False
162+ pkg_name , pkg_ns , affected_constraints , invert = False , logger = logger
163+ )
164+ yield from extract_purls_and_constraints (
165+ pkg_name , pkg_ns , safe_constraints , invert = True , logger = logger
164166 )
165- yield from extract_purls_and_constraints (pkg_name , pkg_ns , safe_constraints , invert = True )
166167
167168
168169def get_safe_and_affected_constraints (pkg ):
0 commit comments