@contrast/assess 1.28.0 → 1.29.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/crypto.js +3 -3
- package/lib/dataflow/propagation/install/JSON/parse-fn.js +5 -5
- package/lib/dataflow/propagation/install/JSON/parse.js +3 -3
- package/lib/dataflow/propagation/install/JSON/stringify.js +24 -17
- package/lib/dataflow/propagation/install/array-prototype-join.js +3 -3
- package/lib/dataflow/propagation/install/buffer.js +60 -2
- package/lib/dataflow/propagation/install/contrast-methods/add.js +1 -3
- package/lib/dataflow/propagation/install/ejs/template.js +3 -3
- package/lib/dataflow/propagation/install/joi/boolean.js +1 -1
- package/lib/dataflow/propagation/install/joi/expression.js +1 -1
- package/lib/dataflow/propagation/install/joi/index.js +1 -1
- package/lib/dataflow/propagation/install/joi/keys.js +5 -4
- package/lib/dataflow/propagation/install/joi/number.js +1 -1
- package/lib/dataflow/propagation/install/joi/string-schema.js +3 -2
- package/lib/dataflow/propagation/install/joi/utils.js +9 -5
- package/lib/dataflow/propagation/install/joi/values.js +4 -3
- package/lib/dataflow/propagation/install/mongoose/schema-map.js +2 -2
- package/lib/dataflow/propagation/install/mongoose/schema-mixed.js +2 -2
- package/lib/dataflow/propagation/install/mongoose/schema-string.js +2 -2
- package/lib/dataflow/propagation/install/path/basename.js +2 -2
- package/lib/dataflow/propagation/install/path/common.js +5 -5
- package/lib/dataflow/propagation/install/path/format.js +7 -4
- package/lib/dataflow/propagation/install/path/join-and-resolve.js +2 -2
- package/lib/dataflow/propagation/install/path/parse.js +4 -5
- package/lib/dataflow/propagation/install/querystring/escape.js +1 -1
- package/lib/dataflow/propagation/install/querystring/parse.js +8 -8
- package/lib/dataflow/propagation/install/querystring/stringify.js +1 -1
- package/lib/dataflow/propagation/install/reg-exp-prototype-exec.js +2 -3
- package/lib/dataflow/propagation/install/send.js +2 -2
- package/lib/dataflow/propagation/install/string/concat.js +19 -19
- package/lib/dataflow/propagation/install/string/html-methods.js +1 -1
- package/lib/dataflow/propagation/install/string/index.js +4 -3
- package/lib/dataflow/propagation/install/string/match-all.js +3 -9
- package/lib/dataflow/propagation/install/string/match.js +6 -5
- package/lib/dataflow/propagation/install/string/replace.js +23 -17
- package/lib/dataflow/propagation/install/string/slice.js +5 -5
- package/lib/dataflow/propagation/install/string/split.js +13 -11
- package/lib/dataflow/propagation/install/string/substring.js +6 -5
- package/lib/dataflow/propagation/install/url/parse.js +1 -1
- package/lib/dataflow/propagation/install/url/searchParams.js +2 -1
- package/lib/dataflow/propagation/install/url/url.js +1 -1
- package/lib/dataflow/sinks/index.js +1 -0
- package/lib/dataflow/sinks/install/child-process.js +4 -4
- package/lib/dataflow/sinks/install/express/reflected-xss.js +7 -5
- package/lib/dataflow/sinks/install/express/unvalidated-redirect.js +1 -2
- package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +1 -3
- package/lib/dataflow/sinks/install/fs.js +3 -3
- package/lib/dataflow/sinks/install/function.js +3 -3
- package/lib/dataflow/sinks/install/hapi/unvalidated-redirect.js +1 -2
- package/lib/dataflow/sinks/install/http/request.js +6 -5
- package/lib/dataflow/sinks/install/koa/unvalidated-redirect.js +2 -2
- package/lib/dataflow/sinks/install/libxmljs.js +1 -1
- package/lib/dataflow/sinks/install/marsdb.js +1 -2
- package/lib/dataflow/sinks/install/mongodb.js +1 -1
- package/lib/dataflow/sinks/install/mysql.js +1 -1
- package/lib/dataflow/sinks/install/postgres.js +1 -3
- package/lib/dataflow/sinks/install/restify.js +208 -0
- package/lib/dataflow/sinks/install/sequelize.js +1 -2
- package/lib/dataflow/sinks/install/vm.js +5 -5
- package/lib/dataflow/sources/handler.js +2 -2
- package/lib/dataflow/sources/index.js +1 -0
- package/lib/dataflow/sources/install/http.js +4 -4
- package/lib/dataflow/sources/install/restify/fieldedTextBodyParser.js +85 -0
- package/lib/dataflow/sources/install/restify/index.js +32 -0
- package/lib/dataflow/sources/install/restify/jsonBodyParser.js +109 -0
- package/lib/dataflow/sources/install/restify/router.js +77 -0
- package/lib/dataflow/tag-utils.js +20 -4
- package/lib/dataflow/tracker.js +1 -0
- package/lib/event-factory.js +3 -3
- package/lib/get-policy.js +2 -2
- package/lib/index.d.ts +18 -0
- package/lib/index.js +13 -0
- package/lib/make-source-context.js +2 -2
- package/lib/response-scanning/handlers/index.js +10 -10
- package/lib/response-scanning/handlers/utils.js +19 -12
- package/lib/response-scanning/install/http.js +9 -59
- package/lib/session-configuration/install/express-session.js +3 -5
- package/lib/session-configuration/install/fastify-cookie.js +3 -3
- package/lib/session-configuration/install/hapi.js +1 -3
- package/lib/session-configuration/install/koa.js +1 -1
- package/package.json +4 -4
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const { StringPrototypeMatchAll, StringPrototypeSubstring, StringPrototypeReplace } = require('@contrast/common');
|
|
19
19
|
const {
|
|
20
20
|
createSubsetTags,
|
|
21
21
|
createAppendTags,
|
|
@@ -35,7 +35,7 @@ function createBasenameTagsInResult({
|
|
|
35
35
|
isWin32,
|
|
36
36
|
}) {
|
|
37
37
|
const segments = Array.from(
|
|
38
|
-
|
|
38
|
+
StringPrototypeMatchAll.call(argStr, isWin32 ? win32RegExp : posixRegExp)
|
|
39
39
|
);
|
|
40
40
|
const basename = segments[segments.length - 1][1];
|
|
41
41
|
const isExtensionRemoved = suffixStr && basename.includes(suffixStr);
|
|
@@ -77,7 +77,7 @@ function createArgTagsInResult({
|
|
|
77
77
|
// the separators eventually including
|
|
78
78
|
// only 1 path separator at the start
|
|
79
79
|
const matchedSegments = Array.from(
|
|
80
|
-
|
|
80
|
+
StringPrototypeMatchAll.call(argStr, isWin32 ? win32RegExp : posixRegExp)
|
|
81
81
|
).reverse();
|
|
82
82
|
|
|
83
83
|
for (let i = 0; i < matchedSegments.length; i++) {
|
|
@@ -107,13 +107,13 @@ function createArgTagsInResult({
|
|
|
107
107
|
i === matchedSegments.length - 1 ? 0 : matchedSegments[i + 1][0].length;
|
|
108
108
|
const segmentStartIdx = startIdx + match.length - segment.length;
|
|
109
109
|
const separators =
|
|
110
|
-
|
|
110
|
+
StringPrototypeSubstring.call(
|
|
111
111
|
argStr,
|
|
112
112
|
previousSegmentIdx + previousSegmentLength,
|
|
113
113
|
segmentStartIdx
|
|
114
114
|
) || '';
|
|
115
115
|
const separatorsInResult = isWin32
|
|
116
|
-
?
|
|
116
|
+
? StringPrototypeReplace.call(separators, /\//g, (_match, idx) => {
|
|
117
117
|
replacedSeparatorsIdxs.push(startIdx - idx);
|
|
118
118
|
|
|
119
119
|
return '\\';
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
|
+
const { ArrayPrototypeJoin, isString } = require('@contrast/common');
|
|
17
18
|
const { patchType } = require('../../common');
|
|
18
|
-
const {
|
|
19
|
-
const { createMergedTags } = require('../../../tag-utils');
|
|
19
|
+
const { createMergedTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
20
20
|
const {
|
|
21
21
|
createArgTagsInResult,
|
|
22
22
|
excludeExtensionDotFromTags
|
|
@@ -65,7 +65,10 @@ module.exports = function(core) {
|
|
|
65
65
|
let newTags = {};
|
|
66
66
|
const propInfo = isString(prop) && tracker.getData(prop);
|
|
67
67
|
if (!propInfo) {
|
|
68
|
-
eventArgs.unshift({
|
|
68
|
+
eventArgs.unshift({
|
|
69
|
+
value: getAdjustedUntrackedValue(prop),
|
|
70
|
+
tracked: false
|
|
71
|
+
});
|
|
69
72
|
continue;
|
|
70
73
|
}
|
|
71
74
|
|
|
@@ -95,7 +98,7 @@ module.exports = function(core) {
|
|
|
95
98
|
name: patchName,
|
|
96
99
|
moduleName: 'path',
|
|
97
100
|
methodName: 'format',
|
|
98
|
-
context: `path.format(
|
|
101
|
+
context: `path.format(${ArrayPrototypeJoin.call(eventArgs.map((a) => a.value))})`,
|
|
99
102
|
history,
|
|
100
103
|
object: {
|
|
101
104
|
value: 'path',
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
|
-
const { isString,
|
|
17
|
+
const { isString, ArrayPrototypeJoin } = require('@contrast/common');
|
|
18
18
|
const { createMergedTags } = require('../../../tag-utils');
|
|
19
19
|
const { patchType } = require('../../common');
|
|
20
20
|
const {
|
|
@@ -97,7 +97,7 @@ module.exports = function(core) {
|
|
|
97
97
|
name,
|
|
98
98
|
moduleName: 'path',
|
|
99
99
|
methodName: method,
|
|
100
|
-
context: `path.${method}(${
|
|
100
|
+
context: `path.${method}(${ArrayPrototypeJoin.call(args
|
|
101
101
|
.map((a) => `'${a.value}'`), ',')})`,
|
|
102
102
|
history,
|
|
103
103
|
object: {
|
|
@@ -14,12 +14,10 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
|
-
const {
|
|
18
|
-
const { isString, inspect } = require('@contrast/common');
|
|
17
|
+
const { isString } = require('@contrast/common');
|
|
19
18
|
const { createSubsetTags } = require('../../../tag-utils');
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
} = require('./common');
|
|
19
|
+
const { patchType } = require('../../common');
|
|
20
|
+
const { excludeExtensionDotFromTags } = require('./common');
|
|
23
21
|
|
|
24
22
|
module.exports = function(core) {
|
|
25
23
|
const {
|
|
@@ -27,6 +25,7 @@ module.exports = function(core) {
|
|
|
27
25
|
patcher,
|
|
28
26
|
scopes: { sources, instrumentation },
|
|
29
27
|
assess: {
|
|
28
|
+
inspect, // todo: remove
|
|
30
29
|
eventFactory: { createPropagationEvent },
|
|
31
30
|
dataflow: { tracker },
|
|
32
31
|
},
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
*/
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const { inspect } = require('util');
|
|
18
17
|
const { DataflowTag: { URL_ENCODED } } = require('@contrast/common');
|
|
19
18
|
const { createFullLengthCopyTags } = require('../../../tag-utils');
|
|
20
19
|
const { patchType } = require('../../common');
|
|
@@ -22,6 +21,7 @@ const { patchType } = require('../../common');
|
|
|
22
21
|
module.exports = function(core) {
|
|
23
22
|
const {
|
|
24
23
|
assess: {
|
|
24
|
+
inspect, // todo: remove
|
|
25
25
|
eventFactory: { createPropagationEvent },
|
|
26
26
|
dataflow: { tracker }
|
|
27
27
|
},
|
|
@@ -18,12 +18,10 @@
|
|
|
18
18
|
const querystring = require('querystring');
|
|
19
19
|
const {
|
|
20
20
|
DataflowTag: { URL_ENCODED },
|
|
21
|
-
|
|
22
|
-
join
|
|
21
|
+
ArrayPrototypeJoin,
|
|
23
22
|
} = require('@contrast/common');
|
|
24
|
-
|
|
23
|
+
const { createSubsetTags, createAppendTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
25
24
|
const { patchType } = require('../../common');
|
|
26
|
-
const { createSubsetTags, createAppendTags } = require('../../../tag-utils');
|
|
27
25
|
|
|
28
26
|
module.exports = function(core) {
|
|
29
27
|
const {
|
|
@@ -48,10 +46,12 @@ module.exports = function(core) {
|
|
|
48
46
|
if (!tagRanges) return result;
|
|
49
47
|
|
|
50
48
|
const resultInfo = tracker.getData(result);
|
|
51
|
-
const [, ...
|
|
49
|
+
const [, ...restArgs] = data.origArgs.map(getAdjustedUntrackedValue);
|
|
50
|
+
const args = [trackingData.value, ...restArgs];
|
|
51
|
+
|
|
52
52
|
const event = createPropagationEvent({
|
|
53
53
|
name: data.name,
|
|
54
|
-
context: `querystring.parse('${
|
|
54
|
+
context: `querystring.parse('${ArrayPrototypeJoin.call(args)})`,
|
|
55
55
|
moduleName: 'querystring',
|
|
56
56
|
methodName: 'parse',
|
|
57
57
|
history: [trackingData],
|
|
@@ -60,7 +60,7 @@ module.exports = function(core) {
|
|
|
60
60
|
tracked: true,
|
|
61
61
|
},
|
|
62
62
|
args: data.origArgs.map((_arg, idx) => ({
|
|
63
|
-
value: idx === 0 ? trackingData.value :
|
|
63
|
+
value: idx === 0 ? trackingData.value : restArgs[idx - 1],
|
|
64
64
|
tracked: !!idx === 0
|
|
65
65
|
})).filter(el => el),
|
|
66
66
|
result: {
|
|
@@ -116,7 +116,7 @@ module.exports = function(core) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
data.idx = 0;
|
|
119
|
-
data.origArgs = data.args;
|
|
119
|
+
data.origArgs = [...data.args];
|
|
120
120
|
data.trackingData = trackingData;
|
|
121
121
|
|
|
122
122
|
data.args[3] = {
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
17
|
const querystring = require('querystring');
|
|
18
|
-
const { inspect } = require('util');
|
|
19
18
|
const { isString } = require('@contrast/common');
|
|
20
19
|
const utils = require('../../../tag-utils');
|
|
21
20
|
const { patchType } = require('../../common');
|
|
@@ -25,6 +24,7 @@ const moduleName = 'querystring';
|
|
|
25
24
|
module.exports = function(core) {
|
|
26
25
|
const {
|
|
27
26
|
assess: {
|
|
27
|
+
inspect, // todo: remove
|
|
28
28
|
dataflow: { tracker },
|
|
29
29
|
eventFactory: { createPropagationEvent },
|
|
30
30
|
},
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
|
-
const {
|
|
18
|
-
const { createSubsetTags } = require('../../tag-utils');
|
|
17
|
+
const { createSubsetTags, getAdjustedUntrackedValue } = require('../../tag-utils');
|
|
19
18
|
const { patchType } = require('../common');
|
|
20
19
|
|
|
21
20
|
module.exports = function(core) {
|
|
@@ -58,7 +57,7 @@ module.exports = function(core) {
|
|
|
58
57
|
],
|
|
59
58
|
tags,
|
|
60
59
|
result: {
|
|
61
|
-
value:
|
|
60
|
+
value: getAdjustedUntrackedValue(untrackedResult),
|
|
62
61
|
tracked: false,
|
|
63
62
|
},
|
|
64
63
|
stacktraceOpts: {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
17
|
const { patchType } = require('../common');
|
|
18
|
-
const {
|
|
18
|
+
const { StringPrototypeSlice } = require('@contrast/common');
|
|
19
19
|
|
|
20
20
|
module.exports = function (core) {
|
|
21
21
|
const {
|
|
@@ -42,7 +42,7 @@ module.exports = function (core) {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const untrackedPath =
|
|
45
|
+
const untrackedPath = StringPrototypeSlice.call(` ${args[0]}`, 1);
|
|
46
46
|
args[0] = untrackedPath;
|
|
47
47
|
},
|
|
48
48
|
});
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const { ArrayPrototypeJoin } = require('@contrast/common');
|
|
19
19
|
const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
|
|
20
|
-
const { createAppendTags } = require('../../../tag-utils');
|
|
20
|
+
const { createAppendTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
21
21
|
const { patchType } = require('../../common');
|
|
22
22
|
|
|
23
23
|
module.exports = function(core) {
|
|
@@ -38,7 +38,7 @@ module.exports = function(core) {
|
|
|
38
38
|
name,
|
|
39
39
|
patchType,
|
|
40
40
|
post(data) {
|
|
41
|
-
const {
|
|
41
|
+
const { obj, result, hooked, orig } = data;
|
|
42
42
|
if (!result || !getSourceContext(PROPAGATOR)) return;
|
|
43
43
|
|
|
44
44
|
const rInfo = tracker.getData(result);
|
|
@@ -47,45 +47,45 @@ module.exports = function(core) {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const argsData = [];
|
|
51
50
|
const objInfo = tracker.getData(obj);
|
|
52
51
|
const history = objInfo ? new Set([objInfo]) : new Set();
|
|
53
|
-
const newTags = { ...objInfo?.tags };
|
|
54
52
|
let globalOffset = typeof obj !== 'function' ? obj.length : 0;
|
|
53
|
+
const args = [];
|
|
54
|
+
let tags = objInfo?.tags;
|
|
55
55
|
|
|
56
|
-
for (const
|
|
57
|
-
const strInfo = tracker.getData(
|
|
56
|
+
for (const arg of data.args) {
|
|
57
|
+
const strInfo = tracker.getData(arg);
|
|
58
58
|
|
|
59
59
|
if (strInfo) {
|
|
60
|
-
|
|
60
|
+
args.push({ tracked: true, value: arg });
|
|
61
61
|
history.add(strInfo);
|
|
62
|
-
|
|
62
|
+
tags = createAppendTags(tags, strInfo.tags, globalOffset);
|
|
63
|
+
} else {
|
|
64
|
+
args.push({ tracked: false, value: getAdjustedUntrackedValue(arg) });
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
value: strInfo?.value ?? str,
|
|
67
|
-
tracked: !!strInfo
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
globalOffset += `${str}`.length;
|
|
67
|
+
globalOffset += `${arg}`.length;
|
|
71
68
|
}
|
|
72
69
|
|
|
70
|
+
|
|
73
71
|
if (history.size) {
|
|
72
|
+
const objVal = objInfo ? `'${objInfo.value}'` : getAdjustedUntrackedValue(obj);
|
|
73
|
+
const context = `${objVal}.concat(${ArrayPrototypeJoin.call(args.map((a) => a.value))})`;
|
|
74
74
|
const event = createPropagationEvent({
|
|
75
75
|
name,
|
|
76
76
|
moduleName: 'String',
|
|
77
77
|
methodName: 'prototype.concat',
|
|
78
|
-
context
|
|
78
|
+
context,
|
|
79
79
|
object: {
|
|
80
|
-
value: objInfo?.value
|
|
80
|
+
value: objInfo?.value ?? getAdjustedUntrackedValue(obj),
|
|
81
81
|
tracked: !!objInfo
|
|
82
82
|
},
|
|
83
83
|
result: {
|
|
84
84
|
value: result,
|
|
85
85
|
tracked: true
|
|
86
86
|
},
|
|
87
|
-
args
|
|
88
|
-
tags
|
|
87
|
+
args,
|
|
88
|
+
tags,
|
|
89
89
|
history: Array.from(history),
|
|
90
90
|
source: objInfo ? (history.size > 1 ? 'A' : 'O') : 'P',
|
|
91
91
|
target: 'R',
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const { inspect } = require('@contrast/common');
|
|
19
18
|
const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
|
|
20
19
|
const { createAppendTags } = require('../../../tag-utils');
|
|
21
20
|
const { patchType } = require('../../common');
|
|
@@ -34,6 +33,7 @@ module.exports = function(core) {
|
|
|
34
33
|
const {
|
|
35
34
|
patcher,
|
|
36
35
|
assess: {
|
|
36
|
+
inspect, // todo: remove
|
|
37
37
|
getSourceContext,
|
|
38
38
|
eventFactory: { createPropagationEvent },
|
|
39
39
|
dataflow: { tracker }
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const { callChildComponentMethodsSync } = require('@contrast/common');
|
|
19
|
-
const {
|
|
19
|
+
const { StringPrototypeSplit } = require('@contrast/common');
|
|
20
|
+
const { getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
20
21
|
|
|
21
22
|
module.exports = function(core) {
|
|
22
23
|
const {
|
|
@@ -40,7 +41,7 @@ module.exports = function(core) {
|
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
function patchCustomMatcher(matcherFn, objInfo, methodArg, name, patchType) {
|
|
43
|
-
const [, , methodName] =
|
|
44
|
+
const [, , methodName] = StringPrototypeSplit.call(name, '.');
|
|
44
45
|
|
|
45
46
|
return patcher.patch(matcherFn, {
|
|
46
47
|
name,
|
|
@@ -55,7 +56,7 @@ module.exports = function(core) {
|
|
|
55
56
|
) return;
|
|
56
57
|
|
|
57
58
|
const args = [{
|
|
58
|
-
value:
|
|
59
|
+
value: getAdjustedUntrackedValue(methodArg),
|
|
59
60
|
tracked: false
|
|
60
61
|
}];
|
|
61
62
|
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
|
-
const { inspect } = require('@contrast/common');
|
|
18
17
|
const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
|
|
19
18
|
const { createSubsetTags } = require('../../../tag-utils');
|
|
20
19
|
const { patchType } = require('../../common');
|
|
@@ -56,15 +55,10 @@ module.exports = function(core) {
|
|
|
56
55
|
value: objInfo.value,
|
|
57
56
|
tracked: true,
|
|
58
57
|
},
|
|
59
|
-
args: [
|
|
60
|
-
{
|
|
61
|
-
value: arg,
|
|
62
|
-
tracked: false,
|
|
63
|
-
},
|
|
64
|
-
],
|
|
58
|
+
args: [{ tracked: false, value: arg }],
|
|
65
59
|
tags,
|
|
66
60
|
result: {
|
|
67
|
-
value:
|
|
61
|
+
value: '[RegExp String Iterator] {}',
|
|
68
62
|
tracked: false,
|
|
69
63
|
},
|
|
70
64
|
stacktraceOpts: {
|
|
@@ -131,7 +125,7 @@ module.exports = function(core) {
|
|
|
131
125
|
resValue.indices && (untrackedResult.indices = resValue.indices);
|
|
132
126
|
|
|
133
127
|
let searchIdx = resValue.index;
|
|
134
|
-
const metadata = { arg:
|
|
128
|
+
const metadata = { arg: `${args[0]}`, hooked, orig };
|
|
135
129
|
|
|
136
130
|
for (let i = 0; i < resValue.length; i++) {
|
|
137
131
|
let match = resValue[i];
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
|
-
const {
|
|
17
|
+
const { ArrayPrototypeJoin } = require('@contrast/common');
|
|
18
18
|
const { patchType } = require('../../common');
|
|
19
|
-
const { createSubsetTags } = require('../../../tag-utils');
|
|
19
|
+
const { createSubsetTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
20
20
|
|
|
21
21
|
module.exports = function(core) {
|
|
22
22
|
const {
|
|
@@ -36,13 +36,14 @@ module.exports = function(core) {
|
|
|
36
36
|
function getPropagationEvent(data, res, objInfo, start) {
|
|
37
37
|
const { args: origArgs, result, hooked, orig } = data;
|
|
38
38
|
const tags = createSubsetTags(objInfo.tags, start, res.length);
|
|
39
|
+
|
|
39
40
|
if (!tags) return;
|
|
40
41
|
|
|
41
42
|
const args = [
|
|
42
43
|
{
|
|
43
|
-
value:
|
|
44
|
+
value: getAdjustedUntrackedValue(origArgs[0]),
|
|
44
45
|
tracked: false,
|
|
45
|
-
}
|
|
46
|
+
}
|
|
46
47
|
];
|
|
47
48
|
|
|
48
49
|
return createPropagationEvent({
|
|
@@ -58,7 +59,7 @@ module.exports = function(core) {
|
|
|
58
59
|
args,
|
|
59
60
|
tags,
|
|
60
61
|
result: {
|
|
61
|
-
value:
|
|
62
|
+
value: ArrayPrototypeJoin.call(result),
|
|
62
63
|
tracked: false,
|
|
63
64
|
},
|
|
64
65
|
stacktraceOpts: {
|
|
@@ -17,13 +17,16 @@
|
|
|
17
17
|
|
|
18
18
|
const {
|
|
19
19
|
DataflowTag: { UNTRUSTED },
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
substring
|
|
20
|
+
StringPrototypeMatch,
|
|
21
|
+
ArrayPrototypeJoin,
|
|
22
|
+
StringPrototypeSubstring,
|
|
24
23
|
} = require('@contrast/common');
|
|
25
24
|
const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
|
|
26
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
createSubsetTags,
|
|
27
|
+
createAppendTags,
|
|
28
|
+
getAdjustedUntrackedValue
|
|
29
|
+
} = require('../../../tag-utils');
|
|
27
30
|
const { patchType } = require('../../common');
|
|
28
31
|
|
|
29
32
|
module.exports = function(core) {
|
|
@@ -70,7 +73,7 @@ module.exports = function(core) {
|
|
|
70
73
|
replace: str.substring(str.indexOf(match) + match.length, str.length)
|
|
71
74
|
}
|
|
72
75
|
].forEach(({ regex, replace }) => {
|
|
73
|
-
if (ret &&
|
|
76
|
+
if (ret && StringPrototypeMatch.call(ret, regex)) {
|
|
74
77
|
// If the match string is tracked, we can actually use the patched replace
|
|
75
78
|
// to keep track of its tag ranges
|
|
76
79
|
if (tracker.getData(replace)) {
|
|
@@ -84,7 +87,7 @@ module.exports = function(core) {
|
|
|
84
87
|
const numberedGroupMatches = replacementType !== 'function' && replacement.match(/\$[1-9][0-9]|\$[1-9]/g);
|
|
85
88
|
if (numberedGroupMatches) {
|
|
86
89
|
numberedGroupMatches.forEach((numberedGroup) => {
|
|
87
|
-
const group = Number(
|
|
90
|
+
const group = Number(StringPrototypeSubstring.call(numberedGroup, 1));
|
|
88
91
|
ret = origReplace.call(ret, numberedGroup, captureGroups[group - 1] || '');
|
|
89
92
|
});
|
|
90
93
|
}
|
|
@@ -167,21 +170,24 @@ module.exports = function(core) {
|
|
|
167
170
|
return;
|
|
168
171
|
}
|
|
169
172
|
|
|
170
|
-
const {
|
|
171
|
-
const args = [
|
|
172
|
-
|
|
173
|
-
tracked:
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
const { obj, args: origArgs, result, hooked, orig } = data;
|
|
174
|
+
const args = [];
|
|
175
|
+
if (tracker.getData(origArgs[0])) {
|
|
176
|
+
args.push({ tracked: true, value: origArgs[0] });
|
|
177
|
+
} else {
|
|
178
|
+
args.push({ tracked: false, value: getAdjustedUntrackedValue(origArgs[0]) });
|
|
179
|
+
}
|
|
180
|
+
if (data._replacement) {
|
|
181
|
+
args.push({ tracked: true, value: data._replacement });
|
|
182
|
+
} else {
|
|
183
|
+
args.push({ tracked: false, value: getAdjustedUntrackedValue(data._replacement) });
|
|
184
|
+
}
|
|
179
185
|
|
|
180
186
|
const event = createPropagationEvent({
|
|
181
187
|
name,
|
|
182
188
|
moduleName: 'String',
|
|
183
189
|
methodName: 'prototype.replace',
|
|
184
|
-
context: `'${obj}'.replace(${
|
|
190
|
+
context: `'${obj}'.replace(${ArrayPrototypeJoin.call(args.map(a => a.value))})`,
|
|
185
191
|
history: Array.from(data._history),
|
|
186
192
|
object: {
|
|
187
193
|
value: obj,
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* way not consistent with the End User License Agreement.
|
|
14
14
|
*/
|
|
15
15
|
'use strict';
|
|
16
|
-
const {
|
|
16
|
+
const { ArrayPrototypeJoin } = require('@contrast/common');
|
|
17
17
|
const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
|
|
18
|
-
const { createSubsetTags } = require('../../../tag-utils');
|
|
18
|
+
const { createSubsetTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
19
19
|
const { patchType } = require('../../common');
|
|
20
20
|
|
|
21
21
|
module.exports = function(core) {
|
|
@@ -72,15 +72,15 @@ module.exports = function(core) {
|
|
|
72
72
|
if (!tags) return;
|
|
73
73
|
|
|
74
74
|
const args = origArgs.map((arg) => ({
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
tracked: false,
|
|
76
|
+
value: getAdjustedUntrackedValue(arg)
|
|
77
77
|
}));
|
|
78
78
|
|
|
79
79
|
const event = createPropagationEvent({
|
|
80
80
|
name,
|
|
81
81
|
moduleName: 'String',
|
|
82
82
|
methodName: 'prototype.slice',
|
|
83
|
-
context: `'${objInfo.value}'.slice(${
|
|
83
|
+
context: `'${objInfo.value}'.slice(${ArrayPrototypeJoin.call(args.map(a => a.value), ', ')})`,
|
|
84
84
|
history: [objInfo],
|
|
85
85
|
object: {
|
|
86
86
|
value: obj,
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const { ArrayPrototypeJoin } = require('@contrast/common');
|
|
19
19
|
const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
|
|
20
|
-
const { createSubsetTags } = require('../../../tag-utils');
|
|
20
|
+
const { createSubsetTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
21
21
|
const { patchType } = require('../../common');
|
|
22
22
|
|
|
23
23
|
module.exports = function(core) {
|
|
@@ -54,17 +54,16 @@ module.exports = function(core) {
|
|
|
54
54
|
|
|
55
55
|
const args = origArgs.map((arg) => {
|
|
56
56
|
const argInfo = tracker.getData(arg);
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
57
|
+
return argInfo ?
|
|
58
|
+
{ tracked: true, value: argInfo.value } :
|
|
59
|
+
{ tracked: false, value: `'${arg}'` };
|
|
61
60
|
});
|
|
62
61
|
|
|
63
62
|
const event = eventFactory.createPropagationEvent({
|
|
64
63
|
name,
|
|
65
64
|
moduleName: 'String',
|
|
66
65
|
methodName: 'prototype.split',
|
|
67
|
-
context: `'${objInfo.value}'.split(${
|
|
66
|
+
context: `'${objInfo.value}'.split(${ArrayPrototypeJoin.call(args.map(a => a.value))})`,
|
|
68
67
|
history: [objInfo],
|
|
69
68
|
object: {
|
|
70
69
|
value: obj,
|
|
@@ -73,7 +72,7 @@ module.exports = function(core) {
|
|
|
73
72
|
args,
|
|
74
73
|
tags: {},
|
|
75
74
|
result: {
|
|
76
|
-
value:
|
|
75
|
+
value: getAdjustedUntrackedValue(result),
|
|
77
76
|
tracked: false
|
|
78
77
|
},
|
|
79
78
|
stacktraceOpts: {
|
|
@@ -95,9 +94,13 @@ module.exports = function(core) {
|
|
|
95
94
|
const objSubstrInfo = tracker.getData(objSubstr);
|
|
96
95
|
if (objSubstrInfo) {
|
|
97
96
|
const tags = createSubsetTags(objInfo.tags, start, res.length);
|
|
98
|
-
if (!tags) continue;
|
|
99
97
|
|
|
100
|
-
|
|
98
|
+
if (!tags) continue;
|
|
99
|
+
const metadata = {
|
|
100
|
+
...event,
|
|
101
|
+
result: { tracked: true, value: res },
|
|
102
|
+
tags,
|
|
103
|
+
};
|
|
101
104
|
eventFactory.createdEvents.add(metadata);
|
|
102
105
|
const { extern } = tracker.track(res, metadata);
|
|
103
106
|
|
|
@@ -114,4 +117,3 @@ module.exports = function(core) {
|
|
|
114
117
|
},
|
|
115
118
|
};
|
|
116
119
|
};
|
|
117
|
-
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const { ArrayPrototypeJoin } = require('@contrast/common');
|
|
19
19
|
const { InstrumentationType: { PROPAGATOR } } = require('../../../../constants');
|
|
20
|
-
const { createSubsetTags } = require('../../../tag-utils');
|
|
20
|
+
const { createSubsetTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
|
|
21
21
|
const { patchType } = require('../../common');
|
|
22
22
|
|
|
23
23
|
module.exports = function(core) {
|
|
@@ -82,14 +82,15 @@ module.exports = function(core) {
|
|
|
82
82
|
if (!tags) return;
|
|
83
83
|
|
|
84
84
|
const args = origArgs.map((arg) => ({
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
tracked: false,
|
|
86
|
+
value: getAdjustedUntrackedValue(arg)
|
|
87
87
|
}));
|
|
88
|
+
|
|
88
89
|
const event = createPropagationEvent({
|
|
89
90
|
name,
|
|
90
91
|
moduleName: 'String',
|
|
91
92
|
methodName: 'prototype.substring',
|
|
92
|
-
context: `'${objInfo.value}'.substring(${
|
|
93
|
+
context: `'${objInfo.value}'.substring(${ArrayPrototypeJoin.call(args.map(a => a.value))})`,
|
|
93
94
|
history: [objInfo],
|
|
94
95
|
object: {
|
|
95
96
|
value: obj,
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const { patchType } = require('../../common');
|
|
19
|
-
const { inspect } = require('@contrast/common');
|
|
20
19
|
|
|
21
20
|
module.exports = function(core) {
|
|
22
21
|
const {
|
|
@@ -24,6 +23,7 @@ module.exports = function(core) {
|
|
|
24
23
|
patcher,
|
|
25
24
|
depHooks,
|
|
26
25
|
assess: {
|
|
26
|
+
inspect, // todo: remove
|
|
27
27
|
eventFactory: { createPropagationEvent },
|
|
28
28
|
dataflow: { tracker }
|
|
29
29
|
}
|