开发者

Restricting access to Java classes in JRuby script

I want to allow c开发者_Python百科lient to write scripts in JRuby and run them on web server. Is there a way to disable java-jruby integration. Or at least a way to disable access to ceratain classes ?


Have a look at the org.jruby.Profile interface. With this you can implement a custom version that disallows loading certain files or classes. As the comments suggest above, disallowing load of "java" should be enough to disable Java integration.

You can set the runtime profile with org.jruby.RubyInstanceConfig#setProfile before the runtime is initialized. If you're using the org.jruby.embed APIs, then use org.jruby.embed.ScriptingContainer#setProfile.


Are you allowing a user to submit a file and have your server execute it as a script? That's probably a very bad idea for several reasons. To begin with, what is it they could do in Java that you don't want them to, that they could not do in plain ruby?

With that being said, ensure a script does not have require 'java' in it will prevent Java integration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