@contrast/agentify 1.27.3 → 1.28.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.
@@ -19,28 +19,36 @@ const fs = require('fs/promises');
19
19
  const path = require('path');
20
20
 
21
21
  module.exports = function init(core) {
22
- core.logDiagnosticFiles = function logDiagnosticFiles() {
22
+ async function logDiagnosticFiles() {
23
23
  const { config, logger } = core;
24
24
 
25
25
  if (!config.agent.diagnostics.enable) return;
26
26
 
27
27
  const { report_path } = config.agent.diagnostics;
28
28
 
29
- // let these run async so they don't block agent startup.
30
- fs.writeFile(
31
- path.join(report_path, 'contrast_effective_config.json'),
32
- JSON.stringify(config.getReport({ redact: true }), null, 2)
33
- ).catch((err) => {
34
- logger.warn({ err }, 'unable to write effective config file');
35
- });
36
-
37
- fs.writeFile(
38
- path.join(report_path, 'contrast_system_info.json'),
39
- JSON.stringify(core.getSystemInfo(), null, 2)
40
- ).catch((err) => {
41
- logger.warn({ err }, 'unable to write system info file');
42
- });
29
+ const effectiveConfig = config.getReport({ redact: true });
30
+ const systemInfo = await core.getSystemInfo();
31
+
32
+ return Promise.all([
33
+ fs.writeFile(
34
+ path.join(report_path, 'contrast_effective_config.json'),
35
+ JSON.stringify(effectiveConfig, null, 2)
36
+ ).catch((err) => {
37
+ logger.warn({ err }, 'unable to write effective config file');
38
+ }),
39
+ fs.writeFile(
40
+ path.join(report_path, 'contrast_system_info.json'),
41
+ JSON.stringify(systemInfo, null, 2)
42
+ ).catch((err) => {
43
+ logger.warn({ err }, 'unable to write system info file');
44
+ }),
45
+ ]);
46
+ }
47
+
48
+ return core.diagnostics = {
49
+ install() {
50
+ // let this run async so it doesn't block agent startup.
51
+ logDiagnosticFiles();
52
+ }
43
53
  };
44
-
45
- return core.logDiagnosticFiles;
46
54
  };
package/lib/index.js CHANGED
@@ -48,6 +48,7 @@ const DEFAULT_INSTALL_ORDER = [
48
48
  'rewriteHooks',
49
49
  'functionHooks',
50
50
  'esmHooks',
51
+ 'diagnostics',
51
52
  ];
52
53
 
53
54
  /**
@@ -123,8 +124,6 @@ module.exports = function init(core = {}) {
123
124
  if (plugin?.install) {
124
125
  await plugin.install();
125
126
  }
126
-
127
- core.logDiagnosticFiles(); // should this be moved into a separate install side-effect?
128
127
  } catch (err) {
129
128
  // TODO: Consider proper UNINSTALLATION and normal startup w/o agent
130
129
  logger.error({ err }, ERROR_MESSAGE);
@@ -141,8 +140,8 @@ module.exports = function init(core = {}) {
141
140
  { name: 'logger', spec: '@contrast/logger', default: true },
142
141
  // call all configValidation functions here
143
142
  { name: 'agent-info', spec: '@contrast/core/lib/agent-info' },
144
- { name: 'system-info', spec: '@contrast/core/lib/system-info' },
145
143
  { name: 'app-info', spec: '@contrast/core/lib/app-info' },
144
+ { name: 'system-info', spec: '@contrast/core/lib/system-info' },
146
145
  // was check for appInfo errors length and throw if found
147
146
  { name: 'sensitive-data-masking', spec: '@contrast/core/lib/sensitive-data-masking' },
148
147
  { name: 'is-agent-path', spec: '@contrast/core/lib/is-agent-path' },
@@ -161,7 +160,7 @@ module.exports = function init(core = {}) {
161
160
  { name: 'heap-snapshots', spec: './heap-snapshots' },
162
161
  { name: 'sources', spec: './sources' },
163
162
  { name: 'function-hooks', spec: './function-hooks' },
164
- { name: 'log-diagnostic-files', spec: './log-diagnostic-files' },
163
+ { name: 'diagnostics', spec: './diagnostics' },
165
164
  { name: 'rewrite-hooks', spec: './rewrite-hooks' },
166
165
  ];
167
166
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agentify",
3
- "version": "1.27.3",
3
+ "version": "1.28.0",
4
4
  "description": "Configures Contrast agent services and instrumentation within an application",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -17,19 +17,19 @@
17
17
  "test": "../scripts/test.sh"
18
18
  },
19
19
  "dependencies": {
20
- "@contrast/common": "1.21.3",
21
- "@contrast/config": "1.28.3",
22
- "@contrast/core": "1.32.3",
23
- "@contrast/deadzones": "1.2.4",
20
+ "@contrast/common": "1.22.0",
21
+ "@contrast/config": "1.29.0",
22
+ "@contrast/core": "1.33.0",
23
+ "@contrast/deadzones": "1.3.0",
24
24
  "@contrast/dep-hooks": "1.3.3",
25
- "@contrast/esm-hooks": "2.6.3",
25
+ "@contrast/esm-hooks": "2.7.0",
26
26
  "@contrast/find-package-json": "^1.1.0",
27
- "@contrast/instrumentation": "1.10.1",
27
+ "@contrast/instrumentation": "1.11.0",
28
28
  "@contrast/logger": "1.8.4",
29
- "@contrast/metrics": "1.8.3",
29
+ "@contrast/metrics": "1.9.0",
30
30
  "@contrast/patcher": "1.7.4",
31
- "@contrast/reporter": "1.27.3",
32
- "@contrast/rewriter": "1.8.4",
31
+ "@contrast/reporter": "1.28.0",
32
+ "@contrast/rewriter": "1.9.0",
33
33
  "@contrast/scopes": "1.4.1",
34
34
  "semver": "^7.6.0"
35
35
  }