Skip to content

Commit

Permalink
Merge pull request #12 from fosslight/cover
Browse files Browse the repository at this point in the history
Add scanner info sheet
  • Loading branch information
soimkim authored Jun 2, 2024
2 parents abe64ef + 70f1a42 commit 4ef8a8d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/fosslight_android/_write_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@
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',
'License Text', 'Exclude', 'Comment', 'Need Check', 'TLSH', 'SHA1']
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)
Expand All @@ -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']
Expand All @@ -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.")
7 changes: 6 additions & 1 deletion src/fosslight_android/android_binary_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -856,7 +857,11 @@ 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)
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

Expand Down

0 comments on commit 4ef8a8d

Please sign in to comment.