Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snyk-go-plugin

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snyk-go-plugin - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

107

lib/index.js

@@ -5,2 +5,3 @@ var fs = require('fs');

var graphlib = require('graphlib');
var tmp = require('tmp');

@@ -13,5 +14,7 @@ var subProcess = require('./sub-process');

var VIRTUAL_ROOT_NODE_ID = '.'
var VIRTUAL_ROOT_NODE_ID = '.';
function inspect(root, targetFile, options) {
return Promise.all([

@@ -35,3 +38,3 @@ getMetaData(root, targetFile),

if (versionMatch) {
runtime = versionMatch[0]
runtime = versionMatch[0];
}

@@ -47,4 +50,63 @@

// Hack:
// We're using Zeit assets feature in order to support Python and Go testing
// within a binary release. By doing "path.join(__dirname, 'PATH'), Zeit adds
// PATH file auto to the assets. Sadly, Zeit doesn't support (as far as I
// understand) adding a full folder as an asset, and this is why we're adding
// the required files this way. In addition, Zeit doesn't support
// path.resolve(), and this is why I'm using path.join()
function createAssets(){
assets = [];
assets.push(path.join(__dirname, '../gosrc/resolve-deps.go'));
assets.push(path.join(__dirname, '../gosrc/resolver/pkg.go'));
assets.push(path.join(__dirname, '../gosrc/resolver/resolver.go'));
assets.push(path.join(__dirname, '../gosrc/resolver/dirwalk/dirwalk.go'));
assets.push(path.join(__dirname, '../gosrc/resolver/graph/graph.go'));
return assets;
}
function writeFile(writeFilePath, contents) {
var dirPath = path.dirname(writeFilePath);
if (!fs.existsSync(dirPath))
{
fs.mkdirSync(dirPath);
}
fs.writeFileSync(writeFilePath, contents);
}
function getFilePathRelativeToDumpDir(filePath) {
var pathParts = filePath.split('\\gosrc\\');
// Windows
if (pathParts.length > 1)
{
return pathParts[1];
}
// Unix
pathParts = filePath.split('/gosrc/');
return pathParts[1];
}
function dumpAllResolveDepsFilesInTempDir(tempDirName) {
createAssets().forEach(function(currentReadFilePath) {
if (!fs.existsSync(currentReadFilePath))
{
throw new Error('The file `' + currentReadFilePath + '` is missing');
}
var relFilePathToDumpDir =
getFilePathRelativeToDumpDir(currentReadFilePath);
var writeFilePath = path.join(tempDirName, relFilePathToDumpDir);
var contents = fs.readFileSync(currentReadFilePath);
writeFile(writeFilePath, contents);
});
}
function getDependencies(root, targetFile) {
var config;
var tempDirObj;
return new Promise(function (resolve, reject) {

@@ -54,4 +116,10 @@ config = parseConfig(root, targetFile);

}).then(function () {
var goResolveTool = path.join(__dirname, '..', 'gosrc', 'resolve-deps.go')
tempDirObj = tmp.dirSync({
unsafeCleanup: true
});
dumpAllResolveDepsFilesInTempDir(tempDirObj.name);
var goResolveTool =
path.join(tempDirObj.name, 'resolve-deps.go');
var ignorePkgsParam;

@@ -65,4 +133,5 @@ if (config.ignoredPkgs && config.ignoredPkgs.length > 0) {

{ cwd: root }
)
);
}).then(function (graph) {
tempDirObj.removeCallback();
graph = JSON.parse(graph);

@@ -80,3 +149,3 @@ graph = graphlib.json.read(graph);

// to these source nodes.
var VIRTUAL_ROOT_NODE_ID = '.'
var VIRTUAL_ROOT_NODE_ID = '.';
var root = graph.node(VIRTUAL_ROOT_NODE_ID);

@@ -89,3 +158,3 @@ if (!root) {

if (nodeId != VIRTUAL_ROOT_NODE_ID) {
graph.setEdge(VIRTUAL_ROOT_NODE_ID, nodeId)
graph.setEdge(VIRTUAL_ROOT_NODE_ID, nodeId);
}

@@ -104,2 +173,3 @@ });

}).catch(function (error) {
tempDirObj.removeCallback();
if (typeof error === 'string') {

@@ -127,3 +197,3 @@ var unresolvedOffset = error.indexOf('Unresolved packages:');

govendor: 'govendor sync',
}
};

@@ -174,3 +244,3 @@ function pkgManagerByTarget(targetFile) {

dependencies: {},
}
};
if (!isRoot && isProjSubpkg) {

@@ -228,3 +298,3 @@ pkg._isProjSubpkg = true;

}
})
});

