@contrast/agentify 1.11.0 → 1.12.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 +24 -35
- package/lib/rewrite-hooks.js +1 -1
- package/lib/sources.js +1 -1
- package/package.json +2 -2
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,7 +88,7 @@ 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
93
|
logger.info('Starting the Contrast agent');
|
|
94
94
|
logger.debug({ config }, 'Agent configuration');
|
|
@@ -99,7 +99,7 @@ class Agent {
|
|
|
99
99
|
await self.install();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
if (plugin
|
|
102
|
+
if (plugin?.install) {
|
|
103
103
|
await plugin.install();
|
|
104
104
|
}
|
|
105
105
|
} catch (err) {
|
|
@@ -128,7 +128,7 @@ class Agent {
|
|
|
128
128
|
async install() {
|
|
129
129
|
for (const svcName of this.opts.svcList) {
|
|
130
130
|
const svc = this.core[svcName];
|
|
131
|
-
if (svc
|
|
131
|
+
if (svc?.install) {
|
|
132
132
|
this.core.logger.trace('installing service: %s', svcName);
|
|
133
133
|
await svc.install();
|
|
134
134
|
}
|
|
@@ -136,35 +136,24 @@ class Agent {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
logDiagnosticFiles() {
|
|
139
|
-
const { config
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
fs.writeFileSync(path.join(outputDir, 'contrast_system_info.json'), systemInfo, 'utf-8');
|
|
158
|
-
} catch (err) {
|
|
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
|
-
}
|
|
139
|
+
const { config: { agent: { diagnostics } }, logger } = this.core;
|
|
140
|
+
|
|
141
|
+
if (!diagnostics.enable) return;
|
|
142
|
+
|
|
143
|
+
// let these run async so they don't block agent startup.
|
|
144
|
+
fs.writeFile(
|
|
145
|
+
path.join(diagnostics.report_path, 'contrast_effective_config.json'),
|
|
146
|
+
JSON.stringify(this.core.getEffectiveConfig(), null, 2)
|
|
147
|
+
).catch((err) => {
|
|
148
|
+
logger.warn({ err }, 'unable to write effective config file');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
fs.writeFile(
|
|
152
|
+
path.join(diagnostics.report_path, 'contrast_system_info.json'),
|
|
153
|
+
JSON.stringify(this.core.getSystemInfo(), null, 2)
|
|
154
|
+
).catch((err) => {
|
|
155
|
+
logger.warn({ err }, 'unable to write system info file');
|
|
156
|
+
});
|
|
168
157
|
}
|
|
169
158
|
}
|
|
170
159
|
|
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.12.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.14.0"
|
|
21
21
|
}
|
|
22
22
|
}
|