@contrast/cli 1.0.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/lib/config-diagnostics.js +48 -0
- package/package.json +26 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Copyright: 2022 Contrast Security, Inc
|
|
4
|
+
* Contact: support@contrastsecurity.com
|
|
5
|
+
* License: Commercial
|
|
6
|
+
|
|
7
|
+
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
8
|
+
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
9
|
+
* made available through public repositories, use of this Software is subject to
|
|
10
|
+
* the applicable End User Licensing Agreement found at
|
|
11
|
+
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
12
|
+
* between Contrast Security and the End User. The Software may not be reverse
|
|
13
|
+
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
14
|
+
* way not consistent with the End User License Agreement.
|
|
15
|
+
*/
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const commander = require('commander');
|
|
21
|
+
|
|
22
|
+
async function runDiagnostics (core = require('@contrast/core')()) {
|
|
23
|
+
commander.program
|
|
24
|
+
.name('config-diagnostics')
|
|
25
|
+
.description('The config-diagnostics utility returns the current effective node agent configuration.')
|
|
26
|
+
.argument('<entrypoint>', 'The entrypoint JavaScript or ESM file for the application')
|
|
27
|
+
.option('-q, --quiet', 'suppress logging to stdout')
|
|
28
|
+
.option('-o, --output <string>', 'output directory for generated JSON file', path.join(process.cwd(), 'contrast_effective_config.json'))
|
|
29
|
+
.action(async function main(entrypoint, options) {
|
|
30
|
+
const { reporter, getEffectiveConfig } = core;
|
|
31
|
+
await reporter.install();
|
|
32
|
+
const content = JSON.stringify(getEffectiveConfig(), null, 2).concat('\n\n');
|
|
33
|
+
|
|
34
|
+
if (!options.quiet) {
|
|
35
|
+
fs.writeFileSync(1, content, 'utf8');
|
|
36
|
+
}
|
|
37
|
+
if (options.output) {
|
|
38
|
+
fs.writeFileSync(options.output, content, 'utf-8');
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
.parse();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = runDiagnostics;
|
|
45
|
+
|
|
46
|
+
if (require.main === module) {
|
|
47
|
+
runDiagnostics();
|
|
48
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
3
|
+
"name": "@contrast/cli",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "A collection of agent related CLI utilities",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "../scripts/test.sh"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"config-diagnostics": "lib/config-diagnostics.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"package.json",
|
|
14
|
+
"lib/"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"npm": ">=6.13.7 <7 || >= 8.3.1",
|
|
18
|
+
"node": ">= 14.15.0"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [],
|
|
21
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@contrast/core": "^1.7.1",
|
|
24
|
+
"commander": "^9.4.1"
|
|
25
|
+
}
|
|
26
|
+
}
|