@opscompass/opscompass-cli 1.0.31 → 1.0.32

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.
Files changed (2) hide show
  1. package/modules/compliance.js +759 -594
  2. package/package.json +2 -2
@@ -1,644 +1,809 @@
1
1
  const { getOpsCompassClient } = require("../opscompass.js");
2
2
  const { getCredentials } = require("../credentials.js");
3
3
 
4
- async function transferOracleDatabaseMetadata(args) {
5
- const callParams = genericMetadataTrasfer(args);
6
- const client = await getOpsCompassClient();
7
- const response = await client.compliance.transferOracleDatabaseMetadata(callParams.company, callParams.type, callParams.filePath);
8
-
9
- console.log(JSON.stringify(response, null, 2));
4
+ async function transferOracleDatabaseMetadata(args) {
5
+ const callParams = genericMetadataTrasfer(args);
6
+ const client = await getOpsCompassClient();
7
+ const response = await client.compliance.transferOracleDatabaseMetadata(
8
+ callParams.company,
9
+ callParams.type,
10
+ callParams.filePath
11
+ );
12
+
13
+ console.log(JSON.stringify(response, null, 2));
14
+ }
15
+
16
+ async function getUpcomingExceptionInfo(args) {
17
+ for (let i = 0; i < args.length; i++) {
18
+ switch (args[i].toLowerCase()) {
19
+ case "--company":
20
+ callParams.company = args[++i];
21
+ break;
22
+ case "--frameworkid":
23
+ case "--framework-id":
24
+ callParams.frameworkId = args[++i];
25
+ break;
26
+ case "--accounts":
27
+ if (typeof callParams.accounts === "string") {
28
+ callParams.accounts = [callParams.accounts];
29
+ }
30
+ if (Array.isArray(callParams.accounts)) {
31
+ callParams.accounts.push(args[++i]);
32
+ } else {
33
+ callParams.accounts = args[++i];
34
+ }
35
+ break;
36
+ }
10
37
  }
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
- }
38
+ const client = await getOpsCompassClient();
39
+ const response = await client.compliance.getUpcomingExceptionInfo(
40
+ callParams.company,
41
+ callParams.accounts,
42
+ callParams.frameworkId
43
+ );
44
+
45
+ console.log(JSON.stringify(response, null, 2));
46
+ }
47
+
48
+ async function getCheckStatusOverview(args) {
49
+ for (let i = 0; i < args.length; i++) {
50
+ switch (args[i].toLowerCase()) {
51
+ case "--company":
52
+ callParams.company = args[++i];
53
+ break;
54
+ case "--frameworkid":
55
+ case "--framework-id":
56
+ callParams.frameworkId = args[++i];
57
+ break;
58
+ case "--accounts":
59
+ if (typeof callParams.accounts === "string") {
60
+ callParams.accounts = [callParams.accounts];
61
+ }
62
+ if (Array.isArray(callParams.accounts)) {
63
+ callParams.accounts.push(args[++i]);
64
+ } else {
65
+ callParams.accounts = args[++i];
66
+ }
67
+ break;
33
68
  }
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
69
  }
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
- }
70
+ const client = await getOpsCompassClient();
71
+ const response = await client.compliance.getCheckStatusOverview(
72
+ callParams.company,
73
+ callParams.accounts,
74
+ callParams.frameworkId
75
+ );
76
+
77
+ console.log(JSON.stringify(response, null, 2));
78
+ }
79
+
80
+ async function getComplianceProblemsOverTime(args) {
81
+ for (let i = 0; i < args.length; i++) {
82
+ switch (args[i].toLowerCase()) {
83
+ case "--company":
84
+ callParams.company = args[i + 1];
85
+ break;
86
+ case "--accounts":
87
+ if (typeof callParams.accounts === "string") {
88
+ callParams.accounts = [callParams.accounts];
89
+ }
90
+ if (Array.isArray(callParams.accounts)) {
91
+ callParams.accounts.push(args[++i]);
92
+ } else {
93
+ callParams.accounts = args[++i];
94
+ }
95
+ break;
96
+ case "--start-date":
97
+ case "--startdate":
98
+ callParams.startDate = args[++i];
99
+ break;
100
+ case "--end-date":
101
+ case "--enddate":
102
+ callParams.endDate = args[++i];
103
+ break;
104
+ case "--frameworkid":
105
+ case "--framework-id":
106
+ callParams.frameworkId = args[++i];
107
+ break;
61
108
  }
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
109
  }
67
110
 
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
- }
111
+ const client = await getOpsCompassClient();
112
+ const response = await client.compliance.getComplianceProblemsOverTime(
113
+ callParams.company,
114
+ callParams.accounts,
115
+ callParams.startDate,
116
+ callParams.endDate,
117
+ callParams.frameworkId
118
+ );
119
+
120
+ console.log(JSON.stringify(response, null, 2));
121
+ }
122
+
123
+ async function listFrameworks(args) {
124
+ for (let i = 0; i < args.length; i++) {
125
+ switch (args[i].toLowerCase()) {
126
+ case "--company":
127
+ callParams.company = args[i + 1];
128
+ break;
97
129
  }
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
130
  }
104
131
 
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;
132
+ const client = await getOpsCompassClient();
133
+ const response = await client.compliance.listFrameworks(callParams.company);
134
+
135
+ console.log(JSON.stringify(response, null, 2));
136
+ }
137
+
138
+ async function listFrameworksWithDetails(args) {
139
+ for (let i = 0; i < args.length; i++) {
140
+ switch (args[i].toLowerCase()) {
141
+ case "--company":
142
+ callParams.company = args[i + 1];
143
+ break;
144
+ case "--accounts":
145
+ if (typeof callParams.accounts === "string") {
146
+ callParams.accounts = [callParams.accounts];
111
147
  }
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
- }
148
+ if (Array.isArray(callParams.accounts)) {
149
+ callParams.accounts.push(args[++i]);
150
+ } else {
151
+ callParams.accounts = args[++i];
152
+ }
153
+ break;
138
154
  }
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
155
  }
146
156
 
