@axway/axway-central-cli 2.17.0 → 2.18.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/dist/cli.js +6 -28
- package/dist/commands/apply/index.js +9 -24
- package/dist/commands/completion/index.js +3 -9
- package/dist/commands/config/common/index.js +2 -11
- package/dist/commands/config/index.js +2 -7
- package/dist/commands/config/list.js +2 -6
- package/dist/commands/config/set.js +4 -31
- package/dist/commands/config/unset.js +2 -12
- package/dist/commands/create/agentResource.js +12 -32
- package/dist/commands/create/environment.js +6 -16
- package/dist/commands/create/index.js +9 -26
- package/dist/commands/create/serviceAccount.js +2 -6
- package/dist/commands/delete/index.js +15 -33
- package/dist/commands/edit/environment.js +6 -21
- package/dist/commands/edit/index.js +4 -8
- package/dist/commands/get/index.js +27 -44
- package/dist/commands/install/agents.js +41 -70
- package/dist/commands/install/apigeexSaasAgents.js +33 -96
- package/dist/commands/install/awsAgents.js +87 -137
- package/dist/commands/install/awsSaasAgents.js +48 -140
- package/dist/commands/install/azureAgents.js +37 -77
- package/dist/commands/install/edgeAgents.js +15 -108
- package/dist/commands/install/gitHubSaasAgents.js +286 -0
- package/dist/commands/install/helpers/creators.js +17 -70
- package/dist/commands/install/helpers/deleters.js +2 -11
- package/dist/commands/install/helpers/getters.js +4 -30
- package/dist/commands/install/helpers/index.js +13 -48
- package/dist/commands/install/helpers/inputs.js +26 -98
- package/dist/commands/install/helpers/regex.js +29 -34
- package/dist/commands/install/helpers/templates/awsTemplates.js +6 -23
- package/dist/commands/install/helpers/templates/azureTemplates.js +5 -24
- package/dist/commands/install/helpers/templates/edgeTemplates.js +7 -38
- package/dist/commands/install/helpers/templates/istioTemplates.js +5 -16
- package/dist/commands/install/index.js +4 -10
- package/dist/commands/install/istioAgents.js +38 -115
- package/dist/commands/install/platform.js +18 -50
- package/dist/commands/proxies/create.js +2 -18
- package/dist/commands/proxies/index.js +4 -8
- package/dist/commands/proxies/promote.js +2 -21
- package/dist/common/ApiServerClient.js +64 -173
- package/dist/common/CacheController.js +11 -32
- package/dist/common/CliConfigManager.js +14 -27
- package/dist/common/CompositeError.js +6 -30
- package/dist/common/CoreConfigController.js +18 -40
- package/dist/common/DefinitionsManager.js +29 -76
- package/dist/common/Kubectl.js +2 -25
- package/dist/common/PlatformClient.js +19 -63
- package/dist/common/Renderer.js +25 -87
- package/dist/common/TmpFile.js +11 -28
- package/dist/common/bashCommands.js +3 -22
- package/dist/common/basicPrompts.js +8 -43
- package/dist/common/dataService.js +22 -50
- package/dist/common/errorHandler.js +0 -9
- package/dist/common/resultsRenderers.js +10 -42
- package/dist/common/types.js +117 -342
- package/dist/common/utils.js +37 -99
- package/dist/main.js +0 -2
- package/package.json +2 -2
|
@@ -4,126 +4,82 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.testables = exports.askBundleType = exports.AWSSaaSInstallMethods = void 0;
|
|
7
|
-
|
|
8
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
|
|
10
8
|
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
11
|
-
|
|
12
9
|
var _basicPrompts = require("../../common/basicPrompts");
|
|
13
|
-
|
|
14
10
|
var _types = require("../../common/types");
|
|
15
|
-
|
|
16
11
|
var _utils = require("../../common/utils");
|
|
17
|
-
|
|
18
12
|
var helpers = _interopRequireWildcard(require("./helpers"));
|
|
19
|
-
|
|
20
13
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
21
|
-
|
|
22
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
-
|
|
24
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
30
20
|
const {
|
|
31
21
|
log
|
|
32
22
|
} = (0, _snooplogg.default)('central: install: agents: saas');
|
|
33
|
-
|
|
34
23
|
class DataplaneConfig {
|
|
35
24
|
constructor(type) {
|
|
36
25
|
_defineProperty(this, "type", void 0);
|
|
37
|
-
|
|
38
26
|
this.type = type || "";
|
|
39
27
|
}
|
|
40
|
-
|
|
41
28
|
}
|
|
42
|
-
|
|
43
29
|
class AWSDataplaneConfig extends DataplaneConfig {
|
|
44
30
|
constructor(arn) {
|
|
45
31
|
super("AWS");
|
|
46
|
-
|
|
47
32
|
_defineProperty(this, "accessLogARN", void 0);
|
|
48
|
-
|
|
49
33
|
this.accessLogARN = arn;
|
|
50
34
|
}
|
|
51
|
-
|
|
52
35
|
}
|
|
53
|
-
|
|
54
36
|
class Sampling {
|
|
55
37
|
constructor() {
|
|
56
38
|
_defineProperty(this, "percentage", void 0);
|
|
57
|
-
|
|
58
39
|
_defineProperty(this, "allErrors", void 0);
|
|
59
|
-
|
|
60
40
|
this.percentage = 10;
|
|
61
41
|
this.allErrors = true;
|
|
62
42
|
}
|
|
63
|
-
|
|
64
43
|
}
|
|
65
|
-
|
|
66
44
|
class Sanitize {
|
|
67
45
|
constructor(k, m) {
|
|
68
46
|
_defineProperty(this, "keyMatch", void 0);
|
|
69
|
-
|
|
70
47
|
_defineProperty(this, "valueMatch", void 0);
|
|
71
|
-
|
|
72
48
|
this.keyMatch = k;
|
|
73
49
|
this.valueMatch = m;
|
|
74
50
|
}
|
|
75
|
-
|
|
76
51
|
}
|
|
77
|
-
|
|
78
52
|
class RedactionSet {
|
|
79
53
|
constructor() {
|
|
80
54
|
_defineProperty(this, "show", void 0);
|
|
81
|
-
|
|
82
55
|
_defineProperty(this, "sanitize", void 0);
|
|
83
|
-
|
|
84
56
|
this.show = [];
|
|
85
57
|
this.sanitize = [];
|
|
86
58
|
}
|
|
87
|
-
|
|
88
59
|
}
|
|
89
|
-
|
|
90
60
|
class Redaction {
|
|
91
61
|
constructor() {
|
|
92
62
|
_defineProperty(this, "maskingCharacter", void 0);
|
|
93
|
-
|
|
94
63
|
_defineProperty(this, "path", void 0);
|
|
95
|
-
|
|
96
64
|
_defineProperty(this, "queryArgument", void 0);
|
|
97
|
-
|
|
98
65
|
_defineProperty(this, "requestHeaders", void 0);
|
|
99
|
-
|
|
100
66
|
_defineProperty(this, "responseHeaders", void 0);
|
|
101
|
-
|
|
102
67
|
this.maskingCharacter = "{*}";
|
|
103
68
|
this.path = [];
|
|
104
69
|
this.queryArgument = new RedactionSet();
|
|
105
70
|
this.requestHeaders = new RedactionSet();
|
|
106
71
|
this.responseHeaders = new RedactionSet();
|
|
107
72
|
}
|
|
108
|
-
|
|
109
73
|
}
|
|
110
|
-
|
|
111
74
|
class SaasAgentValues {
|
|
112
75
|
constructor() {
|
|
113
76
|
_defineProperty(this, "frequencyDA", void 0);
|
|
114
|
-
|
|
115
77
|
_defineProperty(this, "queueDA", void 0);
|
|
116
|
-
|
|
117
78
|
_defineProperty(this, "frequencyTA", void 0);
|
|
118
|
-
|
|
119
79
|
_defineProperty(this, "sampling", void 0);
|
|
120
|
-
|
|
121
80
|
_defineProperty(this, "redaction", void 0);
|
|
122
|
-
|
|
123
81
|
_defineProperty(this, "dataplaneConfig", void 0);
|
|
124
|
-
|
|
125
82
|
_defineProperty(this, "centralConfig", void 0);
|
|
126
|
-
|
|
127
83
|
this.frequencyDA = '';
|
|
128
84
|
this.queueDA = false;
|
|
129
85
|
this.frequencyTA = '';
|
|
@@ -132,31 +88,20 @@ class SaasAgentValues {
|
|
|
132
88
|
this.dataplaneConfig = new DataplaneConfig();
|
|
133
89
|
this.centralConfig = new _types.CentralAgentConfig();
|
|
134
90
|
}
|
|
135
|
-
|
|
136
91
|
getAccessData() {
|
|
137
92
|
return "";
|
|
138
93
|
}
|
|
139
|
-
|
|
140
94
|
}
|
|
141
|
-
|
|
142
95
|
class SaasAWSAgentValues extends SaasAgentValues {
|
|
143
96
|
constructor() {
|
|
144
97
|
super();
|
|
145
|
-
|
|
146
98
|
_defineProperty(this, "authType", void 0);
|
|
147
|
-
|
|
148
99
|
_defineProperty(this, "accessKey", void 0);
|
|
149
|
-
|
|
150
100
|
_defineProperty(this, "secretKey", void 0);
|
|
151
|
-
|
|
152
101
|
_defineProperty(this, "region", void 0);
|
|
153
|
-
|
|
154
102
|
_defineProperty(this, "assumeRole", void 0);
|
|
155
|
-
|
|
156
103
|
_defineProperty(this, "externalID", void 0);
|
|
157
|
-
|
|
158
104
|
_defineProperty(this, "accessLogARN", void 0);
|
|
159
|
-
|
|
160
105
|
this.authType = AWSAuthType.ASSUME;
|
|
161
106
|
this.accessKey = '';
|
|
162
107
|
this.secretKey = '';
|
|
@@ -165,14 +110,12 @@ class SaasAWSAgentValues extends SaasAgentValues {
|
|
|
165
110
|
this.externalID = '';
|
|
166
111
|
this.accessLogARN = '';
|
|
167
112
|
}
|
|
168
|
-
|
|
169
113
|
getAccessData() {
|
|
170
114
|
let data = JSON.stringify({
|
|
171
115
|
region: this.region,
|
|
172
116
|
roleARN: this.assumeRole,
|
|
173
117
|
externalID: this.externalID
|
|
174
118
|
});
|
|
175
|
-
|
|
176
119
|
if (this.authType == AWSAuthType.KEYS) {
|
|
177
120
|
data = JSON.stringify({
|
|
178
121
|
region: this.region,
|
|
@@ -180,22 +123,19 @@ class SaasAWSAgentValues extends SaasAgentValues {
|
|
|
180
123
|
secretAccessKey: this.secretKey
|
|
181
124
|
});
|
|
182
125
|
}
|
|
183
|
-
|
|
184
126
|
return data;
|
|
185
127
|
}
|
|
128
|
+
}
|
|
186
129
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const ConfigFiles = {}; // AWSAuthType - how the agent will authenticate to AWS
|
|
191
|
-
|
|
192
|
-
var AWSAuthType; // AWSSaaSPrompts - all AWS Saas prompts to the user for input
|
|
130
|
+
// ConfigFiles - all the config file that are used in the setup
|
|
131
|
+
const ConfigFiles = {};
|
|
193
132
|
|
|
194
|
-
|
|
133
|
+
// AWSAuthType - how the agent will authenticate to AWS
|
|
134
|
+
var AWSAuthType = /*#__PURE__*/function (AWSAuthType) {
|
|
195
135
|
AWSAuthType["ASSUME"] = "Assume Role Policy";
|
|
196
136
|
AWSAuthType["KEYS"] = "Access and Secret Keys";
|
|
197
|
-
|
|
198
|
-
|
|
137
|
+
return AWSAuthType;
|
|
138
|
+
}(AWSAuthType || {}); // AWSSaaSPrompts - all AWS Saas prompts to the user for input
|
|
199
139
|
const SaasPrompts = {
|
|
200
140
|
AUTHENTICATION_TYPE: 'Authenticate with an AssumeRole Policy or an Access Key ID and Secret Access Key',
|
|
201
141
|
ACCESS_KEY: 'Enter the AWS Access Key ID the agent will use',
|
|
@@ -215,28 +155,24 @@ const SaasPrompts = {
|
|
|
215
155
|
MASKING_CHARS: 'Enter the characters to use when sanitizing a value',
|
|
216
156
|
ENTER_MORE: 'Do you want to enter another {0} for {1}'
|
|
217
157
|
};
|
|
218
|
-
|
|
219
158
|
const askBundleType = async () => {
|
|
220
159
|
return await (0, _basicPrompts.askList)({
|
|
221
160
|
msg: helpers.agentMessages.selectAgentType,
|
|
222
161
|
choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
|
|
223
162
|
});
|
|
224
163
|
};
|
|
225
|
-
|
|
226
164
|
exports.askBundleType = askBundleType;
|
|
227
|
-
|
|
228
165
|
const askConfigType = async () => {
|
|
229
166
|
return _types.AgentConfigTypes.HOSTED;
|
|
230
|
-
};
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
//
|
|
231
170
|
// Complex prompts
|
|
232
171
|
//
|
|
233
|
-
|
|
234
|
-
|
|
235
172
|
const askForRedactionSet = async (setting, redactionSet) => {
|
|
236
173
|
// ask for path reg exs
|
|
237
174
|
let askShow = true;
|
|
238
175
|
console.log(_chalk.default.gray((0, _utils.FormatString)("\nRedaction settings for {0}s", setting)));
|
|
239
|
-
|
|
240
176
|
while (askShow) {
|
|
241
177
|
const input = await (0, _basicPrompts.askInput)({
|
|
242
178
|
msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, setting),
|
|
@@ -250,7 +186,6 @@ const askForRedactionSet = async (setting, redactionSet) => {
|
|
|
250
186
|
choices: _types.YesNoChoices
|
|
251
187
|
})) === _types.YesNo.Yes;
|
|
252
188
|
}
|
|
253
|
-
|
|
254
189
|
console.log(_chalk.default.gray((0, _utils.FormatString)("Sanitization settings for {0}s", setting)));
|
|
255
190
|
let askSanitize = (await (0, _basicPrompts.askList)({
|
|
256
191
|
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_SANITIZE_RULE, setting),
|
|
@@ -258,7 +193,6 @@ const askForRedactionSet = async (setting, redactionSet) => {
|
|
|
258
193
|
choices: _types.YesNoChoices
|
|
259
194
|
})) === _types.YesNo.Yes;
|
|
260
195
|
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
196
|
while (askSanitize) {
|
|
263
197
|
const keyMatch = await (0, _basicPrompts.askInput)({
|
|
264
198
|
msg: (0, _utils.FormatString)(SaasPrompts.SANITIZE_KEY, setting),
|
|
@@ -270,29 +204,24 @@ const askForRedactionSet = async (setting, redactionSet) => {
|
|
|
270
204
|
allowEmptyInput: true,
|
|
271
205
|
validate: (0, _basicPrompts.validateValidRegex)()
|
|
272
206
|
});
|
|
273
|
-
|
|
274
207
|
if (keyMatch === "" || valMatch === "") {
|
|
275
208
|
console.log("can't add sanitization rule with an empty key or value regular expression");
|
|
276
209
|
} else {
|
|
277
210
|
redactionSet.sanitize.push(new Sanitize(keyMatch, valMatch));
|
|
278
211
|
}
|
|
279
|
-
|
|
280
212
|
askSanitize = (await (0, _basicPrompts.askList)({
|
|
281
213
|
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, "sanitization rule", setting),
|
|
282
214
|
default: _types.YesNo.No,
|
|
283
215
|
choices: _types.YesNoChoices
|
|
284
216
|
})) === _types.YesNo.Yes;
|
|
285
217
|
}
|
|
286
|
-
|
|
287
218
|
return redactionSet;
|
|
288
219
|
};
|
|
289
|
-
|
|
290
220
|
const askForRedaction = async hostedAgentValues => {
|
|
291
|
-
console.log(_chalk.default.gray("\nRedaction and Sanitization settings"));
|
|
292
|
-
|
|
221
|
+
console.log(_chalk.default.gray("\nRedaction and Sanitization settings"));
|
|
222
|
+
// ask for path reg exps
|
|
293
223
|
let askPaths = true;
|
|
294
224
|
console.log(_chalk.default.gray("\nRedaction settings for URL paths"));
|
|
295
|
-
|
|
296
225
|
while (askPaths) {
|
|
297
226
|
const input = await (0, _basicPrompts.askInput)({
|
|
298
227
|
msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, "URL path"),
|
|
@@ -306,7 +235,6 @@ const askForRedaction = async hostedAgentValues => {
|
|
|
306
235
|
choices: _types.YesNoChoices
|
|
307
236
|
})) === _types.YesNo.Yes;
|
|
308
237
|
}
|
|
309
|
-
|
|
310
238
|
hostedAgentValues.redaction.queryArgument = await askForRedactionSet("query argument", hostedAgentValues.redaction.queryArgument);
|
|
311
239
|
hostedAgentValues.redaction.requestHeaders = await askForRedactionSet("request header", hostedAgentValues.redaction.requestHeaders);
|
|
312
240
|
hostedAgentValues.redaction.responseHeaders = await askForRedactionSet("response header", hostedAgentValues.redaction.responseHeaders);
|
|
@@ -317,7 +245,6 @@ const askForRedaction = async hostedAgentValues => {
|
|
|
317
245
|
});
|
|
318
246
|
return hostedAgentValues;
|
|
319
247
|
};
|
|
320
|
-
|
|
321
248
|
const askForSampling = async hostedAgentValues => {
|
|
322
249
|
// ask sampling percentage
|
|
323
250
|
console.log(_chalk.default.gray("\nSampling settings"));
|
|
@@ -327,19 +254,20 @@ const askForSampling = async hostedAgentValues => {
|
|
|
327
254
|
msg: SaasPrompts.SAMP_PERCENTAGE,
|
|
328
255
|
defaultValue: 10,
|
|
329
256
|
validate: (0, _basicPrompts.validateValueRange)(0, 50)
|
|
330
|
-
});
|
|
257
|
+
});
|
|
331
258
|
|
|
259
|
+
// ask sampling all errorsSN
|
|
332
260
|
hostedAgentValues.sampling.allErrors = (await (0, _basicPrompts.askList)({
|
|
333
261
|
msg: SaasPrompts.SAMP_ALL_ERRS,
|
|
334
262
|
choices: _types.YesNoChoices
|
|
335
263
|
})) === _types.YesNo.Yes;
|
|
336
264
|
return hostedAgentValues;
|
|
337
265
|
};
|
|
338
|
-
|
|
339
266
|
const askForAWSCredentials = async hostedAgentValues => {
|
|
340
267
|
hostedAgentValues.region = await helpers.askAWSRegion();
|
|
341
|
-
log("gathering access details for aws");
|
|
268
|
+
log("gathering access details for aws");
|
|
342
269
|
|
|
270
|
+
// Ask Auth type
|
|
343
271
|
hostedAgentValues.authType = await (0, _basicPrompts.askList)({
|
|
344
272
|
msg: SaasPrompts.AUTHENTICATION_TYPE,
|
|
345
273
|
default: AWSAuthType.ASSUME,
|
|
@@ -352,73 +280,66 @@ const askForAWSCredentials = async hostedAgentValues => {
|
|
|
352
280
|
}]
|
|
353
281
|
});
|
|
354
282
|
console.log(_chalk.default.gray("Please refer to docs.axway.com for information on creating the necessary AWS IAM policies"));
|
|
355
|
-
|
|
356
283
|
if (hostedAgentValues.authType === AWSAuthType.ASSUME) {
|
|
357
|
-
log("using an assume role policy authentication");
|
|
358
|
-
|
|
284
|
+
log("using an assume role policy authentication");
|
|
285
|
+
// get assume role arn
|
|
359
286
|
hostedAgentValues.assumeRole = await (0, _basicPrompts.askInput)({
|
|
360
287
|
msg: SaasPrompts.ASSUME_ROLE,
|
|
361
288
|
defaultValue: hostedAgentValues.assumeRole !== '' ? hostedAgentValues.assumeRole : undefined,
|
|
362
289
|
validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_ROLE_ARN, helpers.invalidValueExampleErrMsg('assume role arn', 'arn:aws:iam::000000000000:role/name-of-role'))
|
|
363
|
-
});
|
|
290
|
+
});
|
|
364
291
|
|
|
292
|
+
// get external id
|
|
365
293
|
hostedAgentValues.externalID = await (0, _basicPrompts.askInput)({
|
|
366
294
|
msg: SaasPrompts.EXTERNAL_ID,
|
|
367
295
|
defaultValue: hostedAgentValues.externalID !== '' ? hostedAgentValues.externalID : undefined,
|
|
368
296
|
allowEmptyInput: true
|
|
369
297
|
});
|
|
370
298
|
} else {
|
|
371
|
-
log("using key and secret authentication");
|
|
372
|
-
|
|
299
|
+
log("using key and secret authentication");
|
|
300
|
+
// get access key
|
|
373
301
|
hostedAgentValues.accessKey = await (0, _basicPrompts.askInput)({
|
|
374
302
|
msg: SaasPrompts.ACCESS_KEY,
|
|
375
303
|
defaultValue: hostedAgentValues.accessKey !== '' ? hostedAgentValues.accessKey : undefined,
|
|
376
304
|
validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_ACCESS_KEY_ID, helpers.invalidValueExampleErrMsg('access key id', 'AKIAIOSFODNN7EXAMPLE'))
|
|
377
|
-
});
|
|
305
|
+
});
|
|
378
306
|
|
|
307
|
+
// get secret access key
|
|
379
308
|
hostedAgentValues.secretKey = await (0, _basicPrompts.askInput)({
|
|
380
309
|
msg: SaasPrompts.SECRET_KEY,
|
|
381
310
|
defaultValue: hostedAgentValues.secretKey !== '' ? hostedAgentValues.secretKey : undefined,
|
|
382
311
|
validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_SECRET_ACCESS_KEY, helpers.invalidValueExampleErrMsg('secret access key', 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'))
|
|
383
312
|
});
|
|
384
313
|
}
|
|
385
|
-
|
|
386
314
|
return hostedAgentValues;
|
|
387
315
|
};
|
|
388
|
-
|
|
389
316
|
const validateFrequency = () => input => {
|
|
390
317
|
let val = (0, _basicPrompts.validateRegex)(helpers.frequencyRegex, helpers.invalidValueExampleErrMsg('frequency', '3d5h12m'))(input);
|
|
391
|
-
|
|
392
318
|
if (typeof val === "string") {
|
|
393
319
|
return val;
|
|
394
320
|
}
|
|
395
|
-
|
|
396
321
|
let r = input.toString().match(/^(\d*)m/);
|
|
397
|
-
|
|
398
322
|
if (r) {
|
|
399
323
|
// only minutes
|
|
400
324
|
let mins = r[1];
|
|
401
|
-
|
|
402
325
|
if (parseInt(mins, 10) < 30) {
|
|
403
326
|
return "Minimum frequency is 30m";
|
|
404
327
|
}
|
|
405
328
|
}
|
|
406
|
-
|
|
407
329
|
return true;
|
|
408
|
-
};
|
|
409
|
-
|
|
330
|
+
};
|
|
410
331
|
|
|
332
|
+
// @ts-ignore
|
|
411
333
|
const gatewayConnectivity = async installConfig => {
|
|
412
334
|
console.log('\nCONNECTION TO AMAZON API GATEWAY:');
|
|
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"));
|
|
335
|
+
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"));
|
|
414
336
|
|
|
337
|
+
// DeploymentType
|
|
415
338
|
let hostedAgentValues = new SaasAgentValues();
|
|
416
|
-
|
|
417
339
|
if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
|
|
418
340
|
// AWS connection details
|
|
419
341
|
hostedAgentValues = new SaasAWSAgentValues();
|
|
420
342
|
hostedAgentValues = await askForAWSCredentials(hostedAgentValues);
|
|
421
|
-
|
|
422
343
|
if (installConfig.switches.isTaEnabled) {
|
|
423
344
|
console.log(_chalk.default.gray("\nThe access log ARN is a cloud watch log group amazon resource name"));
|
|
424
345
|
hostedAgentValues.accessLogARN = await (0, _basicPrompts.askInput)({
|
|
@@ -426,9 +347,9 @@ const gatewayConnectivity = async installConfig => {
|
|
|
426
347
|
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
348
|
});
|
|
428
349
|
}
|
|
429
|
-
}
|
|
430
|
-
|
|
350
|
+
}
|
|
431
351
|
|
|
352
|
+
// Ask to queue discovery now
|
|
432
353
|
log("getting the frequency and if the agent should run now");
|
|
433
354
|
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
355
|
hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
|
|
@@ -441,7 +362,6 @@ const gatewayConnectivity = async installConfig => {
|
|
|
441
362
|
default: _types.YesNo.No,
|
|
442
363
|
choices: _types.YesNoChoices
|
|
443
364
|
})) === _types.YesNo.Yes;
|
|
444
|
-
|
|
445
365
|
if (installConfig.switches.isTaEnabled) {
|
|
446
366
|
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
367
|
hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
|
|
@@ -453,83 +373,72 @@ const gatewayConnectivity = async installConfig => {
|
|
|
453
373
|
hostedAgentValues = await askForSampling(hostedAgentValues);
|
|
454
374
|
hostedAgentValues = await askForRedaction(hostedAgentValues);
|
|
455
375
|
}
|
|
456
|
-
|
|
457
376
|
return hostedAgentValues;
|
|
458
377
|
};
|
|
459
|
-
|
|
460
378
|
const generateOutput = async installConfig => {
|
|
461
379
|
return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
|
|
462
380
|
};
|
|
463
|
-
|
|
464
381
|
const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
|
|
465
382
|
var _dataplaneRes$securit, _dataplaneRes$securit2;
|
|
466
|
-
|
|
467
383
|
// grab key from data plane resource
|
|
468
384
|
let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || "";
|
|
469
385
|
let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || "";
|
|
470
|
-
|
|
471
386
|
if (key === "" || hash === "") {
|
|
472
387
|
throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
|
|
473
388
|
}
|
|
474
|
-
|
|
475
389
|
let encData = _crypto.default.publicEncrypt({
|
|
476
390
|
key: key,
|
|
477
391
|
padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
|
|
478
392
|
oaepHash: hash
|
|
479
393
|
}, Buffer.from(hostedAgentValues.getAccessData()));
|
|
480
|
-
|
|
481
394
|
return encData.toString("base64");
|
|
482
395
|
};
|
|
483
|
-
|
|
484
396
|
const completeInstall = async (installConfig, apiServerClient, defsManager) => {
|
|
485
397
|
/**
|
|
486
398
|
* Create agent resources
|
|
487
399
|
*/
|
|
488
400
|
console.log("\n");
|
|
489
|
-
let awsAgentValues = installConfig.gatewayConfig;
|
|
401
|
+
let awsAgentValues = installConfig.gatewayConfig;
|
|
490
402
|
|
|
403
|
+
// create the environment, if necessary
|
|
491
404
|
installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
|
|
492
405
|
axwayManaged: installConfig.centralConfig.axwayManaged,
|
|
493
406
|
production: installConfig.centralConfig.production
|
|
494
407
|
}) : installConfig.centralConfig.ampcEnvInfo.name;
|
|
495
|
-
|
|
496
408
|
if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
|
|
497
409
|
awsAgentValues.dataplaneConfig = new AWSDataplaneConfig(awsAgentValues.accessLogARN);
|
|
498
|
-
}
|
|
499
|
-
|
|
410
|
+
}
|
|
500
411
|
|
|
501
|
-
|
|
412
|
+
// create the data plane resource
|
|
413
|
+
let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig);
|
|
502
414
|
|
|
415
|
+
// create data plane secret resource
|
|
503
416
|
try {
|
|
504
417
|
await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
|
|
505
418
|
} catch (error) {
|
|
506
419
|
console.log(_chalk.default.redBright("rolling back installation. Please check the credential data before re-running install"));
|
|
507
|
-
|
|
508
420
|
if (installConfig.centralConfig.ampcEnvInfo.isNew) {
|
|
509
421
|
await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
|
|
510
422
|
} else {
|
|
511
423
|
await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, "Dataplane", "dp", installConfig.centralConfig.environment);
|
|
512
424
|
}
|
|
513
|
-
|
|
514
425
|
return;
|
|
515
|
-
}
|
|
516
|
-
|
|
426
|
+
}
|
|
517
427
|
|
|
428
|
+
// create discovery agent resource
|
|
518
429
|
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
430
|
if (installConfig.switches.isTaEnabled) {
|
|
521
431
|
// 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,
|
|
432
|
+
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,
|
|
433
|
+
// AWS TA is never triggered at install, as DA has to run prior
|
|
523
434
|
{
|
|
524
435
|
sampling: awsAgentValues.sampling,
|
|
525
436
|
redaction: awsAgentValues.redaction
|
|
526
437
|
});
|
|
527
438
|
}
|
|
528
|
-
|
|
529
439
|
console.log(await generateOutput(installConfig));
|
|
530
440
|
};
|
|
531
|
-
|
|
532
|
-
const AWSSaaSInstallMethods = {
|
|
441
|
+
const AWSSaaSInstallMethods = exports.AWSSaaSInstallMethods = {
|
|
533
442
|
GetBundleType: askBundleType,
|
|
534
443
|
GetDeploymentType: askConfigType,
|
|
535
444
|
AskGatewayQuestions: gatewayConnectivity,
|
|
@@ -540,14 +449,13 @@ const AWSSaaSInstallMethods = {
|
|
|
540
449
|
[_types.AgentTypes.ta]: _types.AgentNames.AWS_TA
|
|
541
450
|
},
|
|
542
451
|
GatewayDisplay: _types.GatewayTypes.AWS_GATEWAY
|
|
543
|
-
};
|
|
452
|
+
};
|
|
544
453
|
|
|
545
|
-
|
|
546
|
-
const testables = {
|
|
454
|
+
// These are the items that are not exported, but need to be for testing
|
|
455
|
+
const testables = exports.testables = {
|
|
547
456
|
SaasAgentValues,
|
|
548
457
|
SaasAWSAgentValues,
|
|
549
458
|
AWSAuthType,
|
|
550
459
|
SaasPrompts,
|
|
551
460
|
ConfigFiles
|
|
552
|
-
};
|
|
553
|
-
exports.testables = testables;
|
|
461
|
+
};
|