feat: 安全起见暂时屏蔽load方法和disable方法

merge/2/HEAD
coding 2018-01-09 11:28:00 +00:00
parent d519bface0
commit 318a7cdcfd
3 changed files with 15 additions and 11 deletions

View File

@ -43,7 +43,7 @@ public class ScriptEngine {
@SneakyThrows
public void disableEngine() {
engine.invokeFunction("disable");
engine.invokeFunction("engineDisable");
}
public MiaoScriptEngine getEngine() {

View File

@ -35,9 +35,13 @@
* 初始化模块
*/
function loadRequire() {
global.engineLoad = load;
global.load = function __denyGlobalLoad__() {
throw new Error('系统内部不许允许使用 load 如需执行脚本 请使用 engineLoad !');
}
// 初始化加载器
global.require = load(root + '/core/require.js')(root);
global.requireInternal = function (name) {
global.require = engineLoad(root + '/core/require.js')(root);
global.requireInternal = function requireInternal(name) {
return require(root + '/internal/' + DetectServerType + '/' + name + '.js');
}
}
@ -61,16 +65,16 @@
*/
function loadServerLib() {
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);
};
global.clearTimeout = function (task) {
global.clearTimeout = function clearTimeout(task) {
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);
};
global.clearInterval = function (task) {
global.clearInterval = function clearInterval(task) {
task.cancel();
};
}
@ -95,9 +99,9 @@
/**
* 关闭插件Hook
*/
global.disable = function disable() {
global.engineDisable = function disable() {
if (global.manager && global.manager.$) {
global.manager.disable();
}
}
})(global);
})(global);

View File

@ -204,7 +204,7 @@
}
base.save(cacheFile, "(function __init__(module, exports, require, __dirname, __filename) {" + origin + "});");
// 使用 load 可以保留行号和文件名称
var compiledWrapper = load(cacheFile);
var compiledWrapper = engineLoad(cacheFile);
try {
base.delete(cacheFile);
} catch (ex) {
@ -267,4 +267,4 @@
var cacheModules = [];
console.debug("初始化 require 模块组件 父目录 ", _canonical(parent));
return exports(parent);
});
});