@itentialopensource/adapter-checkpoint_management 0.2.4 → 0.3.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.
Files changed (113) hide show
  1. package/.eslintignore +1 -0
  2. package/AUTH.md +39 -0
  3. package/BROKER.md +199 -0
  4. package/CALLS.md +169 -0
  5. package/CHANGELOG.md +52 -13
  6. package/CODE_OF_CONDUCT.md +12 -17
  7. package/CONTRIBUTING.md +88 -74
  8. package/ENHANCE.md +69 -0
  9. package/PROPERTIES.md +641 -0
  10. package/README.md +228 -420
  11. package/SUMMARY.md +9 -0
  12. package/SYSTEMINFO.md +11 -0
  13. package/TROUBLESHOOT.md +47 -0
  14. package/adapter.js +2359 -37
  15. package/adapterBase.js +1270 -238
  16. package/entities/.generic/action.json +214 -0
  17. package/entities/.generic/schema.json +28 -0
  18. package/entities/.system/action.json +5 -5
  19. package/entities/APISettings/action.json +3 -3
  20. package/entities/AccessLayer/action.json +6 -6
  21. package/entities/AccessRole/action.json +6 -6
  22. package/entities/AccessRule/action.json +6 -6
  23. package/entities/AccessSection/action.json +5 -5
  24. package/entities/AddressRange/action.json +6 -6
  25. package/entities/Administrator/action.json +7 -7
  26. package/entities/Application/action.json +6 -6
  27. package/entities/ApplicationCategory/action.json +6 -6
  28. package/entities/ApplicationGroup/action.json +6 -6
  29. package/entities/DNSDomain/action.json +6 -6
  30. package/entities/DataCenter/action.json +4 -4
  31. package/entities/DataCenterObject/action.json +5 -5
  32. package/entities/Domain/action.json +6 -6
  33. package/entities/DynamicObject/action.json +6 -6
  34. package/entities/GlobalAssignment/action.json +7 -7
  35. package/entities/GlobalDomain/action.json +3 -3
  36. package/entities/Group/action.json +6 -6
  37. package/entities/GroupWithExclusion/action.json +6 -6
  38. package/entities/Host/action.json +6 -6
  39. package/entities/IPS/action.json +5 -5
  40. package/entities/IPSExtendedAttributes/action.json +3 -3
  41. package/entities/LoginMessage/action.json +3 -3
  42. package/entities/Misc/action.json +15 -15
  43. package/entities/MultiDomainServerMDS/action.json +3 -3
  44. package/entities/MulticastAddressRange/action.json +6 -6
  45. package/entities/NATRule/action.json +6 -6
  46. package/entities/NATSection/action.json +5 -5
  47. package/entities/Network/action.json +6 -6
  48. package/entities/OPSECApplication/action.json +6 -6
  49. package/entities/Placeholder/action.json +2 -2
  50. package/entities/Policy/action.json +3 -3
  51. package/entities/PolicyPackage/action.json +6 -6
  52. package/entities/SecurityZone/action.json +6 -6
  53. package/entities/ServiceDCERPC/action.json +6 -6
  54. package/entities/ServiceGroup/action.json +6 -6
  55. package/entities/ServiceICMP/action.json +6 -6
  56. package/entities/ServiceICMP6/action.json +6 -6
  57. package/entities/ServiceOther/action.json +6 -6
  58. package/entities/ServiceRPC/action.json +6 -6
  59. package/entities/ServiceSCTP/action.json +6 -6
  60. package/entities/ServiceTCP/action.json +6 -6
  61. package/entities/ServiceUDP/action.json +6 -6
  62. package/entities/Session/action.json +10 -10
  63. package/entities/SessionManagement/action.json +7 -7
  64. package/entities/SimpleGateway/action.json +6 -6
  65. package/entities/Tags/action.json +6 -6
  66. package/entities/ThreatEmulation/action.json +2 -2
  67. package/entities/ThreatException/action.json +6 -6
  68. package/entities/ThreatExceptionGroup/action.json +6 -6
  69. package/entities/ThreatIndicator/action.json +6 -6
  70. package/entities/ThreatLayer/action.json +6 -6
  71. package/entities/ThreatProfile/action.json +6 -6
  72. package/entities/ThreatProtection/action.json +6 -6
  73. package/entities/ThreatRule/action.json +6 -6
  74. package/entities/Time/action.json +6 -6
  75. package/entities/TimeGroup/action.json +6 -6
  76. package/entities/TrustedClient/action.json +6 -6
  77. package/entities/UpdatableObject/action.json +5 -5
  78. package/entities/UpdatableObjectsRepository/action.json +3 -3
  79. package/entities/VPNCommunityMeshed/action.json +6 -6
  80. package/entities/VPNCommunityStar/action.json +6 -6
  81. package/entities/Wildcard/action.json +6 -6
  82. package/error.json +12 -0
  83. package/package.json +41 -18
  84. package/pronghorn.json +642 -74
  85. package/propertiesDecorators.json +14 -0
  86. package/propertiesSchema.json +472 -4
  87. package/refs?service=git-upload-pack +0 -0
  88. package/report/adapterInfo.json +10 -0
  89. package/report/updateReport1614705421970.json +95 -0
  90. package/report/updateReport1646177180887.json +95 -0
  91. package/report/updateReport1653864222137.json +120 -0
  92. package/sampleProperties.json +113 -12
  93. package/test/integration/adapterTestBasicGet.js +85 -0
  94. package/test/integration/adapterTestConnectivity.js +93 -0
  95. package/test/integration/adapterTestIntegration.js +29 -98
  96. package/test/unit/adapterBaseTestUnit.js +949 -0
  97. package/test/unit/adapterTestUnit.js +642 -109
  98. package/utils/adapterInfo.js +206 -0
  99. package/utils/addAuth.js +94 -0
  100. package/utils/basicGet.js +50 -0
  101. package/utils/checkMigrate.js +63 -0
  102. package/utils/entitiesToDB.js +179 -0
  103. package/utils/findPath.js +74 -0
  104. package/utils/modify.js +154 -0
  105. package/utils/packModificationScript.js +1 -1
  106. package/utils/patches2bundledDeps.js +90 -0
  107. package/utils/pre-commit.sh +3 -0
  108. package/utils/removeHooks.js +20 -0
  109. package/utils/tbScript.js +184 -0
  110. package/utils/tbUtils.js +469 -0
  111. package/utils/testRunner.js +16 -16
  112. package/utils/troubleshootingAdapter.js +190 -0
  113. package/img/adapter.jpg +0 -0
