@contrast/assess 1.4.0 → 1.6.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.
Files changed (59) hide show
  1. package/lib/dataflow/event-factory.js +41 -83
  2. package/lib/dataflow/index.js +0 -1
  3. package/lib/dataflow/propagation/install/array-prototype-join.js +3 -3
  4. package/lib/dataflow/propagation/install/contrast-methods/add.js +23 -16
  5. package/lib/dataflow/propagation/install/contrast-methods/tag.js +30 -22
  6. package/lib/dataflow/propagation/install/decode-uri-component.js +8 -5
  7. package/lib/dataflow/propagation/install/ejs/escape-xml.js +8 -5
  8. package/lib/dataflow/propagation/install/encode-uri-component.js +3 -3
  9. package/lib/dataflow/propagation/install/escape-html.js +10 -7
  10. package/lib/dataflow/propagation/install/escape.js +8 -5
  11. package/lib/dataflow/propagation/install/handlebars-utils-escape-expression.js +8 -5
  12. package/lib/dataflow/propagation/install/mysql-connection-escape.js +8 -5
  13. package/lib/dataflow/propagation/install/pug-runtime-escape.js +3 -3
  14. package/lib/dataflow/propagation/install/querystring/parse.js +11 -6
  15. package/lib/dataflow/propagation/install/sql-template-strings.js +3 -3
  16. package/lib/dataflow/propagation/install/string/concat.js +4 -4
  17. package/lib/dataflow/propagation/install/string/format-methods.js +2 -2
  18. package/lib/dataflow/propagation/install/string/html-methods.js +5 -5
  19. package/lib/dataflow/propagation/install/string/index.js +1 -0
  20. package/lib/dataflow/propagation/install/string/match.js +3 -3
  21. package/lib/dataflow/propagation/install/string/replace.js +9 -5
  22. package/lib/dataflow/propagation/install/string/slice.js +104 -0
  23. package/lib/dataflow/propagation/install/string/split.js +4 -4
  24. package/lib/dataflow/propagation/install/string/substring.js +6 -4
  25. package/lib/dataflow/propagation/install/string/trim.js +2 -2
  26. package/lib/dataflow/propagation/install/unescape.js +8 -5
  27. package/lib/dataflow/propagation/install/url/domain-parsers.js +3 -3
  28. package/lib/dataflow/propagation/install/validator/hooks.js +2 -2
  29. package/lib/dataflow/propagation/install/validator/methods.js +60 -51
  30. package/lib/dataflow/sinks/index.js +15 -2
  31. package/lib/dataflow/sinks/install/child-process.js +224 -0
  32. package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +47 -23
  33. package/lib/dataflow/sinks/install/fs.js +136 -0
  34. package/lib/dataflow/sinks/install/http.js +48 -32
  35. package/lib/dataflow/sinks/install/koa/index.js +30 -0
  36. package/lib/dataflow/sinks/install/koa/unvalidated-redirect.js +122 -0
  37. package/lib/dataflow/sinks/install/marsdb.js +135 -0
  38. package/lib/dataflow/sinks/install/mongodb.js +205 -0
  39. package/lib/dataflow/sinks/install/mssql.js +19 -13
  40. package/lib/dataflow/sinks/install/mysql.js +122 -0
  41. package/lib/dataflow/sinks/install/postgres.js +40 -29
  42. package/lib/dataflow/sinks/install/sqlite3.js +99 -0
  43. package/lib/dataflow/sources/handler.js +19 -15
  44. package/lib/dataflow/sources/index.js +9 -0
  45. package/lib/dataflow/sources/install/busboy1.js +112 -0
  46. package/lib/dataflow/sources/install/fastify/fastify.js +23 -29
  47. package/lib/dataflow/sources/install/fastify/index.js +4 -5
  48. package/lib/dataflow/sources/install/formidable1.js +91 -0
  49. package/lib/dataflow/sources/install/http.js +35 -14
  50. package/lib/dataflow/sources/install/koa/index.js +32 -0
  51. package/lib/dataflow/sources/install/koa/koa-bodyparsers.js +92 -0
  52. package/lib/dataflow/sources/install/koa/koa-routers.js +84 -0
  53. package/lib/dataflow/sources/install/koa/koa2.js +103 -0
  54. package/lib/dataflow/sources/install/qs6.js +84 -0
  55. package/lib/dataflow/utils/is-vulnerable.js +1 -1
  56. package/package.json +2 -2
  57. package/lib/dataflow/signatures/index.js +0 -2006
  58. package/lib/dataflow/signatures/mssql.js +0 -49
  59. package/lib/dataflow/sources/install/fastify/cookie.js +0 -61
