@contrast/agent 4.19.1 → 4.19.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.
|
@@ -20,6 +20,7 @@ const tracker = require('../../tracker');
|
|
|
20
20
|
const stackFactory = require('../../core/stacktrace').singleton;
|
|
21
21
|
const distringuish = require('@contrast/distringuish-prebuilt');
|
|
22
22
|
const { PROXY_TARGET } = require('../../../lib/constants');
|
|
23
|
+
const TagRange = require('../models/tag-range');
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Holds information about the call context of a function
|
|
@@ -102,6 +103,22 @@ module.exports = class CallContext {
|
|
|
102
103
|
return !!(str && typeof str === 'object' && str[PROXY_TARGET]);
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
static getDisplayRange(arg) {
|
|
107
|
+
if (tracker.getData(arg)) {
|
|
108
|
+
return new TagRange(0, arg.length - 1, 'untrusted');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (arg && typeof arg === 'object') {
|
|
112
|
+
for (let key in arg) {
|
|
113
|
+
if (tracker.getData(arg[key])) {
|
|
114
|
+
const start = CallContext.valueString(arg).indexOf(arg[key]);
|
|
115
|
+
return new TagRange(start, start + arg[key].length - 1, 'untrusted');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return {}
|
|
120
|
+
}
|
|
121
|
+
|
|
105
122
|
set result(result) {
|
|
106
123
|
this.__result = CallContext.valueString(result);
|
|
107
124
|
this.resultTracked = CallContext.isTracked(result);
|
|
@@ -113,6 +130,7 @@ module.exports = class CallContext {
|
|
|
113
130
|
set args(args) {
|
|
114
131
|
this.__args = args.map(CallContext.valueString);
|
|
115
132
|
this.argsTracked = args.map((arg) => CallContext.isTracked(arg));
|
|
133
|
+
this.argsDisplayRanges = args.map((arg) => CallContext.getDisplayRange(arg));
|
|
116
134
|
}
|
|
117
135
|
|
|
118
136
|
get args() {
|
|
@@ -25,6 +25,7 @@ const utils = require('./utils');
|
|
|
25
25
|
* Hooks a method to properly bind to AsyncStorage
|
|
26
26
|
* @param {Object} prototype to hook
|
|
27
27
|
* @param {String} method to hook
|
|
28
|
+
* @param {String} patchName of the patch
|
|
28
29
|
*/
|
|
29
30
|
function hookMethod(obj, method, patchName) {
|
|
30
31
|
patcher.patch(obj, method, {
|
|
@@ -72,23 +73,24 @@ function init() {
|
|
|
72
73
|
file: 'lib/topologies/server.js',
|
|
73
74
|
version: '>=3.3.0 <4.0.0'
|
|
74
75
|
},
|
|
75
|
-
(server) =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
(server) =>
|
|
77
|
+
patcher.patch(server, {
|
|
78
|
+
name: 'mongodb.Server',
|
|
79
|
+
patchType: ASYNC_CONTEXT,
|
|
80
|
+
alwaysRun: true,
|
|
81
|
+
post: (data) => {
|
|
82
|
+
const methods = ['command', 'insert', 'update', 'remove'];
|
|
83
|
+
for (const method of methods) {
|
|
84
|
+
hookMethod(data.result, method, 'mongodb.Server');
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
|
-
}
|
|
85
|
-
})
|
|
87
|
+
})
|
|
86
88
|
);
|
|
87
89
|
|
|
88
90
|
requireHook.resolve(
|
|
89
91
|
{ name: 'mongodb', file: 'lib/cursor.js', version: '>=3.3.0 <4.0.0' },
|
|
90
|
-
(cursor) =>
|
|
91
|
-
{
|
|
92
|
+
(cursor) =>
|
|
93
|
+
patcher.patch(cursor, {
|
|
92
94
|
name: 'mongodb.Cursor',
|
|
93
95
|
patchType: ASYNC_CONTEXT,
|
|
94
96
|
alwaysRun: true,
|
|
@@ -102,6 +102,12 @@ class Event {
|
|
|
102
102
|
this.args.push(
|
|
103
103
|
new ObjectDTM(event.context.args[i], event.context.argsTracked[i])
|
|
104
104
|
);
|
|
105
|
+
if (event.tagRanges[i]
|
|
106
|
+
&& event.context.argsDisplayRanges
|
|
107
|
+
&& Object.keys(event.context.argsDisplayRanges[i]).length
|
|
108
|
+
) {
|
|
109
|
+
event.tagRanges[i] = event.context.argsDisplayRanges[i];
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
if (event.code) {
|