@contrast/agent 5.29.0 → 5.31.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.
Files changed (2) hide show
  1. package/lib/start-agent.js +15 -8
  2. package/package.json +11 -8
@@ -17,6 +17,8 @@
17
17
 
18
18
  const process = require('process');
19
19
  const { isMainThread, threadId } = require('worker_threads');
20
+ const { safeConsoleError, safeConsoleWarn } = require('@contrast/common');
21
+ const { Core } = require('@contrast/core/lib/ioc/core');
20
22
  const _agentify = require('@contrast/agentify');
21
23
 
22
24
  const {
@@ -29,7 +31,7 @@ const {
29
31
  } = require('../package.json');
30
32
 
31
33
  function initCore() {
32
- const core = {
34
+ const core = new Core({
33
35
  agentName,
34
36
  agentVersion,
35
37
  nodeEngines,
@@ -41,13 +43,14 @@ function initCore() {
41
43
  install() {
42
44
  if (
43
45
  !core.config.getEffectiveValue('assess.enable') &&
44
- !core.config.getEffectiveValue('protect.enable')
46
+ !core.config.getEffectiveValue('protect.enable') &&
47
+ !core.config.getEffectiveValue('observe.enable')
45
48
  ) {
46
- throw new Error('Neither Assess nor Protect are enabled. Check local configuration and UI settings');
49
+ throw new Error('Neither Assess nor Protect nor Observability are enabled. Check local configuration and UI settings');
47
50
  }
48
51
  }
49
52
  }
50
- };
53
+ });
51
54
 
52
55
  if (process.env.CSI_EXPOSE_CORE) {
53
56
  global[Symbol.for('contrast:core')] = core;
@@ -62,6 +65,7 @@ function loadFeatures(core) {
62
65
  require('@contrast/route-coverage')(core);
63
66
  require('@contrast/assess')(core);
64
67
  require('@contrast/protect')(core);
68
+ require('@contrast/sec-obs')(core);
65
69
  }
66
70
 
67
71
  function startAgent({ type = 'cjs' } = {}) {
@@ -78,6 +82,7 @@ function startAgent({ type = 'cjs' } = {}) {
78
82
  'contrastMethods',
79
83
  'deadzones',
80
84
  'scopes',
85
+ 'secObs',
81
86
  'sources',
82
87
  'architectureComponents',
83
88
  'routeCoverage',
@@ -94,14 +99,16 @@ function startAgent({ type = 'cjs' } = {}) {
94
99
  ],
95
100
  type
96
101
  });
97
- } catch (err) {
102
+ } catch (cause) {
98
103
  // agentify should catch any startup errors and handle necessary logging,
99
104
  // but this is just in case a fatal error occurs during composition.
100
- console.error('Startup error was not handled by agentify. Application Will be run without instrumentation.');
101
- console.error(err);
105
+ safeConsoleError(new Error(
106
+ 'Startup error was not handled by agentify. Application Will be run without instrumentation.',
107
+ { cause }
108
+ ));
102
109
  }
103
110
  } else {
104
- console.warn('Not in main thread. Thread (tid: %d) continuing without instrumentation.', threadId);
111
+ safeConsoleWarn('Not in main thread. Thread (tid: %d) continuing without instrumentation.', threadId);
105
112
  }
106
113
  }
107
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agent",
3
- "version": "5.29.0",
3
+ "version": "5.31.0",
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)",
@@ -24,12 +24,15 @@
24
24
  "test": "../scripts/test.sh"
25
25
  },
26
26
  "dependencies": {
27
- "@contrast/agentify": "1.43.0",
28
- "@contrast/architecture-components": "1.34.0",
29
- "@contrast/assess": "1.48.0",
30
- "@contrast/library-analysis": "1.36.0",
31
- "@contrast/protect": "1.55.0",
32
- "@contrast/route-coverage": "1.36.0",
33
- "@contrast/telemetry": "1.21.0"
27
+ "@contrast/agentify": "1.45.0",
28
+ "@contrast/architecture-components": "1.36.0",
29
+ "@contrast/assess": "1.50.0",
30
+ "@contrast/common": "1.32.0",
31
+ "@contrast/core": "1.48.0",
32
+ "@contrast/library-analysis": "1.38.0",
33
+ "@contrast/protect": "1.57.0",
34
+ "@contrast/route-coverage": "1.38.0",
35
+ "@contrast/sec-obs": "1.1.0",
36
+ "@contrast/telemetry": "1.23.0"
34
37
  }
35
38
  }