eventOneHQ/npm-audit-html

Handle 'vulnerabilities' of undefined

viane opened this issue · 4 comments

viane commented

I'm trying to run with npm audit fix --production --only=prod --json | npm-audit-html and got this error. I assume because the fix done it job and output is missing that entry.

Suggest solution:
haven't look at the code but i believe something like

const vulnerabilities = data.metadata.vulnerabilities || []

and output will show a default message of no vulnerability found.

I'd like to do a PR for this quick fix.

Hey, thanks for the bug report! That fix probably will work. I'd love to accept a PR with a good fix!

Might also want to look into putting a vulnerabilities fixed section in the report.

@viane I just created a PR with a super basic fix. Feel free to improve upon it.

viane commented

@nprail Hello Noah, I'm so sorry for the late reply, was packed last month. I did looked at the problem deeper since the solution I offered is too simple. So based on what I tried last time, the npm audit --fix will return a different sets of properties. I will start research/experiment bit more before I commit to submit a code change ( I think this will have the bug fix + feature support).

@viane After looking at it again, I'm not sure that this is a use case that I want to support. For now, I have added an error message saying that it isn't supported. If you can come up with a good method of handling it, I am still open to PRs.