diff --git a/assets/fickling-audit.py b/assets/fickling-audit.py index a3f690e7..3b9694fc 100644 --- a/assets/fickling-audit.py +++ b/assets/fickling-audit.py @@ -1,16 +1,25 @@ import fickling +from fickling.fickle import PickleDecodeError, EmptyPickleError + from os import environ, path +import sys def is_pickle_unsafe(file_path): try: return not fickling.is_likely_safe(file_path) - except Exception: + except (NotImplementedError, PickleDecodeError, EmptyPickleError): + return False + except Exception as e: + # print exception on stderr + print("%s: (%s) %s" % (e.__class__.__qualname__, file_path, e), file=sys.stderr) return False def main(): with open(path.join(environ["SCRIPTPATH"], "all_changed_files.txt")) as all_changed_files: all_changed_files = [f for f in all_changed_files.read().split("\x00")] + print(all_changed_files, file=sys.stderr) + for f in all_changed_files: if is_pickle_unsafe(f): print("""H:%s:0 This pickle might contain unsafe contructs""" % (f))