@contrast/agentify
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -18,3 +18,6 @@ /* | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const Module = require('module'); | ||
const { env } = require('process'); | ||
@@ -29,2 +32,3 @@ const defaultOpts = { | ||
'sources', | ||
'architectureComponents', | ||
'assess', | ||
@@ -38,8 +42,8 @@ 'protect', | ||
module.exports = function(deps) { | ||
module.exports = function(core) { | ||
// compose add'l local services | ||
require('./sources')(deps); | ||
require('./contrast-methods')(deps); | ||
require('./function-hooks')(deps); | ||
require('./rewrite-hooks')(deps); | ||
require('./sources')(core); | ||
require('./contrast-methods')(core); | ||
require('./function-hooks')(core); | ||
require('./rewrite-hooks')(core); | ||
@@ -62,6 +66,6 @@ /** | ||
return new Agent(deps, opts); | ||
return new Agent(core, opts); | ||
} | ||
deps.agentify = agentify; | ||
core.agentify = agentify; | ||
@@ -74,3 +78,3 @@ return agentify; | ||
* | ||
* @param {object} deps dependencies | ||
* @param {object} core dependencies | ||
* @param {object} opts | ||
@@ -80,7 +84,7 @@ * @param {function} opts.preRunMain custom function for registering services | ||
*/ | ||
constructor(deps, opts) { | ||
constructor(core, opts) { | ||
const self = this; | ||
const { config, logger } = deps; | ||
const { config, logger } = core; | ||
this.deps = deps; | ||
this.core = core; | ||
this.opts = opts; | ||
@@ -98,3 +102,3 @@ this.runMain = Module.runMain; | ||
const plugin = await opts.preRunMain(deps); | ||
const plugin = await opts.preRunMain(core); | ||
@@ -111,2 +115,4 @@ if (opts.install) { | ||
} | ||
self.logEffectiveConfig(); | ||
return self.runMain.apply(this, args); | ||
@@ -124,3 +130,3 @@ }; | ||
async handleInstallFailure(err) { | ||
this.deps.logger.error( | ||
this.core.logger.error( | ||
{ err }, | ||
@@ -133,5 +139,5 @@ 'A fatal agent installation error has occurred. The application will be run without instrumentation.' | ||
for (const svcName of this.opts.svcList) { | ||
this.deps.logger.trace('installing service: %s', svcName); | ||
const svc = this.deps[svcName]; | ||
const svc = this.core[svcName]; | ||
if (svc && svc.install) { | ||
this.core.logger.trace('installing service: %s', svcName); | ||
await svc.install(); | ||
@@ -141,4 +147,25 @@ } | ||
} | ||
logEffectiveConfig() { | ||
const { config, getEffectiveConfig } = this.core; | ||
if (env.CONTRAST__AGENT__DIAGNOSTICS__ENABLE !== 'false') { | ||
const content = JSON.stringify(getEffectiveConfig(), null, 2).concat('\n\n'); | ||
if (env.CONTRAST__AGENT__DIAGNOSTICS__QUIET !== 'true') { | ||
fs.writeFileSync(1, content, 'utf8'); | ||
} | ||
let outputDir = env.CONTRAST__AGENT__DIAGNOSTICS__REPORT_PATH; | ||
if (!outputDir && config.agent.logger.path) { | ||
outputDir = path.join(config.agent.logger.path, '../contrast_effective_config.json'); | ||
} else { | ||
outputDir = path.join(__dirname, 'contrast_effective_config.json'); | ||
} | ||
fs.writeFileSync(outputDir, content, 'utf-8'); | ||
} | ||
} | ||
} | ||
module.exports.Agent = Agent; |
{ | ||
"name": "@contrast/agentify", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Configures Contrast agent services and instrumentation within an application", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19623
504
4