From b42072baf32962acb849cb3e8bbf30ac8bb1f27b Mon Sep 17 00:00:00 2001 From: Riccardo Porreca Date: Mon, 6 Nov 2023 15:29:29 +0100 Subject: [PATCH] OSS: Exclude qualifiers for Conda packages (#145) * As a possible approach to mitigate sonatype-nexus-community/ossindex-python#19 --- jake/command/oss.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/jake/command/oss.py b/jake/command/oss.py index f70a4d0..e8ac071 100644 --- a/jake/command/oss.py +++ b/jake/command/oss.py @@ -44,6 +44,16 @@ from . import parser_selector + +def _oss_component_purl(c: OssIndexComponent) -> PackageURL: + purl: PackageURL = c.purl + if purl.qualifiers and purl.type == "conda": + purl_dict = purl.to_dict() + purl_dict["qualifiers"] = None + purl = PackageURL(**purl_dict) + return purl + + class OssCommand(BaseCommand): _console: Console @@ -81,9 +91,8 @@ def handle_args(self) -> int: progress.update(task_query_ossi, completed=2, description='Cleared OSS Index local cache') progress.update(task_query_ossi, completed=3, description='Querying OSS Index for details on your packages') - oss_index_results = oss.get_component_report( - packages=list(map(lambda c: c.purl, filter(lambda c: c.purl, parser.get_components()))) + packages=list(map(_oss_component_purl, filter(lambda c: c.purl, parser.get_components()))) ) if self.arguments.oss_whitelist_json_file: @@ -120,7 +129,7 @@ def handle_args(self) -> int: for component in parser.get_components(): if component.purl: oss_index_component: OssIndexComponent = list(filter( - lambda oic_: oic_.get_package_url().to_string() == cast(PackageURL, component.purl).to_string(), + lambda oic_: oic_.get_package_url().to_string() == cast(PackageURL, _oss_component_purl(component)).to_string(), oss_index_results )).pop() else: