English 中文(简体)
我如何用javax操作安全带。 描述?
原标题:How do I secure scripts run using javax.scripting?
  • 时间:2009-08-28 13:49:08
  •  标签:

我正在使用<代码>javax.scripting,以补充支持在服务器边操作武断的用户上载的Java文本。 显然,我想确保这些文字!

Rhino本身有一个在业时间获得文字的框架。 但是,<代码>javax.scripting>的文件没有提及安全、许可或限制该笔文字上可使用的类别。 因此,这在<编码>javax.scripting上就是一个巨大的漏洞。 标注:它没有提供一个框架,确保它所执行的文字安全?

我不想直接使用Rhino,因为我最初试图这样做,但有一些问题使Java案件暴露在手稿上。 <代码>javax.scripting framework made it ( which use Rhino under the hood) made this trivial and alsopening scripts in a multi-threaded Service.

我要讲的是白名单的 Java班,可在手稿中查阅/证实。 谁能向我提出如何实现这一目标的榜样或文件?

最佳回答
问题回答

http://codeutopia.net/blog/2009/01/02/sand Boxing-rhino-in-java/ 描述了沙箱 r和 j。 描述使用Rhino作为联合材料书写引擎,因此,尽管包装名称可能有所不同,但你应当能够使用上述工具。

I’ve been working on a Java app which needed Rhino for scripting. The app would need to run untrusted JavaScript code from 3rd parties, so I had to find a way to block access to all Java methods, except the ones I wanted. This would not be a problem if there was an easy way to disable LiveConnect - the feature of Rhino which provides java access to scripts - but there is no such thing.

However, after a lot of digging around, I finally found a way to do this without too much hacking. In fact, it can be done by just extending a few of the Rhino classes, and using the setters provided to override some of the default ones.

如今,在新的Java 8号执行法令中,这是可能的。 使用新发动机“Nashorn”的描述。 见。 ∗ UNEP/POPS/POPRC.3/1。





相关问题
热门标签