From 860bbd2711dfc99a8741523e8f8e1cbd256014b9 Mon Sep 17 00:00:00 2001 From: Andrew Kaiser Date: Tue, 8 Oct 2019 00:17:39 -0400 Subject: [PATCH] fix: bw vulnerabilty & printing bw error properly --- bin/cli.js | 6 +++--- package-lock.json | 12 ++++++------ package.json | 2 +- src/util/error.js | 4 ++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index f4c755f..8b5969a 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -7,7 +7,7 @@ const minimist = require('minimist') const menu = require('../src') const obfuscateState = require('../src/util/obfuscate') const { scheduleCleanup } = require('../src/schedule-cleanup') -const { CancelError } = require('../src/util/error') +const { CancelError, CommandError } = require('../src/util/error') const BW_LIST_ARGS_DEFAULT = '' const CACHE_PASSWORD_DEFAULT = 15 @@ -80,8 +80,8 @@ const pipeErrorToCommand = (command, e) => new Promise((resolve, reject) => { const errorCommand = exec(onErrorCommand) console.log(e) - return - errorCommand.stdin.write(`'${e.toString()}'`) + if (e instanceof CommandError) errorCommand.stdin.write(`'${e.errorMessage}'`) + else errorCommand.stdin.write(`'${e.toString()}'`) errorCommand.stdin.end() errorCommand.on('close', status => { if (status === 0) resolve() diff --git a/package-lock.json b/package-lock.json index 29a09e0..1d8c106 100644 --- a/package-lock.json +++ b/package-lock.json @@ -570,9 +570,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lodash.sortby": { "version": "4.7.0", @@ -728,9 +728,9 @@ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, "prettier": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.17.0.tgz", - "integrity": "sha512-sXe5lSt2WQlCbydGETgfm1YBShgOX4HxQkFPvbxkcwgDvGDeqVau8h+12+lmSVlP3rHPz0oavfddSZg/q+Szjw==", + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", + "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", "dev": true }, "pseudomap": { diff --git a/package.json b/package.json index 5c4085b..abdfd42 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,6 @@ "node": ">=8" }, "devDependencies": { - "prettier": "^1.17.0" + "prettier": "^1.18.2" } } diff --git a/src/util/error.js b/src/util/error.js index 22970a9..2d3a1c0 100644 --- a/src/util/error.js +++ b/src/util/error.js @@ -7,6 +7,10 @@ class CommandError extends Error { this.stderr = stderr ? stderr.toString().trim() : '' this.commandProcess = commandProcess } + + get errorMessage() { + return this.stdout || this.stderr || this.message + } } /**