@contrast/assess 1.52.0 → 1.54.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.
- package/lib/crypto-analysis/install/math.js +0 -1
- package/lib/dataflow/propagation/common.js +6 -6
- package/lib/dataflow/propagation/install/JSON/parse.js +7 -3
- package/lib/dataflow/propagation/install/JSON/stringify.js +7 -6
- package/lib/dataflow/propagation/install/array-prototype-join.js +5 -8
- package/lib/dataflow/propagation/install/buffer.js +4 -4
- package/lib/dataflow/propagation/install/contrast-methods/add.js +42 -38
- package/lib/dataflow/propagation/install/contrast-methods/string.js +4 -2
- package/lib/dataflow/propagation/install/contrast-methods/tag.js +3 -1
- package/lib/dataflow/propagation/install/decode-uri-component.js +5 -7
- package/lib/dataflow/propagation/install/ejs/escape-xml.js +4 -3
- package/lib/dataflow/propagation/install/ejs/template.js +1 -1
- package/lib/dataflow/propagation/install/encode-uri.js +5 -7
- package/lib/dataflow/propagation/install/escape-html.js +4 -3
- package/lib/dataflow/propagation/install/escape.js +5 -7
- package/lib/dataflow/propagation/install/handlebars-utils-escape-expression.js +4 -3
- package/lib/dataflow/propagation/install/joi/boolean.js +1 -3
- package/lib/dataflow/propagation/install/joi/expression.js +1 -3
- package/lib/dataflow/propagation/install/joi/number.js +1 -3
- package/lib/dataflow/propagation/install/joi/string-schema.js +2 -6
- package/lib/dataflow/propagation/install/joi/utils.js +2 -4
- package/lib/dataflow/propagation/install/joi/values.js +1 -3
- package/lib/dataflow/propagation/install/mongoose/schema-map.js +1 -3
- package/lib/dataflow/propagation/install/mongoose/schema-mixed.js +1 -3
- package/lib/dataflow/propagation/install/mongoose/schema-string.js +4 -5
- package/lib/dataflow/propagation/install/mustache-escape.js +4 -3
- package/lib/dataflow/propagation/install/mysql-connection-escape.js +9 -8
- package/lib/dataflow/propagation/install/path/basename.js +6 -7
- package/lib/dataflow/propagation/install/path/common.js +1 -0
- package/lib/dataflow/propagation/install/path/dirname.js +6 -8
- package/lib/dataflow/propagation/install/path/extname.js +8 -22
- package/lib/dataflow/propagation/install/path/format.js +6 -10
- package/lib/dataflow/propagation/install/path/join-and-resolve.js +7 -13
- package/lib/dataflow/propagation/install/path/normalize.js +8 -18
- package/lib/dataflow/propagation/install/path/parse.js +8 -18
- package/lib/dataflow/propagation/install/path/relative.js +8 -15
- package/lib/dataflow/propagation/install/path/toNamespacedPath.js +7 -18
- package/lib/dataflow/propagation/install/pug/index.js +1 -1
- package/lib/dataflow/propagation/install/pug-runtime-escape.js +6 -5
- package/lib/dataflow/propagation/install/querystring/escape.js +3 -1
- package/lib/dataflow/propagation/install/querystring/parse.js +3 -2
- package/lib/dataflow/propagation/install/querystring/stringify.js +4 -4
- package/lib/dataflow/propagation/install/reg-exp-prototype-exec.js +4 -3
- package/lib/dataflow/propagation/install/sequelize/query-generator.js +0 -1
- package/lib/dataflow/propagation/install/sequelize/sql-string.js +16 -17
- package/lib/dataflow/propagation/install/sql-template-strings.js +6 -10
- package/lib/dataflow/propagation/install/string/concat.js +4 -4
- package/lib/dataflow/propagation/install/string/format-methods.js +4 -4
- package/lib/dataflow/propagation/install/string/html-methods.js +5 -6
- package/lib/dataflow/propagation/install/string/index.js +4 -3
- package/lib/dataflow/propagation/install/string/match-all.js +7 -6
- package/lib/dataflow/propagation/install/string/match.js +10 -9
- package/lib/dataflow/propagation/install/string/replace.js +5 -6
- package/lib/dataflow/propagation/install/string/slice.js +4 -3
- package/lib/dataflow/propagation/install/string/split.js +11 -11
- package/lib/dataflow/propagation/install/string/substring.js +4 -3
- package/lib/dataflow/propagation/install/string/trim.js +4 -3
- package/lib/dataflow/propagation/install/unescape.js +6 -14
- package/lib/dataflow/propagation/install/url/domain-parsers.js +6 -5
- package/lib/dataflow/propagation/install/url/parse.js +17 -17
- package/lib/dataflow/propagation/install/url/searchParams.js +36 -25
- package/lib/dataflow/propagation/install/url/url.js +3 -2
- package/lib/dataflow/propagation/install/util-format.js +4 -3
- package/lib/dataflow/propagation/install/validator/hooks.js +0 -1
- package/lib/dataflow/sinks/install/eval.js +3 -1
- package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +1 -1
- package/lib/dataflow/sinks/install/function.js +3 -4
- package/lib/dataflow/sinks/install/marsdb.js +3 -1
- package/lib/dataflow/sinks/install/mongodb.js +3 -1
- package/lib/dataflow/sinks/install/mssql.js +4 -3
- package/lib/dataflow/sinks/install/mysql.js +3 -1
- package/lib/dataflow/sinks/install/restify.js +3 -1
- package/lib/dataflow/sinks/install/sqlite3.js +4 -2
- package/lib/dataflow/sinks/install/vm.js +6 -4
- package/lib/dataflow/sources/handler.js +2 -3
- package/lib/dataflow/sources/install/fastify/fastify.js +5 -5
- package/lib/dataflow/tag-utils.js +15 -1
- package/lib/dataflow/tracker.js +0 -5
- package/lib/event-factory.js +1 -1
- package/lib/session-configuration/install/express-session.js +0 -1
- package/lib/session-configuration/install/fastify-cookie.js +0 -3
- package/lib/session-configuration/install/hapi.js +0 -1
- package/lib/session-configuration/install/koa.js +0 -3
- package/package.json +10 -10
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
const { DataflowTag: { WEAK_URL_ENCODED } } = require('@contrast/common');
|
|
19
19
|
const { createFullLengthCopyTags } = require('../../tag-utils');
|
|
20
|
-
const { patchType
|
|
20
|
+
const { patchType } = require('../common');
|
|
21
21
|
|
|
22
22
|
module.exports = function(core) {
|
|
23
23
|
const {
|
|
@@ -40,7 +40,7 @@ module.exports = function(core) {
|
|
|
40
40
|
patchType,
|
|
41
41
|
usePerf: 'sync',
|
|
42
42
|
post(data) {
|
|
43
|
-
const { args, result, hooked
|
|
43
|
+
const { args, result, hooked } = data;
|
|
44
44
|
if (!result || !args[0] || !getPropagatorContext()) return;
|
|
45
45
|
|
|
46
46
|
const argInfo = tracker.getData(args[0]);
|
|
@@ -57,9 +57,11 @@ module.exports = function(core) {
|
|
|
57
57
|
name,
|
|
58
58
|
moduleName: 'pug-runtime',
|
|
59
59
|
methodName: 'escape',
|
|
60
|
-
context
|
|
60
|
+
get context() {
|
|
61
|
+
return `pugRuntime.escape('${argInfo.value}')`;
|
|
62
|
+
},
|
|
61
63
|
object: {
|
|
62
|
-
value:
|
|
64
|
+
value: 'pug-runtime',
|
|
63
65
|
tracked: false
|
|
64
66
|
},
|
|
65
67
|
result: {
|
|
@@ -74,7 +76,6 @@ module.exports = function(core) {
|
|
|
74
76
|
target: 'R',
|
|
75
77
|
stacktraceOpts: {
|
|
76
78
|
constructorOpt: hooked,
|
|
77
|
-
prependFrames: [orig]
|
|
78
79
|
},
|
|
79
80
|
});
|
|
80
81
|
|
|
@@ -62,7 +62,9 @@ module.exports = function(core) {
|
|
|
62
62
|
const argVal = inspect(strInfo.value);
|
|
63
63
|
const event = createPropagationEvent({
|
|
64
64
|
args: [{ tracked: true, value: argVal }],
|
|
65
|
-
context
|
|
65
|
+
get context() {
|
|
66
|
+
return `querystring.escape(${argVal})`;
|
|
67
|
+
},
|
|
66
68
|
history: [strInfo],
|
|
67
69
|
moduleName: 'querystring',
|
|
68
70
|
methodName: 'escape',
|
|
@@ -51,7 +51,9 @@ module.exports = function(core) {
|
|
|
51
51
|
|
|
52
52
|
const event = createPropagationEvent({
|
|
53
53
|
name: data.name,
|
|
54
|
-
context
|
|
54
|
+
get context() {
|
|
55
|
+
return `querystring.parse('${ArrayPrototypeJoin.call(args)})`;
|
|
56
|
+
},
|
|
55
57
|
moduleName: 'querystring',
|
|
56
58
|
methodName: 'parse',
|
|
57
59
|
history: [trackingData],
|
|
@@ -70,7 +72,6 @@ module.exports = function(core) {
|
|
|
70
72
|
tags: tagRanges,
|
|
71
73
|
stacktraceOpts: {
|
|
72
74
|
constructorOpt: data.hooked,
|
|
73
|
-
prependFrames: [data.orig]
|
|
74
75
|
},
|
|
75
76
|
source: 'P',
|
|
76
77
|
target: 'R'
|
|
@@ -112,10 +112,11 @@ module.exports = function(core) {
|
|
|
112
112
|
|
|
113
113
|
const { name } = data;
|
|
114
114
|
const args = data._args.map((a, i) => ({ tracked: i === 0, value: inspect(a) }));
|
|
115
|
-
const argString = args.reduce((acc, arg, i, arr) => acc + arg.value + (i === arr.length - 1 ? '' : ', '), '');
|
|
116
|
-
const context = `${name}(${argString})`;
|
|
117
115
|
const event = createPropagationEvent({
|
|
118
|
-
context
|
|
116
|
+
get context() {
|
|
117
|
+
const argString = args.reduce((acc, arg, i, arr) => acc + arg.value + (i === arr.length - 1 ? '' : ', '), '');
|
|
118
|
+
return `${name}(${argString})`;
|
|
119
|
+
},
|
|
119
120
|
args,
|
|
120
121
|
name,
|
|
121
122
|
moduleName,
|
|
@@ -127,7 +128,6 @@ module.exports = function(core) {
|
|
|
127
128
|
source: 'P',
|
|
128
129
|
stacktraceOpts: {
|
|
129
130
|
constructorOpt: data.hooked,
|
|
130
|
-
prependFrames: [data.orig],
|
|
131
131
|
},
|
|
132
132
|
tags: data._tags,
|
|
133
133
|
target: 'R',
|
|
@@ -38,13 +38,15 @@ module.exports = function(core) {
|
|
|
38
38
|
const tags = createSubsetTags(strInfo.tags, startIdx, match.length);
|
|
39
39
|
if (!tags) return null;
|
|
40
40
|
|
|
41
|
-
const { name, obj, hooked
|
|
41
|
+
const { name, obj, hooked } = metadata;
|
|
42
42
|
|
|
43
43
|
return createPropagationEvent({
|
|
44
44
|
name,
|
|
45
45
|
moduleName: 'RegExp',
|
|
46
46
|
methodName: 'prototype.exec',
|
|
47
|
-
context
|
|
47
|
+
get context() {
|
|
48
|
+
return `${obj}.exec('${strInfo.value}')`;
|
|
49
|
+
},
|
|
48
50
|
history: [strInfo],
|
|
49
51
|
object: {
|
|
50
52
|
value: 'RegExp',
|
|
@@ -63,7 +65,6 @@ module.exports = function(core) {
|
|
|
63
65
|
},
|
|
64
66
|
stacktraceOpts: {
|
|
65
67
|
constructorOpt: hooked,
|
|
66
|
-
prependFrames: [orig],
|
|
67
68
|
},
|
|
68
69
|
source: 'P',
|
|
69
70
|
target: 'R',
|
|
@@ -20,7 +20,7 @@ const {
|
|
|
20
20
|
primordials: { StringPrototypeMatchAll },
|
|
21
21
|
DataflowTag: { SQL_ENCODED },
|
|
22
22
|
} = require('@contrast/common');
|
|
23
|
-
const { patchType
|
|
23
|
+
const { patchType } = require('../../common');
|
|
24
24
|
|
|
25
25
|
module.exports = function(core) {
|
|
26
26
|
const {
|
|
@@ -64,7 +64,7 @@ module.exports = function(core) {
|
|
|
64
64
|
patchType,
|
|
65
65
|
usePerf: 'sync',
|
|
66
66
|
post(data) {
|
|
67
|
-
const { args, result, hooked
|
|
67
|
+
const { args, result, hooked } = data;
|
|
68
68
|
|
|
69
69
|
if (
|
|
70
70
|
!result ||
|
|
@@ -85,7 +85,9 @@ module.exports = function(core) {
|
|
|
85
85
|
newTags[SQL_ENCODED] = [0, result.length - 1];
|
|
86
86
|
|
|
87
87
|
const event = createPropagationEvent({
|
|
88
|
-
context
|
|
88
|
+
get context() {
|
|
89
|
+
return `sequelize.escape('${argInfo.value}')`;
|
|
90
|
+
},
|
|
89
91
|
name: 'sequelize/lib/sql-string.escape',
|
|
90
92
|
moduleName: 'sequelize',
|
|
91
93
|
methodName: 'escape',
|
|
@@ -105,7 +107,6 @@ module.exports = function(core) {
|
|
|
105
107
|
history,
|
|
106
108
|
stacktraceOpts: {
|
|
107
109
|
constructorOpt: hooked,
|
|
108
|
-
prependFrames: [orig],
|
|
109
110
|
},
|
|
110
111
|
});
|
|
111
112
|
|
|
@@ -119,7 +120,7 @@ module.exports = function(core) {
|
|
|
119
120
|
name: 'Sequelize.Utils.format',
|
|
120
121
|
patchType,
|
|
121
122
|
post(data) {
|
|
122
|
-
const { args, result, hooked
|
|
123
|
+
const { args, result, hooked } = data;
|
|
123
124
|
if (
|
|
124
125
|
!result ||
|
|
125
126
|
!args[0] ||
|
|
@@ -139,8 +140,8 @@ module.exports = function(core) {
|
|
|
139
140
|
return;
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
const replacements = [
|
|
143
|
-
let
|
|
143
|
+
const replacements = [...data.args[1]];
|
|
144
|
+
let replacementsTracked = false;
|
|
144
145
|
const [, , timezone, dialect] = data.args;
|
|
145
146
|
const len = positions.length;
|
|
146
147
|
|
|
@@ -161,7 +162,7 @@ module.exports = function(core) {
|
|
|
161
162
|
if (replacementInfo) {
|
|
162
163
|
history.add(replacementInfo);
|
|
163
164
|
newTags[SQL_ENCODED] = newTags[SQL_ENCODED] || [];
|
|
164
|
-
|
|
165
|
+
replacementsTracked ??= true;
|
|
165
166
|
newTags[SQL_ENCODED].push(positions[i], positions[i] + escapedVal.length - 1);
|
|
166
167
|
}
|
|
167
168
|
//update the string replacement poisitions based on current val length - it's replacing a ? in the origional string
|
|
@@ -176,7 +177,7 @@ module.exports = function(core) {
|
|
|
176
177
|
context: 'Sequelize.Utils.format',
|
|
177
178
|
name: 'sequelize/lib/sql-string.format',
|
|
178
179
|
object: {
|
|
179
|
-
value:
|
|
180
|
+
value: 'sequelize/lib/sql-string.format',
|
|
180
181
|
tracked: false,
|
|
181
182
|
},
|
|
182
183
|
result: {
|
|
@@ -185,7 +186,7 @@ module.exports = function(core) {
|
|
|
185
186
|
},
|
|
186
187
|
args: [
|
|
187
188
|
{ value: firstArgInfo ? firstArgInfo.value : args[0], tracked: !!firstArgInfo },
|
|
188
|
-
{ value: replacements, tracked:
|
|
189
|
+
{ value: replacements, tracked: replacementsTracked },
|
|
189
190
|
{ value: timezone, tracked: false },
|
|
190
191
|
{ value: dialect, tracked: false }
|
|
191
192
|
],
|
|
@@ -196,7 +197,6 @@ module.exports = function(core) {
|
|
|
196
197
|
history: Array.from(history),
|
|
197
198
|
stacktraceOpts: {
|
|
198
199
|
constructorOpt: hooked,
|
|
199
|
-
prependFrames: [orig],
|
|
200
200
|
},
|
|
201
201
|
});
|
|
202
202
|
|
|
@@ -210,7 +210,7 @@ module.exports = function(core) {
|
|
|
210
210
|
name: 'Sequelize.Utils.formatNamedParameters',
|
|
211
211
|
patchType,
|
|
212
212
|
post(data) {
|
|
213
|
-
const { args, result, hooked
|
|
213
|
+
const { args, result, hooked } = data;
|
|
214
214
|
|
|
215
215
|
if (
|
|
216
216
|
!result ||
|
|
@@ -232,7 +232,7 @@ module.exports = function(core) {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
const replacements = Object.assign({}, data.args[1]);
|
|
235
|
-
let
|
|
235
|
+
let replacementsTracked = false;
|
|
236
236
|
const [, , timezone, dialect] = data.args;
|
|
237
237
|
const len = positions.length;
|
|
238
238
|
|
|
@@ -252,7 +252,7 @@ module.exports = function(core) {
|
|
|
252
252
|
if (replacementInfo) {
|
|
253
253
|
history.add(replacementInfo);
|
|
254
254
|
newTags[SQL_ENCODED] = newTags[SQL_ENCODED] || [];
|
|
255
|
-
|
|
255
|
+
replacementsTracked ??= true;
|
|
256
256
|
newTags[SQL_ENCODED].push(Object.values(positions[i])[0], Object.values(positions[i])[0] + escapedVal.length - 1);
|
|
257
257
|
}
|
|
258
258
|
|
|
@@ -272,7 +272,7 @@ module.exports = function(core) {
|
|
|
272
272
|
context: 'Sequelize.Utils.formatNamedParameters',
|
|
273
273
|
name: 'sequelize/lib/sql-string.formatNamedParameters',
|
|
274
274
|
object: {
|
|
275
|
-
value:
|
|
275
|
+
value: 'sequelize/lib/sql-string.formatNamedParameters',
|
|
276
276
|
tracked: false,
|
|
277
277
|
},
|
|
278
278
|
result: {
|
|
@@ -281,7 +281,7 @@ module.exports = function(core) {
|
|
|
281
281
|
},
|
|
282
282
|
args: [
|
|
283
283
|
{ value: firstArgInfo ? firstArgInfo.value : args[0], tracked: !!firstArgInfo },
|
|
284
|
-
{ value: replacements, tracked:
|
|
284
|
+
{ value: replacements, tracked: replacementsTracked },
|
|
285
285
|
{ value: timezone, tracked: false },
|
|
286
286
|
{ value: dialect, tracked: false }
|
|
287
287
|
],
|
|
@@ -292,7 +292,6 @@ module.exports = function(core) {
|
|
|
292
292
|
history: Array.from(history),
|
|
293
293
|
stacktraceOpts: {
|
|
294
294
|
constructorOpt: hooked,
|
|
295
|
-
prependFrames: [orig],
|
|
296
295
|
},
|
|
297
296
|
});
|
|
298
297
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const { DataflowTag: { SQL_ENCODED } } = require('@contrast/common');
|
|
19
|
-
const { patchType
|
|
19
|
+
const { patchType } = require('../common');
|
|
20
20
|
|
|
21
21
|
module.exports = function(core) {
|
|
22
22
|
const {
|
|
@@ -39,11 +39,10 @@ module.exports = function(core) {
|
|
|
39
39
|
patchType,
|
|
40
40
|
usePerf: 'sync',
|
|
41
41
|
post(data) {
|
|
42
|
-
const { args, result, hooked
|
|
42
|
+
const { args, result, hooked } = data;
|
|
43
43
|
if (!result || !args[0] || !getPropagatorContext()) return;
|
|
44
44
|
|
|
45
45
|
const argInfo = tracker.getData(args[0]);
|
|
46
|
-
|
|
47
46
|
if (!argInfo) return;
|
|
48
47
|
|
|
49
48
|
const isResultStringsArray = Array.isArray(result.strings);
|
|
@@ -60,9 +59,11 @@ module.exports = function(core) {
|
|
|
60
59
|
name,
|
|
61
60
|
moduleName: 'sql-template-strings',
|
|
62
61
|
methodName: 'SQL',
|
|
63
|
-
context
|
|
62
|
+
get context() {
|
|
63
|
+
return `SQL\`${argInfo.value}\``;
|
|
64
|
+
},
|
|
64
65
|
object: {
|
|
65
|
-
value:
|
|
66
|
+
value: 'sql-template-strings',
|
|
66
67
|
tracked: false
|
|
67
68
|
},
|
|
68
69
|
result: {
|
|
@@ -77,10 +78,8 @@ module.exports = function(core) {
|
|
|
77
78
|
target: 'R',
|
|
78
79
|
stacktraceOpts: {
|
|
79
80
|
constructorOpt: hooked,
|
|
80
|
-
prependFrames: [orig]
|
|
81
81
|
},
|
|
82
82
|
});
|
|
83
|
-
|
|
84
83
|
if (!event) return;
|
|
85
84
|
|
|
86
85
|
if (resultInfo) {
|
|
@@ -88,16 +87,13 @@ module.exports = function(core) {
|
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
const { extern } = resultInfo || tracker.track(resultValue, event);
|
|
91
|
-
|
|
92
90
|
if (extern) {
|
|
93
91
|
if (idx === 0 && !isResultStringsArray) {
|
|
94
92
|
data.result.strings = extern;
|
|
95
93
|
}
|
|
96
|
-
|
|
97
94
|
if (idx < resultStrings.length && isResultStringsArray) {
|
|
98
95
|
data.result.strings[idx] = extern;
|
|
99
96
|
}
|
|
100
|
-
|
|
101
97
|
if (idx >= resultStrings.length) {
|
|
102
98
|
data.result.values[idx - resultStrings.length] = extern;
|
|
103
99
|
}
|
|
@@ -87,13 +87,14 @@ module.exports = function(core) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
if (history.size) {
|
|
90
|
-
const objVal = objInfo ? `'${objInfo.value}'` : getAdjustedUntrackedValue(data.obj);
|
|
91
|
-
const context = `${objVal}.concat(${ArrayPrototypeJoin.call(args.map((a) => a.value))})`;
|
|
92
90
|
const event = createPropagationEvent({
|
|
93
91
|
name,
|
|
94
92
|
moduleName: 'String',
|
|
95
93
|
methodName: 'prototype.concat',
|
|
96
|
-
context
|
|
94
|
+
get context() {
|
|
95
|
+
const objVal = objInfo ? `'${objInfo.value}'` : getAdjustedUntrackedValue(data.obj);
|
|
96
|
+
return `${objVal}.concat(${ArrayPrototypeJoin.call(args.map((a) => a.value))})`;
|
|
97
|
+
},
|
|
97
98
|
object: {
|
|
98
99
|
value: objInfo?.value ?? getAdjustedUntrackedValue(data.obj),
|
|
99
100
|
tracked: !!objInfo
|
|
@@ -109,7 +110,6 @@ module.exports = function(core) {
|
|
|
109
110
|
target: 'R',
|
|
110
111
|
stacktraceOpts: {
|
|
111
112
|
constructorOpt: data.hooked,
|
|
112
|
-
prependFrames: [data.orig]
|
|
113
113
|
},
|
|
114
114
|
});
|
|
115
115
|
|
|
@@ -37,7 +37,7 @@ module.exports = function(core) {
|
|
|
37
37
|
patchType,
|
|
38
38
|
usePerf: 'sync',
|
|
39
39
|
post(data) {
|
|
40
|
-
const { obj, result, hooked
|
|
40
|
+
const { obj, result, hooked } = data;
|
|
41
41
|
if (!result || !getPropagatorContext()) return;
|
|
42
42
|
|
|
43
43
|
const objInfo = tracker.getData(obj);
|
|
@@ -50,7 +50,9 @@ module.exports = function(core) {
|
|
|
50
50
|
name,
|
|
51
51
|
moduleName: 'String',
|
|
52
52
|
methodName: `prototype.${method}`,
|
|
53
|
-
context
|
|
53
|
+
get context() {
|
|
54
|
+
return `'${objInfo.value}'.${method}()`;
|
|
55
|
+
},
|
|
54
56
|
object: {
|
|
55
57
|
value: objInfo.value,
|
|
56
58
|
tracked: true
|
|
@@ -59,14 +61,12 @@ module.exports = function(core) {
|
|
|
59
61
|
value: result,
|
|
60
62
|
tracked: true
|
|
61
63
|
},
|
|
62
|
-
args: [],
|
|
63
64
|
tags: objInfo.tags,
|
|
64
65
|
history,
|
|
65
66
|
source: 'O',
|
|
66
67
|
target: 'R',
|
|
67
68
|
stacktraceOpts: {
|
|
68
69
|
constructorOpt: hooked,
|
|
69
|
-
prependFrames: [orig]
|
|
70
70
|
},
|
|
71
71
|
});
|
|
72
72
|
|
|
@@ -62,7 +62,7 @@ module.exports = function(core) {
|
|
|
62
62
|
patchType,
|
|
63
63
|
usePost: true,
|
|
64
64
|
post(data) {
|
|
65
|
-
const { args, obj, result, hooked
|
|
65
|
+
const { args, obj, result, hooked } = data;
|
|
66
66
|
if (!result || !getPropagatorContext()) return;
|
|
67
67
|
|
|
68
68
|
const objInfo = tracker.getData(obj);
|
|
@@ -79,7 +79,9 @@ module.exports = function(core) {
|
|
|
79
79
|
name,
|
|
80
80
|
moduleName: 'String',
|
|
81
81
|
methodName: 'prototype.anchor',
|
|
82
|
-
context
|
|
82
|
+
get context() {
|
|
83
|
+
return `${inspect(objInfo?.value) || String(obj)}.anchor(${argInfo ? argInfo.value : arg})`;
|
|
84
|
+
},
|
|
83
85
|
object: {
|
|
84
86
|
value: objInfo?.value || String(obj),
|
|
85
87
|
tracked: !!objInfo
|
|
@@ -97,7 +99,6 @@ module.exports = function(core) {
|
|
|
97
99
|
target: 'R',
|
|
98
100
|
stacktraceOpts: {
|
|
99
101
|
constructorOpt: hooked,
|
|
100
|
-
prependFrames: [orig]
|
|
101
102
|
},
|
|
102
103
|
});
|
|
103
104
|
|
|
@@ -119,7 +120,7 @@ module.exports = function(core) {
|
|
|
119
120
|
name,
|
|
120
121
|
patchType,
|
|
121
122
|
post(data) {
|
|
122
|
-
const { obj, result, hooked
|
|
123
|
+
const { obj, result, hooked } = data;
|
|
123
124
|
if (!result || !getPropagatorContext()) return;
|
|
124
125
|
|
|
125
126
|
const objInfo = tracker.getData(obj);
|
|
@@ -141,14 +142,12 @@ module.exports = function(core) {
|
|
|
141
142
|
value: result,
|
|
142
143
|
tracked: true
|
|
143
144
|
},
|
|
144
|
-
args: [],
|
|
145
145
|
tags: adjustTags(method, objInfo.tags),
|
|
146
146
|
history,
|
|
147
147
|
source: 'O',
|
|
148
148
|
target: 'R',
|
|
149
149
|
stacktraceOpts: {
|
|
150
150
|
constructorOpt: hooked,
|
|
151
|
-
prependFrames: [orig]
|
|
152
151
|
},
|
|
153
152
|
});
|
|
154
153
|
|
|
@@ -47,7 +47,7 @@ module.exports = function(core) {
|
|
|
47
47
|
patchType,
|
|
48
48
|
usePerf: 'sync',
|
|
49
49
|
pre(data) {
|
|
50
|
-
const { args: origArgs, hooked
|
|
50
|
+
const { args: origArgs, hooked } = data;
|
|
51
51
|
if (
|
|
52
52
|
!origArgs.length ||
|
|
53
53
|
typeof origArgs[0] !== 'string' ||
|
|
@@ -64,7 +64,9 @@ module.exports = function(core) {
|
|
|
64
64
|
name,
|
|
65
65
|
moduleName: 'String',
|
|
66
66
|
methodName: `prototype.${methodName}`,
|
|
67
|
-
context
|
|
67
|
+
get context() {
|
|
68
|
+
return `'${objInfo.value}'.${methodName}(${args[0].value})`;
|
|
69
|
+
},
|
|
68
70
|
history: [objInfo],
|
|
69
71
|
object: {
|
|
70
72
|
value: objInfo.value,
|
|
@@ -75,7 +77,6 @@ module.exports = function(core) {
|
|
|
75
77
|
result: undefined,
|
|
76
78
|
stacktraceOpts: {
|
|
77
79
|
constructorOpt: hooked,
|
|
78
|
-
prependFrames: [orig]
|
|
79
80
|
},
|
|
80
81
|
source: 'P',
|
|
81
82
|
target: 'P'
|
|
@@ -40,15 +40,17 @@ module.exports = function(core) {
|
|
|
40
40
|
}) {
|
|
41
41
|
const tags = createSubsetTags(objInfo.tags, startIdx, match.length);
|
|
42
42
|
|
|
43
|
-
if (!tags) return;
|
|
43
|
+
if (!tags) return null;
|
|
44
44
|
|
|
45
|
-
const { arg, hooked
|
|
45
|
+
const { arg, hooked } = metadata;
|
|
46
46
|
|
|
47
47
|
return createPropagationEvent({
|
|
48
48
|
name,
|
|
49
49
|
moduleName: 'String',
|
|
50
50
|
methodName: 'prototype.matchAll',
|
|
51
|
-
context
|
|
51
|
+
get context() {
|
|
52
|
+
return `'${objInfo.value}'.matchAll(${arg})`;
|
|
53
|
+
},
|
|
52
54
|
history: [objInfo],
|
|
53
55
|
object: {
|
|
54
56
|
value: objInfo.value,
|
|
@@ -62,7 +64,6 @@ module.exports = function(core) {
|
|
|
62
64
|
},
|
|
63
65
|
stacktraceOpts: {
|
|
64
66
|
constructorOpt: hooked,
|
|
65
|
-
prependFrames: [orig],
|
|
66
67
|
},
|
|
67
68
|
source: 'O',
|
|
68
69
|
target: 'R',
|
|
@@ -76,7 +77,7 @@ module.exports = function(core) {
|
|
|
76
77
|
patchType,
|
|
77
78
|
usePerf: 'sync',
|
|
78
79
|
around(origFn, data) {
|
|
79
|
-
const { args, obj, hooked
|
|
80
|
+
const { args, obj, hooked } = data;
|
|
80
81
|
|
|
81
82
|
if (
|
|
82
83
|
!obj ||
|
|
@@ -125,7 +126,7 @@ module.exports = function(core) {
|
|
|
125
126
|
resValue.indices && (untrackedResult.indices = resValue.indices);
|
|
126
127
|
|
|
127
128
|
let searchIdx = resValue.index;
|
|
128
|
-
const metadata = { arg: `${args[0]}`, hooked
|
|
129
|
+
const metadata = { arg: `${args[0]}`, hooked };
|
|
129
130
|
|
|
130
131
|
for (let i = 0; i < resValue.length; i++) {
|
|
131
132
|
let match = resValue[i];
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const { primordials: { ArrayPrototypeJoin } } = require('@contrast/common');
|
|
19
18
|
const { createSubsetTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
20
19
|
const { patchType } = require('../../common');
|
|
21
20
|
|
|
@@ -35,11 +34,11 @@ module.exports = function(core) {
|
|
|
35
34
|
|
|
36
35
|
const name = 'String.prototype.match';
|
|
37
36
|
|
|
38
|
-
function getPropagationEvent(data, res, objInfo, start) {
|
|
39
|
-
const { args: origArgs, result, hooked
|
|
37
|
+
function getPropagationEvent(data, res, objInfo, start, resultIdx) {
|
|
38
|
+
const { args: origArgs, result, hooked } = data;
|
|
40
39
|
const tags = createSubsetTags(objInfo.tags, start, res.length);
|
|
41
40
|
|
|
42
|
-
if (!tags) return;
|
|
41
|
+
if (!tags) return null;
|
|
43
42
|
|
|
44
43
|
const args = [
|
|
45
44
|
{
|
|
@@ -52,7 +51,9 @@ module.exports = function(core) {
|
|
|
52
51
|
name,
|
|
53
52
|
moduleName: 'String',
|
|
54
53
|
methodName: 'prototype.match',
|
|
55
|
-
context
|
|
54
|
+
get context() {
|
|
55
|
+
return `'${objInfo.value}'.match(${origArgs[0]})`;
|
|
56
|
+
},
|
|
56
57
|
history: [{ ...objInfo }],
|
|
57
58
|
object: {
|
|
58
59
|
value: objInfo.value,
|
|
@@ -61,12 +62,12 @@ module.exports = function(core) {
|
|
|
61
62
|
args,
|
|
62
63
|
tags,
|
|
63
64
|
result: {
|
|
64
|
-
|
|
65
|
+
// this is not tracked yet
|
|
66
|
+
value: result[resultIdx],
|
|
65
67
|
tracked: false,
|
|
66
68
|
},
|
|
67
69
|
stacktraceOpts: {
|
|
68
70
|
constructorOpt: hooked,
|
|
69
|
-
prependFrames: [orig],
|
|
70
71
|
},
|
|
71
72
|
source: 'O',
|
|
72
73
|
target: 'R',
|
|
@@ -125,12 +126,12 @@ module.exports = function(core) {
|
|
|
125
126
|
|
|
126
127
|
if (res === obj) {
|
|
127
128
|
res = objInfo.value;
|
|
128
|
-
event = getPropagationEvent(data, res, objInfo, 0);
|
|
129
|
+
event = getPropagationEvent(data, res, objInfo, 0, i);
|
|
129
130
|
} else {
|
|
130
131
|
const start = obj.indexOf(res, idx);
|
|
131
132
|
idx += hasCaptureGroups && i === 0 ? 0 : res.length;
|
|
132
133
|
|
|
133
|
-
event = getPropagationEvent(data, res, objInfo, start);
|
|
134
|
+
event = getPropagationEvent(data, res, objInfo, start, i);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
if (!event) continue;
|
|
@@ -237,7 +237,7 @@ module.exports = function(core) {
|
|
|
237
237
|
data.obj === result
|
|
238
238
|
) return result;
|
|
239
239
|
|
|
240
|
-
const { obj, args: origArgs, hooked
|
|
240
|
+
const { obj, args: origArgs, hooked } = data;
|
|
241
241
|
const args = [];
|
|
242
242
|
if (tracker.getData(origArgs[0])) {
|
|
243
243
|
args.push({ tracked: true, value: origArgs[0] });
|
|
@@ -254,7 +254,9 @@ module.exports = function(core) {
|
|
|
254
254
|
name,
|
|
255
255
|
moduleName: 'String',
|
|
256
256
|
methodName: 'prototype.replace',
|
|
257
|
-
context
|
|
257
|
+
get context() {
|
|
258
|
+
return `'${obj}'.replace(${ArrayPrototypeJoin.call(args.map(a => a.value))})`;
|
|
259
|
+
},
|
|
258
260
|
history: Array.from(data._history),
|
|
259
261
|
object: {
|
|
260
262
|
value: obj,
|
|
@@ -268,16 +270,13 @@ module.exports = function(core) {
|
|
|
268
270
|
tags: data._accumTags,
|
|
269
271
|
stacktraceOpts: {
|
|
270
272
|
constructorOpt: hooked,
|
|
271
|
-
prependFrames: [orig]
|
|
272
273
|
},
|
|
273
274
|
source: data._objInfo ? (data._history.size > 1 ? 'A' : 'O') : 'P',
|
|
274
275
|
target: 'R',
|
|
275
276
|
});
|
|
276
|
-
|
|
277
|
-
if (!event) return;
|
|
277
|
+
if (!event) return null;
|
|
278
278
|
|
|
279
279
|
const { extern } = tracker.track(result, event);
|
|
280
|
-
|
|
281
280
|
return extern;
|
|
282
281
|
}
|
|
283
282
|
});
|
|
@@ -55,7 +55,7 @@ module.exports = function(core) {
|
|
|
55
55
|
patchType,
|
|
56
56
|
usePerf: 'sync',
|
|
57
57
|
post(data) {
|
|
58
|
-
const { name, args: origArgs, obj, result, hooked
|
|
58
|
+
const { name, args: origArgs, obj, result, hooked } = data;
|
|
59
59
|
if (!result || !getPropagatorContext()) return;
|
|
60
60
|
|
|
61
61
|
const objInfo = tracker.getData(obj);
|
|
@@ -80,7 +80,9 @@ module.exports = function(core) {
|
|
|
80
80
|
name,
|
|
81
81
|
moduleName: 'String',
|
|
82
82
|
methodName: 'prototype.slice',
|
|
83
|
-
context
|
|
83
|
+
get context() {
|
|
84
|
+
return `'${objInfo.value}'.slice(${ArrayPrototypeJoin.call(args.map(a => a.value), ', ')})`;
|
|
85
|
+
},
|
|
84
86
|
history: [objInfo],
|
|
85
87
|
object: {
|
|
86
88
|
value: obj,
|
|
@@ -96,7 +98,6 @@ module.exports = function(core) {
|
|
|
96
98
|
target: 'R',
|
|
97
99
|
stacktraceOpts: {
|
|
98
100
|
constructorOpt: hooked,
|
|
99
|
-
prependFrames: [orig]
|
|
100
101
|
}
|
|
101
102
|
});
|
|
102
103
|
|