snyk-go-parser
Advanced tools
Comparing version 1.2.0 to 1.3.0
import { parseGoPkgConfig, parseGoVendorConfig } from './parser'; | ||
import { toSnykVersion, parseVersion } from './gomod-parser'; | ||
import { DepTree, GoPackageManagerType, GoProjectConfig, ModuleVersion } from './types'; | ||
import { parseGoMod, toSnykVersion, parseVersion } from './gomod-parser'; | ||
import { DepTree, GoPackageManagerType, GoProjectConfig, ModuleVersion, GoMod } from './types'; | ||
interface DepDict { | ||
@@ -13,5 +13,4 @@ [dep: string]: DepTree; | ||
export { GoPackageManagerType }; | ||
export { parseGoPkgConfig, parseGoVendorConfig, GoProjectConfig, ModuleVersion, toSnykVersion, parseVersion }; | ||
export { parseGoPkgConfig, parseGoVendorConfig, GoProjectConfig, ModuleVersion, toSnykVersion, parseVersion, GoMod, parseGoMod, }; | ||
export declare function buildGoPkgDepTree(manifestFileContents: string, lockFileContents: string, options?: unknown): Promise<DepTree>; | ||
export declare function buildGoVendorDepTree(manifestFileContents: string, options?: unknown): Promise<DepTree>; | ||
export declare function buildGoModDepTree(manifestFileContents: string, options?: unknown): DepTree; |
@@ -8,2 +8,3 @@ "use strict"; | ||
var gomod_parser_1 = require("./gomod-parser"); | ||
exports.parseGoMod = gomod_parser_1.parseGoMod; | ||
exports.toSnykVersion = gomod_parser_1.toSnykVersion; | ||
@@ -35,36 +36,5 @@ exports.parseVersion = gomod_parser_1.parseVersion; | ||
exports.buildGoVendorDepTree = buildGoVendorDepTree; | ||
// We are not using go.sum file here because it's not actually a lockfile and contains dependencies | ||
// that are actually long gone. | ||
function buildGoModDepTree(manifestFileContents, options) { | ||
function buildGoDepTree(goProjectConfig) { | ||
var e_1, _a; | ||
// We actually use only some bits of the go.mod contents | ||
var goMod = gomod_parser_1.parseGoMod(manifestFileContents); | ||
var depTree = { | ||
name: goMod.moduleName, | ||
version: '0.0.0', | ||
dependencies: {}, | ||
}; | ||
var dependencies = depTree.dependencies; | ||
try { | ||
for (var _b = tslib_1.__values(goMod.requires), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var req = _c.value; | ||
dependencies[req.moduleName] = { | ||
name: req.moduleName, | ||
version: gomod_parser_1.toSnykVersion(req.version), | ||
}; | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return depTree; | ||
} | ||
exports.buildGoModDepTree = buildGoModDepTree; | ||
function buildGoDepTree(goProjectConfig) { | ||
var e_2, _a; | ||
var depTree = { | ||
name: goProjectConfig.packageName || 'root', | ||
@@ -84,3 +54,3 @@ version: '0.0.0', | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
@@ -90,3 +60,3 @@ try { | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
@@ -93,0 +63,0 @@ return depTree; |
@@ -40,3 +40,3 @@ { | ||
}, | ||
"version": "1.2.0" | ||
"version": "1.3.0" | ||
} |
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
28889
436