Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions hooks/hook-fosslight_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@
datas += datas_binaryornot
binaries += binaries_binaryornot
hiddenimports += hiddenimports_binaryornot

# Collect python-magic / python-magic-bin (magic database and DLLs)
datas_magic, binaries_magic, hiddenimports_magic = collect_all('magic')
datas += datas_magic
binaries += binaries_magic
hiddenimports += hiddenimports_magic

# Collect rfc3987_syntax data files (.lark grammar file)
datas_rfc, binaries_rfc, hiddenimports_rfc = collect_all('rfc3987_syntax')
datas += datas_rfc
binaries += binaries_rfc
hiddenimports += hiddenimports_rfc
6 changes: 3 additions & 3 deletions src/fosslight_binary/binary_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ def return_bin_only(file_list, need_checksum_tlsh=True):
if need_checksum_tlsh:
file_item.checksum, file_item.tlsh, error_msg = get_checksum_and_tlsh(file_item.bin_name_with_path)
if error_msg:
error_occured(modeerror_msg=error_msg, exit=False)
error_occured(error_msg=error_msg, exit=False)
yield file_item
except Exception as ex:
logger.debug(f"Exception in get_file_list: {ex}")
logger.debug(f"Exception in check_binary: {ex}")
file_item.comment = "Exclude or delete if it is not binary."
yield file_item

Expand All @@ -336,7 +336,7 @@ def check_binary(file_with_path, skip_remove_file_command_result: bool = False):
file_command_failed = True
if file_command_failed:
try:
file_command_result = magic.from_buffer(open(file_with_path).read(BYTES))
file_command_result = magic.from_buffer(open(file_with_path, 'rb').read(BYTES))
except Exception as ex:
logger.debug(f"Failed to check file type:{file_with_path}, {ex}")

Expand Down
Loading