Add run_filecheck_single_file.py to scripts/

pull/21/head
Dan Puttick 2017-08-07 14:13:02 -04:00
parent d86f1f78f9
commit bc1ecf83ab
3 changed files with 30 additions and 2 deletions

View File

@ -520,7 +520,7 @@ class GroomerLogger(object):
)
if file_props['errors']:
error_string = ', '.join([str(key) for key in file_props['errors']])
log_string.append(' Errors: ' + error_string)
log_string += (' Errors: ' + error_string)
if in_tempdir:
depth -= 1
self._write_line_to_log(log_string, depth)

View File

@ -252,7 +252,6 @@ class FileBase(object):
mt = magic.from_file(file_path, mime=True)
# libmagic always returns something, even if it's just 'data'
except UnicodeEncodeError as e:
raise UnicodeEncodeError
self.add_error(e, '')
mt = None
try:

View File

@ -0,0 +1,29 @@
import sys
from bin.filecheck import File
PATH='tests/dangerous/bypass.docx'
# PATH='tests/normal/word_docx.docx'
def main():
try:
file = File(sys.argv[1], '')
except IndexError:
file = File(PATH, '')
file.check()
print(
"Name: " + file.filename,
"Desc: " + file.description_string,
"Mime: " + file.mimetype,
"Desc list: " + repr(file._description_string),
"Size: " + str(file.size),
"Src path: " + file.src_path,
"Is dangerous: " + str(file.is_dangerous),
sep='\n'
)
if __name__ == '__main__':
main()