@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,519 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.testables = exports.askBundleType = exports.AzureSaaSInstallMethods = 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 InvalidMessages = {
|
|
24
|
-
enterApiManagementServiceName: `The API Management Service Name can contain only letters, numbers and hyphens. The first character must be a letter and last character must be a letter or a number.`
|
|
25
|
-
};
|
|
26
|
-
class DataplaneConfig {
|
|
27
|
-
constructor(type) {
|
|
28
|
-
_defineProperty(this, "type", void 0);
|
|
29
|
-
this.type = type || '';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
class AzureDataplaneConfig extends DataplaneConfig {
|
|
33
|
-
constructor(tenantId, resourceGroup, subscriptionId, apimServiceName, mode, eventHubName, eventHubNamespace, eventHubConsumerGroup) {
|
|
34
|
-
super('Azure');
|
|
35
|
-
_defineProperty(this, "tenantId", void 0);
|
|
36
|
-
_defineProperty(this, "resourceGroup", void 0);
|
|
37
|
-
_defineProperty(this, "subscriptionId", void 0);
|
|
38
|
-
_defineProperty(this, "apimServiceName", void 0);
|
|
39
|
-
_defineProperty(this, "mode", void 0);
|
|
40
|
-
_defineProperty(this, "eventHubName", void 0);
|
|
41
|
-
_defineProperty(this, "eventHubNamespace", void 0);
|
|
42
|
-
_defineProperty(this, "eventHubConsumerGroup", void 0);
|
|
43
|
-
this.tenantId = tenantId;
|
|
44
|
-
this.resourceGroup = resourceGroup;
|
|
45
|
-
this.subscriptionId = subscriptionId;
|
|
46
|
-
this.apimServiceName = apimServiceName;
|
|
47
|
-
this.mode = mode;
|
|
48
|
-
this.eventHubName = eventHubName;
|
|
49
|
-
this.eventHubNamespace = eventHubNamespace;
|
|
50
|
-
this.eventHubConsumerGroup = eventHubConsumerGroup;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
class Sampling {
|
|
54
|
-
constructor() {
|
|
55
|
-
_defineProperty(this, "onlyErrors", void 0);
|
|
56
|
-
this.onlyErrors = true;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
class Sanitize {
|
|
60
|
-
constructor(k, m) {
|
|
61
|
-
_defineProperty(this, "keyMatch", void 0);
|
|
62
|
-
_defineProperty(this, "valueMatch", void 0);
|
|
63
|
-
this.keyMatch = k;
|
|
64
|
-
this.valueMatch = m;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
class RedactionSet {
|
|
68
|
-
constructor() {
|
|
69
|
-
_defineProperty(this, "show", void 0);
|
|
70
|
-
_defineProperty(this, "sanitize", void 0);
|
|
71
|
-
this.show = [];
|
|
72
|
-
this.sanitize = [];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
class Redaction {
|
|
76
|
-
constructor() {
|
|
77
|
-
_defineProperty(this, "maskingCharacter", void 0);
|
|
78
|
-
_defineProperty(this, "path", void 0);
|
|
79
|
-
_defineProperty(this, "queryArgument", void 0);
|
|
80
|
-
_defineProperty(this, "requestHeaders", void 0);
|
|
81
|
-
_defineProperty(this, "responseHeaders", void 0);
|
|
82
|
-
this.maskingCharacter = '{*}';
|
|
83
|
-
this.path = [];
|
|
84
|
-
this.queryArgument = new RedactionSet();
|
|
85
|
-
this.requestHeaders = new RedactionSet();
|
|
86
|
-
this.responseHeaders = new RedactionSet();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
class SaasAgentValues {
|
|
90
|
-
constructor() {
|
|
91
|
-
_defineProperty(this, "frequencyDA", void 0);
|
|
92
|
-
_defineProperty(this, "queueDA", void 0);
|
|
93
|
-
_defineProperty(this, "filterDA", void 0);
|
|
94
|
-
_defineProperty(this, "frequencyTA", void 0);
|
|
95
|
-
_defineProperty(this, "sampling", void 0);
|
|
96
|
-
_defineProperty(this, "redaction", void 0);
|
|
97
|
-
_defineProperty(this, "dataplaneConfig", void 0);
|
|
98
|
-
_defineProperty(this, "centralConfig", void 0);
|
|
99
|
-
this.frequencyDA = '';
|
|
100
|
-
this.queueDA = false;
|
|
101
|
-
this.filterDA = '';
|
|
102
|
-
this.frequencyTA = '';
|
|
103
|
-
this.sampling = new Sampling();
|
|
104
|
-
this.redaction = new Redaction();
|
|
105
|
-
this.dataplaneConfig = new DataplaneConfig();
|
|
106
|
-
this.centralConfig = new _types.CentralAgentConfig();
|
|
107
|
-
}
|
|
108
|
-
getAccessData() {
|
|
109
|
-
return '';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
class SaasAzureAgentValues extends SaasAgentValues {
|
|
113
|
-
constructor() {
|
|
114
|
-
super();
|
|
115
|
-
_defineProperty(this, "clientID", void 0);
|
|
116
|
-
_defineProperty(this, "clientSecret", void 0);
|
|
117
|
-
_defineProperty(this, "sharedAccessKeyName", void 0);
|
|
118
|
-
_defineProperty(this, "sharedAccessKeyValue", void 0);
|
|
119
|
-
_defineProperty(this, "eventHubName", void 0);
|
|
120
|
-
_defineProperty(this, "eventHubNamespace", void 0);
|
|
121
|
-
_defineProperty(this, "eventHubConsumerGroup", void 0);
|
|
122
|
-
_defineProperty(this, "resourceGroup", void 0);
|
|
123
|
-
_defineProperty(this, "apimManagementServiceName", void 0);
|
|
124
|
-
_defineProperty(this, "subscriptionId", void 0);
|
|
125
|
-
_defineProperty(this, "tenantId", void 0);
|
|
126
|
-
_defineProperty(this, "mode", void 0);
|
|
127
|
-
this.clientID = '';
|
|
128
|
-
this.clientSecret = '';
|
|
129
|
-
this.sharedAccessKeyName = '';
|
|
130
|
-
this.sharedAccessKeyValue = '';
|
|
131
|
-
this.eventHubName = '';
|
|
132
|
-
this.eventHubNamespace = '';
|
|
133
|
-
this.eventHubConsumerGroup = '';
|
|
134
|
-
this.resourceGroup = '';
|
|
135
|
-
this.apimManagementServiceName = '';
|
|
136
|
-
this.subscriptionId = '';
|
|
137
|
-
this.tenantId = '';
|
|
138
|
-
this.mode = _types.AzureDataplaneMode.APIM;
|
|
139
|
-
}
|
|
140
|
-
getAccessData() {
|
|
141
|
-
let data = JSON.stringify({
|
|
142
|
-
clientID: this.clientID,
|
|
143
|
-
clientSecret: this.clientSecret,
|
|
144
|
-
sharedAccessKeyName: this.sharedAccessKeyName,
|
|
145
|
-
sharedAccessKeyValue: this.sharedAccessKeyValue
|
|
146
|
-
});
|
|
147
|
-
return data;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// ConfigFiles - all the config file that are used in the setup
|
|
152
|
-
const ConfigFiles = {};
|
|
153
|
-
|
|
154
|
-
// AzureSaaSPrompts - all Azure Saas prompts to the user for input
|
|
155
|
-
const SaasPrompts = {
|
|
156
|
-
AUTHENTICATION_TYPE: 'Authenticate with Client and Shared Access Key',
|
|
157
|
-
TENANT_ID: 'Enter the Azure Tenant ID',
|
|
158
|
-
SUBSCRIPTION_ID: 'Enter the Azure Subscription ID',
|
|
159
|
-
CLIENT_ID: 'Enter the Azure Service Principal Client ID',
|
|
160
|
-
CLIENT_SECRET: 'Enter the Azure Service Principal Client Secret',
|
|
161
|
-
RESOURCE_GROUP_NAME: 'Enter the Azure Resource Group Name',
|
|
162
|
-
APIM_SERVICE_MANAGEMENT_NAME: 'Enter the Azure API Management Service Name',
|
|
163
|
-
SHARED_ACCESS_KEY_NAME: 'Enter the Azure Policy Name',
|
|
164
|
-
SHARED_ACCESS_KEY_VALUE: 'Enter the Azure Policy Key',
|
|
165
|
-
EVENT_HUB_NAME: 'Enter the Azure Event Hub Name',
|
|
166
|
-
EVENT_HUB_NAMESPACE: 'Enter the Azure Event Hub Namespace',
|
|
167
|
-
EVENT_HUB_CONSUMER_GROUP: 'Enter the Azure Event Hub Consumer Group',
|
|
168
|
-
// general prompts
|
|
169
|
-
DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
|
|
170
|
-
DA_FILTER: 'Please enter the filter conditions for discovery of API Services based on tags',
|
|
171
|
-
TA_FREQUENCY: 'How often should the traffic collection run, leave blank for manual trigger only',
|
|
172
|
-
QUEUE: 'Do you want to discover immediately after installation',
|
|
173
|
-
REDACT_SHOW: 'Enter a regular expression for {0}s that may be shown',
|
|
174
|
-
ENTER_SANITIZE_RULE: 'Do you want to add sanitization rules for {0}s',
|
|
175
|
-
SANITIZE_KEY: 'Enter a regular expression for {0} keys that values should be sanitized',
|
|
176
|
-
SANITIZE_VAL: 'Enter a regular expression for sanitization of values when matching a {0} key',
|
|
177
|
-
MASKING_CHARS: 'Enter the characters to use when sanitizing a value',
|
|
178
|
-
ENTER_MORE: 'Do you want to enter another {0} for {1}'
|
|
179
|
-
};
|
|
180
|
-
const askBundleType = async gateway => {
|
|
181
|
-
if (gateway === _types.GatewayTypes.AZURE_GATEWAY) {
|
|
182
|
-
return await (0, _basicPrompts.askList)({
|
|
183
|
-
msg: helpers.agentMessages.selectAgentType,
|
|
184
|
-
choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY]
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
return _types.BundleType.DISCOVERY;
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
exports.askBundleType = askBundleType;
|
|
191
|
-
const askConfigType = async () => {
|
|
192
|
-
return _types.AgentConfigTypes.HOSTED;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
//
|
|
196
|
-
// Complex prompts
|
|
197
|
-
//
|
|
198
|
-
const askForRedactionSet = async (setting, redactionSet) => {
|
|
199
|
-
// ask for path reg exs
|
|
200
|
-
let askShow = true;
|
|
201
|
-
console.log(_chalk.default.gray((0, _utils.FormatString)('\nRedaction settings for {0}s', setting)));
|
|
202
|
-
while (askShow) {
|
|
203
|
-
const input = await (0, _basicPrompts.askInput)({
|
|
204
|
-
msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, setting),
|
|
205
|
-
defaultValue: '.*',
|
|
206
|
-
validate: (0, _basicPrompts.validateValidRegex)()
|
|
207
|
-
});
|
|
208
|
-
redactionSet.show.push(input);
|
|
209
|
-
askShow = (await (0, _basicPrompts.askList)({
|
|
210
|
-
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, 'redaction regular expression', setting),
|
|
211
|
-
default: _types.YesNo.No,
|
|
212
|
-
choices: _types.YesNoChoices
|
|
213
|
-
})) === _types.YesNo.Yes;
|
|
214
|
-
}
|
|
215
|
-
console.log(_chalk.default.gray((0, _utils.FormatString)('Sanitization settings for {0}s', setting)));
|
|
216
|
-
let askSanitize = (await (0, _basicPrompts.askList)({
|
|
217
|
-
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_SANITIZE_RULE, setting),
|
|
218
|
-
default: _types.YesNo.No,
|
|
219
|
-
choices: _types.YesNoChoices
|
|
220
|
-
})) === _types.YesNo.Yes;
|
|
221
|
-
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)'));
|
|
222
|
-
while (askSanitize) {
|
|
223
|
-
const keyMatch = await (0, _basicPrompts.askInput)({
|
|
224
|
-
msg: (0, _utils.FormatString)(SaasPrompts.SANITIZE_KEY, setting),
|
|
225
|
-
allowEmptyInput: true,
|
|
226
|
-
validate: (0, _basicPrompts.validateValidRegex)()
|
|
227
|
-
});
|
|
228
|
-
const valMatch = await (0, _basicPrompts.askInput)({
|
|
229
|
-
msg: (0, _utils.FormatString)(SaasPrompts.SANITIZE_VAL, setting),
|
|
230
|
-
allowEmptyInput: true,
|
|
231
|
-
validate: (0, _basicPrompts.validateValidRegex)()
|
|
232
|
-
});
|
|
233
|
-
if (keyMatch === '' || valMatch === '') {
|
|
234
|
-
console.log("can't add sanitization rule with an empty key or value regular expression");
|
|
235
|
-
} else {
|
|
236
|
-
redactionSet.sanitize.push(new Sanitize(keyMatch, valMatch));
|
|
237
|
-
}
|
|
238
|
-
askSanitize = (await (0, _basicPrompts.askList)({
|
|
239
|
-
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, 'sanitization rule', setting),
|
|
240
|
-
default: _types.YesNo.No,
|
|
241
|
-
choices: _types.YesNoChoices
|
|
242
|
-
})) === _types.YesNo.Yes;
|
|
243
|
-
}
|
|
244
|
-
return redactionSet;
|
|
245
|
-
};
|
|
246
|
-
const askForRedaction = async hostedAgentValues => {
|
|
247
|
-
console.log(_chalk.default.gray('\nRedaction and Sanitization settings'));
|
|
248
|
-
// ask for path reg exps
|
|
249
|
-
let askPaths = true;
|
|
250
|
-
console.log(_chalk.default.gray('\nRedaction settings for URL paths'));
|
|
251
|
-
while (askPaths) {
|
|
252
|
-
const input = await (0, _basicPrompts.askInput)({
|
|
253
|
-
msg: (0, _utils.FormatString)(SaasPrompts.REDACT_SHOW, 'URL path'),
|
|
254
|
-
defaultValue: '.*',
|
|
255
|
-
validate: (0, _basicPrompts.validateValidRegex)()
|
|
256
|
-
});
|
|
257
|
-
hostedAgentValues.redaction.path.push(input);
|
|
258
|
-
askPaths = (await (0, _basicPrompts.askList)({
|
|
259
|
-
msg: (0, _utils.FormatString)(SaasPrompts.ENTER_MORE, 'redaction regular expression', 'URL path'),
|
|
260
|
-
default: _types.YesNo.No,
|
|
261
|
-
choices: _types.YesNoChoices
|
|
262
|
-
})) === _types.YesNo.Yes;
|
|
263
|
-
}
|
|
264
|
-
hostedAgentValues.redaction.queryArgument = await askForRedactionSet('query argument', hostedAgentValues.redaction.queryArgument);
|
|
265
|
-
hostedAgentValues.redaction.requestHeaders = await askForRedactionSet('request header', hostedAgentValues.redaction.requestHeaders);
|
|
266
|
-
hostedAgentValues.redaction.responseHeaders = await askForRedactionSet('response header', hostedAgentValues.redaction.responseHeaders);
|
|
267
|
-
hostedAgentValues.redaction.maskingCharacter = await (0, _basicPrompts.askInput)({
|
|
268
|
-
msg: SaasPrompts.MASKING_CHARS,
|
|
269
|
-
defaultValue: '{*}',
|
|
270
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.maskingRegex, 'Please enter a valid value')
|
|
271
|
-
});
|
|
272
|
-
return hostedAgentValues;
|
|
273
|
-
};
|
|
274
|
-
const askForAzureCredentials = async (hostedAgentValues, installConfig) => {
|
|
275
|
-
log('gathering access details for azure');
|
|
276
|
-
hostedAgentValues.tenantId = await (0, _basicPrompts.askInput)({
|
|
277
|
-
msg: SaasPrompts.TENANT_ID
|
|
278
|
-
});
|
|
279
|
-
hostedAgentValues.subscriptionId = await (0, _basicPrompts.askInput)({
|
|
280
|
-
msg: SaasPrompts.SUBSCRIPTION_ID
|
|
281
|
-
});
|
|
282
|
-
hostedAgentValues.clientID = await (0, _basicPrompts.askInput)({
|
|
283
|
-
msg: SaasPrompts.CLIENT_ID
|
|
284
|
-
});
|
|
285
|
-
hostedAgentValues.clientSecret = await (0, _basicPrompts.askInput)({
|
|
286
|
-
msg: SaasPrompts.CLIENT_SECRET
|
|
287
|
-
});
|
|
288
|
-
hostedAgentValues.resourceGroup = await (0, _basicPrompts.askInput)({
|
|
289
|
-
msg: SaasPrompts.RESOURCE_GROUP_NAME
|
|
290
|
-
});
|
|
291
|
-
if (installConfig.gatewayType === _types.GatewayTypes.AZURE_GATEWAY) {
|
|
292
|
-
hostedAgentValues.apimManagementServiceName = await (0, _basicPrompts.askInput)({
|
|
293
|
-
msg: SaasPrompts.APIM_SERVICE_MANAGEMENT_NAME,
|
|
294
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.AzureRegexPatterns.azureApiManagementServiceNameRegex, InvalidMessages.enterApiManagementServiceName)
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
if (installConfig.switches.isTaEnabled) {
|
|
298
|
-
hostedAgentValues.sharedAccessKeyName = await (0, _basicPrompts.askInput)({
|
|
299
|
-
msg: SaasPrompts.SHARED_ACCESS_KEY_NAME,
|
|
300
|
-
defaultValue: 'RootManageSharedAccessKey'
|
|
301
|
-
});
|
|
302
|
-
hostedAgentValues.sharedAccessKeyValue = await (0, _basicPrompts.askInput)({
|
|
303
|
-
msg: SaasPrompts.SHARED_ACCESS_KEY_VALUE
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
return hostedAgentValues;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
// @ts-ignore
|
|
310
|
-
const gatewayConnectivity = async installConfig => {
|
|
311
|
-
console.log('\nCONNECTION TO Azure API GATEWAY:');
|
|
312
|
-
console.log(_chalk.default.gray("The Discovery Agent needs to connect to the Azure API Gateway to discover API's for publishing to Amplify Engage"));
|
|
313
|
-
|
|
314
|
-
// DeploymentType
|
|
315
|
-
let hostedAgentValues = new SaasAgentValues();
|
|
316
|
-
if (installConfig.gatewayType === _types.GatewayTypes.AZURE_GATEWAY || installConfig.gatewayType === _types.GatewayTypes.AZURE_EVENTHUB) {
|
|
317
|
-
// Azure connection details
|
|
318
|
-
hostedAgentValues = new SaasAzureAgentValues();
|
|
319
|
-
hostedAgentValues = await askForAzureCredentials(hostedAgentValues, installConfig);
|
|
320
|
-
if (installConfig.gatewayType === _types.GatewayTypes.AZURE_EVENTHUB) {
|
|
321
|
-
hostedAgentValues.eventHubNamespace = await (0, _basicPrompts.askInput)({
|
|
322
|
-
msg: SaasPrompts.EVENT_HUB_NAMESPACE
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
if (installConfig.switches.isTaEnabled) {
|
|
326
|
-
hostedAgentValues.eventHubName = await (0, _basicPrompts.askInput)({
|
|
327
|
-
msg: SaasPrompts.EVENT_HUB_NAME
|
|
328
|
-
});
|
|
329
|
-
hostedAgentValues.eventHubNamespace = await (0, _basicPrompts.askInput)({
|
|
330
|
-
msg: SaasPrompts.EVENT_HUB_NAMESPACE
|
|
331
|
-
});
|
|
332
|
-
hostedAgentValues.eventHubConsumerGroup = await (0, _basicPrompts.askInput)({
|
|
333
|
-
msg: SaasPrompts.EVENT_HUB_CONSUMER_GROUP,
|
|
334
|
-
validate: (0, _basicPrompts.validateRegex)(helpers.AzureRegexPatterns.azureEventHubConsumerGroupRegex, helpers.invalidValueExampleErrMsg('Event Hub Consumer Group', 'azure-event-hub-c-group')),
|
|
335
|
-
defaultValue: '$Default'
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Ask to queue discovery now
|
|
341
|
-
log('getting the frequency and if the agent should run now');
|
|
342
|
-
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.'));
|
|
343
|
-
hostedAgentValues.frequencyDA = await (0, _basicPrompts.askInput)({
|
|
344
|
-
msg: SaasPrompts.DA_FREQUENCY,
|
|
345
|
-
validate: (0, _agents.validateFrequency)(),
|
|
346
|
-
allowEmptyInput: true
|
|
347
|
-
});
|
|
348
|
-
hostedAgentValues.queueDA = (await (0, _basicPrompts.askList)({
|
|
349
|
-
msg: SaasPrompts.QUEUE,
|
|
350
|
-
default: _types.YesNo.No,
|
|
351
|
-
choices: _types.YesNoChoices
|
|
352
|
-
})) === _types.YesNo.Yes;
|
|
353
|
-
hostedAgentValues.filterDA = await (0, _basicPrompts.askInput)({
|
|
354
|
-
msg: SaasPrompts.DA_FILTER,
|
|
355
|
-
allowEmptyInput: true
|
|
356
|
-
});
|
|
357
|
-
if (installConfig.switches.isTaEnabled) {
|
|
358
|
-
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.'));
|
|
359
|
-
hostedAgentValues.frequencyTA = await (0, _basicPrompts.askInput)({
|
|
360
|
-
msg: SaasPrompts.TA_FREQUENCY,
|
|
361
|
-
defaultValue: '30m',
|
|
362
|
-
validate: (0, _agents.validateFrequency)(),
|
|
363
|
-
allowEmptyInput: true
|
|
364
|
-
});
|
|
365
|
-
hostedAgentValues = await askForRedaction(hostedAgentValues);
|
|
366
|
-
}
|
|
367
|
-
return hostedAgentValues;
|
|
368
|
-
};
|
|
369
|
-
const generateOutput = async installConfig => {
|
|
370
|
-
return `Install complete of hosted agent for ${installConfig.gatewayType} region`;
|
|
371
|
-
};
|
|
372
|
-
const createEncryptedAccessData = async (agentValues, dataplaneRes) => {
|
|
373
|
-
var _dataplaneRes$securit, _dataplaneRes$securit2;
|
|
374
|
-
// grab key from data plane resource
|
|
375
|
-
let key = ((_dataplaneRes$securit = dataplaneRes.security) === null || _dataplaneRes$securit === void 0 ? void 0 : _dataplaneRes$securit.encryptionKey) || '';
|
|
376
|
-
let hash = ((_dataplaneRes$securit2 = dataplaneRes.security) === null || _dataplaneRes$securit2 === void 0 ? void 0 : _dataplaneRes$securit2.encryptionHash) || '';
|
|
377
|
-
if (key === '' || hash === '') {
|
|
378
|
-
throw Error(`cannot encrypt access data as the encryption key info was incomplete`);
|
|
379
|
-
}
|
|
380
|
-
let encData = _crypto.default.publicEncrypt({
|
|
381
|
-
key: key,
|
|
382
|
-
padding: _crypto.default.constants.RSA_PKCS1_OAEP_PADDING,
|
|
383
|
-
oaepHash: hash
|
|
384
|
-
}, Buffer.from(agentValues.getAccessData()));
|
|
385
|
-
return encData.toString('base64');
|
|
386
|
-
};
|
|
387
|
-
const completeInstall = async (installConfig, apiServerClient, defsManager) => {
|
|
388
|
-
/**
|
|
389
|
-
* Create agent resources
|
|
390
|
-
*/
|
|
391
|
-
console.log('\n');
|
|
392
|
-
let azureAgentValues = installConfig.gatewayConfig;
|
|
393
|
-
let resourceFuncsForCleanup = [];
|
|
394
|
-
let referencedIDPs = [];
|
|
395
|
-
let providedIDPs = installConfig.idpConfig[0];
|
|
396
|
-
let providedIDPAuths = installConfig.idpConfig[1];
|
|
397
|
-
// create Identity Provider resource
|
|
398
|
-
try {
|
|
399
|
-
for (let i = 0; i < providedIDPs.length; i++) {
|
|
400
|
-
let idpResource = await helpers.createNewIDPResource(apiServerClient, defsManager, providedIDPs[i]);
|
|
401
|
-
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpResource === null || idpResource === void 0 ? void 0 : idpResource.name, 'IdentityProvider', 'idp');
|
|
402
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
403
|
-
referencedIDPs.push({
|
|
404
|
-
name: idpResource === null || idpResource === void 0 ? void 0 : idpResource.name
|
|
405
|
-
});
|
|
406
|
-
log(idpResource);
|
|
407
|
-
let encryptedAccessData = await createEncryptedAccessData(providedIDPAuths[i], idpResource);
|
|
408
|
-
providedIDPAuths[i].setAccessData(encryptedAccessData);
|
|
409
|
-
let idpSecResource = await helpers.createNewIDPSecretResource(apiServerClient, defsManager, providedIDPAuths[i], idpResource);
|
|
410
|
-
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);
|
|
411
|
-
resourceFuncsForCleanup.push(anotherCleanupFunc);
|
|
412
|
-
}
|
|
413
|
-
} catch (error) {
|
|
414
|
-
log(error);
|
|
415
|
-
console.log(_chalk.default.redBright('rolling back installation. Could not create the Identity Provider resources'));
|
|
416
|
-
await cleanResources(resourceFuncsForCleanup);
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
let refIDPsSubResources = {
|
|
420
|
-
references: {
|
|
421
|
-
identityProviders: referencedIDPs
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
// create the environment, if necessary
|
|
425
|
-
if (installConfig.centralConfig.ampcEnvInfo.isNew) {
|
|
426
|
-
installConfig.centralConfig.environment = await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
|
|
427
|
-
axwayManaged: installConfig.centralConfig.axwayManaged,
|
|
428
|
-
production: installConfig.centralConfig.production
|
|
429
|
-
}, '', refIDPsSubResources);
|
|
430
|
-
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
|
|
431
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
432
|
-
} else {
|
|
433
|
-
// if the env exists, we simply update the references with the newly created IDPs, while preserving the existing IDP references
|
|
434
|
-
// In the case of any failure during the whole process, we return everything back to how it was before.
|
|
435
|
-
installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.name;
|
|
436
|
-
refIDPsSubResources.references.identityProviders.push(...installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders);
|
|
437
|
-
await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', refIDPsSubResources);
|
|
438
|
-
let oldIDPRef = {
|
|
439
|
-
references: {
|
|
440
|
-
identityProviders: installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
let cleanupFunc = async () => await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', oldIDPRef);
|
|
444
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
445
|
-
}
|
|
446
|
-
if (installConfig.gatewayType === _types.GatewayTypes.AZURE_GATEWAY) {
|
|
447
|
-
azureAgentValues.dataplaneConfig = new AzureDataplaneConfig(azureAgentValues.tenantId, azureAgentValues.resourceGroup, azureAgentValues.subscriptionId, azureAgentValues.apimManagementServiceName, _types.AzureDataplaneMode.APIM);
|
|
448
|
-
if (installConfig.switches.isTaEnabled) {
|
|
449
|
-
azureAgentValues.dataplaneConfig = new AzureDataplaneConfig(azureAgentValues.tenantId, azureAgentValues.resourceGroup, azureAgentValues.subscriptionId, azureAgentValues.apimManagementServiceName, _types.AzureDataplaneMode.APIM, azureAgentValues.eventHubName, azureAgentValues.eventHubNamespace, azureAgentValues.eventHubConsumerGroup);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
if (installConfig.gatewayType === _types.GatewayTypes.AZURE_EVENTHUB) {
|
|
453
|
-
azureAgentValues.dataplaneConfig = new AzureDataplaneConfig(azureAgentValues.tenantId, azureAgentValues.resourceGroup, azureAgentValues.subscriptionId, '', _types.AzureDataplaneMode.EventHub, undefined, azureAgentValues.eventHubNamespace);
|
|
454
|
-
}
|
|
455
|
-
// create the data plane resource
|
|
456
|
-
let dataplaneRes;
|
|
457
|
-
try {
|
|
458
|
-
dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], azureAgentValues.dataplaneConfig);
|
|
459
|
-
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
|
|
460
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
461
|
-
} catch (error) {
|
|
462
|
-
console.log(_chalk.default.redBright('rolling back installation. Please check the configuration data before re-running install'));
|
|
463
|
-
await cleanResources(resourceFuncsForCleanup);
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// create data plane secret resource
|
|
468
|
-
try {
|
|
469
|
-
let dataplaneSecretRes = await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(azureAgentValues, dataplaneRes));
|
|
470
|
-
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneSecretRes === null || dataplaneSecretRes === void 0 ? void 0 : dataplaneSecretRes.name, 'DataplaneSecret', 'dps', installConfig.centralConfig.environment);
|
|
471
|
-
resourceFuncsForCleanup.push(cleanupFunc);
|
|
472
|
-
} catch (error) {
|
|
473
|
-
console.log(_chalk.default.redBright('rolling back installation. Please check the credential data before re-running install'));
|
|
474
|
-
await cleanResources(resourceFuncsForCleanup);
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// create discovery agent resource
|
|
479
|
-
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, azureAgentValues.frequencyDA, azureAgentValues.queueDA, undefined, azureAgentValues.filterDA);
|
|
480
|
-
if (installConfig.switches.isTaEnabled) {
|
|
481
|
-
// create traceability agent resource
|
|
482
|
-
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, azureAgentValues.frequencyTA, false,
|
|
483
|
-
// Azure TA is never triggered at install, as DA has to run prior
|
|
484
|
-
{
|
|
485
|
-
sampling: azureAgentValues.sampling,
|
|
486
|
-
redaction: azureAgentValues.redaction
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
console.log(await generateOutput(installConfig));
|
|
490
|
-
};
|
|
491
|
-
const AzureSaaSInstallMethods = exports.AzureSaaSInstallMethods = {
|
|
492
|
-
GetBundleType: askBundleType,
|
|
493
|
-
GetDeploymentType: askConfigType,
|
|
494
|
-
AskGatewayQuestions: gatewayConnectivity,
|
|
495
|
-
AddIDP: true,
|
|
496
|
-
FinalizeGatewayInstall: completeInstall,
|
|
497
|
-
ConfigFiles: [],
|
|
498
|
-
AgentNameMap: {
|
|
499
|
-
[_types.AgentTypes.da]: _types.AgentNames.AZURE_DA,
|
|
500
|
-
[_types.AgentTypes.ta]: _types.AgentNames.AZURE_TA
|
|
501
|
-
},
|
|
502
|
-
GatewayDisplay: _types.GatewayTypes.AZURE_GATEWAY
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
// These are the items that are not exported, but need to be for testing
|
|
506
|
-
const testables = exports.testables = {
|
|
507
|
-
SaasAgentValues,
|
|
508
|
-
SaasAzureAgentValues,
|
|
509
|
-
SaasPrompts,
|
|
510
|
-
ConfigFiles
|
|
511
|
-
};
|
|
512
|
-
// These are useful because there are multiple resources created in a specific order and in case of failure, this goes through
|
|
513
|
-
// everything that was created and deletes it one by one. It deletes the resources in opposite order because resources added
|
|
514
|
-
// at the beginning might be referred by resources added afterwards
|
|
515
|
-
const cleanResources = async cleanupFuncs => {
|
|
516
|
-
for (let i = cleanupFuncs.length - 1; i >= 0; i--) {
|
|
517
|
-
await cleanupFuncs[i]();
|
|
518
|
-
}
|
|
519
|
-
};
|