Skip to content

Commit

Permalink
fickling-audit.py: print exception to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed Nov 8, 2024
1 parent 4108a67 commit cccba49
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion assets/fickling-audit.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
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():
Expand All @@ -14,6 +21,7 @@ def main():
for f in all_changed_files:
if is_pickle_unsafe(f):
print("""H:%s:0 This pickle might contain unsafe contructs""" % (f))
print("""H:%s:0 This pickle might contain unsafe contructs""" % (f), file=sys.stderr)

if __name__ == "__main__":
main()

0 comments on commit cccba49

Please sign in to comment.