From 0205a7ed03f9f2e2dd3c9c4b657916089e552142 Mon Sep 17 00:00:00 2001 From: Jaekwon Bang Date: Wed, 5 Jan 2022 13:40:47 +0900 Subject: [PATCH 1/3] If there is no info. from OWASP, the comment 'OWASP Result' is not printed --- src/fosslight_binary/_jar_analysis.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/fosslight_binary/_jar_analysis.py b/src/fosslight_binary/_jar_analysis.py index caf7318..a95820a 100644 --- a/src/fosslight_binary/_jar_analysis.py +++ b/src/fosslight_binary/_jar_analysis.py @@ -133,14 +133,16 @@ def ananlyze_jar_file(path_to_find_bin): if oss_ver == "" and (product_info['name'] == 'Implementation-Version' or product_info['name'] == 'Bundle-Version'): oss_ver = product_info['value'] - oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url) - oss.set_comment("OWASP Result. ") - - remove_owasp_item = owasp_items.get(file_with_path) - if remove_owasp_item: - remove_owasp_item.append(oss) - else: - owasp_items[file_with_path] = [oss] + + if oss_name != "" or oss_ver != "" or oss_license != "" or oss_dl_url != "": + oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url) + oss.set_comment("OWASP Result. ") + + remove_owasp_item = owasp_items.get(file_with_path) + if remove_owasp_item: + remove_owasp_item.append(oss) + else: + owasp_items[file_with_path] = [oss] except Exception as ex: logger.warning(f"Error to read json file : {ex}") From a0fe9a799531120438941f23f0d3984ef6d5d923 Mon Sep 17 00:00:00 2001 From: Soim Kim Date: Wed, 5 Jan 2022 13:33:11 +0900 Subject: [PATCH 2/3] Print the extension to the output file of the result log --- src/fosslight_binary/binary_analysis.py | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/fosslight_binary/binary_analysis.py b/src/fosslight_binary/binary_analysis.py index 0ed031b..45d1e35 100755 --- a/src/fosslight_binary/binary_analysis.py +++ b/src/fosslight_binary/binary_analysis.py @@ -39,6 +39,7 @@ _error_logs = [] _root_path = "" _start_time = "" +windows = False def init(path_to_find_bin, output_file_name, format): @@ -129,6 +130,8 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""): total_bin_cnt = 0 total_file_cnt = 0 db_loaded_cnt = 0 + success_to_write = False + writing_msg = "" try: if not os.path.isdir(path_to_find_bin): @@ -166,14 +169,25 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""): success_to_write, writing_msg = write_output_file(result_report, output_extension, sheet_list) - logger.info("Writing Output file(" + os.path.basename(result_report) + output_extension - + "):" + str(success_to_write) + " " + writing_msg) - if success_to_write: - _result_log["Output file"] = result_report + output_extension - except Exception as ex: error_occured(error_msg=str(ex), exit=False) + # Print Result + try: + output_files = [] + if output_extension == "": + output_extension = ".xlsx" + if not windows: + output_files.append(f"{result_report}.csv") + output_files.insert(0, f"{result_report}{output_extension}") + + logger.info(f"Writing Output file ({output_files[0]}" + f"):{success_to_write} {writing_msg}") + if success_to_write: + _result_log["Output file"] = output_files + except Exception as ex: + error_occured(error_msg=f"Print log:{ex}", exit=False) + print_result_log(success=True, result_log=_result_log, file_cnt=str(total_file_cnt), bin_file_cnt=str(total_bin_cnt), auto_bin_cnt=str(db_loaded_cnt)) @@ -241,6 +255,7 @@ def print_result_log(success=True, result_log={}, file_cnt="", bin_file_cnt="", def main(): + global windows argv = sys.argv[1:] output_dir = "" path_to_find_bin = "" @@ -265,9 +280,9 @@ def main(): except Exception: print_help_msg() - _windows = platform.system() == "Windows" + windows = platform.system() == "Windows" if path_to_find_bin == "": - if _windows: + if windows: path_to_find_bin = os.getcwd() else: print_help_msg() From e9a4f79c60a37d745e6b7d633e427d53efedae04 Mon Sep 17 00:00:00 2001 From: Jaekwon Bang Date: Wed, 5 Jan 2022 17:34:55 +0900 Subject: [PATCH 3/3] Do not print comment if there is no information from OWASP --- src/fosslight_binary/_jar_analysis.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fosslight_binary/_jar_analysis.py b/src/fosslight_binary/_jar_analysis.py index a95820a..e9636b5 100644 --- a/src/fosslight_binary/_jar_analysis.py +++ b/src/fosslight_binary/_jar_analysis.py @@ -133,7 +133,6 @@ def ananlyze_jar_file(path_to_find_bin): if oss_ver == "" and (product_info['name'] == 'Implementation-Version' or product_info['name'] == 'Bundle-Version'): oss_ver = product_info['value'] - if oss_name != "" or oss_ver != "" or oss_license != "" or oss_dl_url != "": oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url) oss.set_comment("OWASP Result. ")