Report empty files as own category/type.
This commit is contained in:
parent
422112e537
commit
d4ad5f96f8
|
@ -39,6 +39,7 @@ class FileClassification(Enum):
|
|||
LIBRARY = 1
|
||||
LIKELY_LIBRARY = 2
|
||||
APPLICATION = 3
|
||||
EMPTY_FILE = 4
|
||||
|
||||
def load_lib_identifiers():
|
||||
"""Initialize identifiers for known libraries from JSON file."""
|
||||
|
@ -98,6 +99,9 @@ def init_jsinfo(zipfile, js_file):
|
|||
'size': int(js_file.file_size),
|
||||
'path': js_file.filename
|
||||
}
|
||||
if js_info['size'] == 0:
|
||||
js_info['type'] = FileClassification.EMPTY_FILE
|
||||
|
||||
return js_info
|
||||
|
||||
def analyse_md5_checksum(zipfile, js_file, js_info):
|
||||
|
@ -212,6 +216,9 @@ def decompose_js(zipfile):
|
|||
for js_file in list(filter(lambda x: x.filename.endswith(".js"), zipfile.infolist())):
|
||||
js_info = init_jsinfo(zipfile, js_file)
|
||||
|
||||
if js_info['type'] == FileClassification.EMPTY_FILE:
|
||||
js_inventory.append(js_info)
|
||||
else:
|
||||
js_info_file = analyse_md5_checksum(zipfile, js_file, js_info)
|
||||
if not js_info_file:
|
||||
js_info_file = analyse_filename(zipfile, js_file, js_info)
|
||||
|
|
Loading…
Reference in New Issue