@itentialopensource/adapter-beyond_trust 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/.eslintignore +6 -0
  2. package/.eslintrc.js +18 -0
  3. package/.gitlab/.gitkeep +0 -0
  4. package/.gitlab/issue_templates/.gitkeep +0 -0
  5. package/.gitlab/issue_templates/Default.md +17 -0
  6. package/.gitlab/issue_templates/bugReportTemplate.md +76 -0
  7. package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
  8. package/.jshintrc +0 -0
  9. package/AUTH.md +39 -0
  10. package/BROKER.md +199 -0
  11. package/CALLS.md +1004 -0
  12. package/CHANGELOG.md +9 -0
  13. package/CODE_OF_CONDUCT.md +43 -0
  14. package/CONTRIBUTING.md +13 -0
  15. package/ENHANCE.md +69 -0
  16. package/LICENSE +201 -0
  17. package/PROPERTIES.md +641 -0
  18. package/README.md +346 -0
  19. package/SUMMARY.md +9 -0
  20. package/SYSTEMINFO.md +11 -0
  21. package/TAB1.md +5 -0
  22. package/TAB2.md +2226 -0
  23. package/TROUBLESHOOT.md +47 -0
  24. package/adapter.js +12401 -0
  25. package/adapterBase.js +1452 -0
  26. package/entities/.generic/action.json +214 -0
  27. package/entities/.generic/schema.json +28 -0
  28. package/entities/.system/action.json +50 -0
  29. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  30. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  31. package/entities/.system/schema.json +19 -0
  32. package/entities/.system/schemaTokenReq.json +53 -0
  33. package/entities/.system/schemaTokenResp.json +53 -0
  34. package/entities/GroupPolicy/action.json +495 -0
  35. package/entities/GroupPolicy/mockdatafiles/apiConfigGroupPolicyIndex-default.json +18 -0
  36. package/entities/GroupPolicy/mockdatafiles/apiConfigGroupPolicyJumpGroupIndex-default.json +12 -0
  37. package/entities/GroupPolicy/mockdatafiles/apiConfigGroupPolicyJumpointsIndex-default.json +8 -0
  38. package/entities/GroupPolicy/mockdatafiles/apiConfigGroupPolicyMemberIndex-default.json +26 -0
  39. package/entities/GroupPolicy/mockdatafiles/apiConfigGroupPolicyTeamIndex-default.json +10 -0
  40. package/entities/GroupPolicy/mockdatafiles/apiConfigGroupPolicyVaultAccountIndex-default.json +7 -0
  41. package/entities/GroupPolicy/schema.json +119 -0
  42. package/entities/JumpClient/action.json +147 -0
  43. package/entities/JumpClient/mockdatafiles/apiConfigJumpClientIndex-default.json +29 -0
  44. package/entities/JumpClient/schema.json +124 -0
  45. package/entities/JumpGroup/action.json +208 -0
  46. package/entities/JumpGroup/mockdatafiles/apiConfigJumpGroupIndex-default.json +30 -0
  47. package/entities/JumpGroup/mockdatafiles/apiConfigJumpGroupUserIndex-default.json +7 -0
  48. package/entities/JumpGroup/schema.json +72 -0
  49. package/entities/JumpItem/action.json +370 -0
  50. package/entities/JumpItem/mockdatafiles/apiConfigJumpItemRemoteRdpIndex-default.json +52 -0
  51. package/entities/JumpItem/mockdatafiles/apiConfigJumpItemShellJumpIndex-default.json +70 -0
  52. package/entities/JumpItem/mockdatafiles/apiConfigJumpItemWebJumpIndex-default.json +38 -0
  53. package/entities/JumpItem/schema.json +91 -0
  54. package/entities/JumpItemRole/action.json +46 -0
  55. package/entities/JumpItemRole/mockdatafiles/apiConfigJumpItemRoleIndex-default.json +34 -0
  56. package/entities/JumpItemRole/schema.json +42 -0
  57. package/entities/JumpPolicy/action.json +127 -0
  58. package/entities/JumpPolicy/mockdatafiles/apiConfigJumpPolicyIndex-default.json +86 -0
  59. package/entities/JumpPolicy/schema.json +57 -0
  60. package/entities/Jumpoint/action.json +230 -0
  61. package/entities/Jumpoint/mockdatafiles/apiConfigJumpointIndex-default.json +50 -0
  62. package/entities/Jumpoint/schema.json +95 -0
  63. package/entities/OpenapiYaml/action.json +25 -0
  64. package/entities/OpenapiYaml/schema.json +19 -0
  65. package/entities/SecurityProvider/action.json +25 -0
  66. package/entities/SecurityProvider/mockdatafiles/apiConfigSecurityProviderIndex-default.json +26 -0
  67. package/entities/SecurityProvider/schema.json +41 -0
  68. package/entities/SessionPolicy/action.json +25 -0
  69. package/entities/SessionPolicy/mockdatafiles/apiConfigSessionPolicyIndex-default.json +20 -0
  70. package/entities/SessionPolicy/schema.json +41 -0
  71. package/entities/Team/action.json +208 -0
  72. package/entities/Team/mockdatafiles/apiConfigTeamIndex-default.json +14 -0
  73. package/entities/Team/mockdatafiles/apiConfigTeamUserIndex-default.json +7 -0
  74. package/entities/Team/schema.json +72 -0
  75. package/entities/User/action.json +106 -0
  76. package/entities/User/mockdatafiles/apiConfigUserIndex-default.json +18 -0
  77. package/entities/User/schema.json +67 -0
  78. package/entities/Vault/action.json +676 -0
  79. package/entities/Vault/mockdatafiles/apiConfigVaultAccountGroupAccountIndex-default.json +18 -0
  80. package/entities/Vault/mockdatafiles/apiConfigVaultAccountGroupUserIndex-default.json +22 -0
  81. package/entities/Vault/mockdatafiles/apiConfigVaultAccountIndex-default.json +22 -0
  82. package/entities/Vault/mockdatafiles/apiConfigVaultAccountUserIndex-default.json +6 -0
  83. package/entities/Vault/schema.json +128 -0
  84. package/entities/Vendor/action.json +208 -0
  85. package/entities/Vendor/mockdatafiles/apiConfigVendorIndex-default.json +32 -0
  86. package/entities/Vendor/mockdatafiles/apiConfigVendorUserIndex-default.json +17 -0
  87. package/entities/Vendor/schema.json +61 -0
  88. package/error.json +190 -0
  89. package/metadata.json +50 -0
  90. package/package.json +83 -0
  91. package/pronghorn.json +9958 -0
  92. package/propertiesDecorators.json +14 -0
  93. package/propertiesSchema.json +1569 -0
  94. package/refs?service=git-upload-pack +0 -0
  95. package/report/adapterInfo.json +10 -0
  96. package/report/bt-pra-configuration.openapi.yaml-OpenApi3.json +13155 -0
  97. package/report/creationReport.json +970 -0
  98. package/sampleProperties.json +256 -0
  99. package/test/integration/adapterTestBasicGet.js +83 -0
  100. package/test/integration/adapterTestConnectivity.js +142 -0
  101. package/test/integration/adapterTestIntegration.js +4162 -0
  102. package/test/unit/adapterBaseTestUnit.js +1024 -0
  103. package/test/unit/adapterTestUnit.js +6145 -0
  104. package/utils/adapterInfo.js +206 -0
  105. package/utils/addAuth.js +94 -0
  106. package/utils/artifactize.js +146 -0
  107. package/utils/basicGet.js +50 -0
  108. package/utils/checkMigrate.js +63 -0
  109. package/utils/entitiesToDB.js +179 -0
  110. package/utils/findPath.js +74 -0
  111. package/utils/methodDocumentor.js +273 -0
  112. package/utils/modify.js +152 -0
  113. package/utils/packModificationScript.js +35 -0
  114. package/utils/patches2bundledDeps.js +90 -0
  115. package/utils/pre-commit.sh +32 -0
  116. package/utils/removeHooks.js +20 -0
  117. package/utils/setup.js +33 -0
  118. package/utils/taskMover.js +309 -0
  119. package/utils/tbScript.js +239 -0
  120. package/utils/tbUtils.js +489 -0
  121. package/utils/testRunner.js +298 -0
  122. package/utils/troubleshootingAdapter.js +193 -0
@@ -0,0 +1,256 @@
1
+ {
2
+ "id": "Adapter-beyond_trust",
3
+ "type": "BeyondTrust",
4
+ "properties": {
5
+ "host": "localhost",
6
+ "port": 443,
7
+ "choosepath": "",
8
+ "base_path": "/api/config/v1",
9
+ "version": "",
10
+ "cache_location": "none",
11
+ "encode_pathvars": true,
12
+ "encode_queryvars": true,
13
+ "save_metric": false,
14
+ "stub": true,
15
+ "protocol": "https",
16
+ "authentication": {
17
+ "auth_method": "request_token",
18
+ "username": "username",
19
+ "password": "password",
20
+ "token": "token",
21
+ "token_timeout": 600000,
22
+ "token_cache": "local",
23
+ "invalid_token_error": 401,
24
+ "auth_field": "header.headers.Authorization",
25
+ "auth_field_format": "Basic {b64}{username}:{password}{/b64}",
26
+ "auth_logging": false,
27
+ "client_id": "",
28
+ "client_secret": "",
29
+ "grant_type": "",
30
+ "sensitive": [],
31
+ "multiStepAuthCalls": [
32
+ {
33
+ "name": "",
34
+ "requestFields": {},
35
+ "responseFields": {},
36
+ "successfullResponseCode": 200
37
+ }
38
+ ],
39
+ "sso": {
40
+ "protocol": "",
41
+ "host": "",
42
+ "port": 0
43
+ }
44
+ },
45
+ "healthcheck": {
46
+ "type": "none",
47
+ "frequency": 60000,
48
+ "query_object": {},
49
+ "addlHeaders": {}
50
+ },
51
+ "throttle": {
52
+ "throttle_enabled": false,
53
+ "number_pronghorns": 1,
54
+ "sync_async": "sync",
55
+ "max_in_queue": 1000,
56
+ "concurrent_max": 1,
57
+ "expire_timeout": 0,
58
+ "avg_runtime": 200,
59
+ "priorities": [
60
+ {
61
+ "value": 0,
62
+ "percent": 100
63
+ }
64
+ ]
65
+ },
66
+ "request": {
67
+ "number_redirects": 0,
68
+ "number_retries": 3,
69
+ "limit_retry_error": [
70
+ 0
71
+ ],
72
+ "failover_codes": [],
73
+ "attempt_timeout": 5000,
74
+ "global_request": {
75
+ "payload": {},
76
+ "uriOptions": {},
77
+ "addlHeaders": {},
78
+ "authData": {}
79
+ },
80
+ "healthcheck_on_timeout": true,
81
+ "return_raw": false,
82
+ "archiving": false,
83
+ "return_request": false
84
+ },
85
+ "proxy": {
86
+ "enabled": false,
87
+ "host": "",
88
+ "port": 1,
89
+ "protocol": "http",
90
+ "username": "",
91
+ "password": ""
92
+ },
93
+ "ssl": {
94
+ "ecdhCurve": "",
95
+ "enabled": false,
96
+ "accept_invalid_cert": false,
97
+ "ca_file": "",
98
+ "key_file": "",
99
+ "cert_file": "",
100
+ "secure_protocol": "",
101
+ "ciphers": ""
102
+ },
103
+ "mongo": {
104
+ "host": "",
105
+ "port": 0,
106
+ "database": "",
107
+ "username": "",
108
+ "password": "",
109
+ "replSet": "",
110
+ "db_ssl": {
111
+ "enabled": false,
112
+ "accept_invalid_cert": false,
113
+ "ca_file": "",
114
+ "key_file": "",
115
+ "cert_file": ""
116
+ }
117
+ },
118
+ "devicebroker": {
119
+ "getDevice": [
120
+ {
121
+ "path": "/get/devices/{id}",
122
+ "method": "GET",
123
+ "query": {},
124
+ "body": {},
125
+ "headers": {},
126
+ "handleFailure": "fail",
127
+ "requestFields": {
128
+ "id": "name"
129
+ },
130
+ "responseDatakey": "",
131
+ "responseFields": {
132
+ "name": "host",
133
+ "ostype": "os",
134
+ "ostypePrefix": "system-",
135
+ "ipaddress": "attributes.ipaddr",
136
+ "port": "443"
137
+ }
138
+ }
139
+ ],
140
+ "getDevicesFiltered": [
141
+ {
142
+ "path": "/get/devices",
143
+ "method": "GET",
144
+ "pagination": {
145
+ "offsetVar": "",
146
+ "limitVar": "",
147
+ "incrementBy": "limit",
148
+ "requestLocation": "query"
149
+ },
150
+ "query": {},
151
+ "body": {},
152
+ "headers": {},
153
+ "handleFailure": "fail",
154
+ "requestFields": {},
155
+ "responseDatakey": "",
156
+ "responseFields": {
157
+ "name": "host",
158
+ "ostype": "os",
159
+ "ostypePrefix": "system-",
160
+ "ipaddress": "attributes.ipaddr",
161
+ "port": "443"
162
+ }
163
+ }
164
+ ],
165
+ "isAlive": [
166
+ {
167
+ "path": "/get/devices/{id}/status",
168
+ "method": "GET",
169
+ "query": {},
170
+ "body": {},
171
+ "headers": {},
172
+ "handleFailure": "fail",
173
+ "requestFields": {
174
+ "id": "name"
175
+ },
176
+ "responseDatakey": "",
177
+ "responseFields": {
178
+ "status": "status",
179
+ "statusValue": "online"
180
+ }
181
+ }
182
+ ],
183
+ "getConfig": [
184
+ {
185
+ "path": "/get/devices/{id}/configPart1",
186
+ "method": "GET",
187
+ "query": {},
188
+ "body": {},
189
+ "headers": {},
190
+ "handleFailure": "fail",
191
+ "requestFields": {
192
+ "id": "name"
193
+ },
194
+ "responseDatakey": "",
195
+ "responseFields": {}
196
+ }
197
+ ],
198
+ "getCount": [
199
+ {
200
+ "path": "/get/devices",
201
+ "method": "GET",
202
+ "query": {},
203
+ "body": {},
204
+ "headers": {},
205
+ "handleFailure": "fail",
206
+ "requestFields": {},
207
+ "responseDatakey": "",
208
+ "responseFields": {}
209
+ }
210
+ ]
211
+ },
212
+ "cache": {
213
+ "enabled": false,
214
+ "entities": [
215
+ {
216
+ "entityType": "",
217
+ "frequency": 1440,
218
+ "flushOnFail": false,
219
+ "limit": 1000,
220
+ "retryAttempts": 5,
221
+ "sort": true,
222
+ "populate": [
223
+ {
224
+ "path": "",
225
+ "method": "GET",
226
+ "pagination": {
227
+ "offsetVar": "",
228
+ "limitVar": "",
229
+ "incrementBy": "limit",
230
+ "requestLocation": "query"
231
+ },
232
+ "query": {},
233
+ "body": {},
234
+ "headers": {},
235
+ "handleFailure": "ignore",
236
+ "requestFields": {},
237
+ "responseDatakey": "",
238
+ "responseFields": {}
239
+ }
240
+ ],
241
+ "cachedTasks": [
242
+ {
243
+ "name": "",
244
+ "filterField": "",
245
+ "filterLoc": ""
246
+ }
247
+ ]
248
+ }
249
+ ]
250
+ }
251
+ },
252
+ "groups": [],
253
+ "brokers": [],
254
+ "logLevel": "none",
255
+ "timeout": 120000
256
+ }
@@ -0,0 +1,83 @@
1
+ /* @copyright Itential, LLC 2020 */
2
+
3
+ /* global describe context before after */
4
+ /* eslint global-require: warn */
5
+ /* eslint no-unused-vars: warn */
6
+ /* eslint import/no-extraneous-dependencies: warn */
7
+ /* eslint import/no-dynamic-require: warn */
8
+ /* eslint import/no-unresolved: warn */
9
+
10
+ const path = require('path');
11
+ const assert = require('assert');
12
+ const mocha = require('mocha');
13
+ const itParam = require('mocha-param');
14
+
15
+ const utils = require('../../utils/tbUtils');
16
+ const basicGet = require('../../utils/basicGet');
17
+ const { name } = require('../../package.json');
18
+ const { methods } = require('../../pronghorn.json');
19
+
20
+ const getPronghornProps = (iapDir) => {
21
+ console.log('Retrieving properties.json file...');
22
+ const rawProps = require(path.join(iapDir, 'properties.json'));
23
+ console.log('Decrypting properties...');
24
+ const pronghornProps = utils.decryptProperties(rawProps, iapDir);
25
+ console.log('Found properties.\n');
26
+ return pronghornProps;
27
+ };
28
+
29
+ let a;
30
+
31
+ describe('[integration] Adapter BasicGET Test', () => {
32
+ context('Testing GET calls without query parameters', () => {
33
+ before(async () => {
34
+ const iapDir = path.join(__dirname, '../../../../../');
35
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
36
+ const sampleProperties = require('../../sampleProperties.json');
37
+ const adapter = { properties: sampleProperties };
38
+ a = basicGet.getAdapterInstance(adapter);
39
+ } else {
40
+ const pronghornProps = getPronghornProps(iapDir);
41
+ console.log('Connecting to Database...');
42
+ const database = await basicGet.connect(pronghornProps);
43
+ console.log('Connection established.');
44
+ const adapter = await database.collection(utils.SERVICE_CONFIGS_COLLECTION).findOne(
45
+ { model: name }
46
+ );
47
+ a = basicGet.getAdapterInstance(adapter);
48
+ }
49
+ });
50
+
51
+ after((done) => {
52
+ done();
53
+ });
54
+
55
+ const basicGets = methods.filter((method) => (method.route.verb === 'GET' && method.input.length === 0));
56
+ if (basicGets.length === 0) {
57
+ console.log('No non-parameter GET calls found.');
58
+ process.exit(0);
59
+ }
60
+ const functionNames = basicGets.map((g) => g.name);
61
+ const request = function request(f, ad) {
62
+ return new Promise((resolve, reject) => {
63
+ const getRespCode = (resp) => {
64
+ if (resp) {
65
+ if (resp.metrics.code !== 200) {
66
+ console.log('\x1b[31m', `Testing ${f} \nResponseCode: ${resp.metrics.code}`);
67
+ }
68
+ resolve(resp.metrics.code);
69
+ } else {
70
+ console.log('\x1b[31m', `call ${f} results in failure`);
71
+ reject(new Error(`${f} failed`));
72
+ }
73
+ };
74
+ ad[f](getRespCode, console.log);
75
+ });
76
+ };
77
+
78
+ itParam('GET call should return 200', functionNames, (fname) => {
79
+ console.log(`\t ${fname}`);
80
+ return request(fname, a).then((result) => assert.equal(result, 200));
81
+ });
82
+ });
83
+ });
@@ -0,0 +1,142 @@
1
+ /* @copyright Itential, LLC 2020 */
2
+
3
+ /* global describe it context before after */
4
+ /* eslint no-unused-vars: warn */
5
+
6
+ const assert = require('assert');
7
+ const http = require('http');
8
+ const https = require('https');
9
+ const mocha = require('mocha');
10
+ const ping = require('ping');
11
+ const dnsLookup = require('dns-lookup-promise');
12
+
13
+ let host;
14
+ process.argv.forEach((val) => {
15
+ if (val.indexOf('--HOST') === 0) {
16
+ [, host] = val.split('=');
17
+ }
18
+ });
19
+
20
+ describe('[integration] Adapter Test', () => {
21
+ context(`Testing network connection on ${host}`, () => {
22
+ after((done) => {
23
+ done();
24
+ });
25
+
26
+ it('DNS resolve', (done) => {
27
+ dnsLookup(host)
28
+ .then((addresses) => {
29
+ try {
30
+ assert.ok(addresses.length > 0);
31
+ done();
32
+ } catch (error) {
33
+ done(error);
34
+ }
35
+ })
36
+ .catch((err) => {
37
+ done(err);
38
+ });
39
+ });
40
+
41
+ it('Responds to ping', (done) => {
42
+ ping.promise.probe(host)
43
+ .then((result) => {
44
+ try {
45
+ assert.ok(result.alive);
46
+ done();
47
+ } catch (error) {
48
+ done(error);
49
+ }
50
+ })
51
+ .catch((err) => {
52
+ done(err);
53
+ });
54
+ });
55
+
56
+ it('Support HTTP on port 80', (done) => {
57
+ const requestOptions = {
58
+ host,
59
+ port: 80,
60
+ method: 'HEAD'
61
+ };
62
+
63
+ const req = http.request(requestOptions, (res) => {
64
+ try {
65
+ assert.ok(res.statusCode >= 200 && res.statusCode < 400);
66
+ done();
67
+ } catch (error) {
68
+ done(error);
69
+ }
70
+ });
71
+
72
+ req.on('error', (err) => {
73
+ done(err);
74
+ });
75
+
76
+ req.end();
77
+ });
78
+
79
+ it('Support HTTPS on port 443', (done) => {
80
+ const requestOptions = {
81
+ host,
82
+ port: 443,
83
+ method: 'HEAD'
84
+ };
85
+
86
+ const req = https.request(requestOptions, (res) => {
87
+ try {
88
+ assert.ok(res.statusCode >= 200 && res.statusCode < 400);
89
+ done();
90
+ } catch (error) {
91
+ done(error);
92
+ }
93
+ });
94
+
95
+ req.on('error', (err) => {
96
+ done(err);
97
+ });
98
+
99
+ req.end();
100
+ });
101
+
102
+ it('Support IPv4', (done) => {
103
+ const options = {
104
+ family: 4,
105
+ hints: dnsLookup.ADDRCONFIG
106
+ };
107
+
108
+ dnsLookup.lookup(host, options)
109
+ .then((address, family) => {
110
+ try {
111
+ assert.ok(address !== null && family === 4);
112
+ done();
113
+ } catch (error) {
114
+ done(error);
115
+ }
116
+ })
117
+ .catch((err) => {
118
+ done(err);
119
+ });
120
+ });
121
+
122
+ it('Support IPv6', (done) => {
123
+ const options = {
124
+ family: 6,
125
+ hints: dnsLookup.ADDRCONFIG
126
+ };
127
+
128
+ dnsLookup.lookup(host, options)
129
+ .then((address, family) => {
130
+ try {
131
+ assert.ok(address !== null && family === 6);
132
+ done();
133
+ } catch (error) {
134
+ done(error);
135
+ }
136
+ })
137
+ .catch((err) => {
138
+ done(err);
139
+ });
140
+ });
141
+ });
142
+ });