@axway/axway-central-cli 2.15.1 → 2.16.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/da.yaml ADDED
@@ -0,0 +1,47 @@
1
+
2
+ ---
3
+ group: management
4
+ apiVersion: v1alpha1
5
+ kind: DiscoveryAgent
6
+ name: aws-discovery-agent
7
+ title: AWS Discovery Agent
8
+ metadata:
9
+ id: 8ac989a48947da6401894b06933a0008
10
+ audit:
11
+ createTimestamp: 2023-07-12T16:54:29.434+0000
12
+ createUserId: 821ba748-459f-45b0-ab87-82d11052975a
13
+ modifyTimestamp: 2023-07-12T16:54:30.276+0000
14
+ scope:
15
+ id: 8ac989a48947da6401894b068b940000
16
+ kind: Environment
17
+ name: aws-cli
18
+ title: aws-cli
19
+ selfLink: /management/v1alpha1/environments/aws-cli
20
+ acl: []
21
+ accessRights:
22
+ canChangeOwner: true
23
+ canDelete: true
24
+ canWrite: true
25
+ canRead: true
26
+ resourceVersion: '3'
27
+ references:
28
+ - id: 8ac989a48947da6401894b068d870002
29
+ kind: Dataplane
30
+ name: aws-dataplane
31
+ scopeKind: Environment
32
+ scopeName: aws-cli
33
+ selfLink: /management/v1alpha1/environments/aws-cli/dataplanes/aws-dataplane
34
+ type: soft
35
+ group: management
36
+ selfLink: >-
37
+ /management/v1alpha1/environments/aws-cli/discoveryagents/aws-discovery-agent
38
+ attributes: {}
39
+ finalizers: []
40
+ tags: []
41
+ spec:
42
+ config:
43
+ owningTeam: Default Team
44
+ dataplaneType: AWS
45
+ dataplane:
46
+ name: aws-dataplane
47
+ queueDiscovery: true
@@ -37,7 +37,7 @@ var helpers = _interopRequireWildcard(require("./helpers"));
37
37
 
38
38
  var istioAgents = _interopRequireWildcard(require("./istioAgents"));
39
39
 
40
- var saasAgents = _interopRequireWildcard(require("./saasAgents"));
40
+ var saasAgents = _interopRequireWildcard(require("./awsSaasAgents"));
41
41
 
42
42
  var platform = _interopRequireWildcard(require("./platform"));
43
43
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.testables = exports.AWSSaaSInstallMethods = void 0;
6
+ exports.testables = exports.askBundleType = exports.AWSSaaSInstallMethods = void 0;
7
7
 
8
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
9
 
@@ -13,6 +13,8 @@ var _basicPrompts = require("../../common/basicPrompts");
13
13
 
14
14
  var _types = require("../../common/types");
15
15
 
16
+ var _utils = require("../../common/utils");
17
+
16
18
  var helpers = _interopRequireWildcard(require("./helpers"));
17
19
 
18
20
  var _crypto = _interopRequireDefault(require("crypto"));
@@ -29,16 +31,105 @@ const {
29
31
  log
30
32
  } = (0, _snooplogg.default)('central: install: agents: saas');
31
33
 
