Skip to content
This repository has been archived by the owner on May 8, 2018. It is now read-only.

Fix nsp CLI crash in the no window (CI) envs #158

Merged
merged 2 commits into from
Apr 19, 2017
Merged

Fix nsp CLI crash in the no window (CI) envs #158

merged 2 commits into from
Apr 19, 2017

Conversation

koresar
Copy link
Contributor

@koresar koresar commented Apr 10, 2017

This Fixes the following crash:

nsp check

/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/utils.js:11
return Array(times + 1).join(str);
       ^

RangeError: Invalid array length
  at exports.repeat (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/utils.js:11:10)
  at line (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/index.js:140:11)
  at lineTop (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/index.js:154:13)
  at Table.toString (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/index.js:252:5)
  at /var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/lib/formatters/default.js:48:27
  at Array.forEach (native)
  at Object.module.exports (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/lib/formatters/default.js:33:6)
  at /var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/lib/commands/check.js:25:23
  at /var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/lib/check.js:240:7
  at /var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/wreck/lib/index.js:472:20

This Fixes the following crash:

> nsp check
  ```
/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/utils.js:11
  return Array(times + 1).join(str);
         ^
 
RangeError: Invalid array length
    at exports.repeat (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/utils.js:11:10)
    at line (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/index.js:140:11)
    at lineTop (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/index.js:154:13)
    at Table.toString (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/cli-table/lib/index.js:252:5)
    at /var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/lib/formatters/default.js:48:27
    at Array.forEach (native)
    at Object.module.exports (/var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/lib/formatters/default.js:33:6)
    at /var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/lib/commands/check.js:25:23
    at /var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/lib/check.js:240:7
    at /var/lib/buildkite-agent/builds/ip-10-0-51-163-1/app/node_modules/nsp/node_modules/wreck/lib/index.js:472:20
```
@koresar
Copy link
Contributor Author

koresar commented Apr 10, 2017

Hello @nlf

We are trying to apply nsp CLI to out CI/CD. All good until it runs on the build agents. Not sure why isTTY behaves weirdly in our case. But this PR fixes the issue.

Do you think this PR worth publishing a PATCH npm release?

Thanks

@wraithgar
Copy link
Contributor

While we're adding a guard statement, we might as well just make this a full on if statement inside the isTTY one to make sure width is > 0, not just "truthy"

@koresar
Copy link
Contributor Author

koresar commented Apr 10, 2017

@wraithgar @nlf Good suggestion. I've just pushed the fix. Please review.

@koresar
Copy link
Contributor Author

koresar commented Apr 16, 2017

Hello there. Looking to incorporate nsp into our CI.

Do you need help maintaining the project?

@nlf nlf merged commit 73c321d into nodesecurity:master Apr 19, 2017
@koresar koresar deleted the patch-1 branch April 26, 2017 07:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants