@tmsfe/tms-core 0.0.69 → 0.0.70
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/package.json +1 -4
- package/src/index.js +1 -1
- package/src/md5.js +190 -0
- package/src/report/helper.ts +6 -1
- package/src/request.js +1 -1
- package/test/data.js +0 -1
- package/test/test.js +0 -154
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmsfe/tms-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.70",
|
|
4
4
|
"description": "tms运行时框架",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
"esm"
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"md5": "^2.3.0"
|
|
22
|
-
},
|
|
23
20
|
"devDependencies": {
|
|
24
21
|
"@babel/core": "^7.15.0",
|
|
25
22
|
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import syncApi from './syncfnmanager';
|
|
|
6
6
|
import nav from './navigator';
|
|
7
7
|
import { getLogManager, getRealtimeLogManager } from './log';
|
|
8
8
|
import { setEnvInfo, getEnvInfo, setAuthInfo, setAppPagePaths, isAppPageExist, getHomePage } from './env';
|
|
9
|
-
import md5 from 'md5';
|
|
9
|
+
import md5 from './md5';
|
|
10
10
|
import { callCloudFunc } from './cloudService';
|
|
11
11
|
import EventDispatcher from './eventDispatcher';
|
|
12
12
|
import { serialize } from './objUtils';
|
package/src/md5.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright 2017-present, Tencent, Inc. All rights reserved.
|
|
3
|
+
* @author Davis.Lu <davislu@tencent.com>
|
|
4
|
+
*
|
|
5
|
+
* @file crypto tools.
|
|
6
|
+
*
|
|
7
|
+
**/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
* @description 基于md5算法对源字符串进行hash,生成hash字符串
|
|
12
|
+
* @param {String} str 源字符串
|
|
13
|
+
* @returns {String} 源字符串的md5 hash值
|
|
14
|
+
*/
|
|
15
|
+
const md5 = function (str) {
|
|
16
|
+
/**
|
|
17
|
+
* 将unicode编码成utf-8
|
|
18
|
+
* @private
|
|
19
|
+
* @param {string} encoedStr unicode字符
|
|
20
|
+
* @returns {string} utf8格式的字符串
|
|
21
|
+
*/
|
|
22
|
+
const encodeUtf8 = (encoedStr) => {
|
|
23
|
+
const string = encoedStr.replace(/\r\n/g, '\n');
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @param {string} c unicode字符
|
|
27
|
+
* @returns {string} 字符串
|
|
28
|
+
*/
|
|
29
|
+
const charCode = c => String.fromCharCode(c);
|
|
30
|
+
const utftextArr = [];
|
|
31
|
+
for (let n = 0; n < string.length; n += 1) {
|
|
32
|
+
let c = string.charCodeAt(n);
|
|
33
|
+
if (c < 128) {
|
|
34
|
+
utftextArr.push(charCode(c));
|
|
35
|
+
} else if (c < 2048) {
|
|
36
|
+
utftextArr.push(charCode((c >> 6) | 192), charCode((c & 63) | 128));
|
|
37
|
+
} else if (c < 55296 || c >= 57344) {
|
|
38
|
+
utftextArr.push(
|
|
39
|
+
charCode((c >> 12) | 224),
|
|
40
|
+
charCode(((c >> 6) & 63) | 128),
|
|
41
|
+
charCode((c & 63) | 128),
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
c = 65536 + (((c & 1023) << 10) | (string.charCodeAt(n += 1) & 1023));
|
|
45
|
+
utftextArr.push(
|
|
46
|
+
charCode((c >> 18) | 240),
|
|
47
|
+
charCode(((c >> 12) & 63) | 128),
|
|
48
|
+
charCode(((c >> 6) & 63) | 128),
|
|
49
|
+
charCode((c & 63) | 128),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return utftextArr.join('');
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @private
|
|
58
|
+
* @param {string} string 字符串
|
|
59
|
+
* @returns {array} 字符串分组
|
|
60
|
+
*/
|
|
61
|
+
const convertToWordArray = (string) => {
|
|
62
|
+
const msgLen = string.length;
|
|
63
|
+
const lNumberOfWords = ((((msgLen + 8) - ((msgLen + 8) % 64)) / 64) + 1) * 16;
|
|
64
|
+
const lWordArray = Array(lNumberOfWords - 1);
|
|
65
|
+
let lByteCount = 0;
|
|
66
|
+
while (lByteCount <= msgLen) {
|
|
67
|
+
const wordCount = (lByteCount - (lByteCount % 4)) / 4;
|
|
68
|
+
const lBytePosition = (lByteCount % 4) * 8;
|
|
69
|
+
const byteWord = lByteCount === msgLen ? 0x80 : string.charCodeAt(lByteCount);
|
|
70
|
+
lWordArray[wordCount] |= (byteWord << lBytePosition);
|
|
71
|
+
lByteCount += 1;
|
|
72
|
+
}
|
|
73
|
+
lWordArray[lNumberOfWords - 2] = msgLen << 3;
|
|
74
|
+
lWordArray[lNumberOfWords - 1] = msgLen >>> 29;
|
|
75
|
+
return lWordArray;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
* @param {string} lValue 字符串
|
|
81
|
+
* @param {number} iShiftBits 移动位数
|
|
82
|
+
* @returns {string} 字符串
|
|
83
|
+
*/
|
|
84
|
+
const rotateLeft = (
|
|
85
|
+
lValue,
|
|
86
|
+
iShiftBits,
|
|
87
|
+
) => (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @private
|
|
91
|
+
* @param {string} lX 字符串
|
|
92
|
+
* @param {string} lY 字符串
|
|
93
|
+
* @returns {string} 字符串
|
|
94
|
+
*/
|
|
95
|
+
const addUnsigned = (lX, lY) => {
|
|
96
|
+
const lX8 = (lX & 0x80000000);
|
|
97
|
+
const lY8 = (lY & 0x80000000);
|
|
98
|
+
const lX4 = (lX & 0x40000000);
|
|
99
|
+
const lY4 = (lY & 0x40000000);
|
|
100
|
+
const lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
|
|
101
|
+
if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
|
|
102
|
+
if (!(lX4 | lY4)) return (lResult ^ lX8 ^ lY8);
|
|
103
|
+
return (lResult & 0x40000000)
|
|
104
|
+
? (lResult ^ 0xC0000000 ^ lX8 ^ lY8)
|
|
105
|
+
: (lResult ^ 0x40000000 ^ lX8 ^ lY8);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @private
|
|
110
|
+
* @param {object} recycleData 对象
|
|
111
|
+
* @returns {string} 字符串
|
|
112
|
+
*/
|
|
113
|
+
const addRecycling = (recycleData) => {
|
|
114
|
+
const { FN, a, b, c, d, x, s, ac } = recycleData;
|
|
115
|
+
const aa = addUnsigned(a, addUnsigned(addUnsigned(FN(b, c, d), x), ac));
|
|
116
|
+
return addUnsigned(rotateLeft(aa, s), b);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @private
|
|
121
|
+
* @param {string} lValue 字符串
|
|
122
|
+
* @returns {string} 字符串
|
|
123
|
+
*/
|
|
124
|
+
const wordToHex = (lValue) => {
|
|
125
|
+
let WordToHexValue = '';
|
|
126
|
+
for (let lCount = 0; lCount <= 3; lCount += 1) {
|
|
127
|
+
const lByte = (lValue >>> (lCount * 8)) & 255;
|
|
128
|
+
const WordToHexValueTemp = `0${lByte.toString(16)}`;
|
|
129
|
+
WordToHexValue += WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
|
|
130
|
+
}
|
|
131
|
+
return WordToHexValue;
|
|
132
|
+
};
|
|
133
|
+
let [a, b, c, d] = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476];
|
|
134
|
+
const sArr = [[7, 12, 17, 22], [5, 9, 14, 20], [4, 11, 16, 23], [6, 10, 15, 21]];
|
|
135
|
+
const kiArr = ('16b05af49e38d27c58be147ad0369cf207e5c3a18f6d4b29').split('').map(n => parseInt(n, 16));
|
|
136
|
+
const hxArr = [
|
|
137
|
+
0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE, 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501,
|
|
138
|
+
0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE, 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821,
|
|
139
|
+
0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA, 0xD62F105D, 0x2441453, 0xD8A1E681, 0xE7D3FBC8,
|
|
140
|
+
0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED, 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A,
|
|
141
|
+
0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C, 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70,
|
|
142
|
+
0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x4881D05, 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665,
|
|
143
|
+
0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039, 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1,
|
|
144
|
+
0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1, 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391,
|
|
145
|
+
];
|
|
146
|
+
// eslint-disable-next-line require-jsdoc
|
|
147
|
+
const cyc = (i, r = 0) => (i + r) % 4;
|
|
148
|
+
// 4组处理位操作函数
|
|
149
|
+
// eslint-disable-next-line require-jsdoc
|
|
150
|
+
const md5F = (x, y, z) => (x & y) | ((~x) & z);
|
|
151
|
+
// eslint-disable-next-line require-jsdoc
|
|
152
|
+
const md5G = (x, y, z) => (x & z) | (y & (~z));
|
|
153
|
+
// eslint-disable-next-line require-jsdoc
|
|
154
|
+
const md5H = (x, y, z) => (x ^ y ^ z);
|
|
155
|
+
// eslint-disable-next-line require-jsdoc
|
|
156
|
+
const md5I = (x, y, z) => (y ^ (x | (~z)));
|
|
157
|
+
const string = encodeUtf8(str);
|
|
158
|
+
const x = convertToWordArray(string);
|
|
159
|
+
for (let k = 0; k < x.length; k += 16) {
|
|
160
|
+
const AA = a;
|
|
161
|
+
const BB = b;
|
|
162
|
+
const CC = c;
|
|
163
|
+
const DD = d;
|
|
164
|
+
const arr = [a, d, c, b];
|
|
165
|
+
hxArr.forEach((hx, m) => {
|
|
166
|
+
const i = m % 16;
|
|
167
|
+
const g = m / 16 << 0;
|
|
168
|
+
const ki = m < 16 ? m : kiArr[m - 16];
|
|
169
|
+
const FN = [md5F, md5G, md5H, md5I][g];
|
|
170
|
+
|
|
171
|
+
arr[cyc(i)] = addRecycling({
|
|
172
|
+
FN,
|
|
173
|
+
a: arr[cyc(i)],
|
|
174
|
+
b: arr[cyc(i, 3)],
|
|
175
|
+
c: arr[cyc(i, 2)],
|
|
176
|
+
d: arr[cyc(i, 1)],
|
|
177
|
+
x: x[k + ki],
|
|
178
|
+
s: sArr[g][i % 4],
|
|
179
|
+
ac: hx,
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
a = addUnsigned(arr[0], AA);
|
|
183
|
+
b = addUnsigned(arr[3], BB);
|
|
184
|
+
c = addUnsigned(arr[2], CC);
|
|
185
|
+
d = addUnsigned(arr[1], DD);
|
|
186
|
+
}
|
|
187
|
+
return (wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d)).toLowerCase();
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export default md5;
|
package/src/report/helper.ts
CHANGED
|
@@ -77,8 +77,13 @@ function convert2String(value: any): string | null {
|
|
|
77
77
|
*/
|
|
78
78
|
function convert2StringArray(arr: DataItem[]) {
|
|
79
79
|
for (let i = 0; i < arr.length; i++) {
|
|
80
|
-
|
|
80
|
+
/* eslint-disable */
|
|
81
81
|
arr[i] = convert2String(arr[i]);
|
|
82
|
+
if (arr[i]) {
|
|
83
|
+
// 后端是根据 | 来分割字段的,这里只好过滤掉
|
|
84
|
+
arr[i] = arr[i].replace(/\|/g, '[');
|
|
85
|
+
}
|
|
86
|
+
/* eslint-enable */
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
|
package/src/request.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 考虑到对不同运行环境的支持,强依赖运行环境的依赖,比如 wx.request,应通过注入的形式提供。
|
|
9
9
|
* 框架判断在不同的运行环境,切换调用不同运行环境提供的方法。
|
|
10
10
|
*/
|
|
11
|
-
import md5 from 'md5';
|
|
11
|
+
import md5 from './md5';
|
|
12
12
|
import { getLogManager } from './log';
|
|
13
13
|
import { getEnvInfo, getAuthInfo } from './env';
|
|
14
14
|
import { safeJsonParse } from './objUtils';
|
package/test/data.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"__FILENAME__":"/var/log/tke-log-agent/ns-prj6wdcj-1134791-production/ns-prj6wdcj-1134791-production-stsp-sinanserver-f-ab66d07e-025c-44f6-9bff-fe6a44db1dd7/sinanserver-f-1/ab66d07e-025c-44f6-9bff-fe6a44db1dd7/v_applog/4b5dcbe6f3fc0d2e0173491dc16a7461/Wecar.SinanServer_access.log","__PKGID__":"CA5498C625624F5-8B57","__PKG_LOGID__":10354794,"__SOURCE__":"9.144.184.20","__TAG__":{"container_id":"505ccdbca43b91595f5f328820fb949e1c39c0dcdbecacea5587139a0e0ce260","container_name":"main-container","image_name":"csighub.tencentyun.com/th-deploy/th_wecar_sinanserver:feat-albertluo-sinan77a-20220101_154653-c873ef","namespace":"ns-prj6wdcj-1134791-production","pod_label_clusterId":"cls-991r4bpx","pod_label_controller-revision-hash":"sinanserver-f-66999dd78c","pod_label_env":"production","pod_label_k8s-app":"sinanserver-f","pod_label_moduleFourId":"1134791","pod_label_projectName":"prj6wdcj","pod_label_qcloud-app":"sinanserver-f","pod_label_region":"ap-tianjin","pod_label_statefulsetplus-kubernetes-io/pod-name":"sinanserver-f-1","pod_label_workload-kind":"statefulsetplus","pod_name":"sinanserver-f-1","pod_uid":"e135e0e8-b655-11ec-a3e8-525400b30d18"},"__TIMESTAMP__":1649848303067,"clientAddr":"111.206.145.51:55349","deviceFingerprint":"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 wechatdevtools/1.05.2111300 MicroMessenger/8.0.5 Language/zh_CN webview/","downstreamTimeCost":"58","file":"main.go:Run:158","isTxScanner":"false","level":"INFO","method":"POST","requestContent":"\"{\\\"appVersion\\\":\\\"2022.16.0\\\",\\\"nonce\\\":\\\"g0es1cn9ln\\\",\\\"seqId\\\":\\\"1649848302200869298\\\",\\\"sign\\\":\\\"3242dba92a77bef52c7110446f3ce156\\\",\\\"timestamp\\\":1649848302200,\\\"token\\\":\\\"22d6a3884c7494fd754d8851eb29d83f\\\",\\\"types\\\":[{\\\"bussClassify\\\":3,\\\"spIds\\\":[],\\\"status\\\":[3,5,6,7,8,11,31,32,34]}],\\\"userId\\\":\\\"306914\\\",\\\"version\\\":\\\"1.0\\\",\\\"wxAppId\\\":\\\"wx65cc950f42e8fff1\\\"}\"","responseCode":"0","responseContent":"\"{\\\"errCode\\\":0,\\\"errMsg\\\":\\\"success\\\",\\\"resData\\\":{\\\"count\\\":[{\\\"bussClassify\\\":3,\\\"count\\\":51}]}}\"}","seqId":"1649848302200869298","statusCode":"200","time":"2022-04-13 19:11:42.686","timeCost":"138","upstreamAddr":"9.144.241.102:5334","urlPath":"/user/order/countv2","userId":"306914"}
|
package/test/test.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const readline = require('readline');
|
|
4
|
-
// const { md5 } = require('../src/md5');
|
|
5
|
-
const openSourceMd5 = require('md5');
|
|
6
|
-
|
|
7
|
-
const scriptStartDir = process.cwd();
|
|
8
|
-
const srcDataPathArg = process.argv[2];
|
|
9
|
-
const srcDataAbsPath = path.resolve(scriptStartDir, srcDataPathArg);
|
|
10
|
-
const startLine = parseInt(process.argv[3], 10);
|
|
11
|
-
const maxLine = parseInt(process.argv[4], 10);
|
|
12
|
-
|
|
13
|
-
const readLineByLine = (filePath, onReadLine, startLine, endLine) => { // eslint-disable-line
|
|
14
|
-
const promise = new Promise((resolve, reject) => {
|
|
15
|
-
if (!fs.existsSync(filePath)) {
|
|
16
|
-
reject(`${filePath} not exists`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (endLine <= 0) resolve();
|
|
20
|
-
|
|
21
|
-
const rl = readline.createInterface({
|
|
22
|
-
input: fs.createReadStream(filePath),
|
|
23
|
-
crlfDelay: Infinity,
|
|
24
|
-
});
|
|
25
|
-
let line = 0;
|
|
26
|
-
rl.on('line', (data) => {
|
|
27
|
-
line += 1;
|
|
28
|
-
if (line > endLine) return rl.close();
|
|
29
|
-
if (line < startLine) return;
|
|
30
|
-
onReadLine(data);
|
|
31
|
-
});
|
|
32
|
-
rl.on('close', resolve);
|
|
33
|
-
rl.on('error', reject);
|
|
34
|
-
});
|
|
35
|
-
return promise;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const formatLog = (str) => {
|
|
39
|
-
const log = JSON.parse(str);
|
|
40
|
-
const request = JSON.parse(JSON.parse(log.requestContent));
|
|
41
|
-
const errCode = log.responseContent.replace(/.*(errCode[^\d]*)(\d*)(.*)/g, (m, g1, g2) => {
|
|
42
|
-
if (m) return g2;
|
|
43
|
-
const response = JSON.parse(JSON.parse(`${log.responseContent.substring(0, log.responseContent.length - 2)}"`));
|
|
44
|
-
return response.errCode;
|
|
45
|
-
});
|
|
46
|
-
return { request, errCode: parseInt(errCode, 10), urlPath: log.urlPath };
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 用于序列化需要签名的参数
|
|
51
|
-
* @private
|
|
52
|
-
* @param {object} param 需要序列化的参数
|
|
53
|
-
* @returns {string} 序列化之后的参数字符串
|
|
54
|
-
*/
|
|
55
|
-
const seriesParam = (param) => {
|
|
56
|
-
const keys = Object.keys(param)
|
|
57
|
-
.sort();
|
|
58
|
-
const series = keys.map((key) => {
|
|
59
|
-
const val = param[key];
|
|
60
|
-
return `${key}${typeof val === 'object' ? JSON.stringify(val) : val}`;
|
|
61
|
-
});
|
|
62
|
-
return series.join('');
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const sign = (param = {}) => {
|
|
66
|
-
const data = Object.assign({}, param);
|
|
67
|
-
delete data.sign;
|
|
68
|
-
const str = seriesParam(data);
|
|
69
|
-
// return { sign: md5(str), openSourceSign: openSourceMd5(str), str };
|
|
70
|
-
return { sign: '', openSourceSign: openSourceMd5(str), str };
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
(async () => {
|
|
74
|
-
const count = {
|
|
75
|
-
total: 0,
|
|
76
|
-
valid: 0,
|
|
77
|
-
invalid: {
|
|
78
|
-
total: 0,
|
|
79
|
-
list: [],
|
|
80
|
-
},
|
|
81
|
-
match: {
|
|
82
|
-
total: 0,
|
|
83
|
-
urlPaths: new Set(),
|
|
84
|
-
list: [],
|
|
85
|
-
},
|
|
86
|
-
same: {
|
|
87
|
-
total: 0,
|
|
88
|
-
urlPaths: new Set(),
|
|
89
|
-
list: [],
|
|
90
|
-
},
|
|
91
|
-
mismatch: {
|
|
92
|
-
ignore: {
|
|
93
|
-
total: 0,
|
|
94
|
-
patterns: [
|
|
95
|
-
'^/aggre/saas/.*', '^/aggre/datacenter/.*', '^/aggre/rent/.*',
|
|
96
|
-
'^/dd/api/.*',
|
|
97
|
-
'^/fmbapi/business/.*',
|
|
98
|
-
'^/ruqimobility/.*',
|
|
99
|
-
'^/ruqireport/.*',
|
|
100
|
-
'^/taiweb/.*',
|
|
101
|
-
'^/v2/bus/.*',
|
|
102
|
-
],
|
|
103
|
-
urlPaths: new Set(),
|
|
104
|
-
list: [],
|
|
105
|
-
},
|
|
106
|
-
problem: {
|
|
107
|
-
total: 0,
|
|
108
|
-
list: [],
|
|
109
|
-
urlPaths: new Set(),
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
const testLog = (logStr) => {
|
|
114
|
-
let log;
|
|
115
|
-
count.total += 1;
|
|
116
|
-
console.log(count.total + startLine);
|
|
117
|
-
try {
|
|
118
|
-
log = formatLog(logStr);
|
|
119
|
-
count.valid += 1;
|
|
120
|
-
} catch (e) {
|
|
121
|
-
log = null;
|
|
122
|
-
count.invalid.total += 1;
|
|
123
|
-
count.invalid.list.push(logStr);
|
|
124
|
-
}
|
|
125
|
-
if (!log) return;
|
|
126
|
-
|
|
127
|
-
const { sign: signature, openSourceSign, str } = sign(log.request);
|
|
128
|
-
if (openSourceSign === log.request.sign) {
|
|
129
|
-
count.match.total += 1;
|
|
130
|
-
count.match.urlPaths.add(log.urlPath);
|
|
131
|
-
} else if (signature === openSourceSign) {
|
|
132
|
-
count.same.total += 1;
|
|
133
|
-
count.same.urlPaths.add(log.urlPath);
|
|
134
|
-
count.same.list.push({ ...log, str });
|
|
135
|
-
} else {
|
|
136
|
-
const ignore = count.mismatch.ignore.patterns.some(pattern => new RegExp(pattern).test(log.urlPath));
|
|
137
|
-
const store = count.mismatch[ignore ? 'ignore' : 'problem'];
|
|
138
|
-
store.total += 1;
|
|
139
|
-
if (!store.urlPaths.has(log.urlPath)) {
|
|
140
|
-
store.urlPaths.add(log.urlPath);
|
|
141
|
-
store.list.push({ ...log, str });
|
|
142
|
-
}
|
|
143
|
-
// if (!ignore) console.warn(log.request.seqId, str, log.request.sign, signature);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
await readLineByLine(srcDataAbsPath, testLog, isNaN(startLine) ? 0 : startLine, isNaN(maxLine) ? 10 : maxLine);
|
|
147
|
-
console.log('total', count.total, 'valid', count.valid, 'invalid', count.invalid.total);
|
|
148
|
-
console.log('match', count.match.total, 'same', count.same.total, 'mismatch ignore', count.mismatch.ignore.total, 'mismatch problem', count.mismatch.problem.total);
|
|
149
|
-
// console.log('match urls', count.match.urlPaths);
|
|
150
|
-
console.log('same logs', count.same.list);
|
|
151
|
-
// console.log('known mismatch ignore urls', count.mismatch.ignore.urlPaths);
|
|
152
|
-
// console.log('unknown mismatch urls', count.mismatch.problem.urlPaths);
|
|
153
|
-
// console.log('unknown mismatch urls', count.mismatch.problem.list);
|
|
154
|
-
})();
|