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 af4d485
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion assets/fickling-audit.py
Original file line number Diff line number Diff line change
@@ -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))
Expand Down

0 comments on commit af4d485

Please sign in to comment.