snyk-go-plugin
Advanced tools
Comparing version 1.3.4 to 1.3.5
@@ -77,3 +77,4 @@ var fs = require('fs'); | ||
var pkgsTree = recursivelyBuildPkgTree( | ||
graph, root, lockedVersions, projectRootPath, []); | ||
graph, root, lockedVersions, projectRootPath, [], {}); | ||
delete pkgsTree._counts; | ||
@@ -140,3 +141,5 @@ pkgsTree.packageFormatVersion = 'golang:0.0.1'; | ||
projectRootPath, | ||
fromPath) { | ||
fromPath, | ||
counts | ||
) { | ||
@@ -169,9 +172,26 @@ var isRoot = (fromPath.length == 0); | ||
pkg._counts = counts; | ||
var children = graph.successors(node.Name); | ||
children.forEach(function (depName) { | ||
// We drop branches of overly common pkgs: | ||
// this looses some paths, but avoids explosion in result size | ||
if (pkg._counts[depName] > 50) { | ||
return; | ||
} | ||
var dep = graph.node(depName); | ||
var child = recursivelyBuildPkgTree( | ||
graph, dep, lockedVersions, projectRootPath, pkg.from); | ||
graph, | ||
dep, | ||
lockedVersions, | ||
projectRootPath, | ||
pkg.from, | ||
shallowCopyMap(pkg._counts) | ||
); | ||
pkg._counts = sumCounts(pkg._counts, child._counts); | ||
delete child._counts; | ||
if (isInternalPackage(child.name) || child._isProjSubpkg) { | ||
@@ -183,2 +203,5 @@ Object.keys(child.dependencies).forEach(function (grandChildName) { | ||
pkg.dependencies[child.name] = child; | ||
pkg._counts[child.name] = | ||
(pkg._counts[child.name] ? pkg._counts[child.name] + 1 : 1); | ||
} | ||
@@ -190,2 +213,22 @@ }) | ||
function sumCounts(a, b) { | ||
var sum = shallowCopyMap(a); | ||
for (var k in b) { | ||
sum[k] = (sum[k] ? (sum[k] + b[k]) : b[k]) | ||
} | ||
return sum; | ||
} | ||
function shallowCopyMap(m) { | ||
var copy = {}; | ||
for (var k in m) { | ||
copy[k] = m[k] | ||
} | ||
return copy; | ||
} | ||
function isProjSubpackage(pkgPath, projectRootPath) { | ||
@@ -192,0 +235,0 @@ if (pkgPath == projectRootPath) { |
@@ -28,3 +28,3 @@ { | ||
}, | ||
"version": "1.3.4" | ||
"version": "1.3.5" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17368
280