@contrast/assess 1.28.0 → 1.28.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.
Files changed (52) hide show
  1. package/lib/crypto-analysis/install/crypto.js +1 -1
  2. package/lib/dataflow/propagation/install/JSON/parse.js +2 -2
  3. package/lib/dataflow/propagation/install/JSON/stringify.js +10 -11
  4. package/lib/dataflow/propagation/install/array-prototype-join.js +6 -7
  5. package/lib/dataflow/propagation/install/contrast-methods/add.js +1 -3
  6. package/lib/dataflow/propagation/install/joi/boolean.js +2 -4
  7. package/lib/dataflow/propagation/install/joi/expression.js +2 -4
  8. package/lib/dataflow/propagation/install/joi/index.js +1 -1
  9. package/lib/dataflow/propagation/install/joi/number.js +2 -4
  10. package/lib/dataflow/propagation/install/joi/string-schema.js +8 -3
  11. package/lib/dataflow/propagation/install/joi/values.js +5 -1
  12. package/lib/dataflow/propagation/install/path/format.js +7 -4
  13. package/lib/dataflow/propagation/install/path/parse.js +4 -5
  14. package/lib/dataflow/propagation/install/querystring/escape.js +1 -1
  15. package/lib/dataflow/propagation/install/querystring/parse.js +6 -7
  16. package/lib/dataflow/propagation/install/querystring/stringify.js +1 -1
  17. package/lib/dataflow/propagation/install/reg-exp-prototype-exec.js +2 -3
  18. package/lib/dataflow/propagation/install/string/concat.js +19 -19
  19. package/lib/dataflow/propagation/install/string/html-methods.js +1 -1
  20. package/lib/dataflow/propagation/install/string/index.js +3 -3
  21. package/lib/dataflow/propagation/install/string/match-all.js +4 -9
  22. package/lib/dataflow/propagation/install/string/match.js +5 -4
  23. package/lib/dataflow/propagation/install/string/replace.js +18 -12
  24. package/lib/dataflow/propagation/install/string/slice.js +4 -4
  25. package/lib/dataflow/propagation/install/string/split.js +13 -11
  26. package/lib/dataflow/propagation/install/string/substring.js +6 -5
  27. package/lib/dataflow/propagation/install/url/parse.js +1 -1
  28. package/lib/dataflow/propagation/install/url/searchParams.js +2 -1
  29. package/lib/dataflow/propagation/install/url/url.js +1 -1
  30. package/lib/dataflow/sinks/install/child-process.js +1 -1
  31. package/lib/dataflow/sinks/install/express/reflected-xss.js +7 -5
  32. package/lib/dataflow/sinks/install/express/unvalidated-redirect.js +1 -2
  33. package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +1 -3
  34. package/lib/dataflow/sinks/install/fs.js +1 -1
  35. package/lib/dataflow/sinks/install/function.js +1 -1
  36. package/lib/dataflow/sinks/install/hapi/unvalidated-redirect.js +1 -2
  37. package/lib/dataflow/sinks/install/http/request.js +6 -5
  38. package/lib/dataflow/sinks/install/koa/unvalidated-redirect.js +2 -2
  39. package/lib/dataflow/sinks/install/libxmljs.js +1 -1
  40. package/lib/dataflow/sinks/install/marsdb.js +1 -2
  41. package/lib/dataflow/sinks/install/mongodb.js +1 -1
  42. package/lib/dataflow/sinks/install/mysql.js +1 -1
  43. package/lib/dataflow/sinks/install/postgres.js +1 -3
  44. package/lib/dataflow/sinks/install/sequelize.js +1 -2
  45. package/lib/dataflow/sinks/install/vm.js +1 -1
  46. package/lib/dataflow/tag-utils.js +17 -1
  47. package/lib/index.js +13 -0
  48. package/lib/session-configuration/install/express-session.js +1 -3
  49. package/lib/session-configuration/install/fastify-cookie.js +1 -1
  50. package/lib/session-configuration/install/hapi.js +1 -3
  51. package/lib/session-configuration/install/koa.js +1 -1
  52. package/package.json +1 -1