147
-
148
- async function listChecksWithDetails(args) {
149
- for (let i = 0; i < args.length; i++) {
150
- switch (args[i].toLowerCase()) {
151
- case "--company":
152
- callParams.company = args[i+1];
153
- break;
154
- case "--accounts":
155
- if (typeof callParams.accounts === "string") {
156
- callParams.accounts = [callParams.accounts];
157
- }
158
- if (Array.isArray(callParams.accounts)) {
159
- callParams.accounts.push(args[++i]);
160
- } else {
161
- callParams.accounts = args[++i];
162
- }
163
- break;
164
- }
157
+ const client = await getOpsCompassClient();
158
+ const response = await client.compliance.listFrameworksWithDetails(
159
+ callParams.company,
160
+ callParams.accounts
161
+ );
162
+
163
+ console.log(JSON.stringify(response, null, 2));
164
+ }
165
+
166
+ async function listChecksWithDetails(args) {
167
+ for (let i = 0; i < args.length; i++) {
168
+ switch (args[i].toLowerCase()) {
169
+ case "--company":
170
+ callParams.company = args[i + 1];
171
+ break;
172
+ case "--accounts":
173
+ if (typeof callParams.accounts === "string") {
174
+ callParams.accounts = [callParams.accounts];
175
+ }
176
+ if (Array.isArray(callParams.accounts)) {
177
+ callParams.accounts.push(args[++i]);
178
+ } else {
179
+ callParams.accounts = args[++i];
180
+ }
181
+ break;
165
182
  }
166
-
167
-
168
- const client = await getOpsCompassClient();
169
- const response = await client.compliance.listChecksWithDetails(callParams.company, callParams.accounts);
170
-
171
-
172
- console.log(JSON.stringify(response, null, 2));
173
183
  }
174
184
 
175
- async function listDisabledChecks(args) {
176
- for (let i = 0; i < args.length; i++) {
177
- switch (args[i].toLowerCase()) {
178
- case "--company":
179
- callParams.company = args[i+1];
180
- break;
181
- case "--accounts":
182
- if (typeof callParams.accounts === "string") {
183
- callParams.accounts = [callParams.accounts];
184
- }
185
- if (Array.isArray(callParams.accounts)) {
186
- callParams.accounts.push(args[++i]);
187
- } else {
188
- callParams.accounts = args[++i];
189
- }
190
- break;
191
- }
185
+ const client = await getOpsCompassClient();
186
+ const response = await client.compliance.listChecksWithDetails(
187
+ callParams.company,
188
+ callParams.accounts
189
+ );
190
+
191
+ console.log(JSON.stringify(response, null, 2));
192
+ }
193
+
194
+ async function listDisabledChecks(args) {
195
+ for (let i = 0; i < args.length; i++) {
196
+ switch (args[i].toLowerCase()) {
197
+ case "--company":
198
+ callParams.company = args[i + 1];
199
+ break;
200
+ case "--accounts":
201
+ if (typeof callParams.accounts === "string") {
202
+ callParams.accounts = [callParams.accounts];
203
+ }
204
+ if (Array.isArray(callParams.accounts)) {
205
+ callParams.accounts.push(args[++i]);
206
+ } else {
207
+ callParams.accounts = args[++i];
208
+ }
209
+ break;
192
210
  }
193
-
194
-
195
- const client = await getOpsCompassClient();
196
- const response = await client.compliance.listDisabledChecks(callParams.company, callParams.accounts);
197
-
198
-
199
- console.log(JSON.stringify(response, null, 2));
200
211
  }
201
212
 
202
- async function transferVMwareVsphereMetadata(args) {
203
- const callParams = genericMetadataTrasfer(args);
204
- const client = await getOpsCompassClient();
205
- const response = await client.compliance.transferVMwareVsphereMetadata(callParams.company, callParams.filePath);
206
-
207
- console.log(JSON.stringify(response, null, 2));
213
+ const client = await getOpsCompassClient();
214
+ const response = await client.compliance.listDisabledChecks(
215
+ callParams.company,
216
+ callParams.accounts
217
+ );
218
+
219
+ console.log(JSON.stringify(response, null, 2));
220
+ }
221
+
222
+ async function transferVMwareVsphereMetadata(args) {
223
+ const callParams = genericMetadataTrasfer(args);
224
+ const client = await getOpsCompassClient();
225
+ const response = await client.compliance.transferVMwareVsphereMetadata(
226
+ callParams.company,
227
+ callParams.filePath
228
+ );
229
+
230
+ console.log(JSON.stringify(response, null, 2));
231
+ }
232
+
233
+ async function transferNetworkDiscoveryMetadata(args) {
234
+ const callParams = genericMetadataTrasfer(args);
235
+ const client = await getOpsCompassClient();
236
+ const response = await client.compliance.transferNetworkDiscoveryMetadata(
237
+ callParams.company,
238
+ callParams.filePath
239
+ );
240
+
241
+ console.log(JSON.stringify(response, null, 2));
242
+ }
243
+
244
+ async function transferSqlServerDatabaseMetadata(args) {
245
+ const callParams = genericMetadataTrasfer(args);
246
+ const client = await getOpsCompassClient();
247
+ const response = await client.compliance.transferSqlServerDatabaseMetadata(
248
+ callParams.company,
249
+ callParams.type,
250
+ callParams.filePath
251
+ );
252
+
253
+ console.log(JSON.stringify(response, null, 2));
254
+ }
255
+
256
+ function genericMetadataTrasfer(args) {
257
+ for (let i = 0; i < args.length - 1; i++) {
258
+ switch (args[i].toLowerCase()) {
259
+ case "--type":
260
+ callParams.type = args[++i];
261
+ break;
262
+ case "--filepath":
263
+ callParams.filePath = args[++i];
264
+ break;
265
+ case "--company":
266
+ callParams.company = args[++i];
267
+ break;
268
+ }
208
269
  }
209
-
210
- async function transferNetworkDiscoveryMetadata(args) {
211
- const callParams = genericMetadataTrasfer(args);
212
- const client = await getOpsCompassClient();
213
- const response = await client.compliance.transferNetworkDiscoveryMetadata(callParams.company, callParams.filePath);
214
-
215
- console.log(JSON.stringify(response, null, 2));
270
+ return callParams;
271
+ }
272
+
273
+ async function listComplianceExceptions(args) {
274
+ let company = undefined;
275
+ let optionalParams = {
276
+ fromIndex: undefined,
277
+ numberOfRecords: undefined,
278
+ complianceExceptionSort: undefined,
279
+ complianceExceptionSortDirection: undefined,
280
+ searchText: undefined,
281
+ typeFilter: undefined,
282
+ statusFilter: undefined,
283
+ expiresAtFrom: undefined,
284
+ expiresAtTo: undefined,
285
+ checkIdsFilter: undefined,
286
+ resourceIdsFilter: undefined,
287
+ creatorIdsFilter: undefined,
288
+ };
289
+ for (let i = 0; i < args.length - 1; i++) {
290
+ switch (args[i].toLowerCase()) {
291
+ case "--company":
292
+ company = args[++i];
293
+ break;
294
+ case "--from-index":
295
+ case "--fromindex":
296
+ optionalParams.fromIndex = args[++i];
297
+ break;
298
+ case "--number-of-records":
299
+ case "--numberofrecords":
300
+ optionalParams.numberOfRecords = args[++i];
301
+ break;
302
+ case "--compliance-exception-sort":
303
+ case "--complianceexceptionsort":
304
+ optionalParams.complianceExceptionSort = args[++i];
305
+ break;
306
+ case "--compliance-exception-sort-direction":
307
+ case "--complianceexceptionsortdirection":
308
+ optionalParams.complianceExceptionSortDirection = args[++i];
309
+ break;
310
+ case "--search-text":
311
+ case "--searchtext":
312
+ optionalParams.searchText = args[++i];
313
+ break;
314
+ case "--type-filter":
315
+ case "--typefilter":
316
+ optionalParams.typeFilter = args[++i];
317
+ break;
318
+ case "--status-filter":
319
+ case "--statusfilter":
320
+ optionalParams.statusFilter = args[++i];
321
+ break;
322
+ case "--expires-at-from":
323
+ case "--expiresatfrom":
324
+ optionalParams.expiresAtFrom = args[++i];
325
+ break;
326
+ case "--expires-at-to":
327
+ case "--expiresatto":
328
+ optionalParams.expiresAtTo = args[++i];
329
+ break;
330
+ case "--check-ids-filter":
331
+ case "--checkidsfilter":
332
+ optionalParams.checkIdsFilter = args[++i];
333
+ break;
334
+ case "--resource-ids-filter":
335
+ case "--resourceidsfilter":
336
+ optionalParams.resourceIdsFilter = args[++i];
337
+ break;
338
+ case "--creator-ids-filter":
339
+ case "--creatoridsfilter":
340
+ optionalParams.creatorIdsFilter = args[++i];
341
+ break;
342
+ }
216
343
  }
217
344
 
218
- async function transferSqlServerDatabaseMetadata(args) {
219
- const callParams = genericMetadataTrasfer(args);
220
- const client = await getOpsCompassClient();
221
- const response = await client.compliance.transferSqlServerDatabaseMetadata(callParams.company, callParams.type, callParams.filePath);
345
+ const client = await getOpsCompassClient();
346
+ const complianceExceptions = await client.compliance.getComplianceExceptions(
347
+ company,
348
+ optionalParams
349
+ );
350
+
351
+ console.log(JSON.stringify(complianceExceptions, null, 2));
352
+ }
353
+
354
+ async function updateComplianceException(args) {
355
+ for (let i = 0; i < args.length - 1; i++) {
356
+ switch (args[i].toLowerCase()) {
357
+ case "--id":
358
+ callParams.id = args[++i];
359
+ break;
360
+ case "--reason":
361
+ callParams.reason = args[++i];
362
+ break;
363
+ case "--expiresat":
364
+ case "--expires-at":
365
+ const expiresDate = args[++i];
366
+ if (expiresDate === "null") {
367
+ callParams.expiresAt = null;
368
+ } else {
369
+ callParams.expiresAt = expiresDate;
370
+ }
222
371
 
223
- console.log(JSON.stringify(response, null, 2));
372
+ break;
373
+ }
224
374
  }
225
-
226
- function genericMetadataTrasfer(args) {
227
375
 
376
+ const client = await getOpsCompassClient();
377
+ const complianceException = await client.compliance.updateComplianceException(
378
+ callParams.id,
379
+ callParams
380
+ );
381
+ console.log(JSON.stringify(complianceException, null, 2));
382
+ }
383
+
384
+ async function updateComplianceExceptions(args) {
385
+ let callParamsArray = [];
386
+ let jsonIndex = args.indexOf("--json-updates");
387
+ let idIndex = args.indexOf("--id");
388
+
389
+ /* Process bulk update with JSON */
390
+ if (jsonIndex !== -1) {
391
+ const jsonString = args[jsonIndex + 1];
392
+ callParamsArray = JSON.parse(jsonString);
393
+ } else if (idIndex !== -1) {
394
+ /* If no '--json-update' flag, process bulk update with parameter flags (e.g. --id, --name, etc.) */
228
395
  for (let i = 0; i < args.length - 1; i++) {
229
- switch (args[i].toLowerCase()) {
230
- case "--type":
231
- callParams.type = args[++i];
232
- break;
233
- case "--filepath":
234
- callParams.filePath = args[++i];
235
- break;
236
- case "--company":
237
- callParams.company = args[++i];
238
- break;
396
+ const argument = args[i].toLowerCase();
397
+ if (argument === "--id") {
398
+ /* Reset callParams object when a second id is encountered */
399
+ callParams = {};
400
+ /* if theres an existing callParams object, toss it into the array and move on. */
401
+ callParamsArray.push(callParams);
402
+ /* Create the object's properties based on the index (e.g. if the index is --id, you'll find the value at the next index */
403
+ callParams.id = args[i + 1];
404
+ } else if (argument === "--reason") {
405
+ callParams.reason = args[i + 1];
406
+ } else if (argument === "--expiresat" || argument === "--expires-at") {
407
+ const expiresDate = args[i + 1];
408
+ if (expiresDate === "null") {
409
+ callParams.expiresAt = null;
410
+ } else {
411
+ callParams.expiresAt = expiresDate;
239
412
  }
240
- }
241
- return callParams;
242
- }
243
-
244
- async function listComplianceExceptions(args) {
245
- let company = undefined;
246
- let optionalParams = {
247
- fromIndex: undefined,
248
- numberOfRecords: undefined,
249
- complianceExceptionSort: undefined,
250
- complianceExceptionSortDirection: undefined,
251
- searchText: undefined,
252
- typeFilter: undefined,
253
- statusFilter: undefined,
254
- expiresAtFrom: undefined,
255
- expiresAtTo: undefined,
256
- checkIdsFilter: undefined,
257
- resourceIdsFilter: undefined,
258
- creatorIdsFilter: undefined
259
- };
260
- for (let i = 0; i < args.length - 1; i++) {
261
- switch (args[i].toLowerCase()) {
262
- case "--company":
263
- company = args[++i];
264
- break;
265
- case "--from-index":
266
- case "--fromindex":
267
- optionalParams.fromIndex = args[++i];
268
- break;
269
- case "--number-of-records":
270
- case "--numberofrecords":
271
- optionalParams.numberOfRecords = args[++i];
272
- break;
273
- case "--compliance-exception-sort":
274
- case "--complianceexceptionsort":
275
- optionalParams.complianceExceptionSort = args[++i];
276
- break;
277
- case "--compliance-exception-sort-direction":
278
- case "--complianceexceptionsortdirection":
279
- optionalParams.complianceExceptionSortDirection = args[++i];
280
- break;
281
- case "--search-text":
282
- case "--searchtext":
283
- optionalParams.searchText = args[++i];
284
- break;
285
- case "--type-filter":
286
- case "--typefilter":
287
- optionalParams.typeFilter = args[++i];
288
- break;
289
- case "--status-filter":
290
- case "--statusfilter":
291
- optionalParams.statusFilter = args[++i];
292
- break;
293
- case "--expires-at-from":
294
- case "--expiresatfrom":
295
- optionalParams.expiresAtFrom = args[++i];
296
- break;
297
- case "--expires-at-to":
298
- case "--expiresatto":
299
- optionalParams.expiresAtTo = args[++i];
300
- break;
301
- case "--check-ids-filter":
302
- case "--checkidsfilter":
303
- optionalParams.checkIdsFilter = args[++i];
304
- break;
305
- case "--resource-ids-filter":
306
- case "--resourceidsfilter":
307
- optionalParams.resourceIdsFilter = args[++i];
308
- break;
309
- case "--creator-ids-filter":
310
- case "--creatoridsfilter":
311
- optionalParams.creatorIdsFilter = args[++i];
312
- break;
313
413
  }
314
414
  }
315
-
316
- const client = await getOpsCompassClient();
317
- const complianceExceptions = await client.compliance.getComplianceExceptions(company, optionalParams);
318
-
319
- console.log(JSON.stringify(complianceExceptions, null, 2));
415
+ } else {
416
+ console.warn("Invalid input, please see help for examples.");
320
417
  }
321
418
 
322
- async function updateComplianceException(args) {
323
- for (let i = 0; i < args.length - 1; i++) {
324
- switch (args[i].toLowerCase()) {
325
- case "--id":
326
- callParams.id = args[++i];
327
- break;
328
- case "--reason":
329
- callParams.reason = args[++i];
330
- break;
331
- case "--expiresat":
332
- case "--expires-at":
333
- const expiresDate = args[++i];
334
- if (expiresDate === 'null') {
335
- callParams.expiresAt = null;
336
- } else {
337
- callParams.expiresAt = expiresDate;
338
- }
339
-
340
- break;
341
- }
419
+ /* Call the API and print to console */
420
+ const client = await getOpsCompassClient();
421
+ const vCenterConfigurations =
422
+ await client.compliance.updateComplianceExceptions(callParamsArray);
423
+ console.log(JSON.stringify(vCenterConfigurations, null, 2));
424
+ }
425
+
426
+ async function createComplianceResourceCheckException(args) {
427
+ let complianceResourceCheckId = undefined;
428
+ let complianceExceptionType = undefined;
429
+ let reason = undefined;
430
+ let expiresAt = undefined;
431
+
432
+ for (let i = 0; i < args.length - 1; i++) {
433
+ switch (args[i].toLowerCase()) {
434
+ case "--complianceresourcecheckid":
435
+ case "--compliance-resource-check-id":
436
+ complianceResourceCheckId = args[i + 1];
437
+ break;
438
+ case "--complianceexceptiontype":
439
+ case "--compliance-exception-type":
440
+ complianceExceptionType = args[i + 1];
441
+ break;
442
+ case "--reason":
443
+ reason = args[i + 1];
444
+ break;
445
+ case "--expiresat":
446
+ case "--expires-at":
447
+ expiresAt = args[i + 1];
448
+ break;
342
449
  }
343
-
344
- const client = await getOpsCompassClient();
345
- const complianceException = await client.compliance.updateComplianceException(callParams.id, callParams);
346
- console.log(JSON.stringify(complianceException, null, 2));
347
450
  }
348
451
 
349
- async function updateComplianceExceptions(args) {
350
- let callParamsArray = [];
351
- let jsonIndex = args.indexOf('--json-updates');
352
- let idIndex = args.indexOf('--id');
353
-
354
- /* Process bulk update with JSON */
355
- if (jsonIndex !== -1) {
356
- const jsonString = args[jsonIndex + 1];
357
- callParamsArray = JSON.parse(jsonString);
358
- } else if (idIndex !== -1) {
359
- /* If no '--json-update' flag, process bulk update with parameter flags (e.g. --id, --name, etc.) */
360
- for(let i = 0; i < args.length - 1; i++) {
361
- const argument = args[i].toLowerCase();
362
- if(argument === '--id') {
363
- /* Reset callParams object when a second id is encountered */
364
- callParams = {};
365
- /* if theres an existing callParams object, toss it into the array and move on. */
366
- callParamsArray.push(callParams)
367
- /* Create the object's properties based on the index (e.g. if the index is --id, you'll find the value at the next index */
368
- callParams.id = args[i + 1];
369
- } else if(argument === '--reason') {
370
- callParams.reason = args[i + 1];
371
- } else if(argument === '--expiresat' || argument === '--expires-at') {
372
- const expiresDate = args[i + 1];
373
- if (expiresDate === 'null') {
374
- callParams.expiresAt = null;
375
- } else {
376
- callParams.expiresAt = expiresDate;
377
- }
378
- }
379
- }
380
- } else {
381
- console.warn("Invalid input, please see help for examples.")
452
+ const client = await getOpsCompassClient();
453
+ const complianceExceptions =
454
+ await client.compliance.createComplianceResourceCheckException(
455
+ complianceResourceCheckId,
456
+ complianceExceptionType,
457
+ reason,
458
+ expiresAt
459
+ );
460
+ console.log(JSON.stringify(complianceExceptions, null, 2));
461
+ console.log();
462
+ }
463
+
464
+ async function listBreaches(args) {
465
+ for (let i = 0; i < args.length; i++) {
466
+ switch (args[i].toLowerCase()) {
467
+ case "--company":
468
+ callParams.company = args[i + 1];
469
+ break;
382
470
  }
383
-
384
- /* Call the API and print to console */
385
- const client = await getOpsCompassClient();
386
- const vCenterConfigurations = await client.compliance.updateComplianceExceptions(callParamsArray);
387
- console.log(JSON.stringify(vCenterConfigurations, null, 2));
388
471
  }
389
-
390
- async function createComplianceResourceCheckException(args) {
391
- let complianceResourceCheckId= undefined;
392
- let complianceExceptionType= undefined;
393
- let reason = undefined;
394
- let expiresAt = undefined;
395
-
396
- for (let i = 0; i < args.length - 1; i++) {
397
- switch (args[i].toLowerCase()) {
398
- case "--complianceresourcecheckid":
399
- case "--compliance-resource-check-id":
400
- complianceResourceCheckId = args[i+1];
401
- break;
402
- case "--complianceexceptiontype":
403
- case "--compliance-exception-type":
404
- complianceExceptionType = args[i+1];
405
- break;
406
- case "--reason":
407
- reason = args[i+1];
408
- break;
409
- case "--expiresat":
410
- case "--expires-at":
411
- expiresAt = args[i+1];
412
- break;
413
- }
414
- }
415
-
416
- const client = await getOpsCompassClient();
417
- const complianceExceptions = await client.compliance.createComplianceResourceCheckException(complianceResourceCheckId, complianceExceptionType, reason, expiresAt);
418
- console.log(JSON.stringify(complianceExceptions, null, 2));
419
- console.log();
420
- }
421
-
422
- async function listBreaches(args) {
423
- for (let i = 0; i < args.length; i++) {
424
- switch (args[i].toLowerCase()) {
425
- case "--company":
426
- callParams.company = args[i+1];
427
- break;
428
- }
429
- }
430
472
 
473
+ const client = await getOpsCompassClient();
474
+ const response = await client.compliance.listBreaches(callParams.company);
431
475
 
432
- const client = await getOpsCompassClient();
433
- const response = await client.compliance.listBreaches(callParams.company);
476
+ console.log(JSON.stringify(response, null, 2));
477
+ }
434
478
 
435
- console.log(JSON.stringify(response, null, 2));
479
+ async function listBreachedEmails(args) {
480
+ for (let i = 0; i < args.length; i++) {
481
+ switch (args[i].toLowerCase()) {
482
+ case "--company":
483
+ callParams.company = args[i + 1];
484
+ break;
485
+ }
436
486
  }
437
487
 
438
- async function listBreachedEmails(args) {
439
- for (let i = 0; i < args.length; i++) {
440
- switch (args[i].toLowerCase()) {
441
- case "--company":
442
- callParams.company = args[i+1];
443
- break;
444
- }
445
- }
446
-
488
+ const client = await getOpsCompassClient();
489
+ const response = await client.compliance.listBreachedEmails(
490
+ callParams.company
491
+ );
447
492
 
448
- const client = await getOpsCompassClient();
449
- const response = await client.compliance.listBreachedEmails(callParams.company);
493
+ console.log(JSON.stringify(response, null, 2));
494
+ }
450
495
 
451
- console.log(JSON.stringify(response, null, 2));
496
+ async function listBreachedEmailsOfConcern(args) {
497
+ for (let i = 0; i < args.length; i++) {
498
+ switch (args[i].toLowerCase()) {
499
+ case "--company":
500
+ callParams.company = args[i + 1];
501
+ break;
502
+ }
452
503
  }
453
504
 
454
- async function listBreachedEmailsOfConcern(args) {
455
- for (let i = 0; i < args.length; i++) {
456
- switch (args[i].toLowerCase()) {
457
- case "--company":
458
- callParams.company = args[i+1];
459
- break;
460
- }
461
- }
462
-
463
-
464
- const client = await getOpsCompassClient();
465
- const response = await client.compliance.listBreachedEmailsOfConcern(callParams.company);
466
-
467
- console.log(JSON.stringify(response, null, 2));
505
+ const client = await getOpsCompassClient();
506
+ const response = await client.compliance.listBreachedEmailsOfConcern(
507
+ callParams.company
508
+ );
509
+
510
+ console.log(JSON.stringify(response, null, 2));
511
+ }
512
+
513
+ async function printHelp() {
514
+ console.log("Actions available for compliance:");
515
+ console.log();
516
+ console.log(
517
+ "list-checks-with-details",
518
+ "Retrieves the list of compliance checks for the specified company, with the amount of active resource problems and compliance score impact for each check"
519
+ );
520
+ console.log("Parameters:");
521
+ console.log("--company [company_slug]");
522
+ console.log("--accounts (optional) [account_id]");
523
+ console.log();
524
+ console.log(
525
+ "list-disabled-checks",
526
+ "Retrieves the list of disabled compliance checks for the specified company, with the amount of resources that each check is not scanning against."
527
+ );
528
+ console.log("Parameters:");
529
+ console.log("--company [company_slug]");
530
+ console.log("--accounts (optional) [account_id]");
531
+ console.log();
532
+ console.log(
533
+ "list-frameworks",
534
+ "Retrieves the list of compliance frameworks available for the specified company"
535
+ );
536
+ console.log("Parameters:");
537
+ console.log("--company [company_slug]");
538
+ console.log();
539
+ console.log(
540
+ "list-frameworks-with-details",
541
+ "Retrieves the list of compliance frameworks available for the specified company, with the amount of active control problems and compliance score for each framework"
542
+ );
543
+ console.log("Parameters:");
544
+ console.log("--company [company_slug]");
545
+ console.log("--accounts [account_id]");
546
+ console.log();
547
+ console.log(
548
+ "get-upcoming-exception-info",
549
+ "Retrieves the soon to be expiring compliance exception information for the specified company."
550
+ );
551
+ console.log("Parameters:");
552
+ console.log("--company [company_slug]");
553
+ console.log("--accounts (optional) [account_id]");
554
+ console.log("--frameworkId (optional) [compliance_framework_id]");
555
+ console.log();
556
+ console.log(
557
+ "get-check-status-overview",
558
+ "Retrieves an overview of compliance check statuses, associated with a company."
559
+ );
560
+ console.log("Parameters:");
561
+ console.log("--company [company_slug]");
562
+ console.log(
563
+ "--accounts (optional) [account_id] Ex. --accounts account_123,account_456"
564
+ );
565
+ console.log(
566
+ "--frameworkId (optional) [compliance_framework_id] Ex. --frameworkId 28"
567
+ );
568
+ console.log();
569
+ console.log(
570
+ "get-compliance-problems-over-time",
571
+ "Retrieves a list of aggregated information about compliance problems over a specified timeframe."
572
+ );
573
+ console.log("Parameters:");
574
+ console.log("--company [company_slug]");
575
+ console.log("--start-date [2020-11-11 00:00:00.000]");
576
+ console.log("--end-date [2020-11-15 00:00:00.000");
577
+ console.log(
578
+ "--accounts (optional) [account_id] Ex. --accounts account_123,account_456"
579
+ );
580
+ console.log(
581
+ "--frameworkId (optional) [compliance_framework_id] Ex. --frameworkId 28"
582
+ );
583
+ console.log();
584
+ console.log(
585
+ "transfer-oracle-database-metadata",
586
+ "Transfers OpsCompass Oracle Database metadata report into OpsCompass for processing"
587
+ );
588
+ console.log("Parameters:");
589
+ console.log("--company [company_slug]");
590
+ console.log("--type [licensing | compliance | ebusiness]");
591
+ console.log(
592
+ "--filePath [path] Path of the file to transfer to OpsCompass for processing."
593
+ );
594
+ console.log();
595
+ console.log(
596
+ "transfer-vmware-vsphere-metadata",
597
+ "Transfers OpsCompass VMware VSphere metadata report into OpsCompass for processing"
598
+ );
599
+ console.log("Parameters:");
600
+ console.log("--company [company_slug]");
601
+ console.log(
602
+ "--filePath [path] Path of the file to transfer to OpsCompass for processing."
603
+ );
604
+ console.log();
605
+ console.log(
606
+ "transfer-sql-server-database-metadata",
607
+ "Transfers OpsCompass SQL Server Database metadata report into OpsCompass for processing"
608
+ );
609
+ console.log("Parameters:");
610
+ console.log("--company [company_slug]");
611
+ console.log("--type [licensing | compliance]");
612
+ console.log(
613
+ "--filePath [path] Path of the file to transfer to OpsCompass for processing."
614
+ );
615
+ console.log();
616
+ console.log(
617
+ "transfer-network-discovery-metadata",
618
+ "Transfers OpsCompass Network Discovery metadata into OpsCompass for processing"
619
+ );
620
+ console.log("Parameters:");
621
+ console.log("--company [company_slug]");
622
+ console.log(
623
+ "--filePath [path] Path of the file to transfer to OpsCompass for processing."
624
+ );
625
+ console.log();
626
+ console.log(
627
+ "list-compliance-exceptions",
628
+ "Gets list of policy exceptions and mitigations"
629
+ );
630
+ console.log("Parameters:");
631
+ console.log("--company [company_slug]");
632
+ console.log(
633
+ "--from-index (optional) [number] the record index to start at when fetching the next round of records (helps with fetching all records over multiple requests)"
634
+ );
635
+ console.log(
636
+ "--number-of-records (optional) [number] the number of records to fetch with one request"
637
+ );
638
+ console.log(
639
+ "--compliance-exception-sort: (optional) [resource | check | type | created-at | expires-at | reason] the column on which to sort records by"
640
+ );
641
+ console.log(
642
+ "--compliance-exception-sort-direction: (optional) [asc | desc] the direction to sort records by"
643
+ );
644
+ console.log("--search-text: (optional) [string] search columns by this text");
645
+ console.log(
646
+ '--type-filter: (optional) [mitigation and/or policy_exception] filter results by type. Ex: --type-filter "policy_exception, mitigation"'
647
+ );
648
+ console.log(
649
+ '--status-filter: (optional) [active and/or expired] filter results by status. Ex: --status-filter "expired, active"'
650
+ );
651
+ console.log(
652
+ "--expires-at-from: (optional) [string] the date at which to not show records before."
653
+ );
654
+ console.log(
655
+ "Format: UTC, example: '2022-08-23T17:00:00Z' to filter by August 8th, 2022 at 17:00 UTC."
656
+ );
657
+ console.log(
658
+ "--expires-at-to: (optional) [string] the date at which to not show records after."
659
+ );
660
+ console.log(
661
+ "Format: UTC, example: '2022-08-23T17:00:00Z' to filter by August 8th, 2022 at 17:00 UTC."
662
+ );
663
+ console.log(
664
+ '--check-ids-filter: (optional) [string] check ids to filter records by. Ex: --check-ids-filter "123, 456, 789"'
665
+ );
666
+ console.log(
667
+ '--resource-ids-filter: (optional) [string] resource ids to filter records by. Ex: --resource-ids-filter "123, 456, 789"'
668
+ );
669
+ console.log(
670
+ '--creator-ids-filter: (optional) [string] user ids to filter records by. Ex: --creator-ids-filter "123, 456, 789"'
671
+ );
672
+ console.log();
673
+ console.log(
674
+ "update-compliance-exception",
675
+ "Updates single compliance exception record (i.e. mitigations and policy exceptions)"
676
+ );
677
+ console.log("Parameters:");
678
+ console.log("--id [record id]");
679
+ console.log("--reason [string] the reason for the compliance exception");
680
+ console.log(
681
+ "--expiresAt [string] the date at which to expire. If you want to remove a compliance exception from the list, set the expiresAt to todays date."
682
+ );
683
+ console.log(
684
+ "Format: UTC, example: '2022-08-23T17:00:00Z' to expire August 8th, 2022 at 17:00 UTC. To remove this field, pass in null."
685
+ );
686
+ console.log();
687
+ console.log(
688
+ "update-compliance-exceptions",
689
+ "Updates multiple compliance exceptions (i.e. mitigations and policy exceptions)"
690
+ );
691
+ console.log("Parameters:");
692
+ console.log("--id [record id]");
693
+ console.log(
694
+ "--reason (optional) [string] the reason for the compliance exception"
695
+ );
696
+ console.log(
697
+ "--expiresAt (optional) [string] the date at which to expire. If you want to remove a compliance exception from the list, set the expiresAt to todays date."
698
+ );
699
+ console.log(
700
+ "Format: UTC, example: '2022-08-23T17:00:00Z' to expire August 8th, 2022 at 17:00 UTC. To remove this field, pass in null."
701
+ );
702
+ console.log("OR --json-updates [stringified json objects with your updates]");
703
+ console.log("For quick updates, you may use the above parameters");
704
+ console.log(
705
+ 'e.g. opscompass compliance update-compliance-exceptions --id 18 --reason "Valid exception reason" --id 3 --expires-at "09/15/2022"'
706
+ );
707
+ console.log(
708
+ "For larger updates, JavaScript Object Notation (JSON) may be used with the --json-updates flag"
709
+ );
710
+ console.log(
711
+ `e.g. opscompass compliance update-compliance-exceptions --json-updates '[{\"id\":\"18\",\"reason\":\"Valid exception reason\"},{\"id\":\"3\",\"expiresAt\":\"2022-08-23T17:00:00Z\"}]'`
712
+ );
713
+ console.log();
714
+ console.log(
715
+ "create-compliance-resource-check-exceptions",
716
+ "Creates a new compliance resource check exception"
717
+ );
718
+ console.log("Parameters:");
719
+ console.log(
720
+ "--compliance-resource-check-id [the compliance resource check id]"
721
+ );
722
+ console.log(
723
+ "--compliance-exception-type [string] the type of compliance exception: 'mitigation' or 'policy_exception'"
724
+ );
725
+ console.log(
726
+ "--reason [string] the reason for the compliance resource check exception"
727
+ );
728
+ console.log(
729
+ "--expires-at (optional) [string] the date at which to expire. If you want to remove a compliance exception from the list, set the expiresAt to todays date."
730
+ );
731
+ console.log(
732
+ "Format: UTC, example: '2022-08-23T17:00:00Z' to expire August 8th, 2022 at 17:00 UTC."
733
+ );
734
+ console.log();
735
+ console.log(
736
+ "list-breaches",
737
+ "Retrieves the list of breaches company emails have been involved in."
738
+ );
739
+ console.log("Parameters:");
740
+ console.log("--company [company_slug]");
741
+ console.log();
742
+ console.log(
743
+ "list-breached-emails",
744
+ "Retrieves the list of breached emails associated with a provided company"
745
+ );
746
+ console.log("Parameters:");
747
+ console.log("--company [company_slug]");
748
+ console.log();
749
+ console.log(
750
+ "list-breached-emails-of-concern",
751
+ "Retrieves the list of breached emails that have not performed a password reset since a data breach."
752
+ );
753
+ console.log("Parameters:");
754
+ console.log("--company [company_slug]");
755
+ console.log();
756
+ }
757
+
758
+ const complianceModule = (action, ...args) => {
759
+ switch (action?.toLowerCase() ?? "") {
760
+ case "list-checks-with-details":
761
+ return listChecksWithDetails(args);
762
+ case "list-disabled-checks":
763
+ return listDisabledChecks(args);
764
+ case "list-frameworks-with-details":
765
+ return listFrameworksWithDetails(args);
766
+ case "list-frameworks":
767
+ return listFrameworks(args);
768
+ case "get-upcoming-exception-info":
769
+ return getUpcomingExceptionInfo(args);
770
+ case "get-check-status-overview":
771
+ return getCheckStatusOverview(args);
772
+ case "get-compliance-problems-over-time":
773
+ return getComplianceProblemsOverTime(args);
774
+ case "transfer-network-discovery-metadata":
775
+ return transferNetworkDiscoveryMetadata(args);
776
+ case "transfer-vmware-vsphere-metadata":
777
+ return transferVMwareVsphereMetadata(args);
778
+ case "transfer-oracle-database-metadata":
779
+ return transferOracleDatabaseMetadata(args);
780
+ case "transfer-sql-server-database-metadata":
781
+ return transferSqlServerDatabaseMetadata(args);
782
+ case "list-compliance-exceptions":
783
+ return listComplianceExceptions(args);
784
+ case "update-compliance-exception":
785
+ return updateComplianceException(args);
786
+ case "update-compliance-exceptions":
787
+ return updateComplianceExceptions(args);
788
+ case "create-compliance-resource-check-exception":
789
+ return createComplianceResourceCheckException(args);
790
+ case "list-breaches":
791
+ return listBreaches(args);
792
+ case "list-breached-emails":
793
+ return listBreachedEmails(args);
794
+ case "list-breached-emails-of-concern":
795
+ return listBreachedEmailsOfConcern(args);
796
+ case "help":
797
+ case "":
798
+ return printHelp();
799
+ default:
800
+ console.log("Unknown command:", action);
801
+ return printHelp();
468
802
  }
803
+ };
469
804
 
470
- async function printHelp() {
471
- console.log("Actions available for compliance:");
472
- console.log();
473
- console.log("list-checks-with-details", "Retrieves the list of compliance checks for the specified company, with the amount of active resource problems and compliance score impact for each check");
474
- console.log("Parameters:");
475
- console.log("--company [company_slug]");
476
- console.log("--accounts (optional) [account_id]");
477
- console.log();
478
- console.log("list-disabled-checks", "Retrieves the list of disabled compliance checks for the specified company, with the amount of resources that each check is not scanning against.");
479
- console.log("Parameters:");
480
- console.log("--company [company_slug]");
481
- console.log("--accounts (optional) [account_id]");
482
- console.log();
483
- console.log("list-frameworks", "Retrieves the list of compliance frameworks available for the specified company");
484
- console.log("Parameters:");
485
- console.log("--company [company_slug]");
486
- console.log();
487
- 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");
488
- console.log("Parameters:");
489
- console.log("--company [company_slug]");
490
- console.log("--accounts [account_id]");
491
- console.log();
492
- console.log("get-upcoming-exception-info", "Retrieves the soon to be expiring compliance exception information for the specified company.");
493
- console.log("Parameters:");
494
- console.log("--company [company_slug]");
495
- console.log("--accounts (optional) [account_id]");
496
- console.log("--frameworkId (optional) [compliance_framework_id]");
497
- console.log();
498
- console.log("get-check-status-overview", "Retrieves an overview of compliance check statuses, associated with a company.");
499
- console.log("Parameters:");
500
- console.log("--company [company_slug]");
501
- console.log("--accounts (optional) [account_id] Ex. --accounts account_123,account_456");
502
- console.log("--frameworkId (optional) [compliance_framework_id] Ex. --frameworkId 28");
503
- console.log();
504
- console.log("get-compliance-problems-over-time", "Retrieves a list of aggregated information about compliance problems over a specified timeframe.");
505
- console.log("Parameters:");
506
- console.log("--company [company_slug]");
507
- console.log("--start-date [2020-11-11 00:00:00.000]")
508
- console.log("--end-date [2020-11-15 00:00:00.000")
509
- console.log("--accounts (optional) [account_id] Ex. --accounts account_123,account_456");
510
- console.log("--frameworkId (optional) [compliance_framework_id] Ex. --frameworkId 28");
511
- console.log();
512
- console.log("transfer-oracle-database-metadata", "Transfers OpsCompass Oracle Database metadata report into OpsCompass for processing");
513
- console.log("Parameters:");
514
- console.log("--company [company_slug]");
515
- console.log("--type [licensing | compliance]")
516
- console.log("--filePath [path] Path of the file to transfer to OpsCompass for processing.");
517
- console.log();
518
- console.log("transfer-vmware-vsphere-metadata", "Transfers OpsCompass VMware VSphere metadata report into OpsCompass for processing");
519
- console.log("Parameters:");
520
- console.log("--company [company_slug]");
521
- console.log("--filePath [path] Path of the file to transfer to OpsCompass for processing.");
522
- console.log();
523
- console.log("transfer-sql-server-database-metadata", "Transfers OpsCompass SQL Server Database metadata report into OpsCompass for processing");
524
- console.log("Parameters:");
525
- console.log("--company [company_slug]");
526
- console.log("--type [licensing | compliance]")
527
- console.log("--filePath [path] Path of the file to transfer to OpsCompass for processing.");
528
- console.log();
529
- console.log("transfer-network-discovery-metadata", "Transfers OpsCompass Network Discovery metadata into OpsCompass for processing");
530
- console.log("Parameters:");
531
- console.log("--company [company_slug]");
532
- console.log("--filePath [path] Path of the file to transfer to OpsCompass for processing.");
533
- console.log();
534
- console.log("list-compliance-exceptions", "Gets list of policy exceptions and mitigations");
535
- console.log("Parameters:");
536
- console.log("--company [company_slug]");
537
- console.log("--from-index (optional) [number] the record index to start at when fetching the next round of records (helps with fetching all records over multiple requests)");
538
- console.log("--number-of-records (optional) [number] the number of records to fetch with one request");
539
- console.log("--compliance-exception-sort: (optional) [resource | check | type | created-at | expires-at | reason] the column on which to sort records by");
540
- console.log("--compliance-exception-sort-direction: (optional) [asc | desc] the direction to sort records by");
541
- console.log("--search-text: (optional) [string] search columns by this text");
542
- console.log('--type-filter: (optional) [mitigation and/or policy_exception] filter results by type. Ex: --type-filter "policy_exception, mitigation"');
543
- console.log('--status-filter: (optional) [active and/or expired] filter results by status. Ex: --status-filter "expired, active"');
544
- console.log("--expires-at-from: (optional) [string] the date at which to not show records before.");
545
- console.log("Format: UTC, example: '2022-08-23T17:00:00Z' to filter by August 8th, 2022 at 17:00 UTC.");
546
- console.log("--expires-at-to: (optional) [string] the date at which to not show records after.");
547
- console.log("Format: UTC, example: '2022-08-23T17:00:00Z' to filter by August 8th, 2022 at 17:00 UTC.");
548
- console.log('--check-ids-filter: (optional) [string] check ids to filter records by. Ex: --check-ids-filter "123, 456, 789"');
549
- console.log('--resource-ids-filter: (optional) [string] resource ids to filter records by. Ex: --resource-ids-filter "123, 456, 789"');
550
- console.log('--creator-ids-filter: (optional) [string] user ids to filter records by. Ex: --creator-ids-filter "123, 456, 789"');
551
- console.log();
552
- console.log("update-compliance-exception", "Updates single compliance exception record (i.e. mitigations and policy exceptions)");
553
- console.log("Parameters:");
554
- console.log("--id [record id]");
555
- console.log("--reason [string] the reason for the compliance exception");
556
- console.log("--expiresAt [string] the date at which to expire. If you want to remove a compliance exception from the list, set the expiresAt to todays date.");
557
- console.log("Format: UTC, example: '2022-08-23T17:00:00Z' to expire August 8th, 2022 at 17:00 UTC. To remove this field, pass in null.");
558
- console.log();
559
- console.log("update-compliance-exceptions", "Updates multiple compliance exceptions (i.e. mitigations and policy exceptions)");
560
- console.log("Parameters:");
561
- console.log("--id [record id]");
562
- console.log("--reason (optional) [string] the reason for the compliance exception");
563
- console.log("--expiresAt (optional) [string] the date at which to expire. If you want to remove a compliance exception from the list, set the expiresAt to todays date.");
564
- console.log("Format: UTC, example: '2022-08-23T17:00:00Z' to expire August 8th, 2022 at 17:00 UTC. To remove this field, pass in null.");
565
- console.log("OR --json-updates [stringified json objects with your updates]");
566
- console.log("For quick updates, you may use the above parameters");
567
- console.log('e.g. opscompass compliance update-compliance-exceptions --id 18 --reason "Valid exception reason" --id 3 --expires-at "09/15/2022"');
568
- console.log("For larger updates, JavaScript Object Notation (JSON) may be used with the --json-updates flag");
569
- console.log(`e.g. opscompass compliance update-compliance-exceptions --json-updates '[{\"id\":\"18\",\"reason\":\"Valid exception reason\"},{\"id\":\"3\",\"expiresAt\":\"2022-08-23T17:00:00Z\"}]'`);
570
- console.log();
571
- console.log("create-compliance-resource-check-exceptions", "Creates a new compliance resource check exception");
572
- console.log("Parameters:");
573
- console.log("--compliance-resource-check-id [the compliance resource check id]");
574
- console.log("--compliance-exception-type [string] the type of compliance exception: 'mitigation' or 'policy_exception'");
575
- console.log("--reason [string] the reason for the compliance resource check exception");
576
- console.log("--expires-at (optional) [string] the date at which to expire. If you want to remove a compliance exception from the list, set the expiresAt to todays date.");
577
- console.log("Format: UTC, example: '2022-08-23T17:00:00Z' to expire August 8th, 2022 at 17:00 UTC.");
578
- console.log();
579
- console.log("list-breaches", "Retrieves the list of breaches company emails have been involved in.");
580
- console.log("Parameters:");
581
- console.log("--company [company_slug]");
582
- console.log();
583
- console.log("list-breached-emails", "Retrieves the list of breached emails associated with a provided company");
584
- console.log("Parameters:");
585
- console.log("--company [company_slug]");
586
- console.log();
587
- console.log("list-breached-emails-of-concern", "Retrieves the list of breached emails that have not performed a password reset since a data breach.");
588
- console.log("Parameters:");
589
- console.log("--company [company_slug]");
590
- console.log();
591
- }
592
-
593
-
594
- const complianceModule = (action, ...args) => {
595
- switch (action?.toLowerCase() ?? "") {
596
- case "list-checks-with-details":
597
- return listChecksWithDetails(args);
598
- case "list-disabled-checks":
599
- return listDisabledChecks(args);
600
- case "list-frameworks-with-details":
601
- return listFrameworksWithDetails(args);
602
- case "list-frameworks":
603
- return listFrameworks(args);
604
- case "get-upcoming-exception-info":
605
- return getUpcomingExceptionInfo(args);
606
- case "get-check-status-overview":
607
- return getCheckStatusOverview(args);
608
- case "get-compliance-problems-over-time":
609
- return getComplianceProblemsOverTime(args);
610
- case "transfer-network-discovery-metadata":
611
- return transferNetworkDiscoveryMetadata(args);
612
- case "transfer-vmware-vsphere-metadata":
613
- return transferVMwareVsphereMetadata(args);
614
- case "transfer-oracle-database-metadata":
615
- return transferOracleDatabaseMetadata(args);
616
- case "transfer-sql-server-database-metadata":
617
- return transferSqlServerDatabaseMetadata(args);
618
- case "list-compliance-exceptions":
619
- return listComplianceExceptions(args);
620
- case "update-compliance-exception":
621
- return updateComplianceException(args);
622
- case "update-compliance-exceptions":
623
- return updateComplianceExceptions(args);
624
- case "create-compliance-resource-check-exception":
625
- return createComplianceResourceCheckException(args);
626
- case "list-breaches":
627
- return listBreaches(args);
628
- case "list-breached-emails":
629
- return listBreachedEmails(args);
630
- case "list-breached-emails-of-concern":
631
- return listBreachedEmailsOfConcern(args);
632
- case "help":
633
- case "":
634
- return printHelp();
635
- default:
636
- console.log("Unknown command:", action);
637
- return printHelp();
638
- }
639
- };
640
-
641
- complianceModule.requiresLogin = true;
642
- complianceModule.description = "Provides access to details about resource Compliance in OpsCompass.";
643
-
644
- module.exports = complianceModule;
805
+ complianceModule.requiresLogin = true;
806
+ complianceModule.description =
807
+ "Provides access to details about resource Compliance in OpsCompass.";
808
+
809
+ module.exports = complianceModule;