开发者

Remove additional function from Rhino shell

I want to use Rhino as a sandbox to run user supplied scripts on a server. I want to do that from PHP, which doesn't have Java bindings any more, so I have to use the command line interface (Rhino shell).

Unfortunately the Rhino shell adds some intrinsic functions to the environment that ruin the sandbox character, like file access and runCommand() which allows runnning arbitrary commands on the system.

Is there a way to disable them?开发者_高级运维


I found that I can just overwrite them with null or delete them:

runCommand = null;
delete runCommand;

I can find out which global functions and objects there are by getting all properties of the Global, which is stored in this:

Object.getOwnPropertyNames(this);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