@contrast/agent 4.25.6-beta.0 → 4.26.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.
|
@@ -21,6 +21,7 @@ const stackFactory = require('../../core/stacktrace').singleton;
|
|
|
21
21
|
const { PROXY_TARGET } = require('../../../lib/constants');
|
|
22
22
|
const TagRange = require('../models/tag-range');
|
|
23
23
|
const distringuish = require('@contrast/distringuish');
|
|
24
|
+
const agent = require('../../agent');
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Holds information about the call context of a function
|
|
@@ -153,13 +154,36 @@ function valueString(value) {
|
|
|
153
154
|
return type;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
const appendStack = agent.config.assess.enable_lazy_stacktraces ?
|
|
158
|
+
(instance, snapshot) => {
|
|
159
|
+
let stack;
|
|
160
|
+
// This enables the lazy generation of a stacktrace which is a performance
|
|
161
|
+
// improvement, but the snapshot method call is in a closure which creates
|
|
162
|
+
// a memory leak in longer running tests
|
|
163
|
+
Object.defineProperty(instance, 'stack', {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
configurable: true,
|
|
166
|
+
get() {
|
|
167
|
+
if (!stack) {
|
|
168
|
+
stack = snapshot();
|
|
169
|
+
}
|
|
170
|
+
return stack;
|
|
171
|
+
},
|
|
172
|
+
set(value) {
|
|
173
|
+
stack = value;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
} : (instance, snapshot) => {
|
|
177
|
+
instance.stack = snapshot();
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
function create (params) {
|
|
157
181
|
const instance = new CallContext(params);
|
|
158
182
|
const snapshot = params.stacktrace || stackFactory.createSnapshot({
|
|
159
183
|
constructorOpt: params.hooked
|
|
160
184
|
});
|
|
161
185
|
|
|
162
|
-
instance
|
|
186
|
+
appendStack(instance, snapshot);
|
|
163
187
|
|
|
164
188
|
return instance;
|
|
165
189
|
}
|
|
@@ -12,6 +12,8 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
12
12
|
engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
13
|
way not consistent with the End User License Agreement.
|
|
14
14
|
*/
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
15
17
|
const CallContext = require('./call-context');
|
|
16
18
|
const Signature = require('./signature');
|
|
17
19
|
const BaseEvent = require('./base-event');
|
|
@@ -761,6 +761,13 @@ const assess = [
|
|
|
761
761
|
fn: castBoolean,
|
|
762
762
|
desc: 'When set to `false` won\'t track the source events lazily but will track the first up to 250 source events',
|
|
763
763
|
},
|
|
764
|
+
{
|
|
765
|
+
name: 'assess.enable_lazy_stacktraces',
|
|
766
|
+
arg: '[false]',
|
|
767
|
+
default: false,
|
|
768
|
+
fn: castBoolean,
|
|
769
|
+
desc: 'When set to `true` it will evaluate stacktraces lazily, this improves performance, but causes a memory leak if used in a longer running application',
|
|
770
|
+
},
|
|
764
771
|
];
|
|
765
772
|
|
|
766
773
|
const protect = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/agent",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.26.0",
|
|
4
4
|
"description": "Node.js security instrumentation by Contrast Security",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"security",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"dustjs-linkedin": "^3.0.1",
|
|
139
139
|
"ejs": "^3.1.7",
|
|
140
140
|
"escape-html": "^1.0.3",
|
|
141
|
-
"eslint": "^8.
|
|
141
|
+
"eslint": "^8.26.0",
|
|
142
142
|
"eslint-plugin-mocha": "^10.0.3",
|
|
143
143
|
"eslint-plugin-node": "^11.1.0",
|
|
144
144
|
"express": "file:test/mock/express",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"lint-staged": "^12.0.2",
|
|
159
159
|
"madge": "^4.0.1",
|
|
160
160
|
"marsdb": "file:test/mock/marsdb",
|
|
161
|
-
"mocha": "^9.2.
|
|
161
|
+
"mocha": "^9.2.2",
|
|
162
162
|
"mochawesome": "^7.0.1",
|
|
163
163
|
"mock-fs": "^5.1.2",
|
|
164
164
|
"mongodb": "file:test/mock/mongodb",
|