@opscompass/opscompass-cli 1.0.16 → 1.0.17
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/cliHelpers.js +13 -1
- package/modules/compliance.js +174 -0
- package/package.json +3 -2
package/lib/cliHelpers.js
CHANGED
|
@@ -3,6 +3,12 @@ const https = require('https');
|
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const AdmZip = require('adm-zip');
|
|
5
5
|
|
|
6
|
+
let httpsProxyAgent;
|
|
7
|
+
if (process.env.https_proxy || process.env.HTTPS_PROXY) {
|
|
8
|
+
const createHttpsProxyAgent = require("https-proxy-agent");
|
|
9
|
+
httpsProxyAgent = createHttpsProxyAgent(process.env.https_proxy || process.env.HTTPS_PROXY);
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
/**
|
|
7
13
|
* Users need to be able to enter array data into the CLI. They do this by submitting identical argument names with each element value.
|
|
8
14
|
* This method consolidates all data associated with the specified argument names, and creates an array object.
|
|
@@ -100,8 +106,14 @@ function deleteDirectory(directoryPath) {
|
|
|
100
106
|
*/
|
|
101
107
|
async function downloadFile(downloadUrl, downloadFilePath, downloadName) {
|
|
102
108
|
return new Promise((resolve, reject) => {
|
|
109
|
+
const getOptions = {};
|
|
110
|
+
|
|
111
|
+
if (httpsProxyAgent) {
|
|
112
|
+
getOptions.agent = httpsProxyAgent;
|
|
113
|
+
}
|
|
114
|
+
|
|
103
115
|
// Download the file
|
|
104
|
-
https.get(downloadUrl, (res) => {
|
|
116
|
+
https.get(downloadUrl, getOptions, (res) => {
|
|
105
117
|
|
|
106
118
|
// Open file in local filesystem
|
|
107
119
|
const file = fs.createWriteStream(path.join(downloadFilePath, downloadName));
|
package/modules/compliance.js
CHANGED
|
@@ -9,6 +9,141 @@ const { getCredentials } = require("../credentials.js");
|
|
|
9
9
|
console.log(JSON.stringify(response, null, 2));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
async function getUpcomingExceptionInfo(args) {
|
|
13
|
+
for (let i = 0; i < args.length; i++) {
|
|
14
|
+
switch (args[i].toLowerCase()) {
|
|
15
|
+
case "--company":
|
|
16
|
+
callParams.company = args[++i];
|
|
17
|
+
break;
|
|
18
|
+
case "--frameworkid":
|
|
19
|
+
case "--framework-id":
|
|
20
|
+
callParams.frameworkId = args[++i];
|
|
21
|
+
break;
|
|
22
|
+
case "--accounts":
|
|
23
|
+
if (typeof callParams.accounts === "string") {
|
|
24
|
+
callParams.accounts = [callParams.accounts];
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(callParams.accounts)) {
|
|
27
|
+
callParams.accounts.push(args[++i]);
|
|
28
|
+
} else {
|
|
29
|
+
callParams.accounts = args[++i];
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const client = await getOpsCompassClient();
|
|
35
|
+
const response = await client.compliance.getUpcomingExceptionInfo(callParams.company, callParams.accounts, callParams.frameworkId);
|
|
36
|
+
|
|
37
|
+
console.log(JSON.stringify(response, null, 2));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function getCheckStatusOverview(args) {
|
|
41
|
+
for (let i = 0; i < args.length; i++) {
|
|
42
|
+
switch (args[i].toLowerCase()) {
|
|
43
|
+
case "--company":
|
|
44
|
+
callParams.company = args[++i];
|
|
45
|
+
break;
|
|
46
|
+
case "--frameworkid":
|
|
47
|
+
case "--framework-id":
|
|
48
|
+
callParams.frameworkId = args[++i];
|
|
49
|
+
break;
|
|
50
|
+
case "--accounts":
|
|
51
|
+
if (typeof callParams.accounts === "string") {
|
|
52
|
+
callParams.accounts = [callParams.accounts];
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(callParams.accounts)) {
|
|
55
|
+
callParams.accounts.push(args[++i]);
|
|
56
|
+
} else {
|
|
57
|
+
callParams.accounts = args[++i];
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const client = await getOpsCompassClient();
|
|
63
|
+
const response = await client.compliance.getCheckStatusOverview(callParams.company, callParams.accounts, callParams.frameworkId);
|
|
64
|
+
|
|
65
|
+
console.log(JSON.stringify(response, null, 2));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function getComplianceProblemsOverTime(args) {
|
|
69
|
+
for (let i = 0; i < args.length; i++) {
|
|
70
|
+
switch (args[i].toLowerCase()) {
|
|
71
|
+
case "--company":
|
|
72
|
+
callParams.company = args[i+1];
|
|
73
|
+
break;
|
|
74
|
+
case "--accounts":
|
|
75
|
+
if (typeof callParams.accounts === "string") {
|
|
76
|
+
callParams.accounts = [callParams.accounts];
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(callParams.accounts)) {
|
|
79
|
+
callParams.accounts.push(args[++i]);
|
|
80
|
+
} else {
|
|
81
|
+
callParams.accounts = args[++i];
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case "--start-date":
|
|
85
|
+
case "--startdate":
|
|
86
|
+
callParams.startDate = args[++i];
|
|
87
|
+
break;
|
|
88
|
+
case "--end-date":
|
|
89
|
+
case "--enddate":
|
|
90
|
+
callParams.endDate = args[++i];
|
|
91
|
+
break;
|
|
92
|
+
case "--frameworkid":
|
|
93
|
+
case "--framework-id":
|
|
94
|
+
callParams.frameworkId = args[++i];
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const client = await getOpsCompassClient();
|
|
100
|
+
const response = await client.compliance.getComplianceProblemsOverTime(callParams.company, callParams.accounts, callParams.startDate, callParams.endDate, callParams.frameworkId);
|
|
101
|
+
|
|
102
|
+
console.log(JSON.stringify(response, null, 2));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function listFrameworks(args) {
|
|
106
|
+
for (let i = 0; i < args.length; i++) {
|
|
107
|
+
switch (args[i].toLowerCase()) {
|
|
108
|
+
case "--company":
|
|
109
|
+
callParams.company = args[i+1];
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const client = await getOpsCompassClient();
|
|
116
|
+
const response = await client.compliance.listFrameworks(callParams.company);
|
|
117
|
+
|
|
118
|
+
console.log(JSON.stringify(response, null, 2));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function listFrameworksWithDetails(args) {
|
|
122
|
+
for (let i = 0; i < args.length; i++) {
|
|
123
|
+
switch (args[i].toLowerCase()) {
|
|
124
|
+
case "--company":
|
|
125
|
+
callParams.company = args[i+1];
|
|
126
|
+
break;
|
|
127
|
+
case "--accounts":
|
|
128
|
+
if (typeof callParams.accounts === "string") {
|
|
129
|
+
callParams.accounts = [callParams.accounts];
|
|
130
|
+
}
|
|
131
|
+
if (Array.isArray(callParams.accounts)) {
|
|
132
|
+
callParams.accounts.push(args[++i]);
|
|
133
|
+
} else {
|
|
134
|
+
callParams.accounts = args[++i];
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
const client = await getOpsCompassClient();
|
|
142
|
+
const response = await client.compliance.listFrameworksWithDetails(callParams.company, callParams.accounts);
|
|
143
|
+
|
|
144
|
+
console.log(JSON.stringify(response, null, 2));
|
|
145
|
+
}
|
|
146
|
+
|
|
12
147
|
async function transferVMwareVsphereMetadata(args) {
|
|
13
148
|
const callParams = genericMetadataTrasfer(args);
|
|
14
149
|
const client = await getOpsCompassClient();
|
|
@@ -233,6 +368,35 @@ const { getCredentials } = require("../credentials.js");
|
|
|
233
368
|
async function printHelp() {
|
|
234
369
|
console.log("Actions available for compliance:");
|
|
235
370
|
console.log();
|
|
371
|
+
console.log("list-frameworks", "Retrieves the list of compliance frameworks available for the specified company");
|
|
372
|
+
console.log("Parameters:");
|
|
373
|
+
console.log("--company [company_slug]");
|
|
374
|
+
console.log();
|
|
375
|
+
console.log("list-frameworks-with-details", "Retrieves the list of compliance frameworks available for the specified company, with the amount of active control problems and compliance score for each framework");
|
|
376
|
+
console.log("Parameters:");
|
|
377
|
+
console.log("--company [company_slug]");
|
|
378
|
+
console.log("--accounts [account_id]");
|
|
379
|
+
console.log();
|
|
380
|
+
console.log("get-upcoming-exception-info", "Retrieves the soon to be expiring compliance exception information for the specified company.");
|
|
381
|
+
console.log("Parameters:");
|
|
382
|
+
console.log("--company [company_slug]");
|
|
383
|
+
console.log("--accounts (optional) [account_id]");
|
|
384
|
+
console.log("--frameworkId (optional) [compliance_framework_id]");
|
|
385
|
+
console.log();
|
|
386
|
+
console.log("get-check-status-overview", "Retrieves an overview of compliance check statuses, associated with a company.");
|
|
387
|
+
console.log("Parameters:");
|
|
388
|
+
console.log("--company [company_slug]");
|
|
389
|
+
console.log("--accounts (optional) [account_id] Ex. --accounts account_123,account_456");
|
|
390
|
+
console.log("--frameworkId (optional) [compliance_framework_id] Ex. --frameworkId 28");
|
|
391
|
+
console.log();
|
|
392
|
+
console.log("get-compliance-problems-over-time", "Retrieves a list of aggregated information about compliance problems over a specified timeframe.");
|
|
393
|
+
console.log("Parameters:");
|
|
394
|
+
console.log("--company [company_slug]");
|
|
395
|
+
console.log("--start-date [2020-11-11 00:00:00.000]")
|
|
396
|
+
console.log("--end-date [2020-11-15 00:00:00.000")
|
|
397
|
+
console.log("--accounts (optional) [account_id] Ex. --accounts account_123,account_456");
|
|
398
|
+
console.log("--frameworkId (optional) [compliance_framework_id] Ex. --frameworkId 28");
|
|
399
|
+
console.log();
|
|
236
400
|
console.log("transfer-oracle-database-metadata", "Transfers OpsCompass Oracle Database metadata report into OpsCompass for processing");
|
|
237
401
|
console.log("Parameters:");
|
|
238
402
|
console.log("--company [company_slug]");
|
|
@@ -305,6 +469,16 @@ const { getCredentials } = require("../credentials.js");
|
|
|
305
469
|
|
|
306
470
|
const complianceModule = (action, ...args) => {
|
|
307
471
|
switch (action?.toLowerCase() ?? "") {
|
|
472
|
+
case "list-frameworks-with-details":
|
|
473
|
+
return listFrameworksWithDetails(args);
|
|
474
|
+
case "list-frameworks":
|
|
475
|
+
return listFrameworks(args);
|
|
476
|
+
case "get-upcoming-exception-info":
|
|
477
|
+
return getUpcomingExceptionInfo(args);
|
|
478
|
+
case "get-check-status-overview":
|
|
479
|
+
return getCheckStatusOverview(args);
|
|
480
|
+
case "get-compliance-problems-over-time":
|
|
481
|
+
return getComplianceProblemsOverTime(args);
|
|
308
482
|
case "transfer-network-discovery-metadata":
|
|
309
483
|
return transferNetworkDiscoveryMetadata(args);
|
|
310
484
|
case "transfer-vmware-vsphere-metadata":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Calls OpsCompass's APIs",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
"author": "opscompass",
|
|
16
16
|
"license": "SEE LICENSE IN license.txt",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@opscompass/opscompass-api": "^1.0.
|
|
18
|
+
"@opscompass/opscompass-api": "^1.0.17",
|
|
19
19
|
"adm-zip": "^0.5.9",
|
|
20
20
|
"axios": "^0.21.1",
|
|
21
21
|
"fs-extra": "^10.1.0",
|
|
22
|
+
"https-proxy-agent": "^5.0.1",
|
|
22
23
|
"open": "^8.2.1",
|
|
23
24
|
"semver": "^7.3.7"
|
|
24
25
|
},
|