34
+ class DataplaneConfig {
35
+ constructor(type) {
36
+ _defineProperty(this, "type", void 0);
37
+
38
+ this.type = type || "";
39
+ }
40
+
41
+ }
42
+
43
+ class AWSDataplaneConfig extends DataplaneConfig {
44
+ constructor(arn) {
45
+ super("AWS");
46
+
47
+ _defineProperty(this, "accessLogARN", void 0);
48
+
49
+ this.accessLogARN = arn;
50
+ }
51
+
52
+ }
53
+
54
+ class Sampling {
55
+ constructor() {
56
+ _defineProperty(this, "percentage", void 0);
57
+
58
+ _defineProperty(this, "allErrors", void 0);
59
+
60
+ this.percentage = 10;
61
+ this.allErrors = true;
62
+ }
63
+
64
+ }
65
+
66
+ class Sanitize {
67
+ constructor(k, m) {
68
+ _defineProperty(this, "keyMatch", void 0);
69
+
70
+ _defineProperty(this, "valMatch", void 0);
71
+
72
+ this.keyMatch = k;
73
+ this.valMatch = m;
74
+ }
75
+
76
+ }
77
+
78
+ class RedactionSet {
79
+ constructor() {
80
+ _defineProperty(this, "show", void 0);
81
+
82
+ _defineProperty(this, "sanitize", void 0);
83
+
84
+ this.show = [];
85
+ this.sanitize = [];
86
+ }
87
+
88
+ }
89
+
90
+ class Redaction {
91
+ constructor() {
92
+ _defineProperty(this, "maskingCharacter", void 0);
93
+
94
+ _defineProperty(this, "path", void 0);
95
+
96
+ _defineProperty(this, "queryArgument", void 0);
97
+
98
+ _defineProperty(this, "requestHeaders", void 0);
99
+
100
+ _defineProperty(this, "responseHeaders", void 0);
101
+
102
+ this.maskingCharacter = "{*}";
103
+ this.path = [];
104
+ this.queryArgument = new RedactionSet();
105
+ this.requestHeaders = new RedactionSet();
106
+ this.responseHeaders = new RedactionSet();
107
+ }
108
+
109
+ }
110
+
32
111
  class SaasAgentValues {
33
112
  constructor() {
34
- _defineProperty(this, "frequency", void 0);
113
+ _defineProperty(this, "frequencyDA", void 0);
35
114
 
36
- _defineProperty(this, "queue", void 0);
115
+ _defineProperty(this, "queueDA", void 0);
116
+
117
+ _defineProperty(this, "frequencyTA", void 0);
118
+
119
+ _defineProperty(this, "sampling", void 0);
120
+
121
+ _defineProperty(this, "redaction", void 0);
122
+
123
+ _defineProperty(this, "dataplaneConfig", void 0);
37
124
 
38
125
  _defineProperty(this, "centralConfig", void 0);
39
126
 
40
- this.frequency = '';
41
- this.queue = false;
127
+ this.frequencyDA = '';
128
+ this.queueDA = false;
129
+ this.frequencyTA = '';
130
+ this.sampling = new Sampling();
131
+ this.redaction = new Redaction();
132
+ this.dataplaneConfig = new DataplaneConfig();
42
133
  this.centralConfig = new _types.CentralAgentConfig();
43
134
  }
44
135
 
@@ -64,12 +155,15 @@ class SaasAWSAgentValues extends SaasAgentValues {
64
155
 
65
156
  _defineProperty(this, "externalID", void 0);
66
157
 
158
+ _defineProperty(this, "accessLogARN", void 0);
159
+
67
160
  this.authType = AWSAuthType.ASSUME;
68
161
  this.accessKey = '';
69
162
  this.secretKey = '';
70
163
  this.region = '';
71
164
  this.assumeRole = '';
72
165
  this.externalID = '';
166
+ this.accessLogARN = '';
73
167
  }
74
168
 
75
169
  getAccessData() {
@@ -108,14 +202,29 @@ const SaasPrompts = {
108
202
  SECRET_KEY: 'Enter the AWS Secret Access Key the agent will use',
109
203
  ASSUME_ROLE: 'Enter the Role ARN that the agent will Assume',
110
204
  EXTERNAL_ID: 'Enter the External ID the Assume Role expects',
111
- FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
112
- QUEUE: 'Do you want to discover immediately after installation'
205
+ ACCESS_LOG_ARN: 'Enter the ARN for the Access Log that the Discovery will add and the Traceability will use',
206
+ DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
207
+ TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
208
+ QUEUE: 'Do you want to discover immediately after installation',
209
+ SAMP_PERCENTAGE: 'Enter the percentage of transactions to sample',
210
+ SAMP_ALL_ERRS: 'Do you want to see all errors regardless of sampling',
211
+ REDACT_SHOW: 'Enter a regular expression for {0}s that may be shown',
212
+ ENTER_SANITIZE_RULE: 'Do you want to add sanitization rules for {0}s',
213
+ SANITIZE_KEY: 'Enter a regular expression for {0} keys that values should be sanitized',
214
+ SANITIZE_VAL: 'Enter a regular expression for sanitization of values when matching a {0} key',
215
+ MASKING_CHARS: 'Enter the characters to use when sanitizing a value',
216
+ ENTER_MORE: 'Do you want to enter another {0} for {1}'
113
217
  };
114
218
 
115
219
  const askBundleType = async () => {
116
- return _types.BundleType.DISCOVERY;
220
+ return await (0, _basicPrompts.askList)({
221
+ msg: helpers.agentMessages.selectAgentType,
222
+ choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
223
+ });
117
224
  };
118
225
 
226
+ exports.askBundleType = askBundleType;
227
+
119
228
  const askConfigType = async () => {
120
229
  return _types.AgentConfigTypes.HOSTED;
121
230
  }; //
@@ -123,6 +232,110 @@ const askConfigType = async () => {
123
232
  //
124
233
 
125
234
 
235
+ const askForRedactionSet = async (setting, redactionSet) => {
236
+ // ask for path reg exs
237
+ let askShow = true;
238
+ console.log(_chalk.default.gray((0, _utils.FormatString)("\nRedaction settings for {0}s", setting)));
239
+
240
+ while (askShow) {
241
+ const input = await (0, _basicPrompts.askInput)({
242
+ msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, setting),
243
+ defaultValue: ".*",
244
+ validate: (0, _basicPrompts.validateValidRegex)()
245
+ });
246
+ redactionSet.show.push(input);
247
+ askShow = (await (0, _basicPrompts.askList)({
248
+ msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, "redaction regular expression", setting),
249
+ default: _types.YesNo.No,
250
+ choices: _types.YesNoChoices
251
+ })) === _types.YesNo.Yes;
252
+ }
253
+
254
+ console.log(_chalk.default.gray((0, _utils.FormatString)("Sanitization settings for {0}s", setting)));
255
+ let askSanitize = (await (0, _basicPrompts.askList)({
256
+ msg: (0, _utils.FormatString)(SaasPrompts.ENTER_SANITIZE_RULE, setting),
257
+ default: _types.YesNo.No,
258
+ choices: _types.YesNoChoices
259
+ })) === _types.YesNo.Yes;
260
+ console.log(_chalk.default.gray("When a match for the key regular expression is found, a match\nfor the value regular expression will be replaced by the masking character(s)"));
261
+
262
+ while (askSanitize) {
263
+ const keyMatch = await (0, _basicPrompts.askInput)({
264
+ msg: (0, _utils.FormatString)(SaasPrompts.SANITIZE_KEY, setting),
265
+ allowEmptyInput: true,
266
+ validate: (0, _basicPrompts.validateValidRegex)()
267
+ });
268
+ const valMatch = await (0, _basicPrompts.askInput)({
269
+ msg: (0, _utils.FormatString)(SaasPrompts.SANITIZE_VAL, setting),
270
+ allowEmptyInput: true,
271
+ validate: (0, _basicPrompts.validateValidRegex)()
272
+ });
273
+
274
+ if (keyMatch === "" || valMatch === "") {
275
+ console.log("can't add sanitization rule with an empty key or value regular expression");
276
+ } else {
277
+ redactionSet.sanitize.push(new Sanitize(keyMatch, valMatch));
278
+ }
279
+
280
+ askSanitize = (await (0, _basicPrompts.askList)({
281
+ msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, "sanitization rule", setting),
282
+ default: _types.YesNo.No,
283
+ choices: _types.YesNoChoices
284
+ })) === _types.YesNo.Yes;
285
+ }
286
+
287
+ return redactionSet;
288
+ };
289
+
290
+ const askForRedaction = async hostedAgentValues => {
291
+ console.log(_chalk.default.gray("\nRedaction and Sanitization settings")); // ask for path reg exps
292
+
293
+ let askPaths = true;
294
+ console.log(_chalk.default.gray("\nRedaction settings for URL paths"));
295
+
296
+ while (askPaths) {
297
+ const input = await (0, _basicPrompts.askInput)({
298
+ msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, "URL path"),
299
+ defaultValue: ".*",
300
+ validate: (0, _basicPrompts.validateValidRegex)()
301
+ });
302
+ hostedAgentValues.redaction.path.push(input);
303
+ askPaths = (await (0, _basicPrompts.askList)({
304
+ msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, "redaction regular expression", "URL path"),
305
+ default: _types.YesNo.No,
306
+ choices: _types.YesNoChoices
307
+ })) === _types.YesNo.Yes;
308
+ }
309
+
310
+ hostedAgentValues.redaction.queryArgument = await askForRedactionSet("query argument", hostedAgentValues.redaction.queryArgument);
311
+ hostedAgentValues.redaction.requestHeaders = await askForRedactionSet("request header", hostedAgentValues.redaction.requestHeaders);
312
+ hostedAgentValues.redaction.responseHeaders = await askForRedactionSet("response header", hostedAgentValues.redaction.responseHeaders);
313
+ hostedAgentValues.redaction.maskingCharacter = await (0, _basicPrompts.askInput)({
314
+ msg: SaasPrompts.MASKING_CHARS,
315
+ defaultValue: "{*}",
316
+ validate: (0, _basicPrompts.validateRegex)(helpers.maskingRegex, "Please enter a valid value")
317
+ });
318
+ return hostedAgentValues;
319
+ };
320
+
321
+ const askForSampling = async hostedAgentValues => {
322
+ // ask sampling percentage
323
+ console.log(_chalk.default.gray("\nSampling settings"));
324
+ console.log(_chalk.default.gray("Sampling percentage can be a value from 0 to 50"));
325
+ hostedAgentValues.sampling.percentage = await (0, _basicPrompts.askInput)({
326
+ type: "number",
327
+ msg: SaasPrompts.SAMP_PERCENTAGE,
328
+ defaultValue: 10,
329
+ validate: (0, _basicPrompts.validateValueRange)(0, 50)
330
+ }); // ask sampling all errorsSN
331
+
332
+ hostedAgentValues.sampling.allErrors = (await (0, _basicPrompts.askList)({
333
+ msg: SaasPrompts.SAMP_ALL_ERRS,
334
+ choices: _types.YesNoChoices
335
+ })) === _types.YesNo.Yes;
336
+ return hostedAgentValues;
337
+ };
338
+
126
339
  const askForAWSCredentials = async hostedAgentValues => {
127
340
  hostedAgentValues.region = await helpers.askAWSRegion();
128
341
  log("gathering access details for aws"); // Ask Auth type
@@ -197,7 +410,7 @@ const validateFrequency = () => input => {
197
410
 
198
411
  const gatewayConnectivity = async installConfig => {
199
412
  console.log('\nCONNECTION TO AMAZON API GATEWAY:');
200
- console.log(_chalk.default.gray(`The Discovery Agent needs to connect to the AWS API Gateway to discover API's for publishing to Amplify Central`)); // DeploymentType
413
+ console.log(_chalk.default.gray("The Discovery Agent needs to connect to the AWS API Gateway to discover API's for publishing to Amplify Central")); // DeploymentType
201
414
 
202
415
  let hostedAgentValues = new SaasAgentValues();
203
416
 
@@ -205,21 +418,42 @@ const gatewayConnectivity = async installConfig => {
205
418
  // AWS connection details
206
419
  hostedAgentValues = new SaasAWSAgentValues();
207
420
  hostedAgentValues = await askForAWSCredentials(hostedAgentValues);
421
+
422
+ if (installConfig.switches.isTaEnabled) {
423
+ console.log(_chalk.default.gray("\nThe access log ARN is a cloud watch log group amazon resource name"));
424
+ hostedAgentValues.accessLogARN = await (0, _basicPrompts.askInput)({
425
+ msg: SaasPrompts.ACCESS_LOG_ARN,
426
+ validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_ACCESS_LOG_ARN, helpers.invalidValueExampleErrMsg('access log arn', 'arn:aws:logs:region:000000000000:log-group:log-group-name'))
427
+ });
428
+ }
208
429
  } // Ask to queue discovery now
209
430
 
210
431
 
211
432
  log("getting the frequency and if the agent should run now");
212
- console.log(_chalk.default.gray(`00d00h00m format, where 30m = 30 minutes, 1h = 1 hour, 7d = 7 days, and 7d1h30m = 7 days 1 hour and 30 minutes. Minimum of 30m.`));
213
- hostedAgentValues.frequency = await (0, _basicPrompts.askInput)({
214
- msg: SaasPrompts.FREQUENCY,
433
+ console.log(_chalk.default.gray("\n00d00h00m format, where 30m = 30 minutes, 1h = 1 hour, 7d = 7 days, and 7d1h30m = 7 days 1 hour and 30 minutes. Minimum of 30m."));
434
+ hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
435
+ msg: SaasPrompts.DA_FREQUENCY,
215
436
  validate: validateFrequency(),
216
437
  allowEmptyInput: true
217
438
  });
218
- hostedAgentValues.queue = (await (0, _basicPrompts.askList)({
439
+ hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
219
440
  msg: SaasPrompts.QUEUE,
220
441
  default: _types.YesNo.No,
221
442
  choices: _types.YesNoChoices
222
443
  })) === _types.YesNo.Yes;
444
+
445
+ if (installConfig.switches.isTaEnabled) {
446
+ console.log(_chalk.default.gray("\n00d00h00m format, where 30m = 30 minutes, 1h = 1 hour, 7d = 7 days, and 7d1h30m = 7 days 1 hour and 30 minutes. Minimum of 30m."));
447
+ hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
448
+ msg: SaasPrompts.TA_FREQUENCY,
449
+ defaultValue: "30m",
450
+ validate: validateFrequency(),
451
+ allowEmptyInput: true
452
+ });
453
+ hostedAgentValues = await askForSampling(hostedAgentValues);
454
+ hostedAgentValues = await askForRedaction(hostedAgentValues);
455
+ }
456
+
223
457
  return hostedAgentValues;
