@contrast/agent 5.4.1 → 5.4.3

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.
Files changed (2) hide show
  1. package/lib/start-agent.js +30 -25
  2. package/package.json +5 -5
@@ -16,6 +16,7 @@
16
16
  'use strict';
17
17
 
18
18
  const process = require('process');
19
+ const { isMainThread } = require('node:worker_threads');
19
20
  const semver = require('semver');
20
21
  const _agentify = require('@contrast/agentify');
21
22
  const {
@@ -116,31 +117,35 @@ function checkImportVsLoaderVsNodeVersion() {
116
117
  }
117
118
 
118
119
  async function startAgent({ type = 'cjs' } = {}) {
119
- const core = initCore();
120
- const agentify = _agentify(core);
121
-
122
- return agentify(loadFeatures, {
123
- installOrder: [
124
- 'reporter',
125
- 'startupValidation',
126
- 'contrastMethods',
127
- 'deadzones',
128
- 'scopes',
129
- 'sources',
130
- 'architectureComponents',
131
- 'assess',
132
- 'protect',
133
- 'depHooks',
134
- 'routeCoverage',
135
- 'libraryAnalysis',
136
- 'heapSnapshots',
137
- 'metrics',
138
- 'rewriteHooks',
139
- 'functionHooks',
140
- 'esmHooks',
141
- ],
142
- type
143
- });
120
+ if (isMainThread) {
121
+ const core = initCore();
122
+ const agentify = _agentify(core);
123
+
124
+ return agentify(loadFeatures, {
125
+ installOrder: [
126
+ 'reporter',
127
+ 'startupValidation',
128
+ 'contrastMethods',
129
+ 'deadzones',
130
+ 'scopes',
131
+ 'sources',
132
+ 'architectureComponents',
133
+ 'assess',
134
+ 'protect',
135
+ 'depHooks',
136
+ 'routeCoverage',
137
+ 'libraryAnalysis',
138
+ 'heapSnapshots',
139
+ 'metrics',
140
+ 'rewriteHooks',
141
+ 'functionHooks',
142
+ 'esmHooks',
143
+ ],
144
+ type
145
+ });
146
+ } else {
147
+ console.warn('Not in main thread. Thread continuing without instrumentation.');
148
+ }
144
149
  }
145
150
 
146
151
  module.exports = { startAgent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agent",
3
- "version": "5.4.1",
3
+ "version": "5.4.3",
4
4
  "description": "Assess and Protect agents for Node.js",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -21,13 +21,13 @@
21
21
  "test": "../scripts/test.sh"
22
22
  },
23
23
  "dependencies": {
24
- "@contrast/agentify": "1.22.1",
24
+ "@contrast/agentify": "1.22.2",
25
25
  "@contrast/architecture-components": "1.17.0",
26
- "@contrast/assess": "1.26.0",
26
+ "@contrast/assess": "1.26.1",
27
27
  "@contrast/library-analysis": "1.18.0",
28
- "@contrast/protect": "1.34.1",
28
+ "@contrast/protect": "1.34.2",
29
29
  "@contrast/route-coverage": "1.17.0",
30
- "@contrast/telemetry": "1.5.2",
30
+ "@contrast/telemetry": "1.5.3",
31
31
  "semver": "^7.3.7"
32
32
  }
33
33
  }