feat: 安全起见暂时屏蔽load方法和disable方法
This commit is contained in:
parent
d519bface0
commit
318a7cdcfd
@ -43,7 +43,7 @@ public class ScriptEngine {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void disableEngine() {
|
public void disableEngine() {
|
||||||
engine.invokeFunction("disable");
|
engine.invokeFunction("engineDisable");
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiaoScriptEngine getEngine() {
|
public MiaoScriptEngine getEngine() {
|
||||||
|
@ -35,9 +35,13 @@
|
|||||||
* 初始化模块
|
* 初始化模块
|
||||||
*/
|
*/
|
||||||
function loadRequire() {
|
function loadRequire() {
|
||||||
|
global.engineLoad = load;
|
||||||
|
global.load = function __denyGlobalLoad__() {
|
||||||
|
throw new Error('系统内部不许允许使用 load 如需执行脚本 请使用 engineLoad !');
|
||||||
|
}
|
||||||
// 初始化加载器
|
// 初始化加载器
|
||||||
global.require = load(root + '/core/require.js')(root);
|
global.require = engineLoad(root + '/core/require.js')(root);
|
||||||
global.requireInternal = function (name) {
|
global.requireInternal = function requireInternal(name) {
|
||||||
return require(root + '/internal/' + DetectServerType + '/' + name + '.js');
|
return require(root + '/internal/' + DetectServerType + '/' + name + '.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,16 +65,16 @@
|
|||||||
*/
|
*/
|
||||||
function loadServerLib() {
|
function loadServerLib() {
|
||||||
var task = require('api/task');
|
var task = require('api/task');
|
||||||
global.setTimeout = function (func, time, _async) {
|
global.setTimeout = function setTimeout(func, time, _async) {
|
||||||
return _async ? task.laterAsync(func, time) : task.later(func, time);
|
return _async ? task.laterAsync(func, time) : task.later(func, time);
|
||||||
};
|
};
|
||||||
global.clearTimeout = function (task) {
|
global.clearTimeout = function clearTimeout(task) {
|
||||||
task.cancel();
|
task.cancel();
|
||||||
};
|
};
|
||||||
global.setInterval = function (func, time, _async) {
|
global.setInterval = function setInterval(func, time, _async) {
|
||||||
return _async ? task.timerAsync(func, time) : task.timer(func, time);
|
return _async ? task.timerAsync(func, time) : task.timer(func, time);
|
||||||
};
|
};
|
||||||
global.clearInterval = function (task) {
|
global.clearInterval = function clearInterval(task) {
|
||||||
task.cancel();
|
task.cancel();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -95,7 +99,7 @@
|
|||||||
/**
|
/**
|
||||||
* 关闭插件Hook
|
* 关闭插件Hook
|
||||||
*/
|
*/
|
||||||
global.disable = function disable() {
|
global.engineDisable = function disable() {
|
||||||
if (global.manager && global.manager.$) {
|
if (global.manager && global.manager.$) {
|
||||||
global.manager.disable();
|
global.manager.disable();
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@
|
|||||||
}
|
}
|
||||||
base.save(cacheFile, "(function __init__(module, exports, require, __dirname, __filename) {" + origin + "});");
|
base.save(cacheFile, "(function __init__(module, exports, require, __dirname, __filename) {" + origin + "});");
|
||||||
// 使用 load 可以保留行号和文件名称
|
// 使用 load 可以保留行号和文件名称
|
||||||
var compiledWrapper = load(cacheFile);
|
var compiledWrapper = engineLoad(cacheFile);
|
||||||
try {
|
try {
|
||||||
base.delete(cacheFile);
|
base.delete(cacheFile);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user