如何在受限沙箱中运行Java程序
我一直在尝试构建一个在线java编译器。但是在服务器上运行客户端代码会引发许多安全问题。
我能想到的很少——无限循环、限制访问 API、限制内存使用等等。
1)借助策略工具可以限制对API的访问。但是我如何检查内存和CPU使用情况(无限循环,..)?
2) 策略工具提供授予权限而不是限制的选项。那么,如果我选择“运行时权限”并将 getStacktrace 作为目标,那么所有其他权限都会受到限制?
I have been trying to build an online java compiler. But running the clients code on server raises many security issues.
There are few I can think of - infinite loops, Restricted access to API, limiting memory usage, etc.
I have looked here and here. But I have a few more questions.
1) Restricted access to API is possible with the help of policy tool. But how do I check on memory and cpu usage(infinite loops,..)?
2) Policy Tool provides options to give permissions and not to restrict. So, if I choose, "Runtime permission" and getStacktrace as target then all others would be restricted?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Ideone API。免费帐户有一定的限制,但它减轻了您处理安全性等方面的负担。
它可作为 Web 服务使用,其 WSDL 可以在此处找到:ideone.com/api/1/service.wsdl
You could use Ideone API. You have certain restrictions for a free account but it relieves you the burden of handling security and all.
It is available as a webservice and its WSDL can be found here: ideone.com/api/1/service.wsdl
一种想法是在单独的线程上运行代码。如果该线程未在最大允许时间内完成,则终止该线程。
One idea is to run the code on a separate thread. and kill that thread if it does not finish in a maximum allowed time.