@contrast/assess 1.41.0 → 1.43.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 (162) hide show
  1. package/lib/crypto-analysis/install/crypto.js +4 -5
  2. package/lib/crypto-analysis/install/crypto.test.js +1 -1
  3. package/lib/crypto-analysis/install/math.js +2 -4
  4. package/lib/dataflow/propagation/install/JSON/parse.js +2 -3
  5. package/lib/dataflow/propagation/install/JSON/stringify.js +3 -4
  6. package/lib/dataflow/propagation/install/array-prototype-join.js +2 -3
  7. package/lib/dataflow/propagation/install/buffer.js +3 -4
  8. package/lib/dataflow/propagation/install/contrast-methods/add.js +2 -3
  9. package/lib/dataflow/propagation/install/contrast-methods/number.js +2 -3
  10. package/lib/dataflow/propagation/install/contrast-methods/string.js +2 -3
  11. package/lib/dataflow/propagation/install/contrast-methods/tag.js +2 -3
  12. package/lib/dataflow/propagation/install/decode-uri-component.js +2 -3
  13. package/lib/dataflow/propagation/install/ejs/escape-xml.js +3 -4
  14. package/lib/dataflow/propagation/install/ejs/template.js +3 -4
  15. package/lib/dataflow/propagation/install/ejs/template.test.js +1 -1
  16. package/lib/dataflow/propagation/install/encode-uri.js +2 -3
  17. package/lib/dataflow/propagation/install/escape-html.js +3 -4
  18. package/lib/dataflow/propagation/install/escape.js +2 -3
  19. package/lib/dataflow/propagation/install/fastify-send.js +3 -3
  20. package/lib/dataflow/propagation/install/fastify-send.test.js +1 -3
  21. package/lib/dataflow/propagation/install/handlebars-utils-escape-expression.js +3 -4
  22. package/lib/dataflow/propagation/install/isnumeric-0.js +1 -1
  23. package/lib/dataflow/propagation/install/joi/any.js +1 -1
  24. package/lib/dataflow/propagation/install/joi/any.test.js +1 -1
  25. package/lib/dataflow/propagation/install/joi/array.test.js +5 -5
  26. package/lib/dataflow/propagation/install/joi/boolean.js +3 -3
  27. package/lib/dataflow/propagation/install/joi/boolean.test.js +1 -1
  28. package/lib/dataflow/propagation/install/joi/expression.js +3 -3
  29. package/lib/dataflow/propagation/install/joi/expression.test.js +1 -1
  30. package/lib/dataflow/propagation/install/joi/index.js +3 -3
  31. package/lib/dataflow/propagation/install/joi/keys.js +3 -3
  32. package/lib/dataflow/propagation/install/joi/number.js +3 -3
  33. package/lib/dataflow/propagation/install/joi/number.test.js +1 -1
  34. package/lib/dataflow/propagation/install/joi/object.js +1 -1
  35. package/lib/dataflow/propagation/install/joi/object.test.js +1 -1
  36. package/lib/dataflow/propagation/install/joi/ref.test.js +4 -4
  37. package/lib/dataflow/propagation/install/joi/string-schema.js +4 -4
  38. package/lib/dataflow/propagation/install/joi/string-schema.test.js +4 -4
  39. package/lib/dataflow/propagation/install/joi/values.js +3 -3
  40. package/lib/dataflow/propagation/install/mongoose/schema-map.js +4 -4
  41. package/lib/dataflow/propagation/install/mongoose/schema-mixed.js +4 -4
  42. package/lib/dataflow/propagation/install/mongoose/schema-string.js +4 -4
  43. package/lib/dataflow/propagation/install/mustache-escape.js +3 -4
  44. package/lib/dataflow/propagation/install/mustache-escape.test.js +1 -1
  45. package/lib/dataflow/propagation/install/mysql-connection-escape.js +22 -14
  46. package/lib/dataflow/propagation/install/mysql-connection-escape.test.js +1 -1
  47. package/lib/dataflow/propagation/install/parse-int.js +2 -3
  48. package/lib/dataflow/propagation/install/path/basename.js +3 -4
  49. package/lib/dataflow/propagation/install/path/dirname.js +3 -4
  50. package/lib/dataflow/propagation/install/path/extname.js +3 -4
  51. package/lib/dataflow/propagation/install/path/format.js +3 -4
  52. package/lib/dataflow/propagation/install/path/join-and-resolve.js +3 -4
  53. package/lib/dataflow/propagation/install/path/normalize.js +4 -5
  54. package/lib/dataflow/propagation/install/path/parse.js +3 -4
  55. package/lib/dataflow/propagation/install/path/relative.js +4 -5
  56. package/lib/dataflow/propagation/install/path/toNamespacedPath.js +3 -4
  57. package/lib/dataflow/propagation/install/pug/index.js +3 -4
  58. package/lib/dataflow/propagation/install/pug-runtime-escape.js +3 -4
  59. package/lib/dataflow/propagation/install/querystring/escape.js +3 -4
  60. package/lib/dataflow/propagation/install/querystring/escape.test.js +1 -1
  61. package/lib/dataflow/propagation/install/querystring/parse.js +3 -4
  62. package/lib/dataflow/propagation/install/querystring/parse.test.js +1 -1
  63. package/lib/dataflow/propagation/install/querystring/stringify.js +3 -4
  64. package/lib/dataflow/propagation/install/querystring/stringify.test.js +1 -1
  65. package/lib/dataflow/propagation/install/reg-exp-prototype-exec.js +2 -3
  66. package/lib/dataflow/propagation/install/send.js +3 -3
  67. package/lib/dataflow/propagation/install/sequelize/query-generator.js +3 -3
  68. package/lib/dataflow/propagation/install/sequelize/query-generator.test.js +2 -1
  69. package/lib/dataflow/propagation/install/sequelize/sql-string.js +5 -5
  70. package/lib/dataflow/propagation/install/sql-template-strings.js +3 -3
  71. package/lib/dataflow/propagation/install/string/concat.js +2 -3
  72. package/lib/dataflow/propagation/install/string/format-methods.js +2 -3
  73. package/lib/dataflow/propagation/install/string/html-methods.js +3 -4
  74. package/lib/dataflow/propagation/install/string/match-all.js +2 -3
  75. package/lib/dataflow/propagation/install/string/match.js +2 -3
  76. package/lib/dataflow/propagation/install/string/replace.js +2 -3
  77. package/lib/dataflow/propagation/install/string/slice.js +2 -3
  78. package/lib/dataflow/propagation/install/string/split.js +2 -3
  79. package/lib/dataflow/propagation/install/string/substring.js +2 -3
  80. package/lib/dataflow/propagation/install/string/trim.js +2 -3
  81. package/lib/dataflow/propagation/install/unescape.js +2 -3
  82. package/lib/dataflow/propagation/install/url/domain-parsers.js +3 -4
  83. package/lib/dataflow/propagation/install/url/parse.js +3 -4
  84. package/lib/dataflow/propagation/install/url/parse.test.js +2 -2
  85. package/lib/dataflow/propagation/install/url/searchParams.js +3 -4
  86. package/lib/dataflow/propagation/install/url/url.js +3 -4
  87. package/lib/dataflow/propagation/install/util-format.js +3 -4
  88. package/lib/dataflow/propagation/install/validator/hooks.js +9 -9
  89. package/lib/dataflow/sinks/install/child-process.js +5 -6
  90. package/lib/dataflow/sinks/install/eval.js +2 -3
  91. package/lib/dataflow/sinks/install/express/reflected-xss.js +2 -3
  92. package/lib/dataflow/sinks/install/express/unvalidated-redirect.js +2 -3
  93. package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +3 -4
  94. package/lib/dataflow/sinks/install/fs.js +4 -5
  95. package/lib/dataflow/sinks/install/fs.test.js +2 -2
  96. package/lib/dataflow/sinks/install/function.js +2 -3
  97. package/lib/dataflow/sinks/install/hapi/unvalidated-redirect.js +3 -4
  98. package/lib/dataflow/sinks/install/http/request.js +3 -4
  99. package/lib/dataflow/sinks/install/http/request.test.js +2 -2
  100. package/lib/dataflow/sinks/install/http/server-response.js +5 -6
  101. package/lib/dataflow/sinks/install/http/server-response.test.js +3 -3
  102. package/lib/dataflow/sinks/install/koa/unvalidated-redirect.js +3 -4
  103. package/lib/dataflow/sinks/install/libxmljs.js +4 -5
  104. package/lib/dataflow/sinks/install/libxmljs.test.js +2 -2
  105. package/lib/dataflow/sinks/install/marsdb.js +3 -4
  106. package/lib/dataflow/sinks/install/marsdb.test.js +3 -3
  107. package/lib/dataflow/sinks/install/mongodb.js +3 -4
  108. package/lib/dataflow/sinks/install/mongodb.test.js +2 -6
  109. package/lib/dataflow/sinks/install/mssql.js +10 -11
  110. package/lib/dataflow/sinks/install/mssql.test.js +10 -12
  111. package/lib/dataflow/sinks/install/mysql.js +4 -5
  112. package/lib/dataflow/sinks/install/mysql.test.js +2 -11
  113. package/lib/dataflow/sinks/install/node-serialize.js +3 -4
  114. package/lib/dataflow/sinks/install/node-serialize.test.js +1 -3
  115. package/lib/dataflow/sinks/install/postgres.js +5 -6
  116. package/lib/dataflow/sinks/install/postgres.test.js +3 -9
  117. package/lib/dataflow/sinks/install/restify.js +3 -4
  118. package/lib/dataflow/sinks/install/restify.test.js +3 -5
  119. package/lib/dataflow/sinks/install/sequelize.js +3 -4
  120. package/lib/dataflow/sinks/install/sqlite3.js +3 -4
  121. package/lib/dataflow/sinks/install/vm.js +3 -4
  122. package/lib/dataflow/sources/install/body-parser1.js +2 -3
  123. package/lib/dataflow/sources/install/busboy.js +3 -4
  124. package/lib/dataflow/sources/install/busboy.test.js +2 -2
  125. package/lib/dataflow/sources/install/cookie-parser1.js +2 -3
  126. package/lib/dataflow/sources/install/express/params.js +1 -2
  127. package/lib/dataflow/sources/install/express/parsedUrl.js +1 -2
  128. package/lib/dataflow/sources/install/express/parsedUrl.test.js +9 -8
  129. package/lib/dataflow/sources/install/fastify/fastify.js +2 -3
  130. package/lib/dataflow/sources/install/fastify/fastify.test.js +3 -6
  131. package/lib/dataflow/sources/install/formidable1.js +2 -3
  132. package/lib/dataflow/sources/install/hapi/hapi.js +1 -2
  133. package/lib/dataflow/sources/install/http.js +2 -3
  134. package/lib/dataflow/sources/install/http.test.js +2 -2
  135. package/lib/dataflow/sources/install/koa/koa-bodyparsers.js +3 -5
  136. package/lib/dataflow/sources/install/koa/koa-multer.js +3 -4
  137. package/lib/dataflow/sources/install/koa/koa-multer.test.js +1 -1
  138. package/lib/dataflow/sources/install/koa/koa-routers.js +3 -4
  139. package/lib/dataflow/sources/install/koa/koa2.js +2 -4
  140. package/lib/dataflow/sources/install/multer1.js +2 -3
  141. package/lib/dataflow/sources/install/multer1.test.js +1 -3
  142. package/lib/dataflow/sources/install/qs6.js +2 -3
  143. package/lib/dataflow/sources/install/querystring.js +2 -3
  144. package/lib/dataflow/sources/install/restify/fieldedTextBodyParser.js +2 -3
  145. package/lib/dataflow/sources/install/restify/fieldedTextBodyParser.test.js +1 -1
  146. package/lib/dataflow/sources/install/restify/jsonBodyParser.js +2 -3
  147. package/lib/dataflow/sources/install/restify/jsonBodyParser.test.js +1 -1
  148. package/lib/dataflow/sources/install/restify/router.js +2 -3
  149. package/lib/dataflow/sources/install/restify/router.test.js +1 -1
  150. package/lib/get-source-context.js +58 -39
  151. package/lib/get-source-context.test.js +103 -78
  152. package/lib/index.d.ts +3 -9
  153. package/lib/response-scanning/install/http.js +3 -3
  154. package/lib/response-scanning/install/http.test.js +2 -2
  155. package/lib/session-configuration/install/express-session.js +1 -1
  156. package/lib/session-configuration/install/express-session.test.js +1 -3
  157. package/lib/session-configuration/install/fastify-cookie.js +1 -1
  158. package/lib/session-configuration/install/fastify-cookie.test.js +1 -3
  159. package/lib/session-configuration/install/koa.js +1 -1
  160. package/lib/session-configuration/install/koa.test.js +1 -1
  161. package/package.json +11 -11
  162. package/lib/constants.js +0 -26