@@ -15,7 +15,6 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { inspect } = require('util');
19
18
  const {
20
19
  Rule,
21
20
  isString,
@@ -54,6 +53,7 @@ module.exports = function (core) {
54
53
  logger,
55
54
  patcher,
56
55
  assess: {
56
+ inspect, // todo: remove
57
57
  eventFactory,
58
58
  cryptoAnalysis,
59
59
  getSourceContext,
@@ -15,7 +15,7 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { isString, inspect } = require('@contrast/common');
18
+ const { isString } = require('@contrast/common');
19
19
  const { createSubsetTags } = require('../../../tag-utils');
20
20
  const { patchType } = require('../../common');
21
21
  const { getKeyValueIndices } = require('./parse-fn');
@@ -75,7 +75,7 @@ module.exports = function (core) {
75
75
  moduleName: 'JSON',
76
76
  methodName: 'parse',
77
77
  object: {
78
- value: inspect(data.obj),
78
+ value: 'JSON',
79
79
  tracked: false,
80
80
  },
81
81
  args: eventArgs,
@@ -15,12 +15,10 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const {
19
- createMergedTags
20
- } = require('../../../tag-utils');
21
- const { isString, inspect, replace, match, matchAll, slice } = require('@contrast/common');
22
- const { patchType } = require('../../common');
23
18
  const crypto = require('crypto');
19
+ const { isString, replace, match, matchAll, slice } = require('@contrast/common');
20
+ const { createMergedTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
21
+ const { patchType } = require('../../common');
24
22
 
25
23
  function makeCanary() {
26
24
  return replace(
@@ -88,7 +86,6 @@ module.exports = function(core) {
88
86
  return null;
89
87
  }
90
88
 
91
-
92
89
  const props = tracker.getData(slice(space, 0, 10));
93
90
  if (!props || !Object.keys(props.tags).length) {
94
91
  return null;
@@ -246,21 +243,23 @@ module.exports = function(core) {
246
243
  methodName: 'stringify',
247
244
  history: Array.from(metadata.history),
248
245
  object: {
249
- value: inspect(data.obj),
246
+ value: 'JSON',
250
247
  tracked: false
251
248
  },
252
249
  args: [
253
250
  {
254
- value: inspect(metadata.origArgs[0]),
251
+ value: getAdjustedUntrackedValue(metadata.origArgs[0]),
255
252
  tracked: false
256
253
  },
257
254
  (metadata.origArgs[1] && {
258
- value: inspect(metadata.origArgs[1]),
255
+ value: getAdjustedUntrackedValue(metadata.origArgs[1]),
259
256
  tracked: false
260
257
  }),
261
258
  (metadata.origArgs[2] && {
262
- value: inspect(metadata.origArgs[2]),
263
- tracked: !!metadata.spaceProps
259
+ tracked: !!metadata.spaceProps,
260
+ value: metadata.spaceProps ?
261
+ `'${metadata.origArgs[2]}'` :
262
+ getAdjustedUntrackedValue(metadata.origArgs[2]),
264
263
  })
265
264
  ].filter(Boolean),
266
265
  result: {
@@ -15,7 +15,7 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { isString, join, inspect } = require('@contrast/common');
18
+ const { isString } = require('@contrast/common');
19
19
  const { InstrumentationType: { PROPAGATOR } } = require('../../../constants');
20
20
  const { createAppendTags } = require('../../tag-utils');
21
21
  const { patchType } = require('../common');
@@ -78,10 +78,6 @@ module.exports = function(core) {
78
78
  const delimiterInfo = tracker.getData(delimiter);
79
79
  const initHistory = delimiterInfo ? new Set([delimiterInfo]) : new Set();
80
80
  const { newTags, newHistory: history } = accumulateTags(obj, {}, 0, initHistory, delimiterLength, delimiterInfo?.tags);
81
- const object = {
82
- value: obj && join(obj),
83
- tracked: false
84
- };
85
81
 
86
82
  const args = [{
87
83
  value: delimiterInfo ? delimiterInfo.value : delimiter,
@@ -93,8 +89,11 @@ module.exports = function(core) {
93
89
  name,
94
90
  moduleName: 'Array',
95
91
  methodName: 'prototype.join',
96
- context: `${object.value}.join('${inspect(args[0].value) || ''})`,
97
- object,
92
+ context: `[...].join('${args[0].value || ''}')`,
93
+ object: {
94
+ value: 'Array',
95
+ tracked: false
96
+ },
98
97
  result: {
99
98
  value: resultInfo ? resultInfo.value : result,
100
99
  tracked: true
@@ -15,21 +15,19 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const util = require('util');
19
18
  const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
20
19
  const { createAppendTags } = require('../../../tag-utils');
21
20
 
22
21
  module.exports = function(core) {
23
22
  const {
24
- patcher,
25
23
  assess: {
24
+ inspect,
26
25
  getSourceContext,
27
26
  eventFactory: { createPropagationEvent },
28
27
  dataflow: { tracker }
29
28
  }
30
29
  } = core;
31
30
 
32
- const inspect = patcher.unwrap(util.inspect);
33
31
  const origSym = Symbol('ContrastMethods.add.orig');
34
32
 
35
33
  return core.assess.dataflow.propagation.contrastMethodsInstrumentation.add = {
@@ -15,10 +15,7 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const {
19
- DataflowTag: { ALPHANUM_SPACE_HYPHEN },
20
- inspect,
21
- } = require('@contrast/common');
18
+ const { DataflowTag: { ALPHANUM_SPACE_HYPHEN } } = require('@contrast/common');
22
19
  const { patchType } = require('../../common');
23
20
 
24
21
  module.exports = function(core) {
@@ -27,6 +24,7 @@ module.exports = function(core) {
27
24
  scopes: { sources, instrumentation },
28
25
  patcher,
29
26
  assess: {
27
+ inspect, // todo: remove
30
28
  eventFactory: { createPropagationEvent },
31
29
  dataflow: { tracker },
32
30
  },
@@ -15,10 +15,7 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const {
19
- DataflowTag: { HTML_ENCODED },
20
- inspect,
21
- } = require('@contrast/common');
18
+ const { DataflowTag: { HTML_ENCODED } } = require('@contrast/common');
22
19
  const { patchType } = require('../../common');
23
20
 
24
21
  module.exports = function(core) {
@@ -27,6 +24,7 @@ module.exports = function(core) {
27
24
  scopes: { sources, instrumentation },
28
25
  patcher,
29
26
  assess: {
27
+ inspect, // todo: remove
30
28
  eventFactory: { createPropagationEvent },
31
29
  dataflow: { tracker },
32
30
  },
@@ -20,7 +20,6 @@ const {
20
20
  isString,
21
21
  isNonEmptyObject,
22
22
  traverseValues,
23
- inspect,
24
23
  } = require('@contrast/common');
25
24
  const { patchType } = require('../../common');
26
25
  const { tagCustomValidatedString, handleReferences } = require('./utils');
@@ -30,6 +29,7 @@ module.exports = function(core) {
30
29
  patcher,
31
30
  scopes: { sources, instrumentation },
32
31
  assess: {
32
+ inspect, // todo: remove
33
33
  eventFactory: { createPropagationEvent },
34
34
  dataflow: { tracker },
35
35
  },
@@ -15,10 +15,7 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const {
19
- DataflowTag: { LIMITED_CHARS },
20
- inspect,
21
- } = require('@contrast/common');
18
+ const { DataflowTag: { LIMITED_CHARS } } = require('@contrast/common');
22
19
  const { patchType } = require('../../common');
23
20
 
24
21
  module.exports = function(core) {
@@ -27,6 +24,7 @@ module.exports = function(core) {
27
24
  scopes: { sources, instrumentation },
28
25
  patcher,
29
26
  assess: {
27
+ inspect, // todo: remove
30
28
  eventFactory: { createPropagationEvent },
31
29
  dataflow: { tracker },
32
30
  },
@@ -16,12 +16,16 @@
16
16
  'use strict';
17
17
 
18
18
  const {
19
- DataflowTag: { ALPHANUM_SPACE_HYPHEN, LIMITED_CHARS, STRING_TYPE_CHECKED },
20
- inspect,
19
+ DataflowTag: {
20
+ ALPHANUM_SPACE_HYPHEN,
21
+ LIMITED_CHARS,
22
+ STRING_TYPE_CHECKED
23
+ },
21
24
  } = require('@contrast/common');
22
- const { handleReferences } = require('./utils');
23
25
  const { createFullLengthCopyTags } = require('../../../tag-utils');
24
26
  const { patchType } = require('../../common');
27
+ const { handleReferences } = require('./utils');
28
+
25
29
  const VALIDATORS = {
26
30
  base64: ALPHANUM_SPACE_HYPHEN,
27
31
  guid: ALPHANUM_SPACE_HYPHEN,
@@ -42,6 +46,7 @@ module.exports = function(core) {
42
46
  scopes: { sources, instrumentation },
43
47
  patcher,
44
48
  assess: {
49
+ inspect, // todo: remove
45
50
  eventFactory: { createPropagationEvent },
46
51
  dataflow: {
47
52
  tracker, propagation: {
@@ -16,7 +16,10 @@
16
16
  'use strict';
17
17
 
18
18
  const {
19
- isNonEmptyObject, isString, inspect, traverseValues, join
19
+ isNonEmptyObject,
20
+ isString,
21
+ join,
22
+ traverseValues,
20
23
  } = require('@contrast/common');
21
24
  const { createMergedTags } = require('../../../tag-utils');
22
25
  const { patchType } = require('../../common');
@@ -27,6 +30,7 @@ module.exports = function(core) {
27
30
  scopes: { sources, instrumentation },
28
31
  patcher,
29
32
  assess: {
33
+ inspect, // todo: remove
30
34
  eventFactory: { createPropagationEvent },
31
35
  dataflow: { tracker },
32
36
  },
@@ -14,9 +14,9 @@
14
14
  */
15
15
 
16
16
  'use strict';
17
+ const { join, isString } = require('@contrast/common');
17
18
  const { patchType } = require('../../common');
18
- const { isString, inspect } = require('@contrast/common');
19
- const { createMergedTags } = require('../../../tag-utils');
19
+ const { createMergedTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
20
20
  const {
21
21
  createArgTagsInResult,
22
22
  excludeExtensionDotFromTags
@@ -65,7 +65,10 @@ module.exports = function(core) {
65
65
  let newTags = {};
66
66
  const propInfo = isString(prop) && tracker.getData(prop);
67
67
  if (!propInfo) {
68
- eventArgs.unshift({ value: prop, tracked: false });
68
+ eventArgs.unshift({
69
+ value: getAdjustedUntrackedValue(prop),
70
+ tracked: false
71
+ });
69
72
  continue;
70
73
  }
71
74
 
@@ -95,7 +98,7 @@ module.exports = function(core) {
95
98
  name: patchName,
96
99
  moduleName: 'path',
97
100
  methodName: 'format',
98
- context: `path.format('${inspect(...args)}')`,
101
+ context: `path.format(${join(eventArgs.map((a) => a.value))})`,
99
102
  history,
100
103
  object: {
101
104
  value: 'path',
@@ -14,12 +14,10 @@
14
14
  */
15
15
 
16
16
  'use strict';
17
- const { patchType } = require('../../common');
18
- const { isString, inspect } = require('@contrast/common');
17
+ const { isString } = require('@contrast/common');
19
18
  const { createSubsetTags } = require('../../../tag-utils');
20
- const {
21
- excludeExtensionDotFromTags
22
- } = require('./common');
19
+ const { patchType } = require('../../common');
20
+ const { excludeExtensionDotFromTags } = require('./common');
23
21
 
24
22
  module.exports = function(core) {
25
23
  const {
@@ -27,6 +25,7 @@ module.exports = function(core) {
27
25
  patcher,
28
26
  scopes: { sources, instrumentation },
29
27
  assess: {
28
+ inspect, // todo: remove
30
29
  eventFactory: { createPropagationEvent },
31
30
  dataflow: { tracker },
32
31
  },
@@ -14,7 +14,6 @@
14
14
  */
15
15
  'use strict';
16
16
 
17
- const { inspect } = require('util');
18
17
  const { DataflowTag: { URL_ENCODED } } = require('@contrast/common');
19
18
  const { createFullLengthCopyTags } = require('../../../tag-utils');
20
19
  const { patchType } = require('../../common');
@@ -22,6 +21,7 @@ const { patchType } = require('../../common');
22
21
  module.exports = function(core) {
23
22
  const {
24
23
  assess: {
24
+ inspect, // todo: remove
25
25
  eventFactory: { createPropagationEvent },
26
26
  dataflow: { tracker }
27
27
  },
@@ -18,12 +18,10 @@
18
18
  const querystring = require('querystring');
19
19
  const {
20
20
  DataflowTag: { URL_ENCODED },
21
- inspect,
22
21
  join
23
22
  } = require('@contrast/common');
24
-
23
+ const { createSubsetTags, createAppendTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
25
24
  const { patchType } = require('../../common');
26
- const { createSubsetTags, createAppendTags } = require('../../../tag-utils');
27
25
 
28
26
  module.exports = function(core) {
29
27
  const {
@@ -48,10 +46,11 @@ module.exports = function(core) {
48
46
  if (!tagRanges) return result;
49
47
 
50
48
  const resultInfo = tracker.getData(result);
51
- const [, ...restOfArgsValues] = data.origArgs.map(inspect);
49
+ const [, ...restArgs] = data.origArgs.map(getAdjustedUntrackedValue);
50
+ const restArgStr = restArgs.length ? `,${join(restArgs)}` : '';
52
51
  const event = createPropagationEvent({
53
52
  name: data.name,
54
- context: `querystring.parse('${trackingData.value}', ${join(restOfArgsValues, ', ')})`,
53
+ context: `querystring.parse('${trackingData.value}'${restArgStr})`,
55
54
  moduleName: 'querystring',
56
55
  methodName: 'parse',
57
56
  history: [trackingData],
@@ -60,7 +59,7 @@ module.exports = function(core) {
60
59
  tracked: true,
61
60
  },
62
61
  args: data.origArgs.map((_arg, idx) => ({
63
- value: idx === 0 ? trackingData.value : restOfArgsValues[idx - 1],
62
+ value: idx === 0 ? trackingData.value : restArgs[idx - 1],
64
63
  tracked: !!idx === 0
65
64
  })).filter(el => el),
66
65
  result: {
@@ -116,7 +115,7 @@ module.exports = function(core) {
116
115
  }
117
116
 
118
117
  data.idx = 0;
119
- data.origArgs = data.args;
118
+ data.origArgs = [...data.args];
120
119
  data.trackingData = trackingData;
121
120
 
122
121
  data.args[3] = {
@@ -15,7 +15,6 @@
15
15
  'use strict';
16
16
 
17
17
  const querystring = require('querystring');
18
- const { inspect } = require('util');
19
18
  const { isString } = require('@contrast/common');
20
19
  const utils = require('../../../tag-utils');
21
20
  const { patchType } = require('../../common');
@@ -25,6 +24,7 @@ const moduleName = 'querystring';
25
24
  module.exports = function(core) {
26
25
  const {
27
26
  assess: {
27
+ inspect, // todo: remove
28
28
  dataflow: { tracker },
29
29
  eventFactory: { createPropagationEvent },
30
30
  },
@@ -14,8 +14,7 @@
14
14
  */
15
15
 
16
16
  'use strict';
17
- const { inspect } = require('@contrast/common');
18
- const { createSubsetTags } = require('../../tag-utils');
17
+ const { createSubsetTags, getAdjustedUntrackedValue } = require('../../tag-utils');
19
18
  const { patchType } = require('../common');
20
19
 
21
20
  module.exports = function(core) {
@@ -58,7 +57,7 @@ module.exports = function(core) {
58
57
  ],
59
58
  tags,
60
59
  result: {
61
- value: inspect(untrackedResult),
60
+ value: getAdjustedUntrackedValue(untrackedResult),
62
61
  tracked: false,
63
62
  },
64
63
  stacktraceOpts: {
@@ -15,9 +15,9 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { join, inspect } = require('@contrast/common');
18
+ const { join } = require('@contrast/common');
19
19
  const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
20
- const { createAppendTags } = require('../../../tag-utils');
20
+ const { createAppendTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
21
21
  const { patchType } = require('../../common');
22
22
 
23
23
  module.exports = function(core) {
@@ -38,7 +38,7 @@ module.exports = function(core) {
38
38
  name,
39
39
  patchType,
40
40
  post(data) {
41
- const { args, obj, result, hooked, orig } = data;
41
+ const { obj, result, hooked, orig } = data;
42
42
  if (!result || !getSourceContext(PROPAGATOR)) return;
43
43
 
44
44
  const rInfo = tracker.getData(result);
@@ -47,45 +47,45 @@ module.exports = function(core) {
47
47
  return;
48
48
  }
49
49
 
50
- const argsData = [];
51
50
  const objInfo = tracker.getData(obj);
52
51
  const history = objInfo ? new Set([objInfo]) : new Set();
53
- const newTags = { ...objInfo?.tags };
54
52
  let globalOffset = typeof obj !== 'function' ? obj.length : 0;
53
+ const args = [];
54
+ let tags = objInfo?.tags;
55
55
 
56
- for (const str of args) {
57
- const strInfo = tracker.getData(str);
56
+ for (const arg of data.args) {
57
+ const strInfo = tracker.getData(arg);
58
58
 
59
59
  if (strInfo) {
60
- const strTags = strInfo?.tags || {};
60
+ args.push({ tracked: true, value: arg });
61
61
  history.add(strInfo);
62
- Object.assign(newTags, createAppendTags(newTags, strTags, globalOffset));
62
+ tags = createAppendTags(tags, strInfo.tags, globalOffset);
63
+ } else {
64
+ args.push({ tracked: false, value: getAdjustedUntrackedValue(arg) });
63
65
  }
64
66
 
65
- argsData.push({
66
- value: strInfo?.value ?? str,
67
- tracked: !!strInfo
68
- });
69
-
70
- globalOffset += `${str}`.length;
67
+ globalOffset += `${arg}`.length;
71
68
  }
72
69
 
70
+ const objVal = objInfo ? `'${objInfo.value}'` : getAdjustedUntrackedValue(obj);
71
+ const context = `${objVal}.concat(${join(args.map((a) => a.value))})`;
72
+
73
73
  if (history.size) {
74
74
  const event = createPropagationEvent({
75
75
  name,
76
76
  moduleName: 'String',
77
77
  methodName: 'prototype.concat',
78
- context: `${inspect(objInfo?.value) || String(obj)}.concat(${inspect(join(argsData.map(d => d.value)), ', ')})`,
78
+ context,
79
79
  object: {
80
- value: objInfo?.value || String(obj),
80
+ value: objInfo?.value ?? getAdjustedUntrackedValue(obj),
81
81
  tracked: !!objInfo
82
82
  },
83
83
  result: {
84
84
  value: result,
85
85
  tracked: true
86
86
  },
87
- args: argsData,
88
- tags: newTags,
87
+ args,
88
+ tags,
89
89
  history: Array.from(history),
90
90
  source: objInfo ? (history.size > 1 ? 'A' : 'O') : 'P',
91
91
  target: 'R',
@@ -15,7 +15,6 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { inspect } = require('@contrast/common');
19
18
  const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
20
19
  const { createAppendTags } = require('../../../tag-utils');
21
20
  const { patchType } = require('../../common');
@@ -34,6 +33,7 @@ module.exports = function(core) {
34
33
  const {
35
34
  patcher,
36
35
  assess: {
36
+ inspect, // todo: remove
37
37
  getSourceContext,
38
38
  eventFactory: { createPropagationEvent },
39
39
  dataflow: { tracker }
@@ -15,8 +15,8 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { callChildComponentMethodsSync } = require('@contrast/common');
19
- const { inspect, split } = require('@contrast/common');
18
+ const { callChildComponentMethodsSync, split } = require('@contrast/common');
19
+ const { getAdjustedUntrackedValue } = require('../../../tag-utils');
20
20
 
21
21
  module.exports = function(core) {
22
22
  const {
@@ -55,7 +55,7 @@ module.exports = function(core) {
55
55
  ) return;
56
56
 
57
57
  const args = [{
58
- value: inspect(methodArg),
58
+ value: getAdjustedUntrackedValue(methodArg),
59
59
  tracked: false
60
60
  }];
61
61
 
@@ -14,7 +14,7 @@
14
14
  */
15
15
 
16
16
  'use strict';
17
- const { inspect } = require('@contrast/common');
17
+
18
18
  const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
19
19
  const { createSubsetTags } = require('../../../tag-utils');
20
20
  const { patchType } = require('../../common');
@@ -56,15 +56,10 @@ module.exports = function(core) {
56
56
  value: objInfo.value,
57
57
  tracked: true,
58
58
  },
59
- args: [
60
- {
61
- value: arg,
62
- tracked: false,
63
- },
64
- ],
59
+ args: [{ tracked: false, value: arg }],
65
60
  tags,
66
61
  result: {
67
- value: inspect(untrackedResult),
62
+ value: '[RegExp String Iterator] {}',
68
63
  tracked: false,
69
64
  },
70
65
  stacktraceOpts: {
@@ -131,7 +126,7 @@ module.exports = function(core) {
131
126
  resValue.indices && (untrackedResult.indices = resValue.indices);
132
127
 
133
128
  let searchIdx = resValue.index;
134
- const metadata = { arg: inspect(args[0]), hooked, orig };
129
+ const metadata = { arg: `${args[0]}`, hooked, orig };
135
130
 
136
131
  for (let i = 0; i < resValue.length; i++) {
137
132
  let match = resValue[i];
@@ -14,9 +14,9 @@
14
14
  */
15
15
 
16
16
  'use strict';
17
- const { join, inspect } = require('@contrast/common');
17
+ const { join } = require('@contrast/common');
18
18
  const { patchType } = require('../../common');
19
- const { createSubsetTags } = require('../../../tag-utils');
19
+ const { createSubsetTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
20
20
 
21
21
  module.exports = function(core) {
22
22
  const {
@@ -36,13 +36,14 @@ module.exports = function(core) {
36
36
  function getPropagationEvent(data, res, objInfo, start) {
37
37
  const { args: origArgs, result, hooked, orig } = data;
38
38
  const tags = createSubsetTags(objInfo.tags, start, res.length);
39
+
39
40
  if (!tags) return;
40
41
 
41
42
  const args = [
42
43
  {
43
- value: inspect(origArgs[0]),
44
+ value: getAdjustedUntrackedValue(origArgs[0]),
44
45
  tracked: false,
45
- },
46
+ }
46
47
  ];
47
48
 
48
49
  return createPropagationEvent({
@@ -18,12 +18,15 @@
18
18
  const {
19
19
  DataflowTag: { UNTRUSTED },
20
20
  match: origMatch,
21
- inspect,
22
21
  join,
23
22
  substring
24
23
  } = require('@contrast/common');
25
24
  const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
26
- const { createSubsetTags, createAppendTags } = require('../../../tag-utils');
25
+ const {
26
+ createSubsetTags,
27
+ createAppendTags,
28
+ getAdjustedUntrackedValue
29
+ } = require('../../../tag-utils');
27
30
  const { patchType } = require('../../common');
28
31
 
29
32
  module.exports = function(core) {
@@ -167,21 +170,24 @@ module.exports = function(core) {
167
170
  return;
168
171
  }
169
172
 
170
- const { _replacementInfo, obj, args: origArgs, result, hooked, orig } = data;
171
- const args = [{
172
- value: inspect(origArgs[0]),
173
- tracked: !!tracker.getData(origArgs[0])
174
- },
175
- {
176
- value: data._replacement,
177
- tracked: !!_replacementInfo
178
- }];
173
+ const { obj, args: origArgs, result, hooked, orig } = data;
174
+ const args = [];
175
+ if (tracker.getData(origArgs[0])) {
176
+ args.push({ tracked: true, value: origArgs[0] });
177
+ } else {
178
+ args.push({ tracked: false, value: getAdjustedUntrackedValue(origArgs[0]) });
179
+ }
180
+ if (data._replacement) {
181
+ args.push({ tracked: true, value: data._replacement });
182
+ } else {
183
+ args.push({ tracked: false, value: getAdjustedUntrackedValue(data._replacement) });
184
+ }
179
185
 
180
186
  const event = createPropagationEvent({
181
187
  name,
182
188
  moduleName: 'String',
183
189
  methodName: 'prototype.replace',
184
- context: `'${obj}'.replace(${join(args.map(a => a.value), ', ')})`,
190
+ context: `'${obj}'.replace(${join(args.map(a => a.value))})`,
185
191
  history: Array.from(data._history),
186
192
  object: {
187
193
  value: obj,