Fix exec web socket/upload/download

This commit is contained in:
Girish Ramakrishnan
2022-05-16 11:37:25 -07:00
parent b5c2a0ff44
commit 93bacd00da
2 changed files with 7 additions and 10 deletions

View File

@@ -760,12 +760,6 @@ async function startExecWebSocket(req, res, next) {
assert.strictEqual(typeof req.app, 'object');
assert.strictEqual(typeof req.params.execId, 'string');
let cmd = null;
if (req.query.cmd) {
cmd = safe.JSON.parse(req.query.cmd);
if (!Array.isArray(cmd) || cmd.length < 1) return next(new HttpError(400, 'cmd must be array with atleast size 1'));
}
const columns = req.query.columns ? parseInt(req.query.columns, 10) : null;
if (isNaN(columns)) return next(new HttpError(400, 'columns must be a number'));
@@ -777,7 +771,7 @@ async function startExecWebSocket(req, res, next) {
// in a badly configured reverse proxy, we might be here without an upgrade
if (req.headers['upgrade'] !== 'websocket') return next(new HttpError(404, 'exec requires websocket'));
const [error, duplexStream] = await safe(apps.startExec(req.app, { cmd: cmd, rows: rows, columns: columns, tty: tty }));
const [error, duplexStream] = await safe(apps.startExec(req.app, req.params.execId, { rows, columns, tty }));
if (error) return next(BoxError.toHttpError(error));
req.clearTimeout();