def call(__self, __context, __obj, *args, **kwargs): """Call an object from sandboxed code.""" # the double prefixes are to avoid double keyword argument # errors when proxying the call. if not __self.is_safe_callable(__obj): raise SecurityError('%r is not safely callable' % (__obj, )) return __context.call(__obj, *args, **kwargs)
def call(__self, __context, __obj, *args, **kwargs): """Call an object from sandboxed code.""" fmt = inspect_format_method(__obj) if fmt is not None: return __self.format_string(fmt, args, kwargs) # the double prefixes are to avoid double keyword argument # errors when proxying the call. if not __self.is_safe_callable(__obj): raise SecurityError('%r is not safely callable' % (__obj, )) return __context.call(__obj, *args, **kwargs)
def call(_SandboxedEnvironment__self, _SandboxedEnvironment__context, _SandboxedEnvironment__obj, *args, **kwargs): """Call an object from sandboxed code.""" if not __self.is_safe_callable(__obj): raise SecurityError('%r is not safely callable' % (__obj, )) return __context.call(__obj, *args, **kwargs)
def call(__self, __context, __obj, *args, **kwargs): if __obj == importlib.import_module and len(args) == 1: if args[0] not in __self.safe_stdlib_modules: raise SecurityError(f"{args[0]} is not safely importable") return super().call(__context, __obj, *args, **kwargs)