Is there an alternative to rexec for Python sandboxing?

回眸只為那壹抹淺笑 提交于 2019-11-30 20:54:58

You might want to provide your own __import__ to prevent inclusion of any modules you deem "abuse I/O or processor/memory resources."

You might want to start with pypy and create your own interpreter with limitations and constraints on resource use.

in cpython "sandboxing" for security reasons is a: "don't do that at your company kids"-thing.

try :

  • jython with java "sandboxing"
  • pypy -> see Answer S.Lott
  • maybe ironpython has a solution ?

see Warning:

Warning

In Python 2.3 these modules have been disabled due to various known and not readily fixable security holes. The modules are still documented here to help in reading old code that uses the rexec and Bastion modules.

Your best bet for security in cPython is using OS-level sandboxing mechanisms and running untrusted code in a separate process constrained by the OS.

This is equivalent to using 'jython with java "sandboxing"', as per the answer above, but probably a little more difficult to configure.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!