Skip to content

Commit

Permalink
Merge pull request #29 from fosslight/dev2
Browse files Browse the repository at this point in the history
Do not print comment if there is no information from OWASP
  • Loading branch information
bjk7119 authored Jan 6, 2022
2 parents 8aaa528 + e9a4f79 commit b9d9e87
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
17 changes: 9 additions & 8 deletions src/fosslight_binary/_jar_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ 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}")
Expand Down
29 changes: 22 additions & 7 deletions src/fosslight_binary/binary_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
_error_logs = []
_root_path = ""
_start_time = ""
windows = False


def init(path_to_find_bin, output_file_name, format):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 = ""
Expand All @@ -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()
Expand Down

0 comments on commit b9d9e87

Please sign in to comment.