From 02c3cf1c516965e291a2686880aad0d56ab17d9a Mon Sep 17 00:00:00 2001 From: Jaekwon Bang Date: Fri, 9 May 2025 15:36:58 +0900 Subject: [PATCH] Handling of exceeding max. url length --- src/fosslight_binary/_binary.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/fosslight_binary/_binary.py b/src/fosslight_binary/_binary.py index 4c41308..4aecf7d 100755 --- a/src/fosslight_binary/_binary.py +++ b/src/fosslight_binary/_binary.py @@ -4,9 +4,14 @@ # SPDX-License-Identifier: Apache-2.0 from fosslight_util.oss_item import FileItem import urllib.parse +import logging +import fosslight_util.constant as constant EXCLUDE_TRUE_VALUE = "Exclude" TLSH_CHECKSUM_NULL = "0" +MAX_EXCEL_URL_LENGTH = 255 + +logger = logging.getLogger(constant.LOGGER_NAME) class VulnerabilityItem: @@ -58,6 +63,11 @@ def get_print_array(self): lic = ",".join(oss.license) exclude = EXCLUDE_TRUE_VALUE if (self.exclude or oss.exclude) else "" nvd_url = self.get_vulnerability_items() + if nvd_url and len(nvd_url) > MAX_EXCEL_URL_LENGTH: + logger.info(f"self.source_name_or_path: {self.source_name_or_path}") + logger.info(f"oss name: {oss.name}") + logger.info(f"length_url:{len(nvd_url)}, nvd_url: {nvd_url}") + nvd_url = nvd_url[:242] + '...(truncated)' items.append([self.source_name_or_path, oss.name, oss.version, lic, oss.download_location, oss.homepage, oss.copyright, exclude, oss.comment,