diff --git a/bin/filecheck.py b/bin/filecheck.py index c3f2776..df3bd98 100644 --- a/bin/filecheck.py +++ b/bin/filecheck.py @@ -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) diff --git a/kittengroomer/helpers.py b/kittengroomer/helpers.py index 44e5002..847d3bc 100644 --- a/kittengroomer/helpers.py +++ b/kittengroomer/helpers.py @@ -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: diff --git a/scripts/run_filecheck_single_file.py b/scripts/run_filecheck_single_file.py new file mode 100644 index 0000000..7f62845 --- /dev/null +++ b/scripts/run_filecheck_single_file.py @@ -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()