@corellium/corellium-cli 1.2.6 → 1.2.8
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/coverage/cobertura-coverage.xml +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/package.json +2 -2
- package/src/clients/Agent.js +34 -4
- package/src/commands/instances/apps/index.js +30 -23
- package/src/commands/instances/apps/open.js +37 -0
- package/src/commands/mast/api-base-path.js +21 -0
- package/src/commands/mast/constants.js +2 -1
- package/src/commands/mast/create-assessment.js +3 -2
- package/src/commands/mast/delete-assessment.js +3 -2
- package/src/commands/mast/download-report.js +3 -2
- package/src/commands/mast/get-assessment.js +3 -2
- package/src/commands/mast/get-assessments.js +3 -2
- package/src/commands/mast/start-monitor.js +3 -2
- package/src/commands/mast/stop-monitor.js +3 -2
- package/src/commands/mast/test.js +3 -2
@@ -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="
|
3
|
+
<coverage lines-valid="0" lines-covered="0" line-rate="NaN" branches-valid="0" branches-covered="0" branch-rate="NaN" timestamp="1715897730108" 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-
|
89
|
+
at 2024-05-16T22:15:30.115Z
|
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.
|
3
|
+
"version": "1.2.8",
|
4
4
|
"description": "Corellium CLI Tool",
|
5
5
|
"scripts": {
|
6
6
|
"corellium": "node index.js",
|
@@ -27,7 +27,7 @@
|
|
27
27
|
],
|
28
28
|
"dependencies": {
|
29
29
|
"@corellium/client-api": "^0.1.0",
|
30
|
-
"@corellium/corellium-api": "^1.7.
|
30
|
+
"@corellium/corellium-api": "^1.7.7",
|
31
31
|
"axios": "^0.27.2",
|
32
32
|
"chalk": "^4.1.2",
|
33
33
|
"cli-progress": "^3.12.0",
|
package/src/clients/Agent.js
CHANGED
@@ -6,8 +6,15 @@ const { progressBar } = require('../progress')
|
|
6
6
|
const { getCorelliumApi } = require('../corellium-api')
|
7
7
|
|
8
8
|
/**
|
9
|
-
* @typedef {object}
|
10
|
-
* @property {Array<
|
9
|
+
* @typedef {object} App
|
10
|
+
* @property {Array<any>} tags
|
11
|
+
* @property {boolean} running
|
12
|
+
* @property {string} [icon]
|
13
|
+
* @property {number} diskUsage
|
14
|
+
* @property {number} date
|
15
|
+
* @property {string} applicationType
|
16
|
+
* @property {string} name
|
17
|
+
* @property {string} bundleID
|
11
18
|
*/
|
12
19
|
|
13
20
|
/**
|
@@ -30,14 +37,19 @@ class AgentCLI extends Client {
|
|
30
37
|
|
31
38
|
/**
|
32
39
|
* List apps on device
|
33
|
-
* @returns {Promise<Array<
|
40
|
+
* @returns {Promise<Array<App>>}
|
34
41
|
*/
|
35
|
-
listApps = async (options) => {
|
42
|
+
listApps = async (options = { loadIcons: false }) => {
|
36
43
|
const { loadIcons } = options
|
37
44
|
const response = (await this._fetch('GET', `${this.agentBasePath()}/app/apps?loadIcons=${loadIcons ? 1 : 0}`, {}))
|
38
45
|
return response ? response.apps : []
|
39
46
|
}
|
40
47
|
|
48
|
+
/**
|
49
|
+
* Install an app on device
|
50
|
+
* @param {string} app - path to app
|
51
|
+
* @returns {Promise<void>}
|
52
|
+
*/
|
41
53
|
installApp = async (app) => {
|
42
54
|
// get app info
|
43
55
|
const filePath = resolve(app)
|
@@ -47,6 +59,7 @@ class AgentCLI extends Client {
|
|
47
59
|
const corellium = await getCorelliumApi()
|
48
60
|
const instance = await corellium.getInstance(this.instance)
|
49
61
|
const agent = await instance.agent()
|
62
|
+
await agent.ready()
|
50
63
|
|
51
64
|
// configure upload bar for user
|
52
65
|
const uploadBar = progressBar()
|
@@ -64,6 +77,23 @@ class AgentCLI extends Client {
|
|
64
77
|
// cleanup
|
65
78
|
await agent.disconnect()
|
66
79
|
};
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Open an application on a device
|
83
|
+
* @param {string} bundleId - Application Bundle ID
|
84
|
+
* @returns {Promise<void>}
|
85
|
+
*/
|
86
|
+
openApp = async (bundleId) => {
|
87
|
+
// get agent
|
88
|
+
const corellium = await getCorelliumApi()
|
89
|
+
const instance = await corellium.getInstance(this.instance)
|
90
|
+
const agent = await instance.agent()
|
91
|
+
await agent.ready()
|
92
|
+
await agent.openApp(bundleId)
|
93
|
+
|
94
|
+
// cleanup
|
95
|
+
await agent.disconnect()
|
96
|
+
}
|
67
97
|
}
|
68
98
|
|
69
99
|
module.exports = AgentCLI
|
@@ -3,35 +3,42 @@ const { displayTable } = require('../../../table')
|
|
3
3
|
const { validateNonEmpty } = require('../../../utils')
|
4
4
|
const { handleError } = require('../../../error')
|
5
5
|
const InstallCommand = require('./install')
|
6
|
+
const OpenCommand = require('./open')
|
6
7
|
|
7
8
|
async function builder (yargs) {
|
8
9
|
yargs.option('verbose', {
|
9
10
|
alias: 'v',
|
10
11
|
type: 'boolean',
|
11
12
|
describe: 'Console will receive verbose error output'
|
12
|
-
})
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
13
|
+
})
|
14
|
+
.option('project', {
|
15
|
+
type: 'input',
|
16
|
+
describe: 'Project ID',
|
17
|
+
demandOption: true,
|
18
|
+
string: true,
|
19
|
+
validateNonEmpty
|
20
|
+
})
|
21
|
+
.option('instance', {
|
22
|
+
type: 'input',
|
23
|
+
describe: 'Instance ID',
|
24
|
+
demandOption: true,
|
25
|
+
string: true,
|
26
|
+
validateNonEmpty
|
27
|
+
})
|
28
|
+
.option('load-icons', {
|
29
|
+
type: 'input',
|
30
|
+
describe: 'Toggle loading of icons',
|
31
|
+
demandOption: false,
|
32
|
+
boolean: true
|
33
|
+
})
|
34
|
+
.option('format', {
|
35
|
+
type: 'input',
|
36
|
+
describe: 'Output format (default is json) e.g. table',
|
37
|
+
string: true,
|
38
|
+
choices: ['table', 'json', 'csv']
|
39
|
+
})
|
40
|
+
.command(InstallCommand)
|
41
|
+
.command(OpenCommand)
|
35
42
|
}
|
36
43
|
|
37
44
|
async function handler (argv) {
|
@@ -0,0 +1,37 @@
|
|
1
|
+
const AgentCLI = require('../../../clients/Agent')
|
2
|
+
const { validateNonEmpty } = require('../../../utils')
|
3
|
+
const { handleError } = require('../../../error')
|
4
|
+
const log = require('../../../logging')
|
5
|
+
|
6
|
+
async function builder (yargs) {
|
7
|
+
yargs.option('bundle', {
|
8
|
+
alias: 'b',
|
9
|
+
type: 'string',
|
10
|
+
demandOption: true,
|
11
|
+
describe: 'application bundle id',
|
12
|
+
validateNonEmpty
|
13
|
+
})
|
14
|
+
}
|
15
|
+
|
16
|
+
async function handler (argv) {
|
17
|
+
try {
|
18
|
+
const { bundle: bundleId } = argv
|
19
|
+
const agent = new AgentCLI(argv)
|
20
|
+
log.info('Opening app...')
|
21
|
+
const apps = await agent.listApps()
|
22
|
+
if (!apps.filter(app => app.bundleID === bundleId).length) {
|
23
|
+
throw new Error('App not installed.')
|
24
|
+
}
|
25
|
+
await agent.openApp(bundleId)
|
26
|
+
log.info('App opened.')
|
27
|
+
} catch (err) {
|
28
|
+
handleError(err, 'Open app failed', argv.verbose)
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
module.exports = {
|
33
|
+
builder,
|
34
|
+
handler,
|
35
|
+
command: 'open',
|
36
|
+
describe: 'Open app on device instance'
|
37
|
+
}
|
@@ -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,6 +1,6 @@
|
|
1
1
|
const Client = require('../../clients/Client')
|
2
2
|
const { handleError } = require('../../error')
|
3
|
-
const {
|
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
|
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
|
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 {
|
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
|
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 {
|
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
|
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 {
|
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
|
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
|
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
|
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 {
|
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
|
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)
|