@corellium/corellium-cli 1.2.6 → 1.2.7

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.
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" ?>
2
2
  <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
3
- <coverage lines-valid="0" lines-covered="0" line-rate="NaN" branches-valid="0" branches-covered="0" branch-rate="NaN" timestamp="1715705808060" complexity="0" version="0.1">
3
+ <coverage lines-valid="0" lines-covered="0" line-rate="NaN" branches-valid="0" branches-covered="0" branch-rate="NaN" timestamp="1715716510523" complexity="0" version="0.1">
4
4
  <sources>
5
5
  <source>/builds/middleware/corellium-cli</source>
6
6
  </sources>
@@ -86,7 +86,7 @@
86
86
  <div class='footer quiet pad2 space-top1 center small'>
87
87
  Code coverage generated by
88
88
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
89
- at 2024-05-14T16:56:48.070Z
89
+ at 2024-05-14T19:55:10.530Z
90
90
  </div>
91
91
  <script src="prettify.js"></script>
92
92
  <script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corellium/corellium-cli",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "Corellium CLI Tool",
5
5
  "scripts": {
6
6
  "corellium": "node index.js",
@@ -0,0 +1,21 @@
1
+ const { MAST_API_BASE_PATH, MAST_API_BASE_PATH_LEGACY } = require('./constants')
2
+
3
+ /**
4
+ * Temporarily support backwards compatibility with mast/matrix routes.
5
+ * Until all environments are listening on /matrix at the conclusion of release 6.4.0, we need to handle
6
+ * the possibility that some environments will listen to MAST on /mast or /matrix
7
+ *
8
+ * This temporary code can be removed in release 6.5.0 - CORE-7670
9
+ */
10
+ async function getMastApiBasePath (client, instance) {
11
+ try {
12
+ await client._fetch('GET', `${MAST_API_BASE_PATH}/${instance}/instances/${instance}/assessments`)
13
+ return MAST_API_BASE_PATH
14
+ } catch (_) {
15
+ // no-op, we want to fall back to legacy route.
16
+ }
17
+
18
+ return MAST_API_BASE_PATH_LEGACY
19
+ }
20
+
21
+ module.exports = { getMastApiBasePath }
@@ -1,3 +1,4 @@
1
1
  module.exports = {
2
- MAST_API_BASE_PATH: 'v1/services/matrix'
2
+ MAST_API_BASE_PATH: 'v1/services/matrix',
3
+ MAST_API_BASE_PATH_LEGACY: 'v1/services/mast' // CORE-7670
3
4
  }
@@ -1,6 +1,6 @@
1
1
  const Client = require('../../clients/Client')
2
2
  const { handleError } = require('../../error')
3
- const { MAST_API_BASE_PATH } = require('./constants')
3
+ const { getMastApiBasePath } = require('./api-base-path')
4
4
 
5
5
  /**
6
6
  * Create an assessment via corellium-mast API.
@@ -42,7 +42,8 @@ async function handler (argv) {
42
42
  const client = new Client(argv)
43
43
  try {
44
44
  const body = { instanceId: instance, bundleId: bundle, wordlistId: wordlist }
45
- const res = await client._fetch('POST', `${MAST_API_BASE_PATH}/${instance}/assessments`, body)
45
+ const API_BASE_PATH = await getMastApiBasePath(client, instance)
46
+ const res = await client._fetch('POST', `${API_BASE_PATH}/${instance}/assessments`, body)
46
47
  console.log(JSON.stringify(res))
47
48
  } catch (error) {
48
49
  handleError(error, 'create-assessment failed', verbose)
@@ -1,7 +1,7 @@
1
1
  const Client = require('../../clients/Client')
2
2
  const { handleError } = require('../../error')
3
- const { MAST_API_BASE_PATH } = require('./constants')
4
3
  const log = require('../../logging')
4
+ const { getMastApiBasePath } = require('./api-base-path')
5
5
 
6
6
  /**
7
7
  * Delete an assessment via corellium-mast API.
@@ -35,7 +35,8 @@ async function handler (argv) {
35
35
  const { assessment, instance, verbose } = argv
36
36
  const client = new Client(argv)
37
37
  try {
38
- await client._fetch('DELETE', `${MAST_API_BASE_PATH}/${instance}/assessments/${assessment}`)
38
+ const API_BASE_PATH = await getMastApiBasePath(client, instance)
39
+ await client._fetch('DELETE', `${API_BASE_PATH}/${instance}/assessments/${assessment}`)
39
40
  log.info('Assessment deleted.')
40
41
  } catch (error) {
41
42
  handleError(error, 'delete-assessment failed', verbose)
@@ -1,6 +1,6 @@
1
1
  const Client = require('../../clients/Client')
2
2
  const { handleError } = require('../../error')
3
- const { MAST_API_BASE_PATH } = require('./constants')
3
+ const { getMastApiBasePath } = require('./api-base-path')
4
4
 
5
5
  /**
6
6
  * Download assessment report via corellium-mast API.
@@ -43,7 +43,8 @@ async function handler (argv) {
43
43
  const { assessment, instance, format, verbose } = argv
44
44
  const client = new Client(argv)
45
45
  try {
46
- const res = await client._fetch('GET', `${MAST_API_BASE_PATH}/${instance}/assessments/${assessment}/download?format=${format}`)
46
+ const API_BASE_PATH = await getMastApiBasePath(client, instance)
47
+ const res = await client._fetch('GET', `${API_BASE_PATH}/${instance}/assessments/${assessment}/download?format=${format}`)
47
48
  console.log(res)
48
49
  } catch (error) {
49
50
  handleError(error, 'download-report failed', verbose)
@@ -1,6 +1,6 @@
1
1
  const Client = require('../../clients/Client')
2
2
  const { handleError } = require('../../error')
3
- const { MAST_API_BASE_PATH } = require('./constants')
3
+ const { getMastApiBasePath } = require('./api-base-path')
4
4
 
5
5
  /**
6
6
  * Get an assessment via corellium-mast API.
@@ -36,7 +36,8 @@ async function handler (argv) {
36
36
  const { assessment, instance, verbose } = argv
37
37
  const client = new Client(argv)
38
38
  try {
39
- const res = await client._fetch('GET', `${MAST_API_BASE_PATH}/${instance}/assessments/${assessment}`)
39
+ const API_BASE_PATH = await getMastApiBasePath(client, instance)
40
+ const res = await client._fetch('GET', `${API_BASE_PATH}/${instance}/assessments/${assessment}`)
40
41
  console.log(JSON.stringify(res))
41
42
  } catch (error) {
42
43
  handleError(error, 'get-assessment failed', verbose)
@@ -1,6 +1,6 @@
1
1
  const Client = require('../../clients/Client')
2
2
  const { handleError } = require('../../error')
3
- const { MAST_API_BASE_PATH } = require('./constants')
3
+ const { getMastApiBasePath } = require('./api-base-path')
4
4
 
5
5
  /**
6
6
  * Get assessments for an instance via corellium-mast API.
@@ -29,7 +29,8 @@ async function handler (argv) {
29
29
  const { instance, verbose } = argv
30
30
  const client = new Client(argv)
31
31
  try {
32
- const res = await client._fetch('GET', `${MAST_API_BASE_PATH}/${instance}/instances/${instance}/assessments`)
32
+ const API_BASE_PATH = await getMastApiBasePath(client, instance)
33
+ const res = await client._fetch('GET', `${API_BASE_PATH}/${instance}/instances/${instance}/assessments`)
33
34
  console.log(JSON.stringify(res))
34
35
  } catch (error) {
35
36
  handleError(error, 'get-assessments failed', verbose)
@@ -1,7 +1,7 @@
1
1
  const Client = require('../../clients/Client')
2
2
  const { handleError } = require('../../error')
3
- const { MAST_API_BASE_PATH } = require('./constants')
4
3
  const log = require('../../logging')
4
+ const { getMastApiBasePath } = require('./api-base-path')
5
5
 
6
6
  /**
7
7
  * The start-monitor command starts device monitoring via the start-monitor API on corellium-mast
@@ -37,7 +37,8 @@ async function handler (argv) {
37
37
  const { assessment, instance, verbose } = argv
38
38
  const client = new Client(argv)
39
39
  try {
40
- await client._fetch('POST', `${MAST_API_BASE_PATH}/${instance}/assessments/${assessment}/start`)
40
+ const API_BASE_PATH = await getMastApiBasePath(client, instance)
41
+ await client._fetch('POST', `${API_BASE_PATH}/${instance}/assessments/${assessment}/start`)
41
42
  log.info('Monitoring started.')
42
43
  } catch (error) {
43
44
  handleError(error, 'start-monitor failed', verbose)
@@ -1,7 +1,7 @@
1
1
  const Client = require('../../clients/Client')
2
2
  const { handleError } = require('../../error')
3
- const { MAST_API_BASE_PATH } = require('./constants')
4
3
  const log = require('../../logging')
4
+ const { getMastApiBasePath } = require('./api-base-path')
5
5
 
6
6
  /**
7
7
  * The stop-monitor command stops device monitoring via the stop-monitor API on corellium-mast.
@@ -37,7 +37,8 @@ async function handler (argv) {
37
37
  const { assessment, instance, verbose } = argv
38
38
  const client = new Client(argv)
39
39
  try {
40
- await client._fetch('POST', `${MAST_API_BASE_PATH}/${instance}/assessments/${assessment}/stop`)
40
+ const API_BASE_PATH = await getMastApiBasePath(client, instance)
41
+ await client._fetch('POST', `${API_BASE_PATH}/${instance}/assessments/${assessment}/stop`)
41
42
  log.info('Monitoring stopped.')
42
43
  } catch (error) {
43
44
  handleError(error, 'stop-monitor failed', verbose)
@@ -1,6 +1,6 @@
1
1
  const Client = require('../../clients/Client')
2
2
  const { handleError } = require('../../error')
3
- const { MAST_API_BASE_PATH } = require('./constants')
3
+ const { getMastApiBasePath } = require('./api-base-path')
4
4
 
5
5
  /**
6
6
  * The test command executes device testing via the test API on corellium-mast.
@@ -47,7 +47,8 @@ async function handler (argv) {
47
47
  const { grep, invert, assessment, instance, verbose } = argv
48
48
  const client = new Client(argv)
49
49
  try {
50
- const res = await client._fetch('POST', `${MAST_API_BASE_PATH}/${instance}/assessments/${assessment}/test`, { grep, invert })
50
+ const API_BASE_PATH = await getMastApiBasePath(client, instance)
51
+ const res = await client._fetch('POST', `${API_BASE_PATH}/${instance}/assessments/${assessment}/test`, { grep, invert })
51
52
  console.log(JSON.stringify(res))
52
53
  } catch (error) {
53
54
  handleError(error, 'test failed', verbose)