Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
expose isDirect on Vuln type, not just in JSON outpput
Browse files Browse the repository at this point in the history
  • Loading branch information
naugtur committed Sep 20, 2021
1 parent a6c0410 commit 40cb98d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/vuln.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ class Vuln {
}
}

get isDirect () {
const edgesIn = [...this.nodes.values()].flatMap(n => [...n.edgesIn])
const isDirect = edgesIn.some(e => e.from.isProjectRoot)
return isDirect
}

testSpec (spec) {
const specObj = npa(spec)
if (!specObj.registry)
Expand All @@ -94,13 +100,10 @@ class Vuln {
}

toJSON () {
const edgesIn = [...this.nodes.values()].flatMap(n => [...n.edgesIn])
const isDirect = edgesIn.some(e => e.from.isProjectRoot)

return {
name: this.name,
severity: this.severity,
isDirect,
isDirect: this.isDirect,
// just loop over the advisories, since via is only Vuln objects,
// and calculated advisories have all the info we need
via: [...this.advisories].map(v => v.type === 'metavuln' ? v.dependency : {
Expand Down

0 comments on commit 40cb98d

Please sign in to comment.