From e21ee75fe9b946657845ed7caf1cbb4f77613dec Mon Sep 17 00:00:00 2001 From: "jiyeong.seok" Date: Wed, 29 May 2024 17:17:40 +0900 Subject: [PATCH 1/2] Add scanner info sheet Signed-off-by: jiyeong.seok --- requirements.txt | 2 +- src/fosslight_android/_write_excel.py | 10 ++++++---- src/fosslight_android/android_binary_analysis.py | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 367ebf0..3064854 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -fosslight_util>=1.4.39 +fosslight_util>=1.4.40 fosslight_source>=1.6.16 fosslight_binary>=4.1.3 beautifulsoup4 diff --git a/src/fosslight_android/_write_excel.py b/src/fosslight_android/_write_excel.py index 3ec7e78..c41fa17 100644 --- a/src/fosslight_android/_write_excel.py +++ b/src/fosslight_android/_write_excel.py @@ -7,13 +7,13 @@ import logging from fosslight_util.write_txt import write_txt_file from fosslight_util.constant import LOGGER_NAME -from fosslight_util.write_excel import hide_column +from fosslight_util.write_excel import hide_column, write_cover_sheet logger = logging.getLogger(LOGGER_NAME) HIDDEN_HEADER = ['TLSH', 'SHA1'] -def write_result_to_excel(out_file_name, row_list): +def write_result_to_excel(out_file_name, row_list, cover=''): header_row = ['ID', 'Binary Name', 'Source Code Path', 'NOTICE.html', 'OSS Name', 'OSS Version', 'License', 'Download Location', 'Homepage', 'Copyright Text', @@ -21,6 +21,8 @@ def write_result_to_excel(out_file_name, row_list): sheet_name = "BIN (Android)" try: workbook = xlsxwriter.Workbook(out_file_name) + if cover: + write_cover_sheet(workbook, cover) worksheet = create_worksheet(workbook, sheet_name, header_row) write_result_to_sheet(worksheet, row_list) hide_column(worksheet, header_row, HIDDEN_HEADER) @@ -45,7 +47,7 @@ def create_worksheet(workbook, sheet_name, header_row): return worksheet -def write_result_to_txt_and_excel(out_excel_file, final_bin_info, out_txt_file): +def write_result_to_txt_and_excel(out_excel_file, final_bin_info, out_txt_file, cover=''): excel_list = [] final_str = ['Binary Name\tSource Code Path\tNOTICE.html\tOSS Name\tOSS Version\tLicense\tNeed ' 'Check\tComment\ttlsh\tchecksum'] @@ -60,6 +62,6 @@ def write_result_to_txt_and_excel(out_excel_file, final_bin_info, out_txt_file): sys.exit(1) success, error_msg = write_txt_file(out_txt_file, '\n'.join(final_str)) - write_result_to_excel(out_excel_file, excel_list) + write_result_to_excel(out_excel_file, excel_list, cover) else: logger.warning("Nothing is detected from the scanner so output file is not generated.") diff --git a/src/fosslight_android/android_binary_analysis.py b/src/fosslight_android/android_binary_analysis.py index 9d5a34c..05875f1 100755 --- a/src/fosslight_android/android_binary_analysis.py +++ b/src/fosslight_android/android_binary_analysis.py @@ -54,6 +54,7 @@ from fosslight_binary.binary_analysis import return_bin_only import argparse from pathlib import Path +from fosslight_util.cover import CoverItem EXCEPTIONAL_PATH = [r"(/)+gen/META/lic_intermediates/"] android_log_lines = [] @@ -856,7 +857,10 @@ def main(): from ._src_analysis import find_item_to_analyze final_bin_info = find_item_to_analyze(final_bin_info, python_script_dir, now, path_to_exclude) - write_result_to_txt_and_excel(result_excel_file, final_bin_info, result_txt_file) + cover = CoverItem(tool_name=PKG_NAME, + start_time=now, + input_path=python_script_dir) + write_result_to_txt_and_excel(result_excel_file, final_bin_info, result_txt_file, cover) result_log["Output FOSSLight Report"] = result_excel_file result_log["Output result text file"] = result_txt_file From 70f1a42ed739ed3f77063d7a75e3a0e62cba2b1d Mon Sep 17 00:00:00 2001 From: Soim Date: Sun, 2 Jun 2024 20:08:39 +0900 Subject: [PATCH 2/2] Add comment to cover sheet --- src/fosslight_android/android_binary_analysis.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fosslight_android/android_binary_analysis.py b/src/fosslight_android/android_binary_analysis.py index 05875f1..7d109dc 100755 --- a/src/fosslight_android/android_binary_analysis.py +++ b/src/fosslight_android/android_binary_analysis.py @@ -860,6 +860,7 @@ def main(): cover = CoverItem(tool_name=PKG_NAME, start_time=now, input_path=python_script_dir) + cover.comment = f"Total number of binaries: {len(final_bin_info)}" write_result_to_txt_and_excel(result_excel_file, final_bin_info, result_txt_file, cover) result_log["Output FOSSLight Report"] = result_excel_file result_log["Output result text file"] = result_txt_file