Skip to content

Commit 560e97f

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

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-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"\nExceeded 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: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,22 @@ def analyze_jar_file(path_to_find_bin, path_to_exclude):
261261
vulnerability_items = get_vulnerability_info(file_with_path, vulnerability, vulnerability_items, remove_vulnerability_items)
262262

263263
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"
266-
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]
264+
oss_list_for_file = owasp_items.get(file_with_path, [])
265+
266+
existing_oss = None
267+
for item in oss_list_for_file:
268+
if item.name == oss_name and item.version == oss_ver:
269+
existing_oss = item
270+
break
271+
272+
if not existing_oss:
273+
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
274+
oss.comment = "OWASP result"
275+
276+
if file_with_path in owasp_items:
277+
owasp_items[file_with_path].append(oss)
278+
else:
279+
owasp_items[file_with_path] = [oss]
272280
except Exception as ex:
273281
logger.debug(f"Error to get depency Info in jar_contets: {ex}")
274282
success = False

0 commit comments

Comments
 (0)