224
458
  };
225
459
 
@@ -251,14 +485,20 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
251
485
  /**
252
486
  * Create agent resources
253
487
  */
488
+ console.log("\n");
254
489
  let awsAgentValues = installConfig.gatewayConfig; // create the environment, if necessary
255
490
 
256
491
  installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
257
492
  axwayManaged: installConfig.centralConfig.axwayManaged,
258
493
  production: installConfig.centralConfig.production
259
- }) : installConfig.centralConfig.ampcEnvInfo.name; // create the data plane resource
494
+ }) : installConfig.centralConfig.ampcEnvInfo.name;
495
+
496
+ if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
497
+ awsAgentValues.dataplaneConfig = new AWSDataplaneConfig(awsAgentValues.accessLogARN);
498
+ } // create the data plane resource
499
+
260
500
 
261
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType]); // create data plane secret resource
501
+ let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig); // create data plane secret resource
262
502
 
263
503
  try {
264
504
  await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
@@ -275,7 +515,17 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
275
515
  } // create discovery agent resource
276
516
 
277
517
 
278
- installConfig.centralConfig.daAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.da, _types.AgentTypes.da, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Discovery Agent", dataplaneRes.name, awsAgentValues.frequency, awsAgentValues.queue);
518
+ installConfig.centralConfig.daAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.da, _types.AgentTypes.da, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Discovery Agent", dataplaneRes.name, awsAgentValues.frequencyDA, awsAgentValues.queueDA);
519
+
520
+ if (installConfig.switches.isTaEnabled) {
521
+ // create traceability agent resource
522
+ installConfig.centralConfig.taAgentName = await helpers.createNewAgentResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], _types.AgentResourceKind.ta, _types.AgentTypes.ta, installConfig.centralConfig.ampcTeamName, _types.GatewayTypeToDataPlane[installConfig.gatewayType] + " Traceability Agent", dataplaneRes.name, awsAgentValues.frequencyTA, false, // AWS TA is never triggered at install, as DA has to run prior
523
+ {
524
+ sampling: awsAgentValues.sampling,
525
+ redaction: awsAgentValues.redaction
526
+ });
527
+ }
528
+
279
529
  console.log(await generateOutput(installConfig));
