def find_class(self, module, name):
        """Only allow safe classes from builtins"""
        package_name = module.split(".")[0]
        if package_name in safe_modules:
            return super().find_class(module, name)
        else:
            # Forbid everything else
            raise pickle.UnpicklingError("global '%s.%s' is forbidden" % (module, name))
Only allow safe classes from builtins
petastorm/etl/legacy.py