Using PyPy Sandbox to refer to standard python modules? -


i working on project embed python interpreter in website--i users able execute own python code on server-side in secure python sandbox. have been using pypy's sandboxing features , have set virtual tmp/ directory (which corresponds real directory sandbox can read from) server-side files. ideally, users able run own code on server , use whatever libraries make available them (with no ability write of these files/make system calls/do in general mess files).

the issue within server-side code use standard python libraries others have installed separately (e.g. "import datetime", "import pandas", etc.). while sandbox can read server-side code ends failing whenever try import additional libraries within code. have thought of setting virtual tmp/ directory include server-side files + standard python libraries + separately installed libraries such pandas. however, when tried setting python libraries ended not working, not mention solution seems pretty inelegant.

any thoughts on how go fixing this? appreciate whatever advice may have. thanks!

edit: think part of answer lies in following portion of pypy_interact.py (the full source code can found here: https://github.com/ojii/sandlib/blob/master/sandlib/pypy_interact.py):

 def build_virtual_root(self):     # build virtual file system:     # * can access own executable     # * can access pure python libraries     # * can access temporary usession directory /tmp     exclude = ['.pyc', '.pyo']     if self.tmpdir none:         tmpdirnode = dir({})     else:         tmpdirnode = realdir(self.tmpdir, exclude=exclude)     libroot = str(lib_root)      return dir({         'bin': dir({             'pypy-c': realfile(self.executable),             'lib-python': realdir(os.path.join(libroot, 'lib-python'),                                   exclude=exclude),              'lib_pypy': realdir(os.path.join(libroot, 'lib_pypy'),                                   exclude=exclude),             }),          'tmp': tmpdirnode,          }) 

i relatively new python , can't seem figure out how use method properly. suggestions appreciated.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -