@itentialopensource/adapter-utils 5.10.14 → 5.10.16

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/lib/dbUtil.js CHANGED
@@ -595,10 +595,11 @@ class DBUtil {
595
595
  */
596
596
  determineStorage(dbInfo, callback) {
597
597
  const origin = `${this.myid}-dbUtil-determineStorage`;
598
+
598
599
  if (dbInfo) {
599
600
  // priority 1 - use the dbInfo passed in
600
601
  if (dbInfo.dburl && dbInfo.database) {
601
- MongoClient.connect(dbInfo.dburl, dbInfo.dboptions, (err, mongoClient) => {
602
+ return MongoClient.connect(dbInfo.dburl, dbInfo.dboptions, (err, mongoClient) => {
602
603
  if (err) {
603
604
  log.error(`${origin}: Error! Failed to connect to database: ${err}`);
604
605
  return callback(err, null, null, null);
@@ -606,19 +607,20 @@ class DBUtil {
606
607
  log.debug('using dbinfo');
607
608
  return callback(null, Storage.DBINFO, mongoClient, dbInfo.database);
608
609
  });
609
- } else {
610
- const err = 'Error! Marlformed dbInfo';
611
- return callback(err, null, null, Storage.DBINFO);
612
610
  }
613
- } else if (this.adapterMongoClient) {
611
+ const err = 'Error! Malformed dbInfo - require url and database';
612
+ return callback(err, null, null, Storage.DBINFO);
613
+ }
614
+
615
+ if (this.adapterMongoClient) {
614
616
  // priority 2 - use the adapter database
615
617
  log.debug('using adapter db');
616
618
  return callback(null, Storage.ADAPTERDB, this.adapterMongoClient, this.database);
617
- } else if (this.dburl === null && dbInfo === null) {
618
- // priority 3 - use the filesystem
619
- log.debug('using filesystem');
620
- return callback(null, Storage.FILESYSTEM, null, null);
621
619
  }
620
+
621
+ // priority 3 - use the filesystem
622
+ log.debug('using filesystem');
623
+ return callback(null, Storage.FILESYSTEM, null, null);
622
624
  }
623
625
 
624
626
  /**
@@ -1153,7 +1153,7 @@ class AdapterPropertyUtil {
1153
1153
  }
1154
1154
 
1155
1155
  // This is the array of sensitive keys
1156
- let sensList = ['authorization', 'x-auth-token', 'x-csrf-token', 'x-amz-security-token', 'x-aws-ec2-metadata-token', 'cookie', 'set-cookie', 'token', 'tokenp2', 'user', 'username', 'passwd', 'password', 'api-key', 'client-id', 'client-secret', 'client_id', 'client_secret', 'session', 'session-id', 'jsessionid', 'sessionToken', 'accessKeyId', 'secretAccessKey', 'private-token', 'ca'];
1156
+ let sensList = ['authorization', 'x-auth-token', 'x-csrf-token', 'x-amz-security-token', 'x-aws-ec2-metadata-token', 'cookie', 'set-cookie', 'token', 'tokenp2', 'user', 'username', 'passwd', 'password', 'api-key', 'client-id', 'client-secret', 'client_id', 'client_secret', 'session', 'session-id', 'jsessionid', 'sessionToken', 'accessKeyId', 'secretAccessKey', 'private-token', 'ca'].map((item) => item.toLowerCase());
1157
1157
 
1158
1158
  // add any additional items to scrub
1159
1159
  if (addItems && Array.isArray(addItems) && addItems.length > 0) {
@@ -1207,7 +1207,7 @@ class AdapterPropertyUtil {
1207
1207
 
1208
1208
  // go through sensitive word list - maybe can use find in
1209
1209
  for (let j = 0; j < sensList.length; j += 1) {
1210
- if (key.toLowerCase() === sensList[j].toLowerCase()) {
1210
+ if (key.toLowerCase() === sensList[j]) {
1211
1211
  // if sensitive, mask
1212
1212
  retData += `${key}=** masked **`;
1213
1213
  found = true;
@@ -1229,12 +1229,19 @@ class AdapterPropertyUtil {
1229
1229
 
1230
1230
  // want to make a copy and not alter the original object or array
1231
1231
  const retData = JSON.parse(JSON.stringify(actualData));
1232
-
1232
+ if (retData && typeof retData.response === 'string') {
1233
+ try {
1234
+ const parsed = JSON.parse(retData.response);
1235
+ retData.response = parsed;
1236
+ } catch (e) {
1237
+ // ignore parse error
1238
+ }
1239
+ }
1233
1240
  // if we are scrubbing an array
1234
1241
  if (Array.isArray(retData)) {
1235
1242
  // need to go through each item in the array
1236
1243
  for (let i = 0; i < retData.length; i += 1) {
1237
- retData[i] = this.scrubSensitiveInfo(retData[i]);
1244
+ retData[i] = this.scrubSensitiveInfo(retData[i], addItems);
1238
1245
  }
1239
1246
 
1240
1247
  // return the scrubbed array
@@ -1253,18 +1260,18 @@ class AdapterPropertyUtil {
1253
1260
  if (sensList.includes(key.toLowerCase())) {
1254
1261
  retData[key][k] = '** masked **';
1255
1262
  } else {
1256
- retData[key][k] = this.scrubSensitiveInfo(retData[key][k]);
1263
+ retData[key][k] = this.scrubSensitiveInfo(retData[key][k], addItems);
1257
1264
  }
1258
1265
  }
1259
1266
  } else {
1260
- retData[key] = this.scrubSensitiveInfo(retData[key]);
1267
+ retData[key] = this.scrubSensitiveInfo(retData[key], addItems);
1261
1268
  }
1262
1269
  } else {
1263
1270
  // go through sensitive word list - maybe can use find in
1264
1271
  for (let j = 0; j < sensList.length; j += 1) {
1265
- if (key.toUpperCase() === sensList[j].toUpperCase()) {
1272
+ if (key.toLowerCase() === sensList[j]) {
1266
1273
  // if sensitive, mask
1267
- retData[key] = '=** masked **';
1274
+ retData[key] = '** masked **';
1268
1275
  break;
1269
1276
  }
1270
1277
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "5.10.14",
3
+ "version": "5.10.16",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",