@contrast/agentify 1.11.0 → 1.13.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.
- package/LICENSE +1 -1
- package/lib/function-hooks.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +30 -35
- package/lib/rewrite-hooks.js +1 -1
- package/lib/sources.js +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
package/lib/function-hooks.js
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright:
|
|
2
|
+
* Copyright: 2023 Contrast Security, Inc
|
|
3
3
|
* Contact: support@contrastsecurity.com
|
|
4
4
|
* License: Commercial
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const fs = require('fs');
|
|
18
|
+
const fs = require('fs').promises;
|
|
19
19
|
const path = require('path');
|
|
20
20
|
const Module = require('module');
|
|
21
21
|
|
|
@@ -38,7 +38,7 @@ const defaultOpts = {
|
|
|
38
38
|
]
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
module.exports = function(core) {
|
|
41
|
+
module.exports = function (core) {
|
|
42
42
|
// compose add'l local services
|
|
43
43
|
require('./sources')(core);
|
|
44
44
|
require('./function-hooks')(core);
|
|
@@ -88,8 +88,12 @@ class Agent {
|
|
|
88
88
|
* This is one side effect that will always occur, even with `install: false`.
|
|
89
89
|
* The act of calling `agentify()` is enough to cause this side effect, by design.
|
|
90
90
|
*/
|
|
91
|
-
Module.runMain = async function(...args) {
|
|
91
|
+
Module.runMain = async function (...args) {
|
|
92
92
|
try {
|
|
93
|
+
for (const err of config._errors) {
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
logger.info('Starting the Contrast agent');
|
|
94
98
|
logger.debug({ config }, 'Agent configuration');
|
|
95
99
|
|
|
@@ -99,7 +103,7 @@ class Agent {
|
|
|
99
103
|
await self.install();
|
|
100
104
|
}
|
|
101
105
|
|
|
102
|
-
if (plugin
|
|
106
|
+
if (plugin?.install) {
|
|
103
107
|
await plugin.install();
|
|
104
108
|
}
|
|
105
109
|
} catch (err) {
|
|
@@ -128,7 +132,7 @@ class Agent {
|
|
|
128
132
|
async install() {
|
|
129
133
|
for (const svcName of this.opts.svcList) {
|
|
130
134
|
const svc = this.core[svcName];
|
|
131
|
-
if (svc
|
|
135
|
+
if (svc?.install) {
|
|
132
136
|
this.core.logger.trace('installing service: %s', svcName);
|
|
133
137
|
await svc.install();
|
|
134
138
|
}
|
|
@@ -136,35 +140,26 @@ class Agent {
|
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
logDiagnosticFiles() {
|
|
139
|
-
const { config,
|
|
140
|
-
|
|
141
|
-
if (config.agent.diagnostics.enable
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
outputDir = path.join(process.cwd());
|
|
160
|
-
try {
|
|
161
|
-
fs.writeFileSync(path.join(outputDir, 'contrast_effective_config.json'), effectiveConfig, 'utf-8');
|
|
162
|
-
fs.writeFileSync(path.join(outputDir, 'contrast_system_info.json'), systemInfo, 'utf-8');
|
|
163
|
-
} catch (err) {
|
|
164
|
-
fs.writeFileSync(1, `Couldn't create the diagnostic files: ${err}`, 'utf-8');
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
143
|
+
const { config, logger } = this.core;
|
|
144
|
+
|
|
145
|
+
if (!config.agent.diagnostics.enable) return;
|
|
146
|
+
|
|
147
|
+
const { report_path } = config.agent.diagnostics;
|
|
148
|
+
|
|
149
|
+
// let these run async so they don't block agent startup.
|
|
150
|
+
fs.writeFile(
|
|
151
|
+
path.join(report_path, 'contrast_effective_config.json'),
|
|
152
|
+
JSON.stringify(config.getReport({ redact: true }), null, 2)
|
|
153
|
+
).catch((err) => {
|
|
154
|
+
logger.warn({ err }, 'unable to write effective config file');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
fs.writeFile(
|
|
158
|
+
path.join(report_path, 'contrast_system_info.json'),
|
|
159
|
+
JSON.stringify(this.core.getSystemInfo(), null, 2)
|
|
160
|
+
).catch((err) => {
|
|
161
|
+
logger.warn({ err }, 'unable to write system info file');
|
|
162
|
+
});
|
|
168
163
|
}
|
|
169
164
|
}
|
|
170
165
|
|
package/lib/rewrite-hooks.js
CHANGED
package/lib/sources.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/agentify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.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,6 +17,6 @@
|
|
|
17
17
|
"test": "../scripts/test.sh"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@contrast/common": "1.
|
|
20
|
+
"@contrast/common": "1.15.0"
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
}
|