@@ -0,0 +1,95 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 0
8
+ },
9
+ {
10
+ "owner": "errorJson",
11
+ "description": "Adapter errors no longer available for use",
12
+ "value": 0
13
+ },
14
+ {
15
+ "owner": "errorJson",
16
+ "description": "Adapter errors that have been updated (e.g. recommendation changes)",
17
+ "value": 30
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 13
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 7
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 23
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.44.11"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 64
43
+ },
44
+ {
45
+ "owner": "readmeMd",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 688
48
+ },
49
+ {
50
+ "owner": "unitTestJS",
51
+ "description": "Number of lines of code in unit tests",
52
+ "value": 9922
53
+ },
54
+ {
55
+ "owner": "unitTestJS",
56
+ "description": "Number of unit tests",
57
+ "value": 645
58
+ },
59
+ {
60
+ "owner": "integrationTestJS",
61
+ "description": "Number of lines of code in integration tests",
62
+ "value": 10273
63
+ },
64
+ {
65
+ "owner": "integrationTestJS",
66
+ "description": "Number of integration tests",
67
+ "value": 300
68
+ },
69
+ {
70
+ "owner": "staticFile",
71
+ "description": "Number of lines of code in adapterBase.js",
72
+ "value": 1029
73
+ },
74
+ {
75
+ "owner": "staticFile",
76
+ "description": "Number of static files added",
77
+ "value": 34
78
+ },
79
+ {
80
+ "owner": "Overall",
81
+ "description": "Total lines of Code",
82
+ "value": 21224
83
+ },
84
+ {
85
+ "owner": "Overall",
86
+ "description": "Total Tests",
87
+ "value": 945
88
+ },
89
+ {
90
+ "owner": "Overall",
91
+ "description": "Total Files",
92
+ "value": 6
93
+ }
94
+ ]
95
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 1
8
+ },
9
+ {
10
+ "owner": "errorJson",
11
+ "description": "Adapter errors no longer available for use",
12
+ "value": 0
13
+ },
14
+ {
15
+ "owner": "errorJson",
16
+ "description": "Adapter errors that have been updated (e.g. recommendation changes)",
17
+ "value": 30
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 14
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 7
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 22
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.45.6"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 70
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 338
48
+ },
49
+ {
50
+ "owner": "markdown",
51
+ "description": "Number of lines in the SUMMARY.md",
52
+ "value": 9
53
+ },
54
+ {
55
+ "owner": "markdown",
56
+ "description": "Number of lines in the PROPERTIES.md",
57
+ "value": 642
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the TROUBLESHOOT.md",
62
+ "value": 48
63
+ },
64
+ {
65
+ "owner": "markdown",
66
+ "description": "Number of lines in the ENHANCE.md",
67
+ "value": 70
68
+ },
69
+ {
70
+ "owner": "markdown",
71
+ "description": "Number of lines in the BROKER.md",
72
+ "value": 70
73
+ },
74
+ {
75
+ "owner": "unitTestJS",
76
+ "description": "Number of lines of code in unit tests",
77
+ "value": 9838
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 644
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 10194
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 300
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of lines of code in adapterBase.js",
97
+ "value": 1783
98
+ },
99
+ {
100
+ "owner": "staticFile",
101
+ "description": "Number of static files added",
102
+ "value": 36
103
+ },
104
+ {
105
+ "owner": "Overall",
106
+ "description": "Total lines of Code",
107
+ "value": 21815
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 944
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -2,29 +2,39 @@
2
2
  "id": "Adapter-checkpoint_management",
3
3
  "type": "CheckpointManagement",
4
4
  "properties": {
5
- "host": "localhost",
5
+ "host": "INSERT CHECKPOINT HOST HERE",
6
6
  "port": 443,
7
7
  "base_path": "/web_api",
8
8
  "version": "",
9
9
  "cache_location": "none",
10
10
  "encode_pathvars": true,
11
- "save_metric": true,
12
- "stub": true,
11
+ "encode_queryvars": true,
12
+ "save_metric": false,
13
+ "stub": false,
13
14
  "protocol": "https",
14
15
  "authentication": {
15
16
  "auth_method": "request_token",
16
- "username": "username",
17
- "password": "password",
17
+ "username": "INSERT USER NAME HERE",
18
+ "password": "INSERT PASSWORD HERE",
18
19
  "token": "",
19
- "token_timeout": 600000,
20
+ "token_user_field": "user",
21
+ "token_password_field": "password",
22
+ "token_result_field": "sid",
23
+ "token_URI_path": "/login",
24
+ "invalid_token_error": 400,
25
+ "token_timeout": 300000,
20
26
  "token_cache": "local",
21
- "invalid_token_error": 401,
22
- "auth_field": "header.headers.X-chkp-sid",
23
- "auth_field_format": "{token}"
27
+ "auth_field": "header.headers.x-chkp-sid",
28
+ "auth_field_format": "{token}",
29
+ "auth_logging": false,
30
+ "client_id": "",
31
+ "client_secret": "",
32
+ "grant_type": ""
24
33
  },
25
34
  "healthcheck": {
26
35
  "type": "startup",
27
- "frequency": 60000
36
+ "frequency": 60000,
37
+ "query_object": {}
28
38
  },
29
39
  "throttle": {
30
40
  "throttle_enabled": false,
@@ -55,13 +65,16 @@
55
65
  },
56
66
  "healthcheck_on_timeout": true,
57
67
  "return_raw": false,
58
- "archiving": false
68
+ "archiving": false,
69
+ "return_request": false
59
70
  },
60
71
  "proxy": {
61
72
  "enabled": false,
62
73
  "host": "",
63
74
  "port": 1,
64
- "protocol": "http"
75
+ "protocol": "http",
76
+ "username": "",
77
+ "password": ""
65
78
  },
66
79
  "ssl": {
67
80
  "ecdhCurve": "",
@@ -87,6 +100,94 @@
87
100
  "key_file": "",
88
101
  "cert_file": ""
89
102
  }
103
+ },
104
+ "devicebroker": {
105
+ "getDevice": [
106
+ {
107
+ "path": "/get/devices/{id}",
108
+ "method": "GET",
109
+ "query": {},
110
+ "body": {},
111
+ "headers": {},
112
+ "handleFailure": "ignore",
113
+ "requestFields": {
114
+ "id": "name"
115
+ },
116
+ "responseDatakey": "",
117
+ "responseFields": {
118
+ "name": "host",
119
+ "ostype": "os",
120
+ "ostypePrefix": "system-",
121
+ "ipaddress": "attributes.ipaddr",
122
+ "port": "443"
123
+ }
124
+ }
125
+ ],
126
+ "getDevicesFiltered": [
127
+ {
128
+ "path": "/get/devices",
129
+ "method": "GET",
130
+ "query": {},
131
+ "body": {},
132
+ "headers": {},
133
+ "handleFailure": "ignore",
134
+ "requestFields": {},
135
+ "responseDatakey": "",
136
+ "responseFields": {
137
+ "name": "host",
138
+ "ostype": "os",
139
+ "ostypePrefix": "system-",
140
+ "ipaddress": "attributes.ipaddr",
141
+ "port": "443"
142
+ }
143
+ }
144
+ ],
145
+ "isAlive": [
146
+ {
147
+ "path": "/get/devices/{id}/status",
148
+ "method": "GET",
149
+ "query": {},
150
+ "body": {},
151
+ "headers": {},
152
+ "handleFailure": "ignore",
153
+ "requestFields": {
154
+ "id": "name"
155
+ },
156
+ "responseDatakey": "",
157
+ "responseFields": {
158
+ "status": "status",
159
+ "statusValue": "online"
160
+ }
161
+ }
162
+ ],
163
+ "getConfig": [
164
+ {
165
+ "path": "/get/devices/{id}/configPart1",
166
+ "method": "GET",
167
+ "query": {},
168
+ "body": {},
169
+ "headers": {},
170
+ "handleFailure": "ignore",
171
+ "requestFields": {
172
+ "id": "name"
173
+ },
174
+ "responseDatakey": "",
175
+ "responseFields": {}
176
+ }
177
+ ],
178
+ "getCount": [
179
+ {
180
+ "path": "/get/devices",
181
+ "method": "GET",
182
+ "query": {},
183
+ "body": {},
184
+ "headers": {},
185
+ "handleFailure": "ignore",
186
+ "requestFields": {},
187
+ "responseDatakey": "",
188
+ "responseFields": {}
189
+ }
190
+ ]
90
191
  }
