snyk-go-parser
Advanced tools
Comparing version 1.5.0 to 1.5.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.buildGoVendorDepTree = exports.buildGoPkgDepTree = exports.parseGoModGraph = exports.parseGoVendorConfig = exports.parseGoPkgConfig = void 0; | ||
const tslib_1 = require("tslib"); | ||
const parsers_1 = require("./parsers"); | ||
@@ -15,6 +14,4 @@ Object.defineProperty(exports, "parseGoPkgConfig", { enumerable: true, get: function () { return parsers_1.parseGoPkgConfig; } }); | ||
// in particular, it cannot build the proper dependency graph (only a flat list). | ||
function buildGoPkgDepTree(manifestFileContents, lockFileContents, options) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return buildGoDepTree(parsers_1.parseGoPkgConfig(manifestFileContents, lockFileContents)); | ||
}); | ||
async function buildGoPkgDepTree(manifestFileContents, lockFileContents, options) { | ||
return buildGoDepTree(parsers_1.parseGoPkgConfig(manifestFileContents, lockFileContents)); | ||
} | ||
@@ -25,6 +22,4 @@ exports.buildGoPkgDepTree = buildGoPkgDepTree; | ||
// in particular, it cannot build the proper dependency graph (only a flat list). | ||
function buildGoVendorDepTree(manifestFileContents) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return buildGoDepTree(parsers_1.parseGoVendorConfig(manifestFileContents)); | ||
}); | ||
async function buildGoVendorDepTree(manifestFileContents) { | ||
return buildGoDepTree(parsers_1.parseGoVendorConfig(manifestFileContents)); | ||
} | ||
@@ -31,0 +26,0 @@ exports.buildGoVendorDepTree = buildGoVendorDepTree; |
@@ -14,9 +14,23 @@ "use strict"; | ||
function parseGoModGraph(goModGraphOutput, projectName, projectVersion = types_1.DEFAULT_INITIAL_VERSION) { | ||
const rootPkgInfo = { name: projectName, version: projectVersion }; | ||
const depGraph = new dep_graph_1.DepGraphBuilder({ name: GO_MODULES }, rootPkgInfo); | ||
var _a; | ||
const rootPkgInfo = { | ||
name: projectName.length ? projectName : '', | ||
version: projectVersion, | ||
}; | ||
let depGraph = new dep_graph_1.DepGraphBuilder({ name: GO_MODULES }, rootPkgInfo); | ||
for (const line of goModGraphOutput.trim().split('\n')) { | ||
const [[parentName, parentVersion = types_1.DEFAULT_INITIAL_VERSION], [childName, childVersion],] = parseGoModGraphLine(line); | ||
if (!((_a = rootPkgInfo.name) === null || _a === void 0 ? void 0 : _a.length)) { | ||
rootPkgInfo.name = parentName; // On first iteration we populate w/ the module name | ||
// If we updated the package name, we should update to a new DepGraphBuilder | ||
depGraph = new dep_graph_1.DepGraphBuilder({ name: GO_MODULES }, rootPkgInfo); | ||
} | ||
const parentPkg = { name: parentName, version: parentVersion }; | ||
const childPkg = { name: childName, version: childVersion || types_1.DEFAULT_INITIAL_VERSION }; | ||
const parentNodeId = parentName === rootPkgInfo.name ? types_1.DEFAULT_ROOT_NODE_NAME : `${parentName}@${parentVersion}`; | ||
const childPkg = { | ||
name: childName, | ||
version: childVersion || types_1.DEFAULT_INITIAL_VERSION, | ||
}; | ||
const parentNodeId = parentName === rootPkgInfo.name | ||
? types_1.DEFAULT_ROOT_NODE_NAME | ||
: `${parentName}@${parentVersion}`; | ||
const childNodeId = `${childPkg.name}@${childPkg.version}`; | ||
@@ -23,0 +37,0 @@ if (parentPkg.name !== rootPkgInfo.name) { |
@@ -12,7 +12,7 @@ "use strict"; | ||
lockJson.projects.forEach((proj) => { | ||
const version = proj.version || ('#' + proj.revision); | ||
const version = proj.version || '#' + proj.revision; | ||
proj.packages.forEach((subpackageName) => { | ||
const name = (subpackageName === '.' ? | ||
proj.name : | ||
proj.name + '/' + subpackageName); | ||
const name = subpackageName === '.' | ||
? proj.name | ||
: proj.name + '/' + subpackageName; | ||
const dep = { | ||
@@ -19,0 +19,0 @@ name, |
@@ -13,7 +13,7 @@ "use strict"; | ||
}; | ||
const packages = (gvJson.package || gvJson.Package); | ||
const packages = gvJson.package || gvJson.Package; | ||
if (packages) { | ||
packages.forEach((pkg) => { | ||
const revision = pkg.revision || pkg.Revision || pkg.version || pkg.Version; | ||
const version = pkg.versionExact || ('#' + revision); | ||
const version = pkg.versionExact || '#' + revision; | ||
const dep = { | ||
@@ -27,6 +27,9 @@ name: pkg.path, | ||
const ignores = gvJson.ignore || ''; | ||
ignores.split(/\s/).filter((s) => { | ||
ignores | ||
.split(/\s/) | ||
.filter((s) => { | ||
// otherwise it's a build-tag rather than a pacakge | ||
return s.indexOf('/') !== -1; | ||
}).forEach((pkgName) => { | ||
}) | ||
.forEach((pkgName) => { | ||
pkgName = pkgName.replace(/\/+$/, ''); // remove trailing / | ||
@@ -33,0 +36,0 @@ goProjectConfig.ignoredPkgs.push(pkgName); |
@@ -7,7 +7,10 @@ { | ||
"test": "jest", | ||
"lint": "tslint -p tsconfig.json", | ||
"lint:fix": "tslint -p tsconfig.json --fix", | ||
"build": "tsc", | ||
"build-watch": "tsc -w", | ||
"prepare": "npm run build" | ||
"prepare": "npm run build", | ||
"format:check": "prettier --check {lib,tests,scripts}/**/*.{js,ts}", | ||
"format": "prettier --write {lib,tests,scripts}/**/*.{js,ts}", | ||
"lint": "npm run format:check && npm run format:eslint", | ||
"format:eslint": "eslint --cache . --ext .js,.ts" | ||
}, | ||
@@ -35,2 +38,7 @@ "types": "./dist/index.d.ts", | ||
"devDependencies": { | ||
"prettier": "^1.18.2", | ||
"eslint-config-prettier": "^6.7.0", | ||
"@typescript-eslint/eslint-plugin": "^3.7.0", | ||
"@typescript-eslint/parser": "^3.7.0", | ||
"eslint": "^6.8.0", | ||
"@types/jest": "^23.3.14", | ||
@@ -44,3 +52,3 @@ "@types/node": "^8.10.65", | ||
}, | ||
"version": "1.5.0" | ||
"version": "1.5.1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
61211
0
12
22
222