diff --git a/integration/out-of-bounds-read.test.ts b/integration/out-of-bounds-read.test.ts index c5786e2..0b7037c 100644 --- a/integration/out-of-bounds-read.test.ts +++ b/integration/out-of-bounds-read.test.ts @@ -23,6 +23,18 @@ describe('Tests aarch64 version', () => { expect(response.body.status).to.contain('success') }) + test('Handles Exception - aarch64', async () => { + const response = await getOutOfBoundsReadAarch64(app, 'pass', 'abc', -28) + + expect(response.status).to.equal(200) + expect(response.body.output).to.contain('Storing Secret...\nEnd index must be after start index') + expect(response.body.exception).to.deep.contain({ + killed: false, + code: 1, + signal: null, + }) + }) + test('Bad Parameters - aarch64', async () => { const response = await getOutOfBoundsReadAarch64(app, 'badpass', NaN, 'ttttttt') @@ -50,6 +62,23 @@ describe('Tests Cheri version', () => { expect(response.status).to.equal(200) expect(response.body.status).to.contain('error') + expect(response.body).to.have.property('exception').that.deep.contain({ + killed: false, + code: 162, + }) + expect(response.body.output).to.contain('In-address space security exception') + }) + + test('Handles Exception - cheri', async () => { + const response = await getOutOfBoundsReadCheri(app, 'pass', 'abc', -28) + + expect(response.status).to.equal(200) + expect(response.body.output).to.contain('Storing Secret...\nEnd index must be after start index') + expect(response.body.exception).to.deep.contain({ + killed: false, + code: 1, + signal: null, + }) }) test('Bad Parameters - cheri', async () => { diff --git a/package-lock.json b/package-lock.json index a105a2c..2775aa5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@digicatapult/morello-api", - "version": "0.6.6", + "version": "0.6.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@digicatapult/morello-api", - "version": "0.6.6", + "version": "0.6.7", "license": "Apache-2.0", "dependencies": { "body-parser": "^1.20.0", diff --git a/package.json b/package.json index ca8d74e..2f36d1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@digicatapult/morello-api", - "version": "0.6.6", + "version": "0.6.7", "description": "An interface for executing binaries on it's self and morello host.", "main": "src/index.ts", "scripts": { diff --git a/src/controllers/scenario/index.ts b/src/controllers/scenario/index.ts index 82d8fce..b81921d 100644 --- a/src/controllers/scenario/index.ts +++ b/src/controllers/scenario/index.ts @@ -42,14 +42,14 @@ ${eof}` this.log.debug({ msg: `executing ${bin} on ${this.address} host`, scp, ssh }) return new Promise((resolve) => { - exec(`${scp}; ${ssh}`, (err, stdout) => { + exec(`${scp}; ${ssh}`, (stderr, stdout, err) => { exec(rm) // fire and forget, remove binary file return resolve( - err + stderr ? { status: 'error', - output: stdout, - exception: err, + output: err || stdout, + exception: stderr, } : { status: 'success',