diff --git a/services/service.ts b/services/service.ts index 927c96d..e2f8ee2 100644 --- a/services/service.ts +++ b/services/service.ts @@ -620,7 +620,15 @@ function runService() { * Executes a shell command and responds with exit code, stdout and stderr. */ type ExecPayload = { command: string }; - service.register('exec', (message) => { + service.register('exec', (message: Message) => { + if (!('command' in message.payload)) { + message.respond(makeError('missing "command"')); + return; + } else if (typeof message.payload['command'] !== 'string') { + message.respond(makeError('"command" is not a string')); + return; + } + const payload = message.payload as ExecPayload; child_process.exec(payload.command, { encoding: 'buffer' }, (error, stdout, stderr) => { const response = {