如何在受限沙箱中运行Java程序

发布于 2025-01-05 21:53:05 字数 506 浏览 2 评论 0原文

我一直在尝试构建一个在线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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖上得阳光 2025-01-12 21:53:05

您可以使用 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

暮倦 2025-01-12 21:53:05

一种想法是在单独的线程上运行代码。如果该线程未在最大允许时间内完成,则终止该线程。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文