@contrast/assess 1.46.1 → 1.46.2

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 (157) hide show
  1. package/package.json +14 -11
  2. package/lib/crypto-analysis/install/crypto.test.js +0 -146
  3. package/lib/crypto-analysis/install/math.test.js +0 -65
  4. package/lib/dataflow/index.test.js +0 -36
  5. package/lib/dataflow/propagation/index.test.js +0 -103
  6. package/lib/dataflow/propagation/install/JSON/index.test.js +0 -50
  7. package/lib/dataflow/propagation/install/JSON/parse-fn.test.js +0 -232
  8. package/lib/dataflow/propagation/install/JSON/parse.test.js +0 -968
  9. package/lib/dataflow/propagation/install/JSON/stringify.test.js +0 -265
  10. package/lib/dataflow/propagation/install/array-prototype-join.test.js +0 -106
  11. package/lib/dataflow/propagation/install/buffer.test.js +0 -112
  12. package/lib/dataflow/propagation/install/contrast-methods/add.test.js +0 -94
  13. package/lib/dataflow/propagation/install/contrast-methods/index.test.js +0 -49
  14. package/lib/dataflow/propagation/install/contrast-methods/number.test.js +0 -50
  15. package/lib/dataflow/propagation/install/contrast-methods/string.test.js +0 -148
  16. package/lib/dataflow/propagation/install/contrast-methods/tag.test.js +0 -145
  17. package/lib/dataflow/propagation/install/decode-uri-component.test.js +0 -78
  18. package/lib/dataflow/propagation/install/ejs/escape-xml.test.js +0 -69
  19. package/lib/dataflow/propagation/install/ejs/template.test.js +0 -62
  20. package/lib/dataflow/propagation/install/encode-uri.test.js +0 -83
  21. package/lib/dataflow/propagation/install/escape-html.test.js +0 -71
  22. package/lib/dataflow/propagation/install/escape.test.js +0 -73
  23. package/lib/dataflow/propagation/install/fastify-send.test.js +0 -42
  24. package/lib/dataflow/propagation/install/handlebars-utils-escape-expression.test.js +0 -71
  25. package/lib/dataflow/propagation/install/isnumeric-0.test.js +0 -58
  26. package/lib/dataflow/propagation/install/joi/any.test.js +0 -270
  27. package/lib/dataflow/propagation/install/joi/array.test.js +0 -912
  28. package/lib/dataflow/propagation/install/joi/boolean.test.js +0 -103
  29. package/lib/dataflow/propagation/install/joi/expression.test.js +0 -76
  30. package/lib/dataflow/propagation/install/joi/index.test.js +0 -39
  31. package/lib/dataflow/propagation/install/joi/number.test.js +0 -103
  32. package/lib/dataflow/propagation/install/joi/object.test.js +0 -119
  33. package/lib/dataflow/propagation/install/joi/ref.test.js +0 -607
  34. package/lib/dataflow/propagation/install/joi/string-schema.test.js +0 -513
  35. package/lib/dataflow/propagation/install/mongoose/index.test.js +0 -42
  36. package/lib/dataflow/propagation/install/mongoose/schema-map.test.js +0 -348
  37. package/lib/dataflow/propagation/install/mongoose/schema-mixed.test.js +0 -511
  38. package/lib/dataflow/propagation/install/mongoose/schema-string.test.js +0 -199
  39. package/lib/dataflow/propagation/install/mustache-escape.test.js +0 -62
  40. package/lib/dataflow/propagation/install/mysql-connection-escape.test.js +0 -74
  41. package/lib/dataflow/propagation/install/parse-int.test.js +0 -48
  42. package/lib/dataflow/propagation/install/path/basename.test.js +0 -143
  43. package/lib/dataflow/propagation/install/path/dirname.test.js +0 -167
  44. package/lib/dataflow/propagation/install/path/extname.test.js +0 -141
  45. package/lib/dataflow/propagation/install/path/format.test.js +0 -250
  46. package/lib/dataflow/propagation/install/path/index.test.js +0 -45
  47. package/lib/dataflow/propagation/install/path/join-and-resolve.test.js +0 -485
  48. package/lib/dataflow/propagation/install/path/normalize.test.js +0 -176
  49. package/lib/dataflow/propagation/install/path/parse.test.js +0 -238
  50. package/lib/dataflow/propagation/install/path/relative.test.js +0 -239
  51. package/lib/dataflow/propagation/install/path/toNamespacedPath.test.js +0 -158
  52. package/lib/dataflow/propagation/install/pug/index.test.js +0 -55
  53. package/lib/dataflow/propagation/install/pug-runtime-escape.test.js +0 -69
  54. package/lib/dataflow/propagation/install/querystring/escape.test.js +0 -63
  55. package/lib/dataflow/propagation/install/querystring/index.test.js +0 -40
  56. package/lib/dataflow/propagation/install/querystring/parse.test.js +0 -272
  57. package/lib/dataflow/propagation/install/querystring/stringify.test.js +0 -301
  58. package/lib/dataflow/propagation/install/reg-exp-prototype-exec.test.js +0 -283
  59. package/lib/dataflow/propagation/install/send.test.js +0 -63
  60. package/lib/dataflow/propagation/install/sequelize/query-generator.test.js +0 -74
  61. package/lib/dataflow/propagation/install/sequelize/sql-string.test.js +0 -119
  62. package/lib/dataflow/propagation/install/sql-template-strings.test.js +0 -100
  63. package/lib/dataflow/propagation/install/string/concat.test.js +0 -145
  64. package/lib/dataflow/propagation/install/string/format-methods.test.js +0 -74
  65. package/lib/dataflow/propagation/install/string/html-methods.test.js +0 -177
  66. package/lib/dataflow/propagation/install/string/index.test.js +0 -103
  67. package/lib/dataflow/propagation/install/string/match-all.test.js +0 -412
  68. package/lib/dataflow/propagation/install/string/match.test.js +0 -374
  69. package/lib/dataflow/propagation/install/string/replace.test.js +0 -601
  70. package/lib/dataflow/propagation/install/string/slice.test.js +0 -278
  71. package/lib/dataflow/propagation/install/string/split.test.js +0 -513
  72. package/lib/dataflow/propagation/install/string/substring.test.js +0 -251
  73. package/lib/dataflow/propagation/install/string/trim.test.js +0 -135
  74. package/lib/dataflow/propagation/install/unescape.test.js +0 -78
  75. package/lib/dataflow/propagation/install/url/domain-parsers.test.js +0 -63
  76. package/lib/dataflow/propagation/install/url/parse.test.js +0 -391
  77. package/lib/dataflow/propagation/install/url/searchParams.test.js +0 -538
  78. package/lib/dataflow/propagation/install/url/url.test.js +0 -466
  79. package/lib/dataflow/propagation/install/util-format.test.js +0 -336
  80. package/lib/dataflow/propagation/install/validator/hooks.test.js +0 -211
  81. package/lib/dataflow/sinks/index.test.js +0 -78
  82. package/lib/dataflow/sinks/install/child-process.test.js +0 -338
  83. package/lib/dataflow/sinks/install/eval.test.js +0 -95
  84. package/lib/dataflow/sinks/install/express/index.test.js +0 -33
  85. package/lib/dataflow/sinks/install/express/reflected-xss.test.js +0 -109
  86. package/lib/dataflow/sinks/install/express/unvalidated-redirect.test.js +0 -144
  87. package/lib/dataflow/sinks/install/fastify/index.test.js +0 -32
  88. package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.test.js +0 -130
  89. package/lib/dataflow/sinks/install/fs.test.js +0 -138
  90. package/lib/dataflow/sinks/install/function.test.js +0 -103
  91. package/lib/dataflow/sinks/install/hapi/index.test.js +0 -32
  92. package/lib/dataflow/sinks/install/hapi/unvalidated-redirect.test.js +0 -130
  93. package/lib/dataflow/sinks/install/http/index.test.js +0 -33
  94. package/lib/dataflow/sinks/install/http/request.test.js +0 -184
  95. package/lib/dataflow/sinks/install/http/server-response.test.js +0 -160
  96. package/lib/dataflow/sinks/install/koa/index.test.js +0 -32
  97. package/lib/dataflow/sinks/install/koa/unvalidated-redirect.test.js +0 -200
  98. package/lib/dataflow/sinks/install/libxmljs.test.js +0 -158
  99. package/lib/dataflow/sinks/install/marsdb.test.js +0 -166
  100. package/lib/dataflow/sinks/install/mongodb.test.js +0 -617
  101. package/lib/dataflow/sinks/install/mssql.test.js +0 -134
  102. package/lib/dataflow/sinks/install/mysql.test.js +0 -224
  103. package/lib/dataflow/sinks/install/node-serialize.test.js +0 -83
  104. package/lib/dataflow/sinks/install/postgres.test.js +0 -152
  105. package/lib/dataflow/sinks/install/restify.test.js +0 -140
  106. package/lib/dataflow/sinks/install/sequelize.test.js +0 -100
  107. package/lib/dataflow/sinks/install/sqlite3.test.js +0 -118
  108. package/lib/dataflow/sinks/install/vm.test.js +0 -326
  109. package/lib/dataflow/sources/handler.test.js +0 -501
  110. package/lib/dataflow/sources/index.test.js +0 -60
  111. package/lib/dataflow/sources/install/body-parser1.test.js +0 -244
  112. package/lib/dataflow/sources/install/busboy.test.js +0 -152
  113. package/lib/dataflow/sources/install/cookie-parser1.test.js +0 -141
  114. package/lib/dataflow/sources/install/express/params.test.js +0 -110
  115. package/lib/dataflow/sources/install/express/parsedUrl.test.js +0 -107
  116. package/lib/dataflow/sources/install/fastify/fastify.test.js +0 -207
  117. package/lib/dataflow/sources/install/fastify/index.test.js +0 -33
  118. package/lib/dataflow/sources/install/formidable1.test.js +0 -119
  119. package/lib/dataflow/sources/install/graphql-http.test.js +0 -133
  120. package/lib/dataflow/sources/install/hapi/hapi.test.js +0 -171
  121. package/lib/dataflow/sources/install/hapi/index.test.js +0 -33
  122. package/lib/dataflow/sources/install/http.test.js +0 -149
  123. package/lib/dataflow/sources/install/koa/index.test.js +0 -40
  124. package/lib/dataflow/sources/install/koa/koa-bodyparsers.test.js +0 -160
  125. package/lib/dataflow/sources/install/koa/koa-multer.test.js +0 -197
  126. package/lib/dataflow/sources/install/koa/koa-routers.test.js +0 -146
  127. package/lib/dataflow/sources/install/koa/koa2.test.js +0 -145
  128. package/lib/dataflow/sources/install/multer1.test.js +0 -143
  129. package/lib/dataflow/sources/install/qs6.test.js +0 -131
  130. package/lib/dataflow/sources/install/querystring.test.js +0 -82
  131. package/lib/dataflow/sources/install/restify/fieldedTextBodyParser.test.js +0 -86
  132. package/lib/dataflow/sources/install/restify/index.test.js +0 -38
  133. package/lib/dataflow/sources/install/restify/jsonBodyParser.test.js +0 -140
  134. package/lib/dataflow/sources/install/restify/router.test.js +0 -81
  135. package/lib/dataflow/tag-utils-complete.test.js +0 -27
  136. package/lib/dataflow/tag-utils.test.js +0 -192
  137. package/lib/dataflow/tracker.test.js +0 -216
  138. package/lib/dataflow/utils/is-safe-content-type.test.js +0 -16
  139. package/lib/dataflow/utils/is-vulnerable.test.js +0 -115
  140. package/lib/event-factory.test.js +0 -326
  141. package/lib/get-policy.test.js +0 -194
  142. package/lib/get-source-context.test.js +0 -161
  143. package/lib/index.test.js +0 -45
  144. package/lib/make-source-context.test.js +0 -50
  145. package/lib/response-scanning/handlers/index.test.js +0 -419
  146. package/lib/response-scanning/handlers/utils.test.js +0 -380
  147. package/lib/response-scanning/index.test.js +0 -41
  148. package/lib/response-scanning/install/http.test.js +0 -175
  149. package/lib/rule-scopes.test.js +0 -27
  150. package/lib/sampler/common.test.js +0 -101
  151. package/lib/sampler/index.test.js +0 -313
  152. package/lib/session-configuration/handlers.test.js +0 -84
  153. package/lib/session-configuration/index.test.js +0 -36
  154. package/lib/session-configuration/install/express-session.test.js +0 -218
  155. package/lib/session-configuration/install/fastify-cookie.test.js +0 -63
  156. package/lib/session-configuration/install/hapi.test.js +0 -269
  157. package/lib/session-configuration/install/koa.test.js +0 -92