@@ -248,3 +318,3 @@ return pkg;

for (var k in m) {
copy[k] = m[k]
copy[k] = m[k];
}

@@ -278,5 +348,6 @@

var pkgManager = pkgManagerByTarget(targetFile);
var config = {};
switch (pkgManager) {
case 'dep': {
var config = {
config = {
ignoredPkgs: [],

@@ -306,3 +377,3 @@ lockedVersions: {},

var lockJson = toml.parse(String(lock))
var lockJson = toml.parse(String(lock));

@@ -322,3 +393,3 @@ var deps = {};

version: version,
}
};

@@ -336,4 +407,4 @@ deps[dep.name] = dep;

function parseDepManifest(root, targetFile) {
var manifestDir = path.dirname(path.join(root, targetFile))
var manifestPath = path.resolve(path.join(manifestDir, 'Gopkg.toml'))
var manifestDir = path.dirname(path.join(root, targetFile));
var manifestPath = path.resolve(path.join(manifestDir, 'Gopkg.toml'));

@@ -372,3 +443,3 @@ try {

version: version,
}
};

@@ -386,3 +457,3 @@ config.lockedVersions[dep.name] = dep;

config.ignoredPkgs.push(pkgName + '/*');
})
});

@@ -389,0 +460,0 @@ return config;

34

package.json

@@ -1,33 +0,1 @@

{
"name": "snyk-go-plugin",
"description": "Snyk CLI Golang plugin",
"homepage": "https://github.com/snyk/snyk-go-plugin",
"repository": {
"type": "git",
"url": "https://github.com/snyk/snyk-go-plugin"
},
"main": "lib/index.js",
"scripts": {
"lint": "jscs ./lib ./test/*.js ./test/system/*.js -v",
"test-functional": "tap ./test/*.test.js",
"test-system": "tap --timeout=300 ./test/system/*.test.js",
"test": "npm run test-functional && npm run test-system",
"test-system-windows": "tap --timeout=300 ./test/system/*.test.js -g \"^(?!.*prometheus)\"",
"test-windows": "npm run test-functional && npm run test-system-windows",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"watch": "nodemon -e 'js go' -x 'npm run test-functional'"
},
"author": "snyk.io",
"license": "Apache-2.0",
"dependencies": {
"graphlib": "^2.1.1",
"toml": "^2.3.2"
},
"devDependencies": {
"jscs": "^3.0.7",
"semantic-release": "^6.3.6",
"tap": "^10.7.0",
"tap-only": "0.0.5"
},
"version": "1.5.0"
}
{"name":"snyk-go-plugin","description":"Snyk CLI Golang plugin","homepage":"https://github.com/snyk/snyk-go-plugin","repository":{"type":"git","url":"https://github.com/snyk/snyk-go-plugin"},"main":"lib/index.js","scripts":{"lint":"jscs ./lib ./test/*.js ./test/system/*.js -v","test-functional":"tap ./test/*.test.js","test-system":"tap --timeout=300 ./test/system/*.test.js","test":"npm run test-functional && npm run test-system","test-system-windows":"tap --timeout=300 ./test/system/*.test.js -g \"^(?!.*prometheus)\"","test-windows":"npm run test-functional && npm run test-system-windows","semantic-release":"semantic-release pre && npm publish && semantic-release post","watch":"nodemon -e 'js go' -x 'npm run test-functional'"},"author":"snyk.io","license":"Apache-2.0","dependencies":{"graphlib":"^2.1.1","toml":"^2.3.2","tmp":"0.0.33"},"devDependencies":{"jscs":"^3.0.7","semantic-release":"^8.2.3","tap":"^10.7.0","tap-only":"0.0.5"},"version":"1.5.1"}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc