common-rod 1.8.1 → 1.8.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/index.js +0 -1
- package/lib/http-service2.js +1 -1
- package/lib/maskCredential.js +82 -10
- package/lib/openAPI.js +5 -3
- package/lib/rodSession.js +26 -1
- package/package.json +2 -2
- package/readme.md +19 -0
package/index.js
CHANGED
|
@@ -648,7 +648,6 @@ function _startServer(app, envServer, appRodSession){
|
|
|
648
648
|
Object.assign( options, envServer.https_options);
|
|
649
649
|
}
|
|
650
650
|
|
|
651
|
-
|
|
652
651
|
let server = https.createServer(options, app)
|
|
653
652
|
server.listen(envServer.app_port, envServer.app_host, () => {
|
|
654
653
|
appRodSession.info(`Is Secure : | Port : ${envServer.app_port}`);
|
package/lib/http-service2.js
CHANGED
|
@@ -145,7 +145,7 @@ async function requestHttp(rodSession, optionAttributes, ins) {
|
|
|
145
145
|
let processLog = maskCredential.outgoing_request_detail(optionAttribute._service+'.'+optionAttribute._command, {
|
|
146
146
|
"Header" : {...optionAttribute.headers},
|
|
147
147
|
"Url" : getURL(optionAttribute),
|
|
148
|
-
"QueryString" : optionAttribute.params || null,
|
|
148
|
+
"QueryString" : {...optionAttribute.params} || null,
|
|
149
149
|
"Body" : optionAttribute.data, //NOT SHALLOW CLONE
|
|
150
150
|
"_RawData": optionAttribute._rawData //REMOVE AFTER CALL outgoing_request_detail
|
|
151
151
|
}, rodSession.detail().isRawDataEnabled());
|
package/lib/maskCredential.js
CHANGED
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"summary_log":true,
|
|
34
34
|
"detail_log":{
|
|
35
35
|
"raw_data":true,
|
|
36
|
-
"
|
|
36
|
+
"data_path_header": ["a.b","c.d"]
|
|
37
|
+
"data_path_querystrings": ["a.b","c.d"]
|
|
37
38
|
}
|
|
38
39
|
},{
|
|
39
40
|
"type":"fbbid",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"summary_log":true,
|
|
42
43
|
"detail_log":{
|
|
43
44
|
"raw_data":true,
|
|
44
|
-
"
|
|
45
|
+
"data_path_header": ["a.b","c.d"]
|
|
45
46
|
}
|
|
46
47
|
}]
|
|
47
48
|
},
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
"summary_log":true,
|
|
53
54
|
"detail_log":{
|
|
54
55
|
"raw_data":true,
|
|
55
|
-
"
|
|
56
|
+
"data_path_header": ["a.b","c.d"]
|
|
56
57
|
}
|
|
57
58
|
}]
|
|
58
59
|
}
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
//"summary_log":true,
|
|
67
68
|
"detail_log":{
|
|
68
69
|
"raw_data":true,
|
|
69
|
-
"
|
|
70
|
+
"data_path_header": ["a.b","c.d"]
|
|
70
71
|
}
|
|
71
72
|
}]
|
|
72
73
|
}
|
|
@@ -83,7 +84,8 @@
|
|
|
83
84
|
"summary_log":true,
|
|
84
85
|
"detail_log":{
|
|
85
86
|
"raw_data":true,
|
|
86
|
-
"
|
|
87
|
+
"data_path_header": ["a.b","c.d"]
|
|
88
|
+
"data_path_body": ["a.b","c.d"]
|
|
87
89
|
}
|
|
88
90
|
},{
|
|
89
91
|
"type":"fbbid",
|
|
@@ -91,7 +93,7 @@
|
|
|
91
93
|
"summary_log":true,
|
|
92
94
|
"detail_log":{
|
|
93
95
|
"raw_data":true,
|
|
94
|
-
"
|
|
96
|
+
"data_path_body": ["a.b","c.d"]
|
|
95
97
|
}
|
|
96
98
|
}]
|
|
97
99
|
}
|
|
@@ -288,9 +290,10 @@ let maskCredential = function () {
|
|
|
288
290
|
let copyHeaders = {
|
|
289
291
|
...req.headers
|
|
290
292
|
}
|
|
291
|
-
|
|
293
|
+
let queryString = Object.keys(req.query).length === 0 ? null : {...req.query};
|
|
292
294
|
let body;
|
|
293
295
|
let rawData = req.rodRawData;
|
|
296
|
+
let url = req.url;
|
|
294
297
|
if (typeof req.body === 'object') {
|
|
295
298
|
// rawData = Object.keys(req.body).length === 0 ? null : JSON.stringify(req.body);
|
|
296
299
|
// body = {
|
|
@@ -330,6 +333,41 @@ let maskCredential = function () {
|
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
335
|
}
|
|
336
|
+
//url
|
|
337
|
+
if (mask.detail_log.url && url) {
|
|
338
|
+
if (mask_credentails.mask_template[mask.type]) {
|
|
339
|
+
let mt = mask_credentails.mask_template[mask.type];
|
|
340
|
+
for (let k = 0; k < mt.length; k++) {
|
|
341
|
+
let replaced = url.search(mt[k].pattern) >= 0;
|
|
342
|
+
if (replaced) {
|
|
343
|
+
url = url.replace(mt[k].pattern, mt[k].mask_value);
|
|
344
|
+
if (mt[k].continue !== true) {
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
//querystring
|
|
353
|
+
if (mask.detail_log.data_path_querystrings && queryString) {
|
|
354
|
+
for (let j = 0; j < mask.detail_log.data_path_querystrings.length; j++) {
|
|
355
|
+
let queryStringPath = mask.detail_log.data_path_querystrings[j];
|
|
356
|
+
if (queryString[queryStringPath] && mask_credentails.mask_template[mask.type]) {
|
|
357
|
+
let mt = mask_credentails.mask_template[mask.type];
|
|
358
|
+
for (let k = 0; k < mt.length; k++) {
|
|
359
|
+
let replaced = queryString[queryStringPath].search(mt[k].pattern) >= 0;
|
|
360
|
+
if (replaced) {
|
|
361
|
+
queryString[queryStringPath] = queryString[queryStringPath].replace(mt[k].pattern, mt[k].mask_value);
|
|
362
|
+
if (mt[k].continue !== true) {
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
333
371
|
if (mask.detail_log.data_path_headers) {
|
|
334
372
|
for (let j = 0; j < mask.detail_log.data_path_headers.length; j++) {
|
|
335
373
|
let headerPath = mask.detail_log.data_path_headers[j];
|
|
@@ -344,7 +382,6 @@ let maskCredential = function () {
|
|
|
344
382
|
}
|
|
345
383
|
}
|
|
346
384
|
}
|
|
347
|
-
|
|
348
385
|
}
|
|
349
386
|
}
|
|
350
387
|
}
|
|
@@ -395,8 +432,8 @@ let maskCredential = function () {
|
|
|
395
432
|
detailLog.addInputRequest("client", inputCmd, req.invoke,
|
|
396
433
|
rawData, {
|
|
397
434
|
Headers: copyHeaders,
|
|
398
|
-
Url:
|
|
399
|
-
QueryString:
|
|
435
|
+
Url: url,
|
|
436
|
+
QueryString: queryString,
|
|
400
437
|
Body: body
|
|
401
438
|
},
|
|
402
439
|
req.protocol, req.method);
|
|
@@ -823,6 +860,41 @@ let maskCredential = function () {
|
|
|
823
860
|
}
|
|
824
861
|
}
|
|
825
862
|
}
|
|
863
|
+
//url
|
|
864
|
+
if (mask.detail_log.url && obj.Url) {
|
|
865
|
+
if (mask_credentails.mask_template[mask.type]) {
|
|
866
|
+
let mt = mask_credentails.mask_template[mask.type];
|
|
867
|
+
for (let k = 0; k < mt.length; k++) {
|
|
868
|
+
let replaced = obj.Url.search(mt[k].pattern) >= 0;
|
|
869
|
+
if (replaced) {
|
|
870
|
+
obj.Url = obj.Url.replace(mt[k].pattern, mt[k].mask_value);
|
|
871
|
+
if (mt[k].continue !== true) {
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
//querystring
|
|
880
|
+
if (mask.detail_log.data_path_querystrings && obj.QueryString) {
|
|
881
|
+
for (let j = 0; j < mask.detail_log.data_path_querystrings.length; j++) {
|
|
882
|
+
let queryStringPath = mask.detail_log.data_path_querystrings[j];
|
|
883
|
+
if (obj.QueryString[queryStringPath] && mask_credentails.mask_template[mask.type]) {
|
|
884
|
+
let mt = mask_credentails.mask_template[mask.type];
|
|
885
|
+
for (let k = 0; k < mt.length; k++) {
|
|
886
|
+
let replaced = obj.QueryString[queryStringPath].search(mt[k].pattern) >= 0;
|
|
887
|
+
if (replaced) {
|
|
888
|
+
obj.QueryString[queryStringPath] = obj.QueryString[queryStringPath].replace(mt[k].pattern, mt[k].mask_value);
|
|
889
|
+
if (mt[k].continue !== true) {
|
|
890
|
+
break;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
826
898
|
//header
|
|
827
899
|
if (mask.detail_log.data_path_headers) {
|
|
828
900
|
for (let j = 0; j < mask.detail_log.data_path_headers.length; j++) {
|
package/lib/openAPI.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const swaggerUi = require('swagger-ui-express');
|
|
2
|
+
const express = require('express');
|
|
2
3
|
const fs = require('fs');
|
|
3
4
|
const path = require('path');
|
|
4
|
-
const { log } = require('console');
|
|
5
5
|
const currentAppPath = path.dirname(require.main.filename);
|
|
6
6
|
// const pjson = require(currentAppPath + '/package.json');
|
|
7
7
|
let pjson = {};
|
|
@@ -170,6 +170,7 @@ let openAPI = function () {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
+
app.use('/api-docs/img/', express.static(path.join(__dirname, '../res')));
|
|
173
174
|
|
|
174
175
|
// console.log(JSON.stringify(spec, null, 4));
|
|
175
176
|
app.use('/api-docs/', function(req, res, next){
|
|
@@ -177,9 +178,10 @@ let openAPI = function () {
|
|
|
177
178
|
if(req.originalUrl === '/api-docs/'){
|
|
178
179
|
spec.servers = [{"url" : req.protocol + "://"+req.get('host')}];
|
|
179
180
|
req.swaggerDoc = spec;
|
|
180
|
-
}else if(req.url.startsWith("/img/")){
|
|
181
|
-
return res.sendFile( path.resolve( __dirname + "/../res/" + req.url.substring("/img/".length)) );
|
|
182
181
|
}
|
|
182
|
+
// else if(req.url.startsWith("/img/")){
|
|
183
|
+
// return res.sendFile( path.resolve( __dirname + "/../res/" + req.url.substring("/img/".length)) );
|
|
184
|
+
// }
|
|
183
185
|
next();
|
|
184
186
|
}, swaggerUi.serve, swaggerUi.setup(null, options));
|
|
185
187
|
|
package/lib/rodSession.js
CHANGED
|
@@ -186,7 +186,32 @@ RodSession.prototype = function () {
|
|
|
186
186
|
return this._selectorAppConf(key,false);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
},
|
|
189
|
+
},
|
|
190
|
+
https : ()=>{
|
|
191
|
+
return {
|
|
192
|
+
request_old : (optionAttribute)=>{
|
|
193
|
+
return httpService.request(this, optionAttribute);
|
|
194
|
+
},
|
|
195
|
+
request : (optionAttribute)=>{
|
|
196
|
+
return httpService2.requestHttp(this, optionAttribute)
|
|
197
|
+
.catch((err)=>{
|
|
198
|
+
this.warn("this.utils().https().request", err.message);
|
|
199
|
+
return err;
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
isError : (res)=>{
|
|
203
|
+
if(Array.isArray(res)){
|
|
204
|
+
for (let i = 0; i < res.length; i++) {
|
|
205
|
+
if( typeof res[i] === 'string') return true;
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
208
|
+
}else {
|
|
209
|
+
return typeof res === 'string'
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
190
215
|
http : ()=>{
|
|
191
216
|
return {
|
|
192
217
|
request_old : (optionAttribute)=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "common-rod",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"author": "Thanakhan Iaocharoen",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"axios": "^0.
|
|
12
|
+
"axios": "^0.30.0",
|
|
13
13
|
"body-parser": "^1.19.0",
|
|
14
14
|
"cli-table": "^0.3.1",
|
|
15
15
|
"commonlog-kb": "^2.3.0",
|
package/readme.md
CHANGED
|
@@ -357,3 +357,22 @@ upgrade mongo version from 3.x to 4
|
|
|
357
357
|
```
|
|
358
358
|
### Changed
|
|
359
359
|
### Fixed
|
|
360
|
+
|
|
361
|
+
[1.8.2] - 2023-11-01
|
|
362
|
+
### Added
|
|
363
|
+
### Changed
|
|
364
|
+
### Fixed
|
|
365
|
+
```
|
|
366
|
+
fixed insecure Transport: Weak SSL Protocol
|
|
367
|
+
fixed Path Manipulation
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
[1.8.3] - 2025-05-16
|
|
373
|
+
### Added
|
|
374
|
+
### Changed
|
|
375
|
+
```
|
|
376
|
+
change axios from 0.21.4 to 0.30.0
|
|
377
|
+
```
|
|
378
|
+
### Fixed
|