如何限制程序资源+ JVM/OSGi 中的权限?
我想创建一个网站,人们可以在其中解决编程任务并最终上传他们的解决方案(以任何 JVM 语言),以便验证它并与其他人分享。
我认为 OSGi(现在正在学习)可能是处理此任务的好工具(是吗?)。但显然我有点担心让其他人在我的主机上执行他们的代码(顺便说一句,基于输入/输出的解决方案是别无选择的)。
所以我想我需要找出
a)如何允许/限制某些Java功能(例如启动线程、发送邮件、写入文件等)
和
b)如何限制程序/包的 CPU/RAM 资源,因此没有人可以通过无限循环等方式使主机瘫痪。
有什么建议吗?
I want to create a website where people can solve programming tasks and eventually upload their solution (in any JVM-language) in order to verify it and share it with others.
I figured OSGi (learning it right now) might be a good tool to handle this task (is it?). But obviously I'm a little anxious about letting other people executing their code on my host (btw, a input/output-based solution is no alternative).
So I figured I need to find out
a) how to allow/restrict certain Java functionality (e.g. starting a thread, sending a mail, writing a file etc.)
and
b) how to limit a program's/bundle's CPU/RAM resources so no one could bring the host down with an endless loop for example.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
b) 我认为最安全的解决方案是为每个用户提交的解决方案创建专用的 JVM。这样,您就可以使用操作系统的所有工具。
a) Java 功能可能会使用 权限。我从未尝试用它做一些复杂的事情,但为第三方输入制定可靠的策略肯定不是小事。也许 Google 的 Appengine SDK 可能会有所帮助。我怀疑它正在使用权限在本地模仿 Appengine 的行为。
b) I think the safest solution would be to create dedicated JVMs for each user-submitted solution. This way, you have all your operating system's tools at hand.
a) Java functionality may be restricted using Permissions. I've never tried to do something sophisticated with it, but it certainly isn't trivial to make a solid policy for 3rd party input. Maybe Google's Appengine SDK might help. I suspect that it is using permissions to mimic Appengine's behaviour locally.