@itentialopensource/adapter-utils 5.1.0 → 5.1.1

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/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ## 5.1.1 [08-22-2023]
3
+
4
+ * fix scrubing arrays - was not making copy
5
+
6
+ See merge request itentialopensource/adapter-utils!268
7
+
8
+ ---
9
+
2
10
  ## 5.1.0 [08-04-2023]
3
11
 
4
12
  * Changes to choosepath logic
@@ -1173,7 +1173,7 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1173
1173
  if (!tokenSchema.responseDatatype || tokenSchema.responseDatatype === 'JSON') {
1174
1174
  tokenResp.response = JSON.parse(tokenResp.response);
1175
1175
  }
1176
- log.debug(`${origin}: ${JSON.stringify(tokenResp.response)}`);
1176
+ log.debug(`${origin}: ${JSON.stringify(propUtilInst.scrubSensitiveInfo(tokenResp.response))}`);
1177
1177
 
1178
1178
  // return the token from the token schema
1179
1179
  let translated = null;
@@ -2903,7 +2903,7 @@ function requestAuthenticate(request, entitySchema, invalidToken, callProperties
2903
2903
  }
2904
2904
 
2905
2905
  // format the authentication string
2906
- log.debug(`${origin}: ${JSON.stringify(tres)} being used for user: ${useUser}`);
2906
+ log.debug(`${origin}: ${JSON.stringify(propUtilInst.scrubSensitiveInfo(tres))} being used for user: ${useUser}`);
2907
2907
  const authStrs = [];
2908
2908
  if (callProperties && callProperties.authentication && callProperties.authentication.auth_field_format) {
2909
2909
  if (Array.isArray(callProperties.authentication.auth_field_format)) {
@@ -2965,7 +2965,7 @@ function requestAuthenticate(request, entitySchema, invalidToken, callProperties
2965
2965
  return callback(null, errorObj);
2966
2966
  }
2967
2967
 
2968
- log.debug(`${origin}: ${JSON.stringify(tokenObj)} being used for user: ${useUser}`);
2968
+ log.debug(`${origin}: ${JSON.stringify(propUtilInst.scrubSensitiveInfo(tokenObj))} being used for user: ${useUser}`);
2969
2969
  const authStrs = [];
2970
2970
  if (callProperties && callProperties.authentication && callProperties.authentication.auth_field_format) {
2971
2971
  if (Array.isArray(callProperties.authentication.auth_field_format)) {
@@ -1147,7 +1147,7 @@ class AdapterPropertyUtil {
1147
1147
  }
1148
1148
 
1149
1149
  // This is the array of sensitive keys
1150
- 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', 'session', 'session-id'];
1150
+ 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', 'session', 'session-id', 'jsessionid'];
1151
1151
 
1152
1152
  // add any additional items to scrub
1153
1153
  if (addItems && Array.isArray(addItems) && addItems.length > 0) {
@@ -1157,17 +1157,6 @@ class AdapterPropertyUtil {
1157
1157
  // going to use copy of data so we do not mess up input - if object will still need to assign it
1158
1158
  let actualData = inData;
1159
1159
 
1160
- // if we are scrubbing an array
1161
- if (Array.isArray(actualData)) {
1162
- // need to go through each item in the array
1163
- for (let i = 0; i < actualData.length; i += 1) {
1164
- actualData[i] = this.scrubSensitiveInfo(actualData[i]);
1165
- }
1166
-
1167
- // return the scrubbed array
1168
- return actualData;
1169
- }
1170
-
1171
1160
  // if we are scrubbbing a string (e.g. URL)
1172
1161
  if (typeof actualData === 'string') {
1173
1162
  // if it is a Stringified JSON
@@ -1232,10 +1221,22 @@ class AdapterPropertyUtil {
1232
1221
  }
1233
1222
  }
1234
1223
 
1235
- // if we are scrubbing an object (or string that has been parsed)
1236
- if (typeof actualData === 'object') {
1237
- const retData = { ...actualData };
1224
+ // want to make a copy and not alter the original object or array
1225
+ const retData = JSON.parse(JSON.stringify(actualData));
1238
1226
 
1227
+ // if we are scrubbing an array
1228
+ if (Array.isArray(retData)) {
1229
+ // need to go through each item in the array
1230
+ for (let i = 0; i < retData.length; i += 1) {
1231
+ retData[i] = this.scrubSensitiveInfo(retData[i]);
1232
+ }
1233
+
1234
+ // return the scrubbed array
1235
+ return retData;
1236
+ }
1237
+
1238
+ // if we are scrubbing an object (or string that has been parsed)
1239
+ if (typeof retData === 'object') {
1239
1240
  // go through each item in the object
1240
1241
  Object.keys(retData).forEach((key) => {
1241
1242
  // go deep through an object with recursive call
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",
Binary file