common-rod 1.8.2 → 2.0.0

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.
@@ -1,9 +1,9 @@
1
1
  const axios = require('axios');
2
- const buildURL = require('axios/lib/helpers/buildURL')
3
2
  const randomService = require('./random-service');
4
3
  const utils = require('./utils');
5
4
  const maskCredential = require('./maskCredential');
6
5
  const log = require('commonlog-kb');
6
+ // const buildURL = require('./utilAxios');
7
7
 
8
8
  const ERROR_TBL = {
9
9
  TIMEOUT : 'TIMEOUT',
@@ -23,9 +23,10 @@ const ERROR_TBL = {
23
23
  // return Promise.reject(error);
24
24
  // });
25
25
 
26
- //reuse utils of axis
26
+ //reuse utils of axios - custom implementation for URL building
27
27
  const getURL = (config) => {
28
- return buildURL(config.url, config.params, config.paramsSerializer)
28
+ // return buildURL(config.url, config.params, config.paramsSerializer);
29
+ return axios.getUri(config);
29
30
  }
30
31
 
31
32
  function InstanceHTTPReq(reqCount){
@@ -145,7 +146,7 @@ async function requestHttp(rodSession, optionAttributes, ins) {
145
146
  let processLog = maskCredential.outgoing_request_detail(optionAttribute._service+'.'+optionAttribute._command, {
146
147
  "Header" : {...optionAttribute.headers},
147
148
  "Url" : getURL(optionAttribute),
148
- "QueryString" : optionAttribute.params || null,
149
+ "QueryString" : {...optionAttribute.params} || null,
149
150
  "Body" : optionAttribute.data, //NOT SHALLOW CLONE
150
151
  "_RawData": optionAttribute._rawData //REMOVE AFTER CALL outgoing_request_detail
151
152
  }, rodSession.detail().isRawDataEnabled());
@@ -33,7 +33,8 @@
33
33
  "summary_log":true,
34
34
  "detail_log":{
35
35
  "raw_data":true,
36
- "data_path": ["a.b","c.d"]
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
- "data_path": ["a.b","c.d"]
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
- "path": ["a.b","c.d"]
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
- "path": ["a.b","c.d"]
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
- "data_path": ["a.b","c.d"]
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
- "data_path": ["a.b","c.d"]
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: req.url,
399
- QueryString: Object.keys(req.query).length === 0 ? null : req.query,
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "common-rod",
3
- "version": "1.8.2",
3
+ "version": "2.0.0",
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.21.4",
12
+ "axios": "^1.13.5",
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
@@ -365,4 +365,22 @@ upgrade mongo version from 3.x to 4
365
365
  ```
366
366
  fixed insecure Transport: Weak SSL Protocol
367
367
  fixed Path Manipulation
368
- ```
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
379
+
380
+ [2.0.0] - 2026-02-16
381
+ ### Added
382
+ ### Changed
383
+ ```
384
+ change axios from 0.30.0 to 1.13.5
385
+ ```
386
+ ### Fixed