Showing
1 changed file
with
5 additions
and
0 deletions
@@ -8,6 +8,7 @@ const _ = require('lodash'); | @@ -8,6 +8,7 @@ const _ = require('lodash'); | ||
8 | const cache = global.yoho.cache.master; | 8 | const cache = global.yoho.cache.master; |
9 | const helpers = global.yoho.helpers; | 9 | const helpers = global.yoho.helpers; |
10 | const pathToRegexp = require('path-to-regexp'); | 10 | const pathToRegexp = require('path-to-regexp'); |
11 | +const logger = global.yoho.logger; | ||
11 | 12 | ||
12 | const statusCode = { | 13 | const statusCode = { |
13 | code: 4403, | 14 | code: 4403, |
@@ -53,6 +54,7 @@ module.exports = () => { | @@ -53,6 +54,7 @@ module.exports = () => { | ||
53 | let risks = _.get(req.app.locals.wap, 'json.risk', []); | 54 | let risks = _.get(req.app.locals.wap, 'json.risk', []); |
54 | let router = {}; | 55 | let router = {}; |
55 | 56 | ||
57 | + logger.debug(`risk => risks: ${JSON.stringify(risks)}, path: ${path}, ip: ${ip}`); // eslint-disable-line | ||
56 | if (_.isEmpty(path) || _.isEmpty(risks) || IP_WHITE_LIST.indexOf(ip) > -1) { | 58 | if (_.isEmpty(path) || _.isEmpty(risks) || IP_WHITE_LIST.indexOf(ip) > -1) { |
57 | return next(); | 59 | return next(); |
58 | } | 60 | } |
@@ -76,6 +78,7 @@ module.exports = () => { | @@ -76,6 +78,7 @@ module.exports = () => { | ||
76 | return false; | 78 | return false; |
77 | }); | 79 | }); |
78 | 80 | ||
81 | + logger.debug(`risk => router: ${JSON.stringify(router)}, path: ${path}`); // eslint-disable-line | ||
79 | if (_.isEmpty(router)) { | 82 | if (_.isEmpty(router)) { |
80 | return next(); | 83 | return next(); |
81 | } | 84 | } |
@@ -91,6 +94,7 @@ module.exports = () => { | @@ -91,6 +94,7 @@ module.exports = () => { | ||
91 | cache.getAsync(limitKey), | 94 | cache.getAsync(limitKey), |
92 | cache.getAsync(configKey), | 95 | cache.getAsync(configKey), |
93 | ]).then(inters => { | 96 | ]).then(inters => { |
97 | + logger.debug(`risk => getCache: ${JSON.stringify(inters)}, path: ${path}`); // eslint-disable-line | ||
94 | if (inters[0]) { | 98 | if (inters[0]) { |
95 | return Object.assign({}, statusCode, {data: {url: checkUrl}}); | 99 | return Object.assign({}, statusCode, {data: {url: checkUrl}}); |
96 | } | 100 | } |
@@ -114,6 +118,7 @@ module.exports = () => { | @@ -114,6 +118,7 @@ module.exports = () => { | ||
114 | return Object.assign({}, statusCode, {data: {url: checkUrl}}); | 118 | return Object.assign({}, statusCode, {data: {url: checkUrl}}); |
115 | }); | 119 | }); |
116 | }).then(result => { | 120 | }).then(result => { |
121 | + logger.debug(`risk => result: ${JSON.stringify(result)}, path: ${path}`); // eslint-disable-line | ||
117 | return _jumpUrl(req, res, next, result); | 122 | return _jumpUrl(req, res, next, result); |
118 | }).catch(e => { | 123 | }).catch(e => { |
119 | console.log(`risk => path: ${path}, err: ${e.message}`); | 124 | console.log(`risk => path: ${path}, err: ${e.message}`); |
-
Please register or login to post a comment