Commit 8fd98190 authored by 苏文雄's avatar 苏文雄

fix: 高级 mock 无效的bug,增加对登录 email 空格的过滤, deepMath 增加对原型属性过滤

parent 6925c98d
......@@ -85,7 +85,9 @@ exports.isDeepMatch = function(obj, properties) {
}
let match = true;
for (var i in properties) {
let keys = Object.keys(properties)
for (let index=0; index< keys.length; index++) {
let i = keys[index];
if (!Compare(obj[i], properties[i])) {
match = false;
break;
......
......@@ -31,6 +31,7 @@ class userController extends baseController {
//登录
let userInst = yapi.getInst(userModel); //创建user实体
let email = ctx.request.body.email;
email = (email || '').trim();
let password = ctx.request.body.password;
if (!email) {
......
......@@ -282,17 +282,13 @@ exports.verifyPath = path => {
*/
exports.sandbox = (sandbox, script) => {
try {
const { NodeVM } = require('vm2');
sandbox = sandbox || {};
const vm = new NodeVM({
require: {
external: true
},
sandbox: sandbox,
timeout: 3000
})
vm.run(script)
const vm = require('vm');
sandbox = sandbox || {};
script = new vm.Script(script);
const context = new vm.createContext(sandbox);
script.runInContext(context, {
timeout: 3000
});
return sandbox
} catch (err) {
throw err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment