xzwebx-httpfilter 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HttpFilter.js +23 -10
- package/package.json +1 -1
package/HttpFilter.js
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
const Fs = require('fs')
|
|
2
2
|
const Util = require("util")
|
|
3
3
|
const Path = require('path')
|
|
4
|
-
const Crypto = require('crypto')
|
|
5
4
|
|
|
6
5
|
let ResultCodeMap = {}
|
|
7
6
|
let TipsMap = {}
|
|
8
7
|
let ModuleMap = {}
|
|
9
8
|
let ModuleInterfaceMap = {}
|
|
10
9
|
let FieldMap = {}
|
|
11
|
-
|
|
12
|
-
function decrypt(sign, key, iv) {
|
|
13
|
-
let src = ''
|
|
14
|
-
const cipher = Crypto.createDecipheriv('aes-128-cbc', 'uY4576jBeHGi5ElK', 'Kue76RJhg24WjVet')
|
|
15
|
-
src += cipher.update(sign, 'hex', 'utf8')
|
|
16
|
-
src += cipher.final('utf8')
|
|
17
|
-
return src
|
|
18
|
-
}
|
|
19
10
|
async function response(req, res, next) {
|
|
20
11
|
let retData = {
|
|
21
12
|
codeKey: 'SYSTEM_ERR',
|
|
@@ -41,8 +32,9 @@ function MSG(params) {
|
|
|
41
32
|
if (!params.msg) {
|
|
42
33
|
if (TipsMap[params.codeKey]) {
|
|
43
34
|
msg = TipsMap[params.codeKey].tips
|
|
35
|
+
} else {
|
|
36
|
+
msg = ResultCodeMap[params.codeKey].codeDesc
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
} else {
|
|
47
39
|
if (typeof params.msg == 'string') {
|
|
48
40
|
msg = params.msg
|
|
@@ -206,11 +198,17 @@ function IsStringOk(fCfgItem, paramValue) {
|
|
|
206
198
|
}
|
|
207
199
|
|
|
208
200
|
if (!isPass) {
|
|
201
|
+
if (rule.ruleDesc) {
|
|
202
|
+
return rule.ruleDesc
|
|
203
|
+
}
|
|
209
204
|
return ['WRONG_STR_RANGE', fCfgItem.fieldUrl, JSON.stringify(rule.exprVal)]
|
|
210
205
|
}
|
|
211
206
|
} else if (rule.checkType == 'ENU') {
|
|
212
207
|
if (rule.isCaseSensitive == 1) {
|
|
213
208
|
if (rule.exprVal && rule.exprVal.length && !rule.exprVal.includes(paramValue)) {
|
|
209
|
+
if (rule.ruleDesc) {
|
|
210
|
+
return rule.ruleDesc
|
|
211
|
+
}
|
|
214
212
|
return ['WRONG_ENU_VALUE', fCfgItem.fieldUrl, rule.exprVal]
|
|
215
213
|
}
|
|
216
214
|
} else {
|
|
@@ -222,6 +220,9 @@ function IsStringOk(fCfgItem, paramValue) {
|
|
|
222
220
|
}
|
|
223
221
|
}
|
|
224
222
|
if (!isPass) {
|
|
223
|
+
if (rule.ruleDesc) {
|
|
224
|
+
return rule.ruleDesc
|
|
225
|
+
}
|
|
225
226
|
return ['WRONG_ENU_VALUE', fCfgItem.fieldUrl, rule.exprVal]
|
|
226
227
|
}
|
|
227
228
|
}
|
|
@@ -244,6 +245,9 @@ function IsStringOk(fCfgItem, paramValue) {
|
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
if (!isPass) {
|
|
248
|
+
if (rule.ruleDesc) {
|
|
249
|
+
return rule.ruleDesc
|
|
250
|
+
}
|
|
247
251
|
return ['WRONG_REGEX_VALUE', fCfgItem.fieldUrl, exprVal]
|
|
248
252
|
}
|
|
249
253
|
}
|
|
@@ -278,10 +282,16 @@ function IsIntOk(fCfgItem, paramValue) {
|
|
|
278
282
|
}
|
|
279
283
|
|
|
280
284
|
if (!isPass) {
|
|
285
|
+
if (rule.ruleDesc) {
|
|
286
|
+
return rule.ruleDesc
|
|
287
|
+
}
|
|
281
288
|
return ['WRONG_INT_RANGE', fCfgItem.fieldUrl, JSON.stringify(rule.exprVal)]
|
|
282
289
|
}
|
|
283
290
|
} else if (rule.checkType == 'ENU') {
|
|
284
291
|
if (rule.exprVal && rule.exprVal.length && !rule.exprVal.includes(paramValue)) {
|
|
292
|
+
if (rule.ruleDesc) {
|
|
293
|
+
return rule.ruleDesc
|
|
294
|
+
}
|
|
285
295
|
return ['WRONG_ENU_VALUE', fCfgItem.fieldUrl, rule.exprVal]
|
|
286
296
|
}
|
|
287
297
|
} else if (rule.checkType == 'REGEX') {
|
|
@@ -303,6 +313,9 @@ function IsIntOk(fCfgItem, paramValue) {
|
|
|
303
313
|
}
|
|
304
314
|
}
|
|
305
315
|
if (!isPass) {
|
|
316
|
+
if (rule.ruleDesc) {
|
|
317
|
+
return rule.ruleDesc
|
|
318
|
+
}
|
|
306
319
|
return ['WRONG_REGEX_VALUE', fCfgItem.fieldUrl, exprVal]
|
|
307
320
|
}
|
|
308
321
|
}
|