- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试向我们的系统添加一个脚本功能,不受信任的用户可以在其中编写简单的脚本并让它们在服务器端执行。我正在尝试使用 Nashorn 作为脚本引擎。
不幸的是,他们为 Nashorn 添加了一些非标准功能:
https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/shell.html#sthref29
向下滚动到“Additional Nashorn Built-in Functions”并查看“quit()”函数。是的,如果一个不受信任的用户运行此代码,整个 JVM 就会关闭。
这很奇怪,因为 Nashorn 专门预期运行不受信任的脚本。见:https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/api.html#classfilter_introduction
Applications that embed Nashorn, in particular, server-side JavaScript frameworks, often have to run scripts from untrusted sources and therefore must limit access to Java APIs. These applications can implement the ClassFilter interface to restrict Java class access to a subset of Java classes.
最佳答案
不幸的是,目前没有办法控制非标准全局函数的创建。一种解决方法是在 ScriptEngine 初始化后简单地从全局对象中删除这些函数:
final NashornScriptEngineFactory engineManager = new NashornScriptEngineFactory();
final ScriptEngine engine = engineManager.getScriptEngine();
final Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
bindings.remove("print");
bindings.remove("load");
bindings.remove("loadWithNewGlobal");
bindings.remove("exit");
bindings.remove("quit");
System.err.println(engine.eval("'quit is ' + typeof quit"));
delete quit;
会做。
关于nashorn - 如何阻止 Nashorn 允许使用 quit() 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31127641/
可以说我只是使用 pygame 有一个正常的游戏循环。 run = True while run: for event in pygame.event.get(): if ev
如何让控制台应用程序运行直到用户输入“Q”、“q”、“Quit”或“quit”来终止它? 这是我当前的代码: public class Class1 { [STAThread] static
我正在创建一个基于 promise 的 API。如果我一次发出一个请求,一切都会正常,但是,如果 2 个或更多请求在一秒内到达服务器,我会收到以下错误 Error: Cannot enqueue Qu
考虑: (gdb) q A debugging session is active. Inferior 1 [process 9018] will be killed. Quit an
我有以下设置: int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // Create the DBM
我的停靠菜单总是自动添加“退出”和其他 2 个菜单项,我如何阻止/修改它们? 更新: 确实没有办法删除/阻止/重定向“退出”菜单项。最后像打击一样使用了彼得的推荐希望对其他人有帮助 -(NSAppli
这是我的代码:1. 用户输入两个名称,中间有一个空格。这意味着需要读取两个字符串。 IE。输入: 约翰·多伊。 然后在字符数组中检查字符串。 (工作正常)。 while 循环一直持续到用户输入“sto
刚刚弄乱了 pygame 并遇到了这个错误。 代码: import sys import pygame pygame.init() size = width, height = 600, 400 sc
看完Eric Lippert’s answer我的印象是 await和 call/cc几乎是同一枚硬币的两面,最多只是句法上的差异。然而,在尝试实际实现时 call/cc在 C# 5 中,我遇到了一个
Memcached quit 命令用户关闭一个客户端连接 语法 quit 范例 连接到127.0.0.1 上 11211 的 Memcached 服务, 然后退出 $ telnet 12
这只是一种方便,但我认为很有用。请注意,IPython 和 Matlab 一样允许纯退出。因此,在 Julia 中允许混叠是合理的。 感谢您提供有关如何执行此操作的任何想法。 最佳答案 退出 Juli
我正在运行Django服务,该服务将启动chromedriver用于 Selenium ,并爬取网站以获取数据。 另一个Java服务通过HTTP调用Django服务。 这是代码: views.py p
Iam在我的游戏中一起使用Adcolony和Vungle时,一切正常,但是当用Application.Quit()游戏退出游戏时,关闭了游戏,但弹出了文本“不幸的应用程序崩溃”的弹出窗口。 在这里我附
我最近做了一个小游戏,然后用pyinstaller把它变成了一个应用程序。运行时,有两种关闭方式。它是全屏的,因此不包括单击红色 x 按钮,但基本上我有这个 if keys[pygame.K_ESCA
我正在练习使用递归,但有些东西我不太明白。例如,我写了这个简单的倒计时函数,它应该等到一秒过去,然后倒计时到下一秒。 我首先是这样写的: function countdown(sec) { con
我正在使用 Appium 安装应用程序。安装后,应用程序应该在后台运行。另一项测试应使用 Chrome 在应用程序在后台运行时检查互联网连接。问题是 driver.quit() 甚至启动 Androi
我有一个正在运行测试的框架;任何错误都会导致 WebDriver 实例调用类似 handleException 方法的方法,我在其中调用 driver.quit() 方法。我觉得 driver.qui
我知道所有基本的处理程序,即 on run、on open 和 onreopen。但是这个处理程序,on quit,让我很困惑。我的问题是,它的用途是什么以及它是如何触发的? 最佳答案 on quit
我有两个 for 循环: for event in pygame.event.get(): if event.type == QUIT:
我目前正在编写一个小的 GUI 程序,它可以完成一些工作并在之后退出。工作完成后,GUI 线程会更新用户的信息。 这是我目前使用的模式,我认为它不是最优雅的模式: static void MainFo
我是一名优秀的程序员,十分优秀!