280
530
  };
281
531
 
@@ -108,7 +108,7 @@ const createByResourceType = async (client, defsManager, name, resourceType, res
108
108
 
109
109
  exports.createByResourceType = createByResourceType;
110
110
 
111
- const createNewAgentResource = async (client, defsManager, envName, dataPlaneType, agentResource, agentType, owningTeam, agentName, dataPlaneName, frequency, queue) => {
111
+ const createNewAgentResource = async (client, defsManager, envName, dataPlaneType, agentResource, agentType, owningTeam, agentName, dataPlaneName, frequency, queue, config) => {
112
112
  console.log(`Creating a new ${agentResource}, with data plane type: ${dataPlaneType}.`); // NOTE: only a first found set is used
113
113
 
114
114
  const defs = defsManager.findDefsByWord(agentType);
@@ -126,23 +126,18 @@ const createNewAgentResource = async (client, defsManager, envName, dataPlaneTyp
126
126
  withSubResources = true;
127
127
  }
128
128
 
129
- if (frequency) {
130
- dataplane.frequency = frequency;
131
- }
132
-
133
- if (queue) {
134
- dataplane.queueDiscovery = queue;
135
- }
136
-
129
+ frequency ? dataplane.frequency = frequency : null;
130
+ queue ? agentResource === _types.AgentResourceKind.da ? dataplane.queueDiscovery = queue : dataplane.queueTrafficCollection = queue : null;
131
+ config ? null : config = {
132
+ owningTeam: owningTeam
133
+ };
137
134
  const result = await client.createResource({
138
135
  // @ts-ignore payload
139
136
  resource: {
140
137
  title: agentName,
141
138
  spec: {
142
139
  dataplaneType: dataPlaneType,
143
- config: {
144
- owningTeam: owningTeam
145
- }
140
+ config: config
146
141
  },
147
142
  dataplane: dataplane
148
143
  },
@@ -179,7 +174,7 @@ const createNewAgentResource = async (client, defsManager, envName, dataPlaneTyp
179
174
 
180
175
  exports.createNewAgentResource = createNewAgentResource;
181
176
 
182
- const createNewDataPlaneResource = async (client, defsManager, envName, dataPlaneType) => {
177
+ const createNewDataPlaneResource = async (client, defsManager, envName, dataPlaneType, config) => {
183
178
  console.log(`Creating a new Dataplane resource, with type: ${dataPlaneType}.`); // NOTE: only a first found set is used
184
179
 
185
180
  const defs = defsManager.findDefsByWord("dp");
@@ -193,7 +188,8 @@ const createNewDataPlaneResource = async (client, defsManager, envName, dataPlan
193
188
  resource: {
194
189
  title: dataPlaneType + " Dataplane",
195
190
  spec: {
196
- type: dataPlaneType
191
+ type: dataPlaneType,
192
+ config: config
197
193
  }
198
194
  },
199
195
  resourceDef: defs[0].resource,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceRegex = exports.percentageRegex = exports.namespaceRegex = exports.invalidResourceMsg = exports.invalidPercentage = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.AzureRegexPatterns = exports.AWSRegexPatterns = void 0;
6
+ exports.resourceRegex = exports.percentageRegex = exports.namespaceRegex = exports.maskingRegex = exports.invalidResourceMsg = exports.invalidPercentage = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.AzureRegexPatterns = exports.AWSRegexPatterns = void 0;
7
7
  const resourceRegex = '^(?:[a-z0-9]*(?:\\.(?=[a-z0-9])|-+(?=[a-z0-9]))?)+[a-z0-9]$';
8
8
  exports.resourceRegex = resourceRegex;
9
9
  const namespaceRegex = '^[a-z0-9]?(?:[-a-z0-9]*[a-z0-9]){1,100}?$';
@@ -16,6 +16,8 @@ const percentageRegex = '^[1-9][0-9]?$|^100$';
16
16
  exports.percentageRegex = percentageRegex;
17
17
  const frequencyRegex = '^(\\d*[d])?(\\d*[h])?(\\d*[m])?$|^$';
18
18
  exports.frequencyRegex = frequencyRegex;
19
+ const maskingRegex = '^[a-zA-Z0-9-*#^~.{}]{0,5}$';
20
+ exports.maskingRegex = maskingRegex;
19
21
  const invalidPercentage = 'Percentage must be an integer between 1-100';
20
22
  exports.invalidPercentage = invalidPercentage;
21
23
  const invalidDosaName = 'Account name can contain A-z 0-9 _ - ( ) [ ] and can include 1-100 characters.';
@@ -39,8 +41,9 @@ const AWSRegexPatterns = {
39
41
  AWS_REGEXP_SUBNET: '^subnet-[0-9a-z]*$|^$',
40
42
  AWS_REGEXP_SSH_LOCATION: '^\\d{1,3}(\\.\\d{1,3}){3}\\/\\d{1,2}$',
41
43
  AWS_REGEXP_ACCESS_KEY_ID: '((?:ASIA|AKIA|AROA|AIDA)([A-Z0-7]{16}))',
42
- AWS_REGEXP_SECRET_ACCESS_KEY: '([a-zA-Z0-9+/]{40})',
43
- AWS_REGEXP_ROLE_ARN: '^arn:(aws[a-zA-Z-]*)?:iam::\\d{12}:role\\/?[a-zA-Z_0-9+=,.@\\-_\\/]{1,128}$'
44
+ AWS_REGEXP_SECRET_ACCESS_KEY: '[a-zA-Z0-9+/]{40}',
45
+ AWS_REGEXP_ROLE_ARN: '^arn:aws[a-zA-Z-]*:iam::\\d{12}:role\\/?[a-zA-Z0-9+=,.@\\-_\\/]{1,128}$',
46
+ AWS_ACCESS_LOG_ARN: '^arn:aws[a-zA-Z-]*:logs:[a-zA-Z0-9\-]*:\\d{12}:log-group:[a-zA-Z0-9_\\-\\/\\.#]{1,512}$'
44
47
  }; // AzureRegexPatterns - regex patters to validate user inputs
45
48
 
46
49
  exports.AWSRegexPatterns = AWSRegexPatterns;
@@ -122,7 +122,7 @@ const getCentralConfig = async (apiServerClient, platformClient, defsManager, ap
122
122
 
123
123
  centralConfig.taAgentName = '';
124
124
 
125
- if (installConfig.switches.isTaEnabled) {
125
+ if (installConfig.switches.isTaEnabled && !installConfig.switches.isHostedInstall) {
126
126
  centralConfig.taAgentName = await helpers.askAgentName(apiServerClient, defsManager, _types.AgentTypes.ta, centralConfig.ampcEnvInfo.name);
127
127
  }
128
128
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.validateRegex = exports.validateNonEmptyInput = exports.validateInputIsNew = exports.runValidations = exports.filterEmptyNumberInput = exports.askUsernameAndPassword = exports.askList = exports.askInputValidation = exports.askInput = void 0;
6
+ exports.validateValueRange = exports.validateValidRegex = exports.validateRegex = exports.validateNonEmptyInput = exports.validateInputIsNew = exports.runValidations = exports.filterEmptyNumberInput = exports.askUsernameAndPassword = exports.askList = exports.askInputValidation = exports.askInput = void 0;
7
7
 
8
8
  var _inquirer = _interopRequireDefault(require("inquirer"));
9
9
 
@@ -32,13 +32,55 @@ const validateRegex = (regexp, message) => input => {
32
32
 
33
33
  exports.validateRegex = validateRegex;
34
34
 
35
+ const validateValidRegex = () => input => {
36
+ try {
37
+ new RegExp(input.toString());
38
+ } catch (error) {
39
+ return 'Please provide a valid regular expression.';
40
+ }
41
+
42
+ return true;
43
+ };
44
+
45
+ exports.validateValidRegex = validateValidRegex;
46
+
35
47
  const validateInputIsNew = (options, error) => input => {
36
48
  const isFound = options.find(opt => opt === input);
37
49
  return isFound ? error : true;
50
+ };
51
+
52
+ exports.validateInputIsNew = validateInputIsNew;
53
+
54
+ const validateValueRange = (lowerLimit, upperLimit) => input => {
55
+ const inputNum = Number(input);
56
+
57
+ if (isNaN(inputNum)) {
58
+ return 'Please provide a number.';
59
+ }
60
+
61
+ let msg = "";
62
+
63
+ if (typeof lowerLimit !== undefined && typeof upperLimit !== undefined) {
64
+ msg = `Please provide a number from ${lowerLimit} to ${upperLimit}`;
65
+ } else if (typeof lowerLimit !== undefined) {
66
+ msg = `Please provide a minimum number of ${lowerLimit}`;
67
+ } else if (typeof upperLimit !== undefined) {
68
+ msg = `Please provide a maximum number of ${upperLimit}`;
69
+ }
70
+
71
+ if (typeof lowerLimit !== undefined && inputNum < lowerLimit) {
72
+ return msg;
73
+ }
74
+
75
+ if (typeof upperLimit !== undefined && inputNum > upperLimit) {
76
+ return msg;
77
+ }
78
+
79
+ return true;
38
80
  }; // exporting for test
39
81
 
40
82
 
41
- exports.validateInputIsNew = validateInputIsNew;
83
+ exports.validateValueRange = validateValueRange;
42
84
 
43
85
  const validateNonEmptyInput = input => {
44
86
  return String(input).length ? true : 'Please provide a non-empty value.';
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.FormatString = FormatString;
6
7
  exports.parseScopeParam = exports.loadAndVerifySpecs = exports.isWindows = exports.isValidJson = exports.isApiServerErrorType = exports.isApiServerErrorResponseType = exports.hbsCompare = exports.getConfig = exports.configFile = exports.compareResourcesByKindDesc = exports.compareResourcesByKindAsc = exports.buildTemplate = exports.buildGenericResource = void 0;
7
8
  exports.sanitizeMetadata = sanitizeMetadata;
8
9
  exports.writeToFile = exports.writeTemplates = exports.verifyScopeParam = exports.verifyFile = exports.transformSimpleFilters = void 0;
@@ -403,4 +404,12 @@ const transformSimpleFilters = (title, attribute, tag) => {
403
404
  return transformedFilter;
404
405
  };
405
406
 
406
- exports.transformSimpleFilters = transformSimpleFilters;
407
+ exports.transformSimpleFilters = transformSimpleFilters;
408
+
409
+ function FormatString(str, ...val) {
410
+ for (let index = 0; index < val.length; index++) {
411
+ str = str.replace(`{${index}}`, val[index]);
412
+ }
413
+
414
+ return str;
415
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "2.15.1",
3
+ "version": "2.16.0",
4
4
  "description": "Manage APIs, services and publish to the Unified Catalog",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {