@contrast/agent 4.23.1 → 4.24.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.
|
@@ -112,7 +112,17 @@ class BaseEvent {
|
|
|
112
112
|
this._expanded = true;
|
|
113
113
|
this.thread = process.pid;
|
|
114
114
|
if (this.source === 'P') {
|
|
115
|
-
|
|
115
|
+
const numArgs = this.context.hasArgsTracked.length;
|
|
116
|
+
if (numArgs === 1) {
|
|
117
|
+
this.source = 'P0'
|
|
118
|
+
} else {
|
|
119
|
+
this.source = '';
|
|
120
|
+
for (let i = 0; i < numArgs; i++) {
|
|
121
|
+
if (this.context.hasArgsTracked[i]) {
|
|
122
|
+
this.source += `P${i},`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
116
126
|
}
|
|
117
127
|
|
|
118
128
|
if (this.signature) {
|
|
@@ -103,6 +103,25 @@ module.exports = class CallContext {
|
|
|
103
103
|
return !!(str && typeof str === 'object' && str[PROXY_TARGET]);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
static hasTrackedArg(arg, iteration = 0) {
|
|
107
|
+
if (tracker.getData(arg)) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (arg && typeof arg === 'object') {
|
|
112
|
+
|
|
113
|
+
for (const key in arg) {
|
|
114
|
+
if (tracker.getData(arg[key])) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if (arg[key] && typeof arg[key] === 'object' && iteration < 100) {
|
|
118
|
+
return CallContext.hasTrackedArg(arg[key], iteration += 1);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
|
|
106
125
|
static getDisplayRange(arg, orgArg = arg, iteration = 0) {
|
|
107
126
|
if (tracker.getData(arg)) {
|
|
108
127
|
return new TagRange(0, arg.length - 1, 'untrusted');
|
|
@@ -144,6 +163,7 @@ module.exports = class CallContext {
|
|
|
144
163
|
set args(args) {
|
|
145
164
|
this.__args = args.map(CallContext.valueString);
|
|
146
165
|
this.argsTracked = args.map((arg) => CallContext.isTracked(arg));
|
|
166
|
+
this.hasArgsTracked = args.map((arg) => CallContext.hasTrackedArg(arg));
|
|
147
167
|
this.argsDisplayRanges = args.map((arg) => CallContext.getDisplayRange(arg));
|
|
148
168
|
}
|
|
149
169
|
|
|
@@ -102,12 +102,15 @@ class Event {
|
|
|
102
102
|
this.args.push(
|
|
103
103
|
new ObjectDTM(event.context.args[i], event.context.argsTracked[i])
|
|
104
104
|
);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
const displayRanges = event.context.argsDisplayRanges.filter((tagRange) => Object.keys(tagRange).length);;
|
|
109
|
+
|
|
110
|
+
if (displayRanges.length) {
|
|
111
|
+
// If displayRanges is non-empty (=/= [{}]), use that instead
|
|
112
|
+
// since it's more accurate when reporting
|
|
113
|
+
event.tagRanges = displayRanges;
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
if (event.code) {
|