@@ -21,7 +21,6 @@ const {
21
21
  primordials: { StringPrototypeToLowerCase },
22
22
  } = require('@contrast/common');
23
23
  const semver = require('semver');
24
- const { InstrumentationType: { RULE } } = require('../../constants');
25
24
  const { PATCH_TYPE: patchType } = require('../common');
26
25
 
27
26
  const SAFE_HASH_ALGORITHMS = new Set([
@@ -68,19 +67,19 @@ module.exports = function (core) {
68
67
  assess: {
69
68
  eventFactory,
70
69
  cryptoAnalysis,
71
- getSourceContext,
70
+ getSinkContext,
72
71
  },
73
72
  } = core;
74
73
 
75
74
  const installer = core.assess.cryptoAnalysis.installers.crypto = {
76
75
  install() {
77
- depHooks.resolve({ name: 'crypto' }, (_export) => {
76
+ depHooks.resolve({ name: 'crypto', version: '*' }, (_export) => {
78
77
  patcher.patch(_export, 'createHash', {
79
78
  name: 'crypto.createHash',
80
79
  patchType,
81
80
  post(data) {
82
81
  const [alg] = data.args;
83
- if (!isString(alg) || !getSourceContext(RULE, Rule.CRYPTO_BAD_MAC)) return;
82
+ if (!isString(alg) || !getSinkContext(Rule.CRYPTO_BAD_MAC)) return;
84
83
 
85
84
  const algLower = StringPrototypeToLowerCase.call(alg);
86
85
  if (SAFE_HASH_ALGORITHMS.has(algLower)) return;
@@ -134,7 +133,7 @@ module.exports = function (core) {
134
133
  patchType,
135
134
  post(data) {
136
135
  const [alg] = data.args;
137
- if (!isString(alg) || !getSourceContext(RULE, Rule.CRYPTO_BAD_CIPHERS)) return;
136
+ if (!isString(alg) || !getSinkContext(Rule.CRYPTO_BAD_CIPHERS)) return;
138
137
 
139
138
  const algLower = StringPrototypeToLowerCase.call(alg);
140
139
  for (const prefix of SAFE_CIPHER_ALGORITHM_PREFIXES) {
@@ -17,7 +17,7 @@ describe('assess crypto-analysis node:crypto', function () {
17
17
  createCipher: sinon.stub(),
18
18
  createCipheriv: sinon.stub(),
19
19
  };
20
- core.depHooks.resolve.withArgs({ name: 'crypto' }).yields(mockCrypto);
20
+ core.depHooks.resolve.yields(mockCrypto);
21
21
  sinon.spy(core.assess.cryptoAnalysis, 'report');
22
22
  core.assess.cryptoAnalysis.installers.crypto.install();
23
23
  });
@@ -16,11 +16,9 @@
16
16
  'use strict';
17
17
 
18
18
  const { Rule } = require('@contrast/common');
19
- const { InstrumentationType } = require('../../constants');
20
19
  const { PATCH_TYPE: patchType } = require('../common');
21
20
 
22
21
  const { CRYPTO_WEAK_RANDOMNESS: ruleId } = Rule;
23
- const { RULE } = InstrumentationType;
24
22
 
25
23
  const SAFE_RANDOM_LIBS = [
26
24
  'node_modules/node-uuid/',
@@ -38,7 +36,7 @@ module.exports = function (core) {
38
36
  assess: {
39
37
  eventFactory,
40
38
  cryptoAnalysis,
41
- getSourceContext,
39
+ getSinkContext,
42
40
  },
43
41
  config,
44
42
  logger,
@@ -51,7 +49,7 @@ module.exports = function (core) {
51
49
  name: 'global.Math.random',
52
50
  patchType,
53
51
  post(data) {
54
- if (!getSourceContext(RULE, ruleId)) return;
52
+ if (!getSinkContext(ruleId)) return;
55
53
 
56
54
  const event = eventFactory.createCryptoAnalysisEvent({
57
55
  args: [],
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { isString } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
20
19
  const { createSubsetTags } = require('../../../tag-utils');
21
20
  const { patchType } = require('../../common');
22
21
  const { getKeyValueIndices } = require('./parse-fn');
@@ -50,7 +49,7 @@ module.exports = function (core) {
50
49
  logger,
51
50
  patcher,
52
51
  assess: {
53
- getSourceContext,
52
+ getPropagatorContext,
54
53
  eventFactory: { createPropagationEvent },
55
54
  dataflow: { tracker },
56
55
  },
@@ -102,7 +101,7 @@ module.exports = function (core) {
102
101
  patchType,
103
102
  usePerf: 'sync',
104
103
  pre(data) {
105
- if (!data.args[0] || !getSourceContext(PROPAGATOR)) return;
104
+ if (!data.args[0] || !getPropagatorContext()) return;
106
105
  const [input, reviver] = data.args;
107
106
 
108
107
  const strInfo = tracker.getData(input);
@@ -26,7 +26,6 @@ const {
26
26
  }
27
27
  } = require('@contrast/common');
28
28
  const crypto = require('crypto');
29
- const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
30
29
  const { createMergedTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
31
30
  const { patchType } = require('../../common');
32
31
 
@@ -83,7 +82,7 @@ module.exports = function(core) {
83
82
  const {
84
83
  patcher,
85
84
  assess: {
86
- getSourceContext,
85
+ getPropagatorContext,
87
86
  eventFactory: { createPropagationEvent },
88
87
  dataflow: { tracker }
89
88
  }
@@ -167,7 +166,7 @@ module.exports = function(core) {
167
166
  patchType,
168
167
  usePerf: 'sync',
169
168
  pre(data) {
170
- if (!getSourceContext(PROPAGATOR)) return;
169
+ if (!getPropagatorContext()) return;
171
170
 
172
171
  const [input, , space] = data.args;
173
172
  let [, replacer] = data.args;
@@ -224,7 +223,7 @@ module.exports = function(core) {
224
223
  data.args = [input, contrastReplacer, space];
225
224
  },
226
225
  post(data) {
227
- if (!getSourceContext(PROPAGATOR)) return;
226
+ if (!getPropagatorContext()) return;
228
227
  let tags = {};
229
228
  const vulnerableSources = [];
230
229
  if (!data.metadata?.propagate) {
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { isString, primordials: { ArrayPrototypeJoin } } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../constants');
20
19
  const { createAppendTags } = require('../../tag-utils');
21
20
  const { patchType } = require('../common');
22
21
 
@@ -25,7 +24,7 @@ module.exports = function(core) {
25
24
  patcher,
26
25
  assess: {
27
26
  inspect,
28
- getSourceContext,
27
+ getPropagatorContext,
29
28
  eventFactory: { createPropagationEvent },
30
29
  dataflow: { tracker }
31
30
  }
@@ -72,7 +71,7 @@ module.exports = function(core) {
72
71
  usePerf: 'sync',
73
72
  post(data) {
74
73
  const { args: origArgs, obj, result, hooked, orig } = data;
75
- if (!result || !getSourceContext(PROPAGATOR)) return;
74
+ if (!result || !getPropagatorContext()) return;
76
75
 
77
76
  const resultInfo = tracker.getData(result);
78
77
  const delimiter = origArgs[0] === undefined ? ',' : origArgs[0];
@@ -15,14 +15,13 @@
15
15
  'use strict';
16
16
 
17
17
  const { isString, primordials: { ArrayPrototypeJoin, StringPrototypeSubstring, BufferPrototypeToString } } = require('@contrast/common');
18
- const { InstrumentationType: { PROPAGATOR } } = require('../../../constants');
19
18
  const { getAdjustedUntrackedValue } = require('../../tag-utils');
20
19
  const { patchType } = require('../common');
21
20
 
22
21
  module.exports = function(core) {
23
22
  const {
24
23
  assess: {
25
- getSourceContext,
24
+ getPropagatorContext,
26
25
  eventFactory: { createPropagationEvent },
27
26
  dataflow: { tracker }
28
27
  },
@@ -39,7 +38,7 @@ module.exports = function(core) {
39
38
  post(data) {
40
39
  const { hooked, obj, orig, result } = data;
41
40
 
42
- if (!result || !getSourceContext(PROPAGATOR)) return;
41
+ if (!result || !getPropagatorContext()) return;
43
42
 
44
43
  const bufferInfo = tracker.getData(obj);
45
44
  if (!bufferInfo) {
@@ -92,7 +91,7 @@ module.exports = function(core) {
92
91
  if (
93
92
  !data.args[0] ||
94
93
  !typeSupported ||
95
- !getSourceContext(PROPAGATOR)
94
+ !getPropagatorContext()
96
95
  ) return;
97
96
 
98
97
  const trkInfo = tracker.getData(data.args[0]);
@@ -15,14 +15,13 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
19
18
  const { createAppendTags } = require('../../../tag-utils');
20
19
 
21
20
  module.exports = function(core) {
22
21
  const {
23
22
  assess: {
24
23
  inspect,
25
- getSourceContext,
24
+ getPropagatorContext,
26
25
  eventFactory: { createPropagationEvent },
27
26
  dataflow: { tracker }
28
27
  }
@@ -41,7 +40,7 @@ module.exports = function(core) {
41
40
  // first get result, then following logic acts as post-hook in patcher speak
42
41
  const result = add(...args);
43
42
 
44
- if (!result || !getSourceContext(PROPAGATOR)) return result;
43
+ if (!result || !getPropagatorContext()) return result;
45
44
 
46
45
  const rInfo = tracker.getData(result);
47
46
  if (rInfo) {
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { isString } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
20
19
  const { patchType } = require('../../common');
21
20
 
22
21
  module.exports = function (core) {
@@ -24,7 +23,7 @@ module.exports = function (core) {
24
23
  logger,
25
24
  patcher,
26
25
  assess: {
27
- getSourceContext,
26
+ getPropagatorContext,
28
27
  dataflow: { tracker }
29
28
  }
30
29
  } = core;
@@ -44,7 +43,7 @@ module.exports = function (core) {
44
43
  isNaN(result) ||
45
44
  !value ||
46
45
  !isString(value) ||
47
- !getSourceContext(PROPAGATOR)
46
+ !getPropagatorContext()
48
47
  ) return;
49
48
 
50
49
  tracker.untrack(value);
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { DataflowTag } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
20
19
  const { patchType } = require('../../common');
21
20
 
22
21
  function metadataUpdate(strInfo, event) {
@@ -32,7 +31,7 @@ module.exports = function(core) {
32
31
  const {
33
32
  patcher,
34
33
  assess: {
35
- getSourceContext,
34
+ getPropagatorContext,
36
35
  eventFactory: { createPropagationEvent },
37
36
  dataflow: { tracker },
38
37
  }
@@ -46,7 +45,7 @@ module.exports = function(core) {
46
45
  patchType,
47
46
  usePerf: 'sync',
48
47
  post(data) {
49
- if (!data.result || !getSourceContext(PROPAGATOR)) return;
48
+ if (!data.result || !getPropagatorContext()) return;
50
49
 
51
50
  const arg = data.args[0];
52
51
  let argInfo = tracker.getData(arg);
@@ -15,13 +15,12 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
19
18
  const { patchType } = require('../../common');
20
19
 
21
20
  module.exports = function(core) {
22
21
  const {
23
22
  assess: {
24
- getSourceContext,
23
+ getPropagatorContext,
25
24
  eventFactory: { createPropagationEvent },
26
25
  dataflow: { tracker },
27
26
  },
@@ -35,7 +34,7 @@ module.exports = function(core) {
35
34
  patchType,
36
35
  usePerf: 'sync',
37
36
  post(data) {
38
- if (!data.result || !getSourceContext(PROPAGATOR)) {
37
+ if (!data.result || !getPropagatorContext()) {
39
38
  return;
40
39
  }
41
40
 
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { DataflowTag: { URL_ENCODED } } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../constants');
20
19
  const { createFullLengthCopyTags } = require('../../tag-utils');
21
20
  const { patchType, createObjectLabel } = require('../common');
22
21
 
@@ -24,7 +23,7 @@ module.exports = function(core) {
24
23
  const {
25
24
  patcher,
26
25
  assess: {
27
- getSourceContext,
26
+ getPropagatorContext,
28
27
  eventFactory: { createPropagationEvent },
29
28
  dataflow: { tracker }
30
29
  }
@@ -40,7 +39,7 @@ module.exports = function(core) {
40
39
  usePerf: 'sync',
41
40
  post(data) {
42
41
  const { args, result, hooked, orig } = data;
43
- if (!result || !args[0] || !getSourceContext(PROPAGATOR)) return;
42
+ if (!result || !args[0] || !getPropagatorContext()) return;
44
43
 
45
44
  const argInfo = tracker.getData(args[0]);
46
45
 
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { DataflowTag: { WEAK_URL_ENCODED } } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
20
19
  const { createFullLengthCopyTags } = require('../../../tag-utils');
21
20
  const { patchType } = require('../../common');
22
21
 
@@ -25,7 +24,7 @@ module.exports = function(core) {
25
24
  patcher,
26
25
  depHooks,
27
26
  assess: {
28
- getSourceContext,
27
+ getPropagatorContext,
29
28
  eventFactory: { createPropagationEvent },
30
29
  dataflow: { tracker }
31
30
  }
@@ -33,7 +32,7 @@ module.exports = function(core) {
33
32
 
34
33
  return core.assess.dataflow.propagation.ejsInstrumentation.escapeXML = {
35
34
  install() {
36
- depHooks.resolve({ name: 'ejs', file: 'lib/utils.js', version: '>=2.6.2' }, (ejsUtils) => {
35
+ depHooks.resolve({ name: 'ejs', file: 'lib/utils.js', version: '>=2.6.2 <4' }, (ejsUtils) => {
37
36
  const name = 'ejs.utils.escapeXML';
38
37
  patcher.patch(ejsUtils, 'escapeXML', {
39
38
  name,
@@ -41,7 +40,7 @@ module.exports = function(core) {
41
40
  usePerf: 'sync',
42
41
  post(data) {
43
42
  const { args, result, hooked, orig } = data;
44
- if (!result || !args[0] || !getSourceContext(PROPAGATOR)) return;
43
+ if (!result || !args[0] || !getPropagatorContext()) return;
45
44
 
46
45
  const argInfo = tracker.getData(args[0]);
47
46
 
@@ -18,7 +18,6 @@
18
18
  const { EOL } = require('os');
19
19
  const { primordials: { ArrayPrototypeJoin, StringPrototypeSubstring } } = require('@contrast/common');
20
20
  const { patchType } = require('../../common');
21
- const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
22
21
 
23
22
  /**
24
23
  * @param {{
@@ -30,7 +29,7 @@ const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants')
30
29
  */
31
30
  module.exports = function (core) {
32
31
  const {
33
- assess: { getSourceContext },
32
+ assess: { getPropagatorContext },
34
33
  depHooks,
35
34
  logger,
36
35
  patcher,
@@ -56,13 +55,13 @@ module.exports = function (core) {
56
55
  * function __append() { // rewritten }
57
56
  */
58
57
  install() {
59
- depHooks.resolve({ name: 'ejs', version: '>=2.6.2' }, (_export, version) => {
58
+ depHooks.resolve({ name: 'ejs', version: '>=2.6.2 <4' }, (_export, version) => {
60
59
  patcher.patch(_export.Template.prototype, 'generateSource', {
61
60
  name: 'ejs.Template.prototype.generateSource',
62
61
  patchType,
63
62
  usePerf: 'sync',
64
63
  post(data) {
65
- if (!getSourceContext(PROPAGATOR)) return;
64
+ if (!getPropagatorContext()) return;
66
65
 
67
66
  try {
68
67
  const { code } = rewriter.rewriteSync(`${WRAPPER_PREFIX}${data.obj.source}${WRAPPER_SUFFIX}`, REWRITE_OPTS);
@@ -21,7 +21,7 @@ describe('assess dataflow propagation ejs.Template', function () {
21
21
  MockEjsTemplate.prototype.generateSource = function() {
22
22
  };
23
23
 
24
- core.depHooks.resolve.withArgs({ name: 'ejs', version: '>=2.6.2' }).yields({ Template: MockEjsTemplate });
24
+ core.depHooks.resolve.withArgs({ name: 'ejs', version: '>=2.6.2 <4' }).yields({ Template: MockEjsTemplate });
25
25
  core.assess.dataflow.propagation.ejsInstrumentation.template.install();
26
26
  });
27
27
 
@@ -18,7 +18,6 @@
18
18
  const {
19
19
  DataflowTag: { URL_ENCODED, WEAK_URL_ENCODED }
20
20
  } = require('@contrast/common');
21
- const { InstrumentationType: { PROPAGATOR } } = require('../../../constants');
22
21
  const { createEscapeTagRanges } = require('../../tag-utils');
23
22
  const { patchType, createObjectLabel } = require('../common');
24
23
 
@@ -26,7 +25,7 @@ module.exports = function(core) {
26
25
  const {
27
26
  patcher,
28
27
  assess: {
29
- getSourceContext,
28
+ getPropagatorContext,
30
29
  eventFactory: { createPropagationEvent },
31
30
  dataflow: { tracker }
32
31
  }
@@ -51,7 +50,7 @@ module.exports = function(core) {
51
50
  usePerf: 'sync',
52
51
  post(data) {
53
52
  const { args, result, hooked, orig } = data;
54
- if (!result || !args[0] || !getSourceContext(PROPAGATOR)) return;
53
+ if (!result || !args[0] || !getPropagatorContext()) return;
55
54
 
56
55
  const argInfo = tracker.getData(args[0]);
57
56
 
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { DataflowTag: { HTML_ENCODED } } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../constants');
20
19
  const { createEscapeTagRanges } = require('../../tag-utils');
21
20
  const { patchType } = require('../common');
22
21
 
@@ -25,7 +24,7 @@ module.exports = function(core) {
25
24
  patcher,
26
25
  depHooks,
27
26
  assess: {
28
- getSourceContext,
27
+ getPropagatorContext,
29
28
  eventFactory: { createPropagationEvent },
30
29
  dataflow: { tracker }
31
30
  }
@@ -33,7 +32,7 @@ module.exports = function(core) {
33
32
 
34
33
  return core.assess.dataflow.propagation.escapeHtml = {
35
34
  install() {
36
- depHooks.resolve({ name: 'escape-html' }, (escapeHtml) => {
35
+ depHooks.resolve({ name: 'escape-html', version: '<2' }, (escapeHtml) => {
37
36
  const name = 'escape-html';
38
37
 
39
38
  return patcher.patch(escapeHtml, {
@@ -42,7 +41,7 @@ module.exports = function(core) {
42
41
  usePerf: 'sync',
43
42
  post(data) {
44
43
  const { args, result, hooked, orig } = data;
45
- if (!result || !args[0] || !getSourceContext(PROPAGATOR)) return;
44
+ if (!result || !args[0] || !getPropagatorContext()) return;
46
45
 
47
46
  const argInfo = tracker.getData(args[0]);
48
47
 
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { DataflowTag: { WEAK_URL_ENCODED } } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../constants');
20
19
  const { createFullLengthCopyTags } = require('../../tag-utils');
21
20
  const { patchType, createObjectLabel } = require('../common');
22
21
 
@@ -24,7 +23,7 @@ module.exports = function(core) {
24
23
  const {
25
24
  patcher,
26
25
  assess: {
27
- getSourceContext,
26
+ getPropagatorContext,
28
27
  eventFactory: { createPropagationEvent },
29
28
  dataflow: { tracker }
30
29
  }
@@ -40,7 +39,7 @@ module.exports = function(core) {
40
39
  usePerf: 'sync',
41
40
  post(data) {
42
41
  const { args, result, hooked, orig } = data;
43
- if (!result || !args[0] || !getSourceContext(PROPAGATOR)) return;
42
+ if (!result || !args[0] || !getPropagatorContext()) return;
44
43
 
45
44
  const argInfo = tracker.getData(args[0]);
46
45
 
@@ -21,12 +21,12 @@ module.exports = function (core) {
21
21
  const {
22
22
  depHooks,
23
23
  patcher,
24
- assess: { getSourceContext }
24
+ assess: { getPropagatorContext }
25
25
  } = core;
26
26
 
27
27
  return core.assess.dataflow.propagation.fastifySend = {
28
28
  install() {
29
- depHooks.resolve({ name: '@fastify/send', file: 'lib/SendStream.js' }, (_SendStream) => {
29
+ depHooks.resolve({ name: '@fastify/send', version: '<4', file: 'lib/SendStream.js' }, (_SendStream) => {
30
30
  patcher.patch(_SendStream.prototype, 'sendFile', {
31
31
  name: '@fastify/send/lib/SendStream.js',
32
32
  patchType,
@@ -34,7 +34,7 @@ module.exports = function (core) {
34
34
  pre(data) {
35
35
  const { args } = data;
36
36
 
37
- if (!getSourceContext()) return;
37
+ if (!getPropagatorContext()) return;
38
38
 
39
39
  const untrackedPath = StringPrototypeSlice.call(` ${args[0]}`, 1);
40
40
  args[0] = untrackedPath;
@@ -22,9 +22,7 @@ describe('assess @fastify/send', function() {
22
22
  sendFileStub(path);
23
23
  }
24
24
  };
25
- core.depHooks.resolve
26
- .withArgs({ name: '@fastify/send', file: 'lib/SendStream.js' })
27
- .yield(SendStreamMock);
25
+ core.depHooks.resolve.yield(SendStreamMock);
28
26
  });
29
27
 
30
28
  afterEach(function() {
@@ -16,7 +16,6 @@
16
16
  'use strict';
17
17
 
18
18
  const { DataflowTag: { HTML_ENCODED } } = require('@contrast/common');
19
- const { InstrumentationType: { PROPAGATOR } } = require('../../../constants');
20
19
  const { createFullLengthCopyTags } = require('../../tag-utils');
21
20
  const { patchType } = require('../common');
22
21
 
@@ -25,7 +24,7 @@ module.exports = function(core) {
25
24
  patcher,
26
25
  depHooks,
27
26
  assess: {
28
- getSourceContext,
27
+ getPropagatorContext,
29
28
  eventFactory: { createPropagationEvent },
30
29
  dataflow: { tracker }
31
30
  }
@@ -33,7 +32,7 @@ module.exports = function(core) {
33
32
 
34
33
  return core.assess.dataflow.propagation.handlebarsEscapeExpression = {
35
34
  install() {
36
- depHooks.resolve({ name: 'handlebars', version: '>=4.0.0' }, (handlebars) => {
35
+ depHooks.resolve({ name: 'handlebars', version: '>=4 <5' }, (handlebars) => {
37
36
  const name = 'handlebars.Utils.escapeExpression';
38
37
 
39
38
  patcher.patch(handlebars.Utils, 'escapeExpression', {
@@ -42,7 +41,7 @@ module.exports = function(core) {
42
41
  usePerf: 'sync',
43
42
  post(data) {
44
43
  const { args, result, hooked, orig } = data;
45
- if (!result || !args[0] || !getSourceContext(PROPAGATOR)) return;
44
+ if (!result || !args[0] || !getPropagatorContext()) return;
46
45
 
47
46
  const argInfo = tracker.getData(args[0]);
48
47
 
@@ -33,7 +33,7 @@ module.exports = function (core) {
33
33
  install() {
34
34
  const name = 'isnumeric';
35
35
 
36
- depHooks.resolve({ name, version: '<1.0.0' }, (_export, { version }) => {
36
+ depHooks.resolve({ name, version: '<1' }, (_export, { version }) => {
37
37
  const fullName = `${name}@${version}`;
38
38
  return patcher.patch(_export, {
39
39
  name,
@@ -28,7 +28,7 @@ module.exports = function(core) {
28
28
  joiInstrumentation.any = {
29
29
  install() {
30
30
  depHooks.resolve(
31
- { name: 'joi', file: 'lib/types/any', version: '>=17.0.0' },
31
+ { name: 'joi', file: 'lib/types/any', version: '>=17 <18' },
32
32
  (exp) => {
33
33
  const anyTypePrototype = Object.getPrototypeOf(exp);
34
34
  const def = anyTypePrototype?._definition;
@@ -12,7 +12,7 @@ describe('assess dataflow propagation joi object validator with custom or extern
12
12
  tracker = core.assess.dataflow.tracker;
13
13
  core.config.assess.trust_custom_validators = true;
14
14
 
15
- core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/types/any', version: '>=17.0.0' }).yields(require('joi-17/lib/types/any'));
15
+ core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/types/any', version: '>=17 <18' }).yields(require('joi-17/lib/types/any'));
16
16
 
17
17
  require('./index')(core).install();
18
18
  joi = require('joi-17');
@@ -41,11 +41,11 @@ describe('assess dataflow propagation joi array schema validation', function() {
41
41
  tracker = core.assess.dataflow.tracker;
42
42
  core.config.assess.trust_custom_validators = true;
43
43
 
44
- core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/types/string.js', version: '>=17.0.0' }).yields(require('joi-17/lib/types/string'));
45
- core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/types/keys.js', version: '>=17.0.0' }).yields(require('joi-17/lib/types/keys'));
46
- core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/types/any', version: '>=17.0.0' }).yields(require('joi-17/lib/types/any'));
47
- core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/validator', version: '>=17.0.0' }).yields(require('joi-17/lib/validator'));
48
- core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/values.js', version: '>=17.0.0' }).yields(require('joi-17/lib/values'));
44
+ core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/types/string.js', version: '>=17 <18' }).yields(require('joi-17/lib/types/string'));
45
+ core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/types/keys.js', version: '>=17 <18' }).yields(require('joi-17/lib/types/keys'));
46
+ core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/types/any', version: '>=17 <18' }).yields(require('joi-17/lib/types/any'));
47
+ core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/validator', version: '>=17 <18' }).yields(require('joi-17/lib/validator'));
48
+ core.depHooks.resolve.withArgs({ name: 'joi', file: 'lib/values.js', version: '>=17 <18' }).yields(require('joi-17/lib/values'));
49
49
 
50
50
  require('./index')(core).install();
51
51
  joi = require('joi-17');
@@ -25,7 +25,7 @@ module.exports = function(core) {
25
25
  depHooks,
26
26
  patcher,
27
27
  assess: {
28
- getSourceContext,
28
+ getPropagatorContext,
29
29
  inspect, // TODO NODE-3455: remove
30
30
  eventFactory: { createPropagationEvent },
31
31
  dataflow: { tracker },
@@ -50,7 +50,7 @@ module.exports = function(core) {
50
50
  if (
51
51
  !data.result?.value ||
52
52
  typeof data.result.value !== 'boolean' ||
53
- !getSourceContext()
53
+ !getPropagatorContext()
54
54
  ) return;
55
55
 
56
56
  const argInfo = tracker.getData(data.args[0]);
@@ -100,7 +100,7 @@ module.exports = function(core) {
100
100
  return core.assess.dataflow.propagation.joiInstrumentation.booleanCoerce = {
101
101
  install() {
102
102
  depHooks.resolve(
103
- { name: 'joi', file: 'lib/types/boolean.js', version: '>=17.0.0' },
103
+ { name: 'joi', file: 'lib/types/boolean.js', version: '>=17 <18' },
104
104
  instrumentJoiBoolean
105
105
  );
106
106
  },
@@ -20,7 +20,7 @@ describe('assess dataflow propagation joi boolean', function() {
20
20
  .withArgs({
21
21
  name: 'joi',
22
22
  file: 'lib/types/boolean.js',
23
- version: '>=17.0.0',
23
+ version: '>=17 <18',
24
24
  })
25
25
  .yields(require('joi-17/lib/types/boolean'));
26
26