@@ -1,374 +0,0 @@
1
- 'use strict';
2
-
3
- const { expect } = require('chai');
4
- const { inspect } = require('util');
5
- const { DataflowTag: { UNTRUSTED } } = require('@contrast/common');
6
- const { initAssessFixture } = require('@contrast/test/fixtures');
7
-
8
- describe('assess dataflow propagation string match', function () {
9
- let core, simulateRequestScope, trackString, tracker;
10
- const allPatcher = new Map();
11
-
12
- beforeEach(function () {
13
- ({
14
- core,
15
- trackString,
16
- simulateRequestScope
17
- } = initAssessFixture());
18
-
19
- tracker = core.assess.dataflow.tracker;
20
-
21
- core.assess.dataflow.propagation.regExpExec.install();
22
- core.assess.dataflow.propagation.stringInstrumentation.match.install();
23
- core.assess.dataflow.propagation.stringInstrumentation.substring.install();
24
- });
25
-
26
- afterEach(function () {
27
- core.assess.dataflow.propagation.regExpExec.uninstall();
28
- core.assess.dataflow.propagation.stringInstrumentation.match.uninstall();
29
- core.assess.dataflow.propagation.stringInstrumentation.substring.uninstall();
30
- });
31
-
32
- // eslint-disable-next-line mocha/no-sibling-hooks
33
- afterEach(function() {
34
- core.Perf.fromAllToMap('patcher', allPatcher);
35
- });
36
-
37
- after(function() {
38
- const stats = core.Perf.getStats(allPatcher);
39
- for (const [key, { n, totalMicros, mean }] of stats.entries()) {
40
- console.log(key, n, totalMicros, 'nsec', mean, 'mean');
41
- }
42
- });
43
-
44
- describe('base cases', function () {
45
- [
46
- [],
47
- [undefined],
48
- ['']
49
- ].forEach((val) => {
50
- it(`returns empty string match for ${inspect(val[0])}`, function () {
51
- simulateRequestScope(() => {
52
- const ret = 'foo'.match(val[0]);
53
- expect(ret[0]).to.equal('');
54
- expect(tracker.getData(ret[0])).to.be.null;
55
- });
56
- });
57
- });
58
-
59
- it('returns null when no match is found', function () {
60
- simulateRequestScope(() => {
61
- const ret = ''.match('foo');
62
- expect(ret).to.be.null;
63
- });
64
- });
65
-
66
- it('returns first match string', function () {
67
- simulateRequestScope(() => {
68
- const ret = 'foo'.match(/f/);
69
- expect(ret).to.deep.equal(['f']);
70
- expect(tracker.getData(ret[0])).to.be.null;
71
- });
72
- });
73
-
74
- it('returns all match strings', function () {
75
- simulateRequestScope(() => {
76
- const ret = 'foo'.match(/o/g);
77
- expect(ret).to.deep.equal(['o', 'o']);
78
- ret.forEach((val) => {
79
- expect(tracker.getData(val)).to.be.null;
80
- });
81
- });
82
- });
83
-
84
- it('converts string to regex and returns match ', function () {
85
- simulateRequestScope(() => {
86
- const ret = 'foo'.match('f');
87
- expect(ret).to.deep.equal(['f']);
88
- expect(tracker.getData(ret[0])).to.be.null;
89
- });
90
- });
91
-
92
- it('returns first match string using capture groups', function () {
93
- simulateRequestScope(() => {
94
- const ret = 'foo'.match(/(f)|(o)/);
95
- expect(ret).to.deep.equal(['f', 'f', undefined]);
96
- expect(ret.groups).to.be.undefined;
97
- ret.forEach((val) => {
98
- expect(tracker.getData(val)).to.be.null;
99
- });
100
- });
101
- });
102
-
103
- it('returns first match string using named capture groups', function () {
104
- simulateRequestScope(() => {
105
- const ret = 'foo'.match(/(?<foo>f)|(?<bar>o)/);
106
- expect(ret).to.deep.equal(['f', 'f', undefined]);
107
- expect(ret.groups.foo).to.equal('f');
108
- ret.forEach((val) => {
109
- expect(tracker.getData(val)).to.be.null;
110
- });
111
- });
112
- });
113
-
114
- it('returns match from custom matcher', function () {
115
- simulateRequestScope(() => {
116
- const ret = 'foo'.match({
117
- [Symbol.match](_str) {
118
- return ['foo'];
119
- },
120
- });
121
- expect(ret).to.deep.equal(['foo']);
122
- expect(tracker.getData(ret[0])).to.be.null;
123
- });
124
- });
125
- });
126
-
127
- describe('propagation', function () {
128
- it('keeps track of tracked first matched string', function () {
129
- simulateRequestScope(() => {
130
- const extern = trackString('foobarfoo');
131
-
132
- const ret = extern.match(/foo/);
133
- const retFirstArgInfo = tracker.getData(ret[0]);
134
-
135
- expect(ret).to.deep.equal(['foo']);
136
- expect(retFirstArgInfo.tags).to.deep.equal({
137
- [UNTRUSTED]: [0, 2]
138
- });
139
- expect(retFirstArgInfo.name).to.equal('String.prototype.match');
140
- });
141
- });
142
-
143
- it('keeps track of tracked of all globally matched strings', function () {
144
- simulateRequestScope(() => {
145
- const extern = trackString('foobarfoo');
146
-
147
- const ret = extern.match(/foo/g);
148
-
149
- expect(ret).to.deep.equal(['foo', 'foo']);
150
- ret.forEach((val) => {
151
- const valInfo = tracker.getData(val);
152
-
153
- expect(valInfo.tags).to.deep.equal({
154
- [UNTRUSTED]: [0, 2]
155
- });
156
- expect(valInfo.name).to.equal('String.prototype.match');
157
- });
158
- });
159
- });
160
-
161
- it('keeps track of partially tracked matched strings', function () {
162
- simulateRequestScope(() => {
163
- const extern = trackString('foobarfoo', {
164
- tags: {
165
- [UNTRUSTED]: [0, 5]
166
- }
167
- });
168
-
169
- const ret = extern.match(/foo/g);
170
- const retFirstArgInfo = tracker.getData(ret[0]);
171
-
172
- expect(ret).to.deep.equal(['foo', 'foo']);
173
- expect(retFirstArgInfo.tags).to.deep.equal({
174
- [UNTRUSTED]: [0, 2]
175
- });
176
- expect(retFirstArgInfo.name).to.equal('String.prototype.match');
177
- expect(tracker.getData(ret[1])).to.be.null;
178
- });
179
- });
180
-
181
- it('keeps track of tracked strings with multiple ranges', function () {
182
- simulateRequestScope(() => {
183
- const extern = trackString('foobarfoo', {
184
- tags: {
185
- foo: [0, 2, 6, 8],
186
- bar: [3, 5],
187
- foobar: [0, 5],
188
- barfoo: [3, 8]
189
- }
190
- });
191
-
192
- const ret = extern.match(/foo/g);
193
- const retFirstArgInfo = tracker.getData(ret[0]);
194
- const retSecondArgInfo = tracker.getData(ret[1]);
195
-
196
- expect(ret).to.deep.equal(['foo', 'foo']);
197
- expect(retFirstArgInfo.tags).to.deep.equal({
198
- foo: [0, 2],
199
- foobar: [0, 2]
200
- });
201
- expect(retFirstArgInfo.name).to.equal('String.prototype.match');
202
- expect(retSecondArgInfo.tags).to.deep.equal({
203
- foo: [0, 2],
204
- barfoo: [0, 2]
205
- });
206
- expect(retSecondArgInfo.name).to.equal('String.prototype.match');
207
- });
208
- });
209
-
210
- describe('empty or full matches', function () {
211
- it('handles full string matches', function () {
212
- simulateRequestScope(() => {
213
- const extern = trackString('foobar');
214
-
215
- const ret = extern.match(/(?<full>foobar)/);
216
- const matchInfo = tracker.getData(ret[0]);
217
- const captrueMatchInfo = tracker.getData(ret[1]);
218
- const fullGroupInfo = tracker.getData(ret.groups.full);
219
-
220
- expect(ret).to.deep.equal([
221
- 'foobar',
222
- 'foobar',
223
- ]);
224
- expect(matchInfo.tags).to.deep.equal({
225
- [UNTRUSTED]: [0, 5]
226
- });
227
- expect(matchInfo.name).to.equal('String.prototype.match');
228
- expect(captrueMatchInfo.tags).to.deep.equal({
229
- [UNTRUSTED]: [0, 5]
230
- });
231
- expect(captrueMatchInfo.name).to.equal('String.prototype.match');
232
- expect(ret.groups.full).to.equal('foobar');
233
- expect(fullGroupInfo.tags).to.deep.equal({
234
- [UNTRUSTED]: [0, 5]
235
- });
236
- expect(fullGroupInfo.name).to.equal('String.prototype.match');
237
- });
238
- });
239
-
240
- it('handles empty string matches', function () {
241
- simulateRequestScope(() => {
242
- const extern = trackString('foobar');
243
-
244
- const ret = extern.match(/(?<empty>)/);
245
- const matchInfo = tracker.getData(ret[0]);
246
- const captrueMatchInfo = tracker.getData(ret[1]);
247
- const emptyGroupInfo = tracker.getData(ret.groups.empty);
248
-
249
- expect(ret).to.deep.equal([
250
- '',
251
- '',
252
- ]);
253
- expect(matchInfo).to.be.null;
254
- expect(captrueMatchInfo).to.be.null;
255
- expect(ret.groups.empty).to.equal('');
256
- expect(emptyGroupInfo).to.be.null;
257
- });
258
- });
259
- });
260
-
261
- describe('capture groups', function () {
262
- it('keeps track of tracked strings within matched capture groups', function () {
263
- simulateRequestScope(() => {
264
- const extern = trackString('foobar');
265
-
266
- const ret = extern.match(/(foo)|(bar)/);
267
- const retFirstArgInfo = tracker.getData(ret[0]);
268
- const retSecondArgInfo = tracker.getData(ret[1]);
269
-
270
- expect(ret).to.deep.equal(['foo', 'foo', undefined]);
271
- expect(ret.groups).to.be.undefined;
272
- expect(retFirstArgInfo.tags).to.deep.equal({
273
- [UNTRUSTED]: [0, 2]
274
- });
275
- expect(retFirstArgInfo.name).to.equal('String.prototype.match');
276
- expect(retSecondArgInfo.tags).to.deep.equal({
277
- [UNTRUSTED]: [0, 2]
278
- });
279
- expect(retSecondArgInfo.name).to.equal('String.prototype.match');
280
- });
281
- });
282
-
283
- it('keeps track of tracked strings within matched named capture groups', function () {
284
- simulateRequestScope(() => {
285
- const extern = trackString('foobar');
286
-
287
- const ret = extern.match(/(?<fooOrBar>foo|bar)/);
288
- const retFirstArgInfo = tracker.getData(ret[0]);
289
- const retSecondArgInfo = tracker.getData(ret[1]);
290
- const groupsValueInfo = tracker.getData(ret.groups.fooOrBar);
291
-
292
- expect(ret).to.deep.equal(['foo', 'foo']);
293
- expect(ret.groups.fooOrBar).to.equal('foo');
294
- expect(retFirstArgInfo.tags).to.deep.equal({
295
- [UNTRUSTED]: [0, 2]
296
- });
297
- expect(retFirstArgInfo.name).to.equal('String.prototype.match');
298
- expect(retSecondArgInfo.tags).to.deep.equal({
299
- [UNTRUSTED]: [0, 2]
300
- });
301
- expect(retSecondArgInfo.name).to.equal('String.prototype.match');
302
- expect(groupsValueInfo.tags).to.deep.equal({
303
- [UNTRUSTED]: [0, 2]
304
- });
305
- expect(groupsValueInfo.name).to.equal('String.prototype.match');
306
- });
307
- });
308
-
309
- it('keeps track of tracked strings within multiple matched named capture groups', function () {
310
- simulateRequestScope(() => {
311
- const extern = trackString('foobar');
312
-
313
- const ret = extern.match(/(?<fizzOrBuzz>fizz|buzz)|(?<fooOrBar>foo|bar)/);
314
- const retFirstArgInfo = tracker.getData(ret[0]);
315
- const retThirdArgInfo = tracker.getData(ret[2]);
316
- const groupsValueInfo = tracker.getData(ret.groups.fooOrBar);
317
-
318
- expect(ret).to.deep.equal(['foo', undefined, 'foo']);
319
- expect(ret.groups).to.deep.equal({ fizzOrBuzz: undefined, fooOrBar: 'foo' });
320
- expect(retFirstArgInfo.tags).to.deep.equal({
321
- [UNTRUSTED]: [0, 2]
322
- });
323
- expect(retFirstArgInfo.name).to.equal('String.prototype.match');
324
- expect(retThirdArgInfo.tags).to.deep.equal({
325
- [UNTRUSTED]: [0, 2]
326
- });
327
- expect(retThirdArgInfo.name).to.equal('String.prototype.match');
328
- expect(groupsValueInfo.tags).to.deep.equal({
329
- [UNTRUSTED]: [0, 2]
330
- });
331
- expect(groupsValueInfo.name).to.equal('String.prototype.match');
332
- });
333
- });
334
- });
335
-
336
- describe('custom matcher', function () {
337
- it('keeps track of tracked string returned by custom matcher', function () {
338
- simulateRequestScope(() => {
339
- const extern = trackString('foo');
340
-
341
- const ret = 'foo'.match({
342
- [Symbol.match](_str) {
343
- return [extern];
344
- },
345
- });
346
-
347
- expect(ret).to.deep.equal(['foo']);
348
- expect(tracker.getData(ret[0]).tags).to.deep.equal({
349
- [UNTRUSTED]: [0, 2]
350
- });
351
- });
352
- });
353
-
354
- it('keeps track of tracked string copied by custom matcher', function () {
355
- simulateRequestScope(() => {
356
- const extern = trackString('foobar');
357
-
358
- const ret = extern.match({
359
- [Symbol.match](str) {
360
- return [str.substring(0, 3)];
361
- },
362
- });
363
- const retInfo = tracker.getData(ret[0]);
364
-
365
- expect(ret).to.deep.equal(['foo']);
366
- expect(retInfo.tags).to.deep.equal({
367
- [UNTRUSTED]: [0, 2]
368
- });
369
- expect(retInfo.history[0].name).to.equal('String.prototype.match');
370
- });
371
- });
372
- });
373
- });
374
- });