snyk-go-plugin
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -33,3 +33,4 @@ var fs = require('fs'); | ||
var pkgsTree = recursivelyBuildPkgTree(tree, depLocks, []); | ||
var projectRootPath = path.dirname(path.resolve(targetFile)); | ||
var pkgsTree = recursivelyBuildPkgTree(tree, depLocks, projectRootPath, []); | ||
pkgsTree.packageFormatVersion = 'golang:0.0.1'; | ||
@@ -55,3 +56,27 @@ | ||
function recursivelyBuildPkgTree(goDepsTree, depLocks, fromPath) { | ||
function isInternalPkg(pkgPath, projectRootPath) { | ||
if (pkgPath == projectRootPath) { | ||
return true; | ||
} | ||
var root = projectRootPath; | ||
root = | ||
(root[root.length - 1] == path.sep) ? root : (root + path.sep); | ||
if (pkgPath.indexOf(root) != 0) { | ||
return false; | ||
} | ||
var pkgRelativePath = pkgPath.slice(root.length); | ||
if ( | ||
pkgRelativePath.indexOf('vendor/') == 0 || | ||
pkgRelativePath.indexOf('/vendor/') >= 0) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
function recursivelyBuildPkgTree(goDepsTree, depLocks, projectRootPath, fromPath) { | ||
var isRoot = (fromPath.length == 0); | ||
@@ -64,6 +89,9 @@ | ||
if (isRoot) { | ||
if (isRoot || isInternalPkg(goDepsTree.Dir, projectRootPath)) { | ||
pkg.version = '0.0.0'; | ||
} else if (!depLocks[pkg.name]) { | ||
pkg.version = ''; | ||
// TODO: throw or warn here | ||
} else { | ||
pkg.version = depLocks[pkg.name] ? depLocks[pkg.name].version : ''; | ||
pkg.version = depLocks[pkg.name].version; | ||
} | ||
@@ -74,3 +102,4 @@ | ||
goDepsTree.Deps && goDepsTree.Deps.forEach(function (dep) { | ||
var child = recursivelyBuildPkgTree(dep, depLocks, pkg.from) | ||
var child = recursivelyBuildPkgTree( | ||
dep, depLocks, projectRootPath, pkg.from) | ||
pkg.dependencies[child.name] = child; | ||
@@ -77,0 +106,0 @@ }) |
@@ -28,3 +28,3 @@ { | ||
}, | ||
"version": "1.1.3" | ||
"version": "1.1.4" | ||
} |
Sorry, the diff of this file is not supported yet
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
11603
124