【发布时间】:2011-06-22 00:51:39
【问题描述】:
我想使用 Rhino 作为沙箱在服务器上运行用户提供的脚本。我想从不再有 Java 绑定的 PHP 中做到这一点,所以我必须使用命令行界面(Rhino shell)。
不幸的是,Rhino shell 在环境中添加了一些破坏沙盒字符的内在函数,例如文件访问和允许在系统上运行任意命令的runCommand()。
有没有办法禁用它们?
【问题讨论】:
标签: rhino rhino-security
我想使用 Rhino 作为沙箱在服务器上运行用户提供的脚本。我想从不再有 Java 绑定的 PHP 中做到这一点,所以我必须使用命令行界面(Rhino shell)。
不幸的是,Rhino shell 在环境中添加了一些破坏沙盒字符的内在函数,例如文件访问和允许在系统上运行任意命令的runCommand()。
有没有办法禁用它们?
【问题讨论】:
标签: rhino rhino-security
我发现我可以用 null 覆盖它们或删除它们:
runCommand = null;
delete runCommand;
可以通过Global的getting all properties找出有哪些全局函数和对象,存储在this中:
Object.getOwnPropertyNames(this);
【讨论】: