@axway/axway-central-cli 4.5.0 → 4.6.0-rc.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/.security-profile-branches.json +18 -0
- package/package.json +1 -1
- package/dist/cli.js +0 -71
- package/dist/commands/apply/index.js +0 -112
- package/dist/commands/completion/index.js +0 -100
- package/dist/commands/config/common/index.js +0 -28
- package/dist/commands/config/index.js +0 -20
- package/dist/commands/config/list.js +0 -24
- package/dist/commands/config/set.js +0 -102
- package/dist/commands/config/unset.js +0 -48
- package/dist/commands/create/agentResource.js +0 -108
- package/dist/commands/create/environment.js +0 -62
- package/dist/commands/create/index.js +0 -109
- package/dist/commands/create/serviceAccount.js +0 -15
- package/dist/commands/delete/index.js +0 -196
- package/dist/commands/edit/environment.js +0 -101
- package/dist/commands/edit/index.js +0 -28
- package/dist/commands/get/index.js +0 -272
- package/dist/commands/install/agents.js +0 -290
- package/dist/commands/install/apigeexAgents.js +0 -223
- package/dist/commands/install/apigeexSaasAgents.js +0 -300
- package/dist/commands/install/awsAgents.js +0 -525
- package/dist/commands/install/awsSaasAgents.js +0 -508
- package/dist/commands/install/azureAgents.js +0 -242
- package/dist/commands/install/azureSaasAgents.js +0 -519
- package/dist/commands/install/backstageAgents.js +0 -167
- package/dist/commands/install/edgeAgents.js +0 -409
- package/dist/commands/install/gitHubSaasAgents.js +0 -294
- package/dist/commands/install/gitLabAgents.js +0 -178
- package/dist/commands/install/graylogAgent.js +0 -147
- package/dist/commands/install/helpers/creators.js +0 -359
- package/dist/commands/install/helpers/deleters.js +0 -36
- package/dist/commands/install/helpers/getters.js +0 -95
- package/dist/commands/install/helpers/index.js +0 -267
- package/dist/commands/install/helpers/inputs.js +0 -593
- package/dist/commands/install/helpers/regex.js +0 -67
- package/dist/commands/install/helpers/templates/apigeexTemplates.js +0 -109
- package/dist/commands/install/helpers/templates/awsTemplates.js +0 -129
- package/dist/commands/install/helpers/templates/azureTemplates.js +0 -125
- package/dist/commands/install/helpers/templates/backstageTemplates.js +0 -95
- package/dist/commands/install/helpers/templates/edgeTemplates.js +0 -360
- package/dist/commands/install/helpers/templates/gitLabTemplates.js +0 -66
- package/dist/commands/install/helpers/templates/graylogTemplates.js +0 -75
- package/dist/commands/install/helpers/templates/ibmAPIConnectTemplates.js +0 -116
- package/dist/commands/install/helpers/templates/istioTemplates.js +0 -214
- package/dist/commands/install/helpers/templates/kafkaTemplates.js +0 -194
- package/dist/commands/install/helpers/templates/sapApiPortalTemplates.js +0 -114
- package/dist/commands/install/helpers/templates/softwareAGWebMethodsTemplates.js +0 -93
- package/dist/commands/install/helpers/templates/traceableTemplates.js +0 -135
- package/dist/commands/install/helpers/templates/wso2Templates.js +0 -85
- package/dist/commands/install/helpers/util.js +0 -26
- package/dist/commands/install/ibmAPIConnectAgents.js +0 -213
- package/dist/commands/install/index.js +0 -36
- package/dist/commands/install/istioAgents.js +0 -346
- package/dist/commands/install/kafkaAgents.js +0 -303
- package/dist/commands/install/platform.js +0 -175
- package/dist/commands/install/sapApiPortalAgents.js +0 -198
- package/dist/commands/install/softwareAGWebMethodsAgents.js +0 -161
- package/dist/commands/install/swaggerHubSaasAgents.js +0 -272
- package/dist/commands/install/traceableAgents.js +0 -257
- package/dist/commands/install/traceableSaasAgents.js +0 -275
- package/dist/commands/install/wso2Agents.js +0 -163
- package/dist/commands/productize/helpers/productizationHelper.js +0 -408
- package/dist/commands/productize/index.js +0 -99
- package/dist/common/ApiServerClient.js +0 -1109
- package/dist/common/CacheController.js +0 -146
- package/dist/common/CliConfigManager.js +0 -76
- package/dist/common/CompositeError.js +0 -95
- package/dist/common/CoreConfigController.js +0 -174
- package/dist/common/DefinitionsManager.js +0 -298
- package/dist/common/Kubectl.js +0 -68
- package/dist/common/PlatformClient.js +0 -128
- package/dist/common/Renderer.js +0 -409
- package/dist/common/TmpFile.js +0 -96
- package/dist/common/bashCommands.js +0 -97
- package/dist/common/basicPrompts.js +0 -160
- package/dist/common/dataService.js +0 -312
- package/dist/common/errorHandler.js +0 -46
- package/dist/common/modules.d.js +0 -1
- package/dist/common/resultsRenderers.js +0 -164
- package/dist/common/types.js +0 -746
- package/dist/common/utils.js +0 -476
- package/dist/main.js +0 -8
|
@@ -1,508 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.testables = exports.askBundleType = exports.AWSSaaSInstallMethods = void 0;
|
|
7
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
-
var _snooplogg = _interopRequireDefault(require("snooplogg"));
|
|
9
|
-
var _basicPrompts = require("../../common/basicPrompts");
|
|
10
|
-
var _types = require("../../common/types");
|
|
11
|
-
var _utils = require("../../common/utils");
|
|
12
|
-
var _agents = require("./agents");
|
|
13
|
-
var helpers = _interopRequireWildcard(require("./helpers"));
|
|
14
|
-
var _crypto = _interopRequireDefault(require("crypto"));
|
|
15
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
19
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
-
const {
|
|
21
|
-
log
|
|
22
|
-
} = (0, _snooplogg.default)('engage: install: agents: saas');
|
|
23
|
-
const STAGE_TAG_NAME_LENGTH = 127;
|
|
24
|
-
class DataplaneConfig {
|
|
25
|
-
constructor(type) {
|
|
26
|
-
_defineProperty(this, "type", void 0);
|
|
27
|
-
this.type = type || '';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
class AWSDataplaneConfig extends DataplaneConfig {
|
|
31
|
-
constructor(arn, enableFullTransactionLogging, stageTagName) {
|
|
32
|
-
super('AWS');
|
|
33
|
-
_defineProperty(this, "accessLogARN", void 0);
|
|
34
|
-
_defineProperty(this, "fullTransactionLogging", void 0);
|
|
35
|
-
_defineProperty(this, "stageTagName", void 0);
|
|
36
|
-
this.accessLogARN = arn;
|
|
37
|
-
this.fullTransactionLogging = enableFullTransactionLogging;
|
|
38
|
-
this.stageTagName = stageTagName;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
class Sanitize {
|
|
42
|
-
constructor(k, m) {
|
|
43
|
-
_defineProperty(this, "keyMatch", void 0);
|
|
44
|
-
_defineProperty(this, "valueMatch", void 0);
|
|
45
|
-
this.keyMatch = k;
|
|
46
|
-
this.valueMatch = m;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
class RedactionSet {
|
|
50
|
-
constructor() {
|
|
51
|
-
_defineProperty(this, "show", void 0);
|
|
52
|
-
_defineProperty(this, "sanitize", void 0);
|
|
53
|
-
this.show = [];
|
|
54
|
-
this.sanitize = [];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
class Redaction {
|
|
58
|
-
constructor() {
|
|
59
|
-
_defineProperty(this, "maskingCharacter", void 0);
|
|
60
|
-
_defineProperty(this, "path", void 0);
|
|
61
|
-
_defineProperty(this, "queryArgument", void 0);
|
|
62
|
-
_defineProperty(this, "requestHeaders", void 0);
|
|
63
|
-
_defineProperty(this, "responseHeaders", void 0);
|
|
64
|
-
this.maskingCharacter = '{*}';
|
|
65
|
-
this.path = [];
|
|
66
|
-
this.queryArgument = new RedactionSet();
|
|
67
|
-
this.requestHeaders = new RedactionSet();
|
|
68
|
-
this.responseHeaders = new RedactionSet();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
class SaasAgentValues {
|
|
72
|
-
constructor() {
|
|
73
|
-
_defineProperty(this, "frequencyDA", void 0);
|
|
74
|
-
_defineProperty(this, "queueDA", void 0);
|
|
75
|
-
_defineProperty(this, "filterDA", void 0);
|
|
76
|
-
_defineProperty(this, "frequencyTA", void 0);
|
|
77
|
-
_defineProperty(this, "redaction", void 0);
|
|
78
|
-
_defineProperty(this, "dataplaneConfig", void 0);
|
|
79
|
-
_defineProperty(this, "centralConfig", void 0);
|
|
80
|
-
this.frequencyDA = '';
|
|
81
|
-
this.queueDA = false;
|
|
82
|
-
this.frequencyTA = '';
|
|
83
|
-
this.filterDA = '';
|
|
84
|
-
this.redaction = new Redaction();
|
|
85
|
-
this.dataplaneConfig = new DataplaneConfig();
|
|
86
|
-
this.centralConfig = new _types.CentralAgentConfig();
|
|
87
|
-
}
|
|
88
|
-
getAccessData() {
|
|
89
|
-
return '';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
class SaasAWSAgentValues extends SaasAgentValues {
|
|
93
|
-
constructor() {
|
|
94
|
-
super();
|
|
95
|
-
_defineProperty(this, "authType", void 0);
|
|
96
|
-
_defineProperty(this, "accessKey", void 0);
|
|
97
|
-
_defineProperty(this, "secretKey", void 0);
|
|
98
|
-
_defineProperty(this, "region", void 0);
|
|
99
|
-
_defineProperty(this, "assumeRole", void 0);
|
|
100
|
-
_defineProperty(this, "externalID", void 0);
|
|
101
|
-
_defineProperty(this, "accessLogARN", void 0);
|
|
102
|
-
_defineProperty(this, "fullTransactionLogging", void 0);
|
|
103
|
-
_defineProperty(this, "stageTagName", void 0);
|
|
104
|
-
this.authType = AWSAuthType.ASSUME;
|
|
105
|
-
this.accessKey = '';
|
|
106
|
-
this.secretKey = '';
|
|
107
|
-
this.region = '';
|
|
108
|
-
this.assumeRole = '';
|
|
109
|
-
this.externalID = '';
|
|
110
|
-
this.accessLogARN = '';
|
|
111
|
-
this.fullTransactionLogging = false;
|
|
112
|
-
this.stageTagName = '';
|
|
113
|
-
}
|
|
114
|
-
getAccessData() {
|
|
115
|
-
let data = JSON.stringify({
|
|
116
|
-
region: this.region,
|
|
117
|
-
roleARN: this.assumeRole,
|
|
118
|
-
externalID: this.externalID
|
|
119
|
-
});
|
|
120
|
-
if (this.authType == AWSAuthType.KEYS) {
|
|
121
|
-
data = JSON.stringify({
|
|
122
|
-
region: this.region,
|
|
123
|
-
accessKeyID: this.accessKey,
|
|
124
|
-
secretAccessKey: this.secretKey
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return data;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// ConfigFiles - all the config file that are used in the setup
|
|
132
|
-
const ConfigFiles = {};
|
|
133
|
-
|
|
134
|
-
// AWSAuthType - how the agent will authenticate to AWS
|
|
135
|
-
var AWSAuthType = /*#__PURE__*/function (AWSAuthType) {
|
|
136
|
-
AWSAuthType["ASSUME"] = "Assume Role Policy";
|
|
137
|
-
AWSAuthType["KEYS"] = "Access and Secret Keys";
|
|
138
|
-
return AWSAuthType;
|
|
139
|
-
}(AWSAuthType || {}); // AWSSaaSPrompts - all AWS Saas prompts to the user for input
|
|
140
|
-
const SaasPrompts = {
|
|
141
|
-
AUTHENTICATION_TYPE: 'Authenticate with an AssumeRole Policy or an Access Key ID and Secret Access Key',
|
|
142
|
-
ACCESS_KEY: 'Enter the AWS Access Key ID the agent will use',
|
|
143
|
-
SECRET_KEY: 'Enter the AWS Secret Access Key the agent will use',
|
|
144
|
-
ASSUME_ROLE: 'Enter the Role ARN that the agent will Assume',
|
|
145
|
-
EXTERNAL_ID: 'Enter the External ID the Assume Role expects',
|
|
146
|
-
ACCESS_LOG_ARN: 'Enter the ARN for the Access Log that the Discovery will add and the Traceability will use',
|
|
147
|
-
STAGE_TAG_NAME: 'Enter the name of the tag on AWS API Gateway Stage that holds mapped stage on Amplify Engage',
|
|
148
|
-
FULL_TRANSACTION_LOGGING: 'Do you want to enable Full Transaction Logging? Please note that CloudWatch costs would increase when Full Transaction Logging is enabled',
|
|
149
|
-
DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
|
|
150
|
-
DA_FILTER: 'Please enter the filter conditions for discovery of API Services based on tags',
|
|
151
|
-
TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
|
|
152
|
-
QUEUE: 'Do you want to discover immediately after installation',
|
|
153
|
-
REDACT_SHOW: 'Enter a regular expression for {0}s that may be shown',
|
|
154
|
-
ENTER_SANITIZE_RULE: 'Do you want to add sanitization rules for {0}s',
|
|
155
|
-
SANITIZE_KEY: 'Enter a regular expression for {0} keys that values should be sanitized',
|
|
156
|
-
SANITIZE_VAL: 'Enter a regular expression for sanitization of values when matching a {0} key',
|
|
157
|
-
MASKING_CHARS: 'Enter the characters to use when sanitizing a value',
|
|
158
|
-
ENTER_MORE: 'Do you want to enter another {0} for {1}'
|
|
159
|
-
};
|
|
160
|
-
const askBundleType = async () => {
|
|
161
|
-
return await (0, _basicPrompts.askList)({
|
|
162
|
-
msg: helpers.agentMessages.selectAgentType,
|
|
163
|
-
choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
exports.askBundleType = askBundleType;
|
|
167
|
-
const askConfigType = async () => {
|
|
168
|
-
return _types.AgentConfigTypes.HOSTED;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
//
|
|
172
|
-
// Complex prompts
|
|
173
|
-
//
|
|
174
|
-
const askForRedactionSet = async (setting, redactionSet) => {
|
|
175
|
-
// ask for path reg exs
|
|
176
|
-
let askShow = true;
|
|
177
|
-
console.log(_chalk.default.gray((0, _utils.FormatString)('\nRedaction settings for {0}s', setting)));
|
|
178
|
-
while (askShow) {
|
|
179
|
-
const input = await (0, _basicPrompts.askInput)({
|
|
180
|
-
msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, setting),
|
|
181
|
-
defaultValue: '.*',
|
|
182
|
-
validate: (0, _basicPrompts.validateValidRegex)()
|
|
183
|
-
});
|
|
184
|
-
redactionSet.show.push(input);
|
|
185
|
-
askShow = (await (0, _basicPrompts.askList)({
|
|
186
|
-
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, 'redaction regular expression', setting),
|
|
187
|
-
default: _types.YesNo.No,
|
|
188
|
-
choices: _types.YesNoChoices
|
|
189
|
-
})) === _types.YesNo.Yes;
|
|
190
|
-
}
|
|
191
|
-
console.log(_chalk.default.gray((0, _utils.FormatString)('Sanitization settings for {0}s', setting)));
|
|
192
|
-
let askSanitize = (await (0, _basicPrompts.askList)({
|
|
193
|
-
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_SANITIZE_RULE, setting),
|
|
194
|
-
default: _types.YesNo.No,
|
|
195
|
-
choices: _types.YesNoChoices
|
|
196
|
-
})) === _types.YesNo.Yes;
|
|
197
|
-
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)'));
|
|
198
|
-
while (askSanitize) {
|
|
199
|
-
const keyMatch = await (0, _basicPrompts.askInput)({
|
|
200
|
-
msg: (0, _utils.FormatString)(SaasPrompts.SANITIZE_KEY, setting),
|
|
201
|
-
allowEmptyInput: true,
|
|
202
|
-
validate: (0, _basicPrompts.validateValidRegex)()
|
|
203
|
-
});
|
|
204
|
-
const valMatch = await (0, _basicPrompts.askInput)({
|
|
205
|
-
msg: (0, _utils.FormatString)(SaasPrompts.SANITIZE_VAL, setting),
|
|
206
|
-
allowEmptyInput: true,
|
|
207
|
-
validate: (0, _basicPrompts.validateValidRegex)()
|
|
208
|
-
});
|
|
209
|
-
if (keyMatch === '' || valMatch === '') {
|
|
210
|
-
console.log("can't add sanitization rule with an empty key or value regular expression");
|
|
211
|
-
} else {
|
|
212
|
-
redactionSet.sanitize.push(new Sanitize(keyMatch, valMatch));
|
|
213
|
-
}
|
|
214
|
-
askSanitize = (await (0, _basicPrompts.askList)({
|
|
215
|
-
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, 'sanitization rule', setting),
|
|
216
|
-
default: _types.YesNo.No,
|
|
217
|
-
choices: _types.YesNoChoices
|
|
218
|
-
})) === _types.YesNo.Yes;
|
|
219
|
-
}
|
|
220
|
-
return redactionSet;
|
|
221
|
-
};
|
|
222
|
-
const askForRedaction = async hostedAgentValues => {
|
|
223
|
-
console.log(_chalk.default.gray('\nRedaction and Sanitization settings'));
|
|
224
|
-
// ask for path reg exps
|
|
225
|
-
let askPaths = true;
|
|
226
|
-
console.log(_chalk.default.gray('\nRedaction settings for URL paths'));
|
|
227
|
-
while (askPaths) {
|
|
228
|
-
const input = await (0, _basicPrompts.askInput)({
|
|
229
|
-
msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, 'URL path'),
|
|
230
|
-
defaultValue: '.*',
|
|
231
|
-
validate: (0, _basicPrompts.validateValidRegex)()
|
|
232
|
-
});
|
|
233
|
-
hostedAgentValues.redaction.path.push(input);
|
|
234
|
-
askPaths = (await (0, _basicPrompts.askList)({
|
|
235
|
-
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, 'redaction regular expression', 'URL path'),
|
|
236
|
-
default: _types.YesNo.No,
|
|
237
|
-
choices: _types.YesNoChoices
|
|
238
|
-
})) === _types.YesNo.Yes;
|
|
239
|
-
}
|
|
240
|
-
hostedAgentValues.redaction.queryArgument = await askForRedactionSet('query argument', hostedAgentValues.redaction.queryArgument);
|
|
241
|
-
hostedAgentValues.redaction.requestHeaders = await askForRedactionSet('request header', hostedAgentValues.redaction.requestHeaders);
|
|
242
|
-
hostedAgentValues.redaction.responseHeaders = await askForRedactionSet('response header', hostedAgentValues.redaction.responseHeaders);
|
|
243
|
-
hostedAgentValues.redaction.maskingCharacter = await (0, _basicPrompts.askInput)({
|
|
244
|
-
msg: SaasPrompts.MASKING_CHARS,
|
|
245
|
-
defaultValue: '{*}',
|
|
246
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.maskingRegex, 'Please enter a valid value')
|
|
247
|
-
});
|
|
248
|
-
return hostedAgentValues;
|
|
249
|
-
};
|
|
250
|
-
const askForAWSCredentials = async hostedAgentValues => {
|
|
251
|
-
hostedAgentValues.region = await helpers.askAWSRegion();
|
|
252
|
-
log('gathering access details for aws');
|
|
253
|
-
|
|
254
|
-
// Ask Auth type
|
|
255
|
-
hostedAgentValues.authType = await (0, _basicPrompts.askList)({
|
|
256
|
-
msg: SaasPrompts.AUTHENTICATION_TYPE,
|
|
257
|
-
default: AWSAuthType.ASSUME,
|
|
258
|
-
choices: [{
|
|
259
|
-
name: AWSAuthType.ASSUME,
|
|
260
|
-
value: AWSAuthType.ASSUME
|
|
261
|
-
}, {
|
|
262
|
-
name: AWSAuthType.KEYS,
|
|
263
|
-
value: AWSAuthType.KEYS
|
|
264
|
-
}]
|
|
265
|
-
});
|
|
266
|
-
console.log(_chalk.default.gray('Please refer to docs.axway.com for information on creating the necessary AWS IAM policies'));
|
|
267
|
-
if (hostedAgentValues.authType === AWSAuthType.ASSUME) {
|
|
268
|
-
log('using an assume role policy authentication');
|
|
269
|
-
// get assume role arn
|
|
270
|
-
hostedAgentValues.assumeRole = await (0, _basicPrompts.askInput)({
|
|
271
|
-
msg: SaasPrompts.ASSUME_ROLE,
|
|
272
|
-
defaultValue: hostedAgentValues.assumeRole !== '' ? hostedAgentValues.assumeRole : undefined,
|
|
273
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_ROLE_ARN, helpers.invalidValueExampleErrMsg('assume role arn', 'arn:aws:iam::000000000000:role/name-of-role'))
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// get external id
|
|
277
|
-
hostedAgentValues.externalID = await (0, _basicPrompts.askInput)({
|
|
278
|
-
msg: SaasPrompts.EXTERNAL_ID,
|
|
279
|
-
defaultValue: hostedAgentValues.externalID !== '' ? hostedAgentValues.externalID : undefined,
|
|
280
|
-
allowEmptyInput: true
|
|
281
|
-
});
|
|
282
|
-
} else {
|
|
283
|
-
log('using key and secret authentication');
|
|
284
|
-
// get access key
|
|
285
|
-
hostedAgentValues.accessKey = await (0, _basicPrompts.askInput)({
|
|
286
|
-
msg: SaasPrompts.ACCESS_KEY,
|
|
287
|
-
defaultValue: hostedAgentValues.accessKey !== '' ? hostedAgentValues.accessKey : undefined,
|
|
288
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_ACCESS_KEY_ID, helpers.invalidValueExampleErrMsg('access key id', 'AKIAIOSFODNN7EXAMPLE'))
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
// get secret access key
|
|
292
|
-
hostedAgentValues.secretKey = await (0, _basicPrompts.askInput)({
|
|
293
|
-
msg: SaasPrompts.SECRET_KEY,
|
|
294
|
-
defaultValue: hostedAgentValues.secretKey !== '' ? hostedAgentValues.secretKey : undefined,
|
|
295
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_SECRET_ACCESS_KEY, helpers.invalidValueExampleErrMsg('secret access key', 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'))
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
return hostedAgentValues;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
// @ts-ignore
|
|
302
|
-
const gatewayConnectivity = async installConfig => {
|
|
303
|
-
console.log('\nCONNECTION TO AMAZON API GATEWAY:');
|
|
304
|
-
console.log(_chalk.default.gray("The Discovery Agent needs to connect to the AWS API Gateway to discover API's for publishing to Amplify Engage"));
|
|
305
|
-
|
|
306
|
-
// DeploymentType
|
|
307
|
-
let hostedAgentValues = new SaasAgentValues();
|
|
308
|
-
if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
|
|
309
|
-
// AWS connection details
|
|
310
|
-
hostedAgentValues = new SaasAWSAgentValues();
|
|
311
|
-
hostedAgentValues = await askForAWSCredentials(hostedAgentValues);
|
|
312
|
-
hostedAgentValues.stageTagName = await (0, _basicPrompts.askInput)({
|
|
313
|
-
msg: SaasPrompts.STAGE_TAG_NAME,
|
|
314
|
-
validate: (0, _basicPrompts.validateInputLength)(STAGE_TAG_NAME_LENGTH, "Maximum length of 'stage tag name' is 127")
|
|
315
|
-
});
|
|
316
|
-
if (installConfig.switches.isTaEnabled) {
|
|
317
|
-
console.log(_chalk.default.gray('\nThe access log ARN is a cloud watch log group amazon resource name'));
|
|
318
|
-
hostedAgentValues.accessLogARN = await (0, _basicPrompts.askInput)({
|
|
319
|
-
msg: SaasPrompts.ACCESS_LOG_ARN,
|
|
320
|
-
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'))
|
|
321
|
-
});
|
|
322
|
-
hostedAgentValues.fullTransactionLogging = (await (0, _basicPrompts.askList)({
|
|
323
|
-
msg: SaasPrompts.FULL_TRANSACTION_LOGGING,
|
|
324
|
-
default: _types.YesNo.No,
|
|
325
|
-
choices: _types.YesNoChoices
|
|
326
|
-
})) === _types.YesNo.Yes;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Ask to queue discovery now
|
|
331
|
-
log('getting the frequency and if the agent should run now');
|
|
332
|
-
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.'));
|
|
333
|
-
hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
|
|
334
|
-
msg: SaasPrompts.DA_FREQUENCY,
|
|
335
|
-
validate: (0, _agents.validateFrequency)(),
|
|
336
|
-
allowEmptyInput: true
|
|
337
|
-
});
|
|
338
|
-
hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
|
|
339
|
-
msg: SaasPrompts.QUEUE,
|
|
340
|
-
default: _types.YesNo.No,
|
|
341
|
-
choices: _types.YesNoChoices
|
|
342
|
-
})) === _types.YesNo.Yes;
|
|
343
|
-
hostedAgentValues.filterDA = await (0, _basicPrompts.askInput)({
|
|
344
|
-
msg: SaasPrompts.DA_FILTER,
|
|
345
|
-
allowEmptyInput: true
|
|
346
|
-
});
|
|
347
|
-
if (installConfig.switches.isTaEnabled) {
|
|
348
|
-
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.'));
|
|
349
|
-
hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
|
|
350
|
-
msg: SaasPrompts.TA_FREQUENCY,
|
|
351
|
-
defaultValue: '30m',
|
|
352
|
-
validate: (0, _agents.validateFrequency)(),
|
|
353
|
-
allowEmptyInput: true
|
|
354
|
-
});
|
|
355
|
-
hostedAgentValues = await askForRedaction(hostedAgentValues);
|
|
356
|
-
}
|
|
357
|
-
return hostedAgentValues;
|
|
358
|
-
};
|
|
359
|
-
const generateOutput = async installConfig => {
|
|
360
|
-
return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
|
|
361
|
-
};
|
|
362
|
-
const createEncryptedAccessData = async (hostedAgentValues, dataplaneRes) => {
|
|
363
|
-
var _dataplaneRes$securit, _dataplaneRes$securit2;
|
|
364
|
-
// grab key from data plane resource
|
|
365
|
-
let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || '';
|
|
366
|
-
let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || '';
|
|
367
|
-
if (key === '' || hash === '') {
|
|
368
|
-
throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
|
|
369
|
-
}
|
|
370
|
-
let encData = _crypto.default.publicEncrypt({
|
|
371
|
-
key: key,
|
|
372
|
-
padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
|
|
373
|
-
oaepHash: hash
|
|
374
|
-
}, Buffer.from(hostedAgentValues.getAccessData()));
|
|
375
|
-
return encData.toString('base64');
|
|
376
|
-
};
|
|
377
|
-
const completeInstall = async (installConfig, apiServerClient, defsManager) => {
|
|
378
|
-
/**
|
|
379
|
-
* Create agent resources
|
|
380
|
-
*/
|
|
381
|
-
console.log('\n');
|
|
382
|
-
let awsAgentValues = installConfig.gatewayConfig;
|
|
383
|
-
let resourceFuncsForCleanup = [];
|
|
384
|
-
let referencedIDPs = [];
|
|
385
|
-
let providedIDPs = installConfig.idpConfig[0];
|
|
386
|
-
let providedIDPAuths = installConfig.idpConfig[1];
|
|
387
|
-
// create Identity Provider resource
|
|
388
|
-
try {
|
|
389
|
-
for (let i = 0; i < providedIDPs.length; i++) {
|
|
390
|
-
let idpResource = await helpers.createNewIDPResource(apiServerClient, defsManager, providedIDPs[i]);
|
|
391
|
-
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpResource === null || idpResource === void 0 ? void 0 : idpResource.name, 'IdentityProvider', 'idp');
|
|
392
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
393
|
-
referencedIDPs.push({
|
|
394
|
-
name: idpResource === null || idpResource === void 0 ? void 0 : idpResource.name
|
|
395
|
-
});
|
|
396
|
-
log(idpResource);
|
|
397
|
-
let encryptedAccessData = await createEncryptedAccessData(providedIDPAuths[i], idpResource);
|
|
398
|
-
providedIDPAuths[i].setAccessData(encryptedAccessData);
|
|
399
|
-
let idpSecResource = await helpers.createNewIDPSecretResource(apiServerClient, defsManager, providedIDPAuths[i], idpResource);
|
|
400
|
-
let anotherCleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpSecResource === null || idpSecResource === void 0 ? void 0 : idpSecResource.name, 'IdentityProviderSecret', 'idpsec', idpResource === null || idpResource === void 0 ? void 0 : idpResource.name);
|
|
401
|
-
resourceFuncsForCleanup.push(anotherCleanupFunc);
|
|
402
|
-
}
|
|
403
|
-
} catch (error) {
|
|
404
|
-
log(error);
|
|
405
|
-
console.log(_chalk.default.redBright('rolling back installation. Could not create the Identity Provider resources'));
|
|
406
|
-
await cleanResources(resourceFuncsForCleanup);
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
let refIDPsSubResources = {
|
|
410
|
-
references: {
|
|
411
|
-
identityProviders: referencedIDPs
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
// create the environment, if necessary
|
|
415
|
-
if (installConfig.centralConfig.ampcEnvInfo.isNew) {
|
|
416
|
-
installConfig.centralConfig.environment = await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
|
|
417
|
-
axwayManaged: installConfig.centralConfig.axwayManaged,
|
|
418
|
-
production: installConfig.centralConfig.production
|
|
419
|
-
}, '', refIDPsSubResources);
|
|
420
|
-
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
|
|
421
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
422
|
-
} else {
|
|
423
|
-
// if the env exists, we simply update the references with the newly created IDPs, while preserving the existing IDP references
|
|
424
|
-
// In the case of any failure during the whole process, we return everything back to how it was before.
|
|
425
|
-
installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.name;
|
|
426
|
-
refIDPsSubResources.references.identityProviders.push(...installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders);
|
|
427
|
-
await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', refIDPsSubResources);
|
|
428
|
-
let oldIDPRef = {
|
|
429
|
-
references: {
|
|
430
|
-
identityProviders: installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
let cleanupFunc = async () => await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', oldIDPRef);
|
|
434
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
435
|
-
}
|
|
436
|
-
if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
|
|
437
|
-
if (installConfig.switches.isTaEnabled) {
|
|
438
|
-
awsAgentValues.dataplaneConfig = new AWSDataplaneConfig(awsAgentValues.accessLogARN, awsAgentValues.fullTransactionLogging, awsAgentValues.stageTagName);
|
|
439
|
-
} else {
|
|
440
|
-
awsAgentValues.dataplaneConfig = new DataplaneConfig('AWS');
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// create the data plane resource
|
|
445
|
-
let dataplaneRes;
|
|
446
|
-
try {
|
|
447
|
-
dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig);
|
|
448
|
-
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
|
|
449
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
450
|
-
} catch (error) {
|
|
451
|
-
console.log(_chalk.default.redBright('rolling back installation. Please check the configuration data before re-running install'));
|
|
452
|
-
await cleanResources(resourceFuncsForCleanup);
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// create data plane secret resource
|
|
457
|
-
try {
|
|
458
|
-
let dataplaneSecretRes = await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
|
|
459
|
-
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneSecretRes === null || dataplaneSecretRes === void 0 ? void 0 : dataplaneSecretRes.name, 'DataplaneSecret', 'dps', installConfig.centralConfig.environment);
|
|
460
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
461
|
-
} catch (error) {
|
|
462
|
-
console.log(_chalk.default.redBright('rolling back installation. Please check the credential data before re-running install'));
|
|
463
|
-
await cleanResources(resourceFuncsForCleanup);
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// create discovery agent resource
|
|
468
|
-
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, undefined, awsAgentValues.filterDA);
|
|
469
|
-
if (installConfig.switches.isTaEnabled) {
|
|
470
|
-
// create traceability agent resource
|
|
471
|
-
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,
|
|
472
|
-
// AWS TA is never triggered at install, as DA has to run prior
|
|
473
|
-
{
|
|
474
|
-
redaction: awsAgentValues.redaction
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
console.log(await generateOutput(installConfig));
|
|
478
|
-
};
|
|
479
|
-
const AWSSaaSInstallMethods = exports.AWSSaaSInstallMethods = {
|
|
480
|
-
GetBundleType: askBundleType,
|
|
481
|
-
GetDeploymentType: askConfigType,
|
|
482
|
-
AskGatewayQuestions: gatewayConnectivity,
|
|
483
|
-
AddIDP: true,
|
|
484
|
-
FinalizeGatewayInstall: completeInstall,
|
|
485
|
-
ConfigFiles: [],
|
|
486
|
-
AgentNameMap: {
|
|
487
|
-
[_types.AgentTypes.da]: _types.AgentNames.AWS_DA,
|
|
488
|
-
[_types.AgentTypes.ta]: _types.AgentNames.AWS_TA
|
|
489
|
-
},
|
|
490
|
-
GatewayDisplay: _types.GatewayTypes.AWS_GATEWAY
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
// These are the items that are not exported, but need to be for testing
|
|
494
|
-
const testables = exports.testables = {
|
|
495
|
-
SaasAgentValues,
|
|
496
|
-
SaasAWSAgentValues,
|
|
497
|
-
AWSAuthType,
|
|
498
|
-
SaasPrompts,
|
|
499
|
-
ConfigFiles
|
|
500
|
-
};
|
|
501
|
-
// These are useful because there are multiple resources created in a specific order and in case of failure, this goes through
|
|
502
|
-
// everything that was created and deletes it one by one. It deletes the resources in opposite order because resources added
|
|
503
|
-
// at the beginning might be referred by resources added afterwards
|
|
504
|
-
const cleanResources = async cleanupFuncs => {
|
|
505
|
-
for (let i = cleanupFuncs.length - 1; i >= 0; i--) {
|
|
506
|
-
await cleanupFuncs[i]();
|
|
507
|
-
}
|
|
508
|
-
};
|