@@ -16,7 +16,7 @@
16
16
  'use strict';
17
17
 
18
18
 
19
- const { InputType } = require('@contrast/common');
19
+ const { InputType, signatures } = require('@contrast/common');
20
20
  const annotationRegExp = /^(A|O|R|P|P\d+)$/;
21
21
 
22
22
  module.exports = function(core) {
@@ -25,10 +25,8 @@ module.exports = function(core) {
25
25
  config,
26
26
  logger,
27
27
  scopes: { sources },
28
- assess: {
29
- dataflow: { signatures }
30
- }
31
28
  } = core;
29
+
32
30
  const eventFactory = core.assess.dataflow.eventFactory = {};
33
31
 
34
32
  eventFactory.createdEvents = new WeakSet();
@@ -36,9 +34,10 @@ module.exports = function(core) {
36
34
  eventFactory.createSourceEvent = function(data = {}) {
37
35
  const {
38
36
  name,
39
- result = { value: null, isTracked: false },
37
+ result = { value: null, tracked: false },
40
38
  tags,
41
39
  inputType,
40
+ stack,
42
41
  } = data;
43
42
 
44
43
  const baseMessage = 'Source event not created: %s';
@@ -63,6 +62,13 @@ module.exports = function(core) {
63
62
  return null;
64
63
  }
65
64
 
65
+
66
+ if (!stack || !Array.isArray(stack)) {
67
+ logger.debug({ data }, baseMessage, 'invalid stack');
68
+ return null;
69
+ }
70
+
71
+ data.time = Date.now();
66
72
  eventFactory.createdEvents.add(data);
67
73
 
68
74
  return data;
@@ -72,9 +78,10 @@ module.exports = function(core) {
72
78
  const {
73
79
  name = '',
74
80
  history = [],
75
- object = { value: null, isTracked: false },
81
+ object = { value: null, tracked: false },
76
82
  args = [],
77
- result = { value: null, isTracked: false },
83
+ context,
84
+ result = { value: null, tracked: false },
78
85
  tags = {},
79
86
  addedTags = [],
80
87
  removedTags = [],
@@ -123,18 +130,19 @@ module.exports = function(core) {
123
130
  }
124
131
 
125
132
  const event = {
126
- time: Date.now(),
133
+ addedTags,
134
+ args,
135
+ context,
127
136
  history,
128
137
  name,
129
138
  object,
130
- args,
131
- result,
132
- tags,
133
- addedTags,
134
139
  removedTags,
140
+ result,
135
141
  source,
142
+ stack,
143
+ tags,
136
144
  target,
137
- stack
145
+ time: Date.now(),
138
146
  };
139
147
 
140
148
  eventFactory.createdEvents.add(event);
@@ -145,50 +153,56 @@ module.exports = function(core) {
145
153
 
146
154
  eventFactory.createSinkEvent = function(data) {
147
155
  const {
156
+ context,
148
157
  name = '',
149
158
  history = [],
150
- object = { value: null, isTracked: false },
159
+ object = { value: null, tracked: false },
151
160
  args = [],
152
- result = { value: null, isTracked: false },
161
+ result = { value: null, tracked: false },
153
162
  tags = {},
154
163
  source,
155
164
  stacktraceOpts
156
165
  } = data;
157
- const sourceContext = sources.getStore()?.assess;
158
166
 
167
+ const sourceContext = sources.getStore()?.assess;
159
168
  if (!sourceContext) {
160
- logger.debug('No sourceContext found during Sink event creation');
169
+ logger.debug('no sourceContext found during sink event creation');
161
170
  return null;
162
171
  }
163
-
164
172
  const signature = signatures.get(name);
165
-
173
+ if (!signature) {
174
+ logger.debug({ name }, 'no signature found for sink event name');
175
+ return null;
176
+ }
177
+ if (!history.length) {
178
+ logger.debug({ data }, 'empty history for sink event');
179
+ return null;
180
+ }
166
181
  if (
167
- !signature ||
168
- !history.length ||
169
182
  ((source && !source.match(annotationRegExp)) || (!source && !signature.source))
170
183
  ) {
171
- logger.debug({ data }, 'Wrong sink event data submited. Sink event not created');
184
+ logger.debug({ data }, 'malformed or missing sink event source field');
172
185
  return null;
173
186
  }
174
187
 
175
188
  let stack;
176
189
  if (config.assess.stacktraces !== 'NONE') {
177
- stack = createSnapshot(stacktraceOpts);
190
+ stack = createSnapshot(stacktraceOpts)();
178
191
  } else {
179
192
  stack = [];
180
193
  }
181
194
 
182
195
  const event = {
183
- time: Date.now(),
196
+ args,
197
+ context,
184
198
  history,
185
199
  name,
186
200
  object,
187
- args,
188
201
  result,
189
- tags,
190
202
  source,
191
- stack
203
+ stack,
204
+ tags,
205
+ time: Date.now(),
192
206
  };
193
207
 
194
208
  eventFactory.createdEvents.add(event);
@@ -198,59 +212,3 @@ module.exports = function(core) {
198
212
 
199
213
  return eventFactory;
200
214
  };
201
-
202
-
203
- // Sample event data
204
- // const e = {
205
- // // we need the time the event occurred
206
- // time: '1234',
207
- // history: ['argsTrackedInfo'],
208
- // name: 'ContrastMethods.add', // as this method is used to rewrite not only `+` but `+=` too
209
- // context: {
210
- // obj: null,
211
- // args: ['...args'],
212
- // resultTracked: 'result'
213
- // },
214
- // stack: 'createSnapshot()',
215
- // tags: 'newTags',
216
- // // we need a property with add/removed tags
217
- // addedTags: [],
218
- // removedTags: [],
219
- // // we need info for the source and the targeto
220
- // source: 'A | P | O | R',
221
- // target: 'A | P | O | R',
222
- // // optional code property for the propagation through the ContrastMethods
223
- // code: 'const a = b + c',
224
- // // we need a signature property
225
- // signature: {
226
- // // in v4 we are storing all the signatures in a json file,
227
- // // so we get the values from there and format them accordingly
228
- // }
229
- // };
230
-
231
- // Sample payload for a discovered vulnerability
232
- // const payload = {
233
- // created: Date.now(),
234
- // events: [
235
- // {
236
- // action: e.addedTags.length || e.removedTags.length ? 'TAG' : `${e.source}2${e.target}`,
237
- // args: e.context.args, // they will be "expanded" before reporting
238
- // code: e.code,
239
- // eventSources: [], // only for SourceEvents
240
- // fieldName: '', // we don't set it in v4
241
- // object: e.context.obj, // again it will be expanded later
242
- // parentObjectsIds: [], // we don't set it in v4
243
- // properties: [], // not needed for dataflow
244
- // ret: e.context.resultTracked,
245
- // signature: e.signature,
246
- // source: e.source,
247
- // stacktrace: e.stack,
248
- // tags: e.addedTags.join(), // in v4 we set all tags here, idk why
249
- // taintRanges: e.tags.map(), // the tag ranges we want highlighted in ContrastUI
250
- // target: e.target,
251
- // thread: process.pid,
252
- // time: e.time,
253
- // type: e.addedTags.length || e.removedTags.length ? 'TAG' : 'PROPAGATION'
254
- // }
255
- // ]
256
- // };
@@ -20,7 +20,6 @@ const { callChildComponentMethodsSync } = require('@contrast/common');
20
20
  module.exports = function(core) {
21
21
  const dataflow = core.assess.dataflow = {};
22
22
 
23
- require('./signatures')(core);
24
23
  require('./event-factory')(core);
25
24
  require('./tracker')(core);
26
25
  require('./sources')(core);
@@ -83,15 +83,15 @@ module.exports = function(core) {
83
83
  name: 'Array.prototype.join',
84
84
  object: {
85
85
  value: originalJoin.call(obj),
86
- isTracked: false
86
+ tracked: false
87
87
  },
88
88
  result: {
89
89
  value: resultInfo ? resultInfo.value : result,
90
- isTracked: true
90
+ tracked: true
91
91
  },
92
92
  args: [{
93
93
  value: delimiterInfo ? delimiterInfo.value : delimiter,
94
- isTracked: !!delimiterInfo
94
+ tracked: !!delimiterInfo
95
95
  }],
96
96
  tags: newTags,
97
97
  history: Array.from(history),
@@ -15,10 +15,11 @@
15
15
 
16
16
  'use strict';
17
17
 
18
+ const util = require('util');
18
19
  const {
19
20
  createAppendTags
20
21
  } = require('../../../tag-utils');
21
- const { patchType, createObjectLabel } = require('../../common');
22
+ const { patchType } = require('../../common');
22
23
 
23
24
  module.exports = function(core) {
24
25
  const {
@@ -29,13 +30,15 @@ module.exports = function(core) {
29
30
  }
30
31
  } = core;
31
32
 
33
+ const inspect = patcher.unwrap(util.inspect);
34
+
32
35
  return core.assess.dataflow.propagation.contrastMethodsInstrumentation.add = {
33
36
  install() {
34
37
  patcher.patch(global.ContrastMethods, 'add', {
35
38
  name: 'ContrastMethods.add',
36
39
  patchType,
37
40
  post(data) {
38
- const { args, result, hooked, orig } = data;
41
+ const { args, result, hooked } = data;
39
42
  if (!result || !sources.getStore()?.assess || instrumentation.isLocked()) return;
40
43
 
41
44
  const rInfo = tracker.getData(result);
@@ -61,32 +64,36 @@ module.exports = function(core) {
61
64
  }
62
65
 
63
66
  if (history.length) {
67
+ const leftArg = leftStringInfo ? leftStringInfo.value : args[0];
68
+ const rightArg = rightStringInfo ? rightStringInfo.value : args[1];
64
69
  const event = createPropagationEvent({
65
- name: 'ContrastMethods.add',
66
- history,
67
- object: {
68
- value: createObjectLabel('ContrastMethods'),
69
- isTracked: false
70
- },
71
70
  args: [
72
71
  {
73
- value: args[0],
74
- isTracked: !!leftStringInfo
72
+ tracked: !!leftStringInfo,
73
+ value: leftArg
75
74
  },
76
75
  {
77
- value: args[1],
78
- isTracked: !!rightStringInfo
76
+ tracked: !!rightStringInfo,
77
+ value: rightArg,
79
78
  }
80
79
  ],
80
+ context: `${inspect(leftArg)} + ${inspect(rightArg)}`,
81
+ history,
82
+ object: {
83
+ value: 'String Addition',
84
+ tracked: false
85
+ },
86
+ name: 'ContrastMethods.add',
81
87
  result: {
82
88
  value: result,
83
- isTracked: true
89
+ tracked: true
84
90
  },
85
- tags: newTags,
91
+ source: 'P',
86
92
  stacktraceOpts: {
87
93
  constructorOpt: hooked,
88
- prependFrames: [orig]
89
- }
94
+ },
95
+ tags: newTags,
96
+ target: 'R',
90
97
  });
91
98
  const { extern } = tracker.track(result, event);
92
99
 
@@ -48,45 +48,53 @@ module.exports = function (core) {
48
48
  return;
49
49
  }
50
50
 
51
- const [strings, ...args] = data.args;
52
- const argsData = [
53
- strings.map((str) => ({
54
- value: str,
55
- isTracked: false,
56
- })),
57
- ];
58
-
51
+ const [strings, ...expressions] = data.args;
52
+ const args = [];
59
53
  const history = new Set();
60
- args.forEach((arg) => {
61
- const argData = tracker.getData(arg);
62
- argsData.push({
63
- value: argData?.value ?? arg,
64
- isTracked: !!argData,
54
+ let context = '';
55
+
56
+ // interleave hard-coded strings and interpolated expressions
57
+ for (let i = 0; i < strings.length; i++) {
58
+ const str = strings[i];
59
+ args.push({
60
+ tracked: false,
61
+ value: str,
65
62
  });
66
- if (argData) history.add(argData);
67
- });
63
+ context += str;
64
+
65
+ if (i < strings.length - 1) {
66
+ const argData = tracker.getData(expressions[i]);
67
+ if (argData) history.add(argData);
68
+ const value = argData ? argData.value : expressions[i];
69
+ args.push({
70
+ tracked: !!argData,
71
+ value,
72
+ });
73
+ context += `\${expr${i}}`;
74
+ }
75
+ }
68
76
 
69
77
  Object.assign(
70
78
  resultData,
71
79
  createPropagationEvent({
72
- name: 'ContrastMethods.tag',
80
+ args,
81
+ context: `\`${context}\``,
73
82
  history: Array.from(history),
74
83
  object: {
75
- value: 'ContrastMethods@0000',
76
- isTracked: false,
84
+ tracked: false,
85
+ value: 'Template Literal',
77
86
  },
78
- args: argsData,
79
87
  result: {
88
+ tracked: true,
80
89
  value: resultData.value,
81
- isTracked: true,
82
90
  },
83
- tags: resultData.tags,
91
+ name: 'ContrastMethods.tag',
84
92
  source: 'P',
85
93
  target: 'R',
86
94
  stacktraceOpts: {
87
95
  constructorOpt: data.hooked,
88
- prependFrames: [data.orig],
89
96
  },
97
+ tags: resultData.tags,
90
98
  }),
91
99
  );
92
100
  },
@@ -15,6 +15,9 @@
15
15
 
16
16
  'use strict';
17
17
 
18
+ const {
19
+ DataflowTag: { URL_ENCODED }
20
+ } = require('@contrast/common');
18
21
  const {
19
22
  createFullLengthCopyTags
20
23
  } = require('../../tag-utils');
@@ -47,7 +50,7 @@ module.exports = function(core) {
47
50
  // the result is not tracked, so we don't need to check for that
48
51
  const history = [argInfo];
49
52
  const newTags = createFullLengthCopyTags(argInfo.tags, result.length);
50
- delete newTags['url-encoded'];
53
+ delete newTags[URL_ENCODED];
51
54
 
52
55
  if (!Object.keys(newTags).length) return;
53
56
 
@@ -55,16 +58,16 @@ module.exports = function(core) {
55
58
  name: 'global.decodeURIComponent',
56
59
  object: {
57
60
  value: createObjectLabel('global'),
58
- isTracked: false
61
+ tracked: false
59
62
  },
60
63
  result: {
61
64
  value: result,
62
- isTracked: true
65
+ tracked: true
63
66
  },
64
- args: [{ value: argInfo.value, isTracked: true }],
67
+ args: [{ value: argInfo.value, tracked: true }],
65
68
  tags: newTags,
66
69
  history,
67
- removedTags: ['url-encoded'],
70
+ removedTags: [URL_ENCODED],
68
71
  stacktraceOpts: {
69
72
  constructorOpt: hooked,
70
73
  prependFrames: [orig]
@@ -15,6 +15,9 @@
15
15
 
16
16
  'use strict';
17
17
 
18
+ const {
19
+ DataflowTag: { WEAK_URL_ENCODED }
20
+ } = require('@contrast/common');
18
21
  const {
19
22
  createFullLengthCopyTags
20
23
  } = require('../../../tag-utils');
@@ -48,21 +51,21 @@ module.exports = function(core) {
48
51
  const history = [argInfo];
49
52
  const newTags = createFullLengthCopyTags(argInfo.tags, result.length);
50
53
 
51
- newTags['weak-url-encoded'] = [0, result.length - 1];
54
+ newTags[WEAK_URL_ENCODED] = [0, result.length - 1];
52
55
 
53
56
  const event = createPropagationEvent({
54
57
  name: 'ejs.utils.escapeXML',
55
58
  object: {
56
59
  value: `[${createModuleLabel('ejs', version)}].utils`,
57
- isTracked: false
60
+ tracked: false
58
61
  },
59
62
  result: {
60
63
  value: resultInfo ? resultInfo.value : result,
61
- isTracked: true
64
+ tracked: true
62
65
  },
63
- args: [{ value: argInfo.value, isTracked: true }],
66
+ args: [{ value: argInfo.value, tracked: true }],
64
67
  tags: newTags,
65
- addedTags: ['weak-url-encoded'],
68
+ addedTags: [WEAK_URL_ENCODED],
66
69
  history,
67
70
  stacktraceOpts: {
68
71
  constructorOpt: hooked,
@@ -54,13 +54,13 @@ module.exports = function(core) {
54
54
  name: 'global.encodeURIComponent',
55
55
  object: {
56
56
  value: createObjectLabel('global'),
57
- isTracked: false
57
+ tracked: false
58
58
  },
59
59
  result: {
60
60
  value: result,
61
- isTracked: true
61
+ tracked: true
62
62
  },
63
- args: [{ value: argInfo.value, isTracked: true }],
63
+ args: [{ value: argInfo.value, tracked: true }],
64
64
  tags: newTags,
65
65
  history,
66
66
  addedTags: ['url-encoded'],
@@ -15,10 +15,13 @@
15
15
 
16
16
  'use strict';
17
17
 
18
+ const {
19
+ DataflowTag: { HTML_ENCODED }
20
+ } = require('@contrast/common');
18
21
  const {
19
22
  createFullLengthCopyTags
20
23
  } = require('../../tag-utils');
21
- const { patchType, createModuleLabel } = require('../common');
24
+ const { patchType } = require('../common');
22
25
 
23
26
  module.exports = function(core) {
24
27
  const {
@@ -48,22 +51,22 @@ module.exports = function(core) {
48
51
  const history = [argInfo];
49
52
  const newTags = createFullLengthCopyTags(argInfo.tags, result.length);
50
53
 
51
- newTags['html-encoded'] = [0, result.length - 1];
54
+ newTags[HTML_ENCODED] = [0, result.length - 1];
52
55
 
53
56
  const event = createPropagationEvent({
54
57
  name: 'escape-html',
55
58
  object: {
56
- value: createModuleLabel('escape-html', version),
57
- isTracked: false
59
+ value: 'escape-html',
60
+ tracked: false
58
61
  },
59
62
  result: {
60
63
  value: resultInfo ? resultInfo.value : result,
61
- isTracked: true
64
+ tracked: true
62
65
  },
63
- args: [{ value: argInfo.value, isTracked: true }],
66
+ args: [{ value: argInfo.value, tracked: true }],
64
67
  tags: newTags,
65
68
  history,
66
- addedTags: ['html-encoded'],
69
+ addedTags: [HTML_ENCODED],
67
70
  stacktraceOpts: {
68
71
  constructorOpt: hooked,
69
72
  prependFrames: [orig]
@@ -15,6 +15,9 @@
15
15
 
16
16
  'use strict';
17
17
 
18
+ const {
19
+ DataflowTag: { WEAK_URL_ENCODED }
20
+ } = require('@contrast/common');
18
21
  const {
19
22
  createFullLengthCopyTags
20
23
  } = require('../../tag-utils');
@@ -46,22 +49,22 @@ module.exports = function(core) {
46
49
  const history = [argInfo];
47
50
  const newTags = createFullLengthCopyTags(argInfo.tags, result.length);
48
51
 
49
- newTags['weak-url-encoded'] = [0, result.length - 1];
52
+ newTags[WEAK_URL_ENCODED] = [0, result.length - 1];
50
53
 
51
54
  const event = createPropagationEvent({
52
55
  name: 'global.escape',
53
56
  object: {
54
57
  value: createObjectLabel('global'),
55
- isTracked: false
58
+ tracked: false
56
59
  },
57
60
  result: {
58
61
  value: resultInfo ? resultInfo.value : result,
59
- isTracked: true
62
+ tracked: true
60
63
  },
61
- args: [{ value: argInfo.value, isTracked: true }],
64
+ args: [{ value: argInfo.value, tracked: true }],
62
65
  tags: newTags,
63
66
  history,
64
- addedTags: ['weak-url-encoded'],
67
+ addedTags: [WEAK_URL_ENCODED],
65
68
  stacktraceOpts: {
66
69
  constructorOpt: hooked,
67
70
  prependFrames: [orig]
@@ -15,6 +15,9 @@
15
15
 
16
16
  'use strict';
17
17
 
18
+ const {
19
+ DataflowTag: { HTML_ENCODED }
20
+ } = require('@contrast/common');
18
21
  const {
19
22
  createFullLengthCopyTags
20
23
  } = require('../../tag-utils');
@@ -48,21 +51,21 @@ module.exports = function(core) {
48
51
  const history = [argInfo];
49
52
  const newTags = createFullLengthCopyTags(argInfo.tags, result.length);
50
53
 
51
- newTags['html-encoded'] = [0, result.length - 1];
54
+ newTags[HTML_ENCODED] = [0, result.length - 1];
52
55
 
53
56
  const event = createPropagationEvent({
54
57
  name: 'handlebars.Utils.escapeExpression',
55
58
  object: {
56
59
  value: `[${createModuleLabel('handlebars', version)}].Utils`,
57
- isTracked: false
60
+ tracked: false
58
61
  },
59
62
  result: {
60
63
  value: resultInfo ? resultInfo.value : result,
61
- isTracked: true
64
+ tracked: true
62
65
  },
63
- args: [{ value: argInfo.value, isTracked: true }],
66
+ args: [{ value: argInfo.value, tracked: true }],
64
67
  tags: newTags,
65
- addedTags: ['html-encoded'],
68
+ addedTags: [HTML_ENCODED],
66
69
  history,
67
70
  stacktraceOpts: {
68
71
  constructorOpt: hooked,
@@ -15,6 +15,9 @@
15
15
 
16
16
  'use strict';
17
17
 
18
+ const {
19
+ DataflowTag: { SQL_ENCODED }
20
+ } = require('@contrast/common');
18
21
  const {
19
22
  createFullLengthCopyTags
20
23
  } = require('../../tag-utils');
@@ -43,21 +46,21 @@ module.exports = function(core) {
43
46
  const history = [argInfo];
44
47
  const newTags = createFullLengthCopyTags(argInfo.tags, result.length);
45
48
 
46
- newTags['sql-encoded'] = [0, result.length - 1];
49
+ newTags[SQL_ENCODED] = [0, result.length - 1];
47
50
 
48
51
  const event = createPropagationEvent({
49
52
  name: eventName,
50
53
  object: {
51
54
  value: objectValue,
52
- isTracked: false
55
+ tracked: false
53
56
  },
54
57
  result: {
55
58
  value: resultInfo ? resultInfo.value : result,
56
- isTracked: true
59
+ tracked: true
57
60
  },
58
- args: [{ value: argInfo.value, isTracked: true }],
61
+ args: [{ value: argInfo.value, tracked: true }],
59
62
  tags: newTags,
60
- addedTags: ['sql-encoded'],
63
+ addedTags: [SQL_ENCODED],
61
64
  history,
62
65
  stacktraceOpts: {
63
66
  constructorOpt: hooked,
@@ -54,13 +54,13 @@ module.exports = function(core) {
54
54
  name: 'pug-runtime.escape',
55
55
  object: {
56
56
  value: createModuleLabel('pug-runtime', version),
57
- isTracked: false
57
+ tracked: false
58
58
  },
59
59
  result: {
60
60
  value: resultInfo ? resultInfo.value : result,
61
- isTracked: true
61
+ tracked: true
62
62
  },
63
- args: [{ value: argInfo.value, isTracked: true }],
63
+ args: [{ value: argInfo.value, tracked: true }],
64
64
  tags: newTags,
65
65
  addedTags: ['weak-url-encoded'],
66
66
  history,