Secure Nashorn JS Execution

前端 未结 9 1288
故里飘歌
故里飘歌 2020-12-04 12:07

How can I securely execute some user supplied JS code using Java8 Nashorn?

The script extends some computations for some servlet based reports. The app has many diff

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 12:39

    An external sandbox library can be used if you don't want to implement your own ClassLoader & SecurityManager (that's the only way of sandboxing for now).

    I've tried "The Java Sandbox" (http://blog.datenwerke.net/p/the-java-sandbox.html) although it's a bit rough around the edges, but it works.

提交回复
热议问题