Skip to content

Commit d55ea1a

Browse files
committed
Minor modification to append comment
1 parent a08b9df commit d55ea1a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/fosslight_binary/_binary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_vulnerability_items(self, oss):
5454
nvd_url = ", ".join(nvd_url).strip()
5555

5656
if nvd_url and len(nvd_url) > MAX_EXCEL_URL_LENGTH:
57-
oss.comment += f"\nExceeded the maximum vulnerability URL length of {MAX_EXCEL_URL_LENGTH} characters."
57+
oss.comment = f"Exceeded the maximum vulnerability URL length of {MAX_EXCEL_URL_LENGTH} characters."
5858
return nvd_url
5959

6060
def get_print_binary_only(self):

src/fosslight_binary/_jar_analysis.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ def get_oss_info_from_pkg_info(pkg_info):
166166

167167

168168
def analyze_jar_file(path_to_find_bin, path_to_exclude):
169-
remove_owasp_item = []
170169
owasp_items = {}
171170
remove_vulnerability_items = []
172171
vulnerability_items = {}
@@ -261,14 +260,22 @@ def analyze_jar_file(path_to_find_bin, path_to_exclude):
261260
vulnerability_items = get_vulnerability_info(file_with_path, vulnerability, vulnerability_items, remove_vulnerability_items)
262261

263262
if oss_name != "" or oss_ver != "" or oss_license != "" or oss_dl_url != "":
264-
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
265-
oss.comment = "OWASP result"
263+
oss_list_for_file = owasp_items.get(file_with_path, [])
266264

267-
remove_owasp_item = owasp_items.get(file_with_path)
268-
if remove_owasp_item:
269-
remove_owasp_item.append(oss)
270-
else:
271-
owasp_items[file_with_path] = [oss]
265+
existing_oss = None
266+
for item in oss_list_for_file:
267+
if item.name == oss_name and item.version == oss_ver:
268+
existing_oss = item
269+
break
270+
271+
if not existing_oss:
272+
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
273+
oss.comment = "OWASP result"
274+
275+
if file_with_path in owasp_items:
276+
owasp_items[file_with_path].append(oss)
277+
else:
278+
owasp_items[file_with_path] = [oss]
272279
except Exception as ex:
273280
logger.debug(f"Error to get depency Info in jar_contets: {ex}")
274281
success = False

0 commit comments

Comments
 (0)