I have bunch of python-projects with untrusted WSGI-apps inside them. I need to run them simulatiously and safely. So I need restrictions for directory access, python module usage and limitations for CPU and Memory.
I consider two approaches:
Import via imp-module WSGI-object from defined file, and running it with pysandbox. Now I have
SandboxError: Read only object
when doing:self.config = SandboxConfig('stdout') self.sandbox = Sandbox(self.config) self.s = imp.get_suffixes() wsgi_obj = imp.load_module("run", open(path+"/run.py", "r"), path, self.s[2]).app … return self.sandbox.call(wsgi_obj, environ, start_response)
Modify Python interpreter, exclude potentially risky modules, run in parallel processes, communicate via ZMQ/Unix sockets. I even don't know where to start here.
What could you recommend?