Closed Raynos closed 5 years ago
Spent 5 minutes looking into adding a test to this PR but it appears that the mock server uses version gating as part of its logic, so I aborted for now.
This is wrong. Ignore it in the sort if you must.
At least log something. Anything.
I've improved handling of bad data from ncm-api.
Instead of skipping the module we set the version to unknown.
The output of report looks like
raynos at raynos-Precision-5530
~/nodesource/ncm-cli on handle-bad-data*
$ node bin/ncm-cli.js report --long --dir ./test/fixtures/poisoned-project/
╔═════════════════════════╗
║ poisoned-project Report ║
╚═════════════════════════╝
4 packages checked
! 0 critical risk
1 high risk
0 medium risk
0 low risk
✓ No security vulnerabilities found
! 1 noncompliant modules found
|➔ Run `ncm report --filter=compliance` for a list
─────────────────────────────────────────────────────────────────────────────────────────────────
Modules
-------------------------------------------------------------------------------------------------
Module Name Risk License Security
┌──────────────────────────────────────────┬────────────┬───────────────────────┬───────────────┐
│ left-pad @ 1.3.0 │ |||| High │ X WTFPL │ ✓ 0 │
│ is-path-in-cwd… @ 0.0.0-UNKNOWN-VERSION │ │ │ │
│ is-path-inside @ 2.1.0 │ |||| None │ ✓ MIT │ ✓ 0 │
│ path-is-inside @ 1.0.2 │ |||| None │ ✓ (WTFPL OR MIT) │ ✓ 0 │
└──────────────────────────────────────────┴────────────┴───────────────────────┴───────────────┘
This reflects that we did find the module and we attempted to compute its score but we print empty because we have no data for that module.
@Fishrock123 I believe I resolved all the open issues while @Raynos is out. PTAL.
Looks good. I will land in the morning if it isn't already by then.
It's possible for some data from ncm-api to come back as malformed. We do not want to include it in the report.
This allows
ncm-cli report
to return data from almost all modules, instead of a single bad module in ncm-api causing the entire report to fail.If the version field is falsey then skip this item and drop it from the report.