91
192
  },
92
193
  "groups": [],
@@ -0,0 +1,85 @@
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 mocha = require('mocha');
11
+ const path = require('path');
12
+ const assert = require('assert');
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
+ const { Discovery } = require('@itential/itential-utils');
22
+ console.log('Retrieving properties.json file...');
23
+ const rawProps = require(path.join(iapDir, 'properties.json'));
24
+ console.log('Decrypting properties...');
25
+ const discovery = new Discovery();
26
+ const pronghornProps = utils.decryptProperties(rawProps, path.join(__dirname, '..'), discovery);
27
+ console.log('Found properties.\n');
28
+ return pronghornProps;
29
+ };
30
+
31
+ let a;
32
+
33
+ describe('[integration] Adapter BasicGET Test', () => {
34
+ context('Testing GET calls without query parameters', () => {
35
+ before(async () => {
36
+ const iapDir = path.join(__dirname, '../../../../../');
37
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
38
+ const sampleProperties = require('../../sampleProperties.json');
39
+ const adapter = { properties: sampleProperties };
40
+ a = basicGet.getAdapterInstance(adapter);
41
+ } else {
42
+ const pronghornProps = getPronghornProps(iapDir);
43
+ console.log('Connecting to Database...');
44
+ const database = await basicGet.connect(pronghornProps);
45
+ console.log('Connection established.');
46
+ const adapter = await database.collection(utils.SERVICE_CONFIGS_COLLECTION).findOne(
47
+ { model: name }
48
+ );
49
+ a = basicGet.getAdapterInstance(adapter);
50
+ }
51
+ });
52
+
53
+ after((done) => {
54
+ done();
55
+ });
56
+
57
+ const basicGets = methods.filter((method) => (method.route.verb === 'GET' && method.input.length === 0));
58
+ if (basicGets.length === 0) {
59
+ console.log('No non-parameter GET calls found.');
60
+ process.exit(0);
61
+ }
62
+ const functionNames = basicGets.map((g) => g.name);
63
+ const request = function request(f, ad) {
64
+ return new Promise((resolve, reject) => {
65
+ const getRespCode = (resp) => {
66
+ if (resp) {
67
+ if (resp.metrics.code !== 200) {
68
+ console.log('\x1b[31m', `Testing ${f} \nResponseCode: ${resp.metrics.code}`);
69
+ }
70
+ resolve(resp.metrics.code);
71
+ } else {
72
+ console.log('\x1b[31m', `call ${f} results in failure`);
73
+ reject(new Error(`${f} failed`));
74
+ }
75
+ };
76
+ ad[f](getRespCode, console.log);
77
+ });
78
+ };
79
+
80
+ itParam('GET call should return 200', functionNames, (fname) => {
81
+ console.log(`\t ${fname}`);
82
+ return request(fname, a).then((result) => assert.equal(result, 200));
83
+ });
84
+ });
85
+ });
@@ -0,0 +1,93 @@
1
+ /* @copyright Itential, LLC 2020 */
2
+
3
+ /* global describe it context before after */
4
+ /* eslint no-unused-vars: warn */
5
+
6
+ const mocha = require('mocha');
7
+ const assert = require('assert');
8
+ const diagnostics = require('network-diagnostics');
9
+
10
+ let host;
11
+ process.argv.forEach((val) => {
12
+ if (val.indexOf('--HOST') === 0) {
13
+ [, host] = val.split('=');
14
+ }
15
+ });
16
+
17
+ describe('[integration] Adapter Test', () => {
18
+ context(`Testing network connection on ${host}`, () => {
19
+ before(() => {
20
+ diagnostics.setTestURL(host);
21
+ });
22
+
23
+ after((done) => {
24
+ done();
25
+ });
26
+
27
+ it('DNS resolve', (done) => {
28
+ diagnostics.haveDNS((result) => {
29
+ try {
30
+ assert.equal(result, true);
31
+ done();
32
+ } catch (error) {
33
+ done(error);
34
+ }
35
+ });
36
+ });
37
+
38
+ it('Responds to ping', (done) => {
39
+ diagnostics.havePing((result) => {
40
+ try {
41
+ assert.equal(result, true);
42
+ done();
43
+ } catch (error) {
44
+ done(error);
45
+ }
46
+ });
47
+ });
48
+
49
+ it('Support HTTP on port 80', (done) => {
50
+ diagnostics.haveHTTP((result) => {
51
+ try {
52
+ assert.equal(result, true);
53
+ done();
54
+ } catch (error) {
55
+ done(error);
56
+ }
57
+ });
58
+ });
59
+
60
+ it('Support HTTPS on port 443', (done) => {
61
+ diagnostics.haveHTTPS((result) => {
62
+ try {
63
+ assert.equal(result, true);
64
+ done();
65
+ } catch (error) {
66
+ done(error);
67
+ }
68
+ });
69
+ });
70
+
71
+ it('Support IPv4', (done) => {
72
+ diagnostics.haveIPv4Async((result) => {
73
+ try {
74
+ assert.equal(result, true);
75
+ done();
76
+ } catch (error) {
77
+ done(error);
78
+ }
79
+ });
80
+ });
81
+
82
+ it('Support IPv6', (done) => {
83
+ diagnostics.haveIPv6Async((result) => {
84
+ try {
85
+ assert.equal(result, true);
86
+ done();
87
+ } catch (error) {
88
+ done(error);
89
+ }
90
+ });
91
+ });
92
+ });
93
+ });