Skip to content

Commit

Permalink
feat: dep & govendor as separate pkg managers
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-go committed Dec 12, 2017
1 parent c526a3f commit 107d16b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
3 changes: 2 additions & 1 deletion cli/commands/protect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var unsupportedPackageManagers = {
pip: 'Python',
sbt: 'SBT',
gradle: 'Gradle',
golang: 'Golang',
golangdep: 'Golang/Dep',
govendor: 'Govendor',
nuget: 'NuGet',
composer: 'Composer',
};
Expand Down
3 changes: 2 additions & 1 deletion cli/commands/protect/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ var unsupportedPackageManagers = {
pip: 'Python',
sbt: 'SBT',
gradle: 'Gradle',
golang: 'Golang',
golangdep: 'Golang/Dep',
govendor: 'Govendor',
nuget: 'NuGet',
composer: 'Composer',
};
Expand Down
4 changes: 2 additions & 2 deletions lib/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var DETECTABLE_PACKAGE_MANAGERS = {
'build.sbt': 'sbt',
'yarn.lock': 'yarn',
'requirements.txt': 'pip',
'Gopkg.lock': 'golang',
'vendor.json': 'golang',
'Gopkg.lock': 'golangdep',
'vendor.json': 'govendor',
'project.json': 'nuget',
'project.assets.json': 'nuget',
'packages.config': 'nuget',
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function loadPlugin(packageManager) {
case 'pip': {
return require('snyk-python-plugin');
}
case 'golang': {
case 'golangdep':
case 'govendor': {
return require('snyk-go-plugin');
}
case 'nuget': {
Expand Down
12 changes: 10 additions & 2 deletions lib/snyk-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ function run(root, options) {
if (['npm', 'yarn'].indexOf(packageManager) >= 0) {
return require('./npm')(root, options);
}
if (['rubygems', 'maven', 'gradle', 'sbt', 'pip',
'golang', 'nuget', 'composer',].indexOf(packageManager) === -1) {
if (['rubygems',
'maven',
'gradle',
'sbt',
'pip',
'golangdep',
'govendor',
'nuget',
'composer',
].indexOf(packageManager) === -1) {
throw new Error('Unsupported package manager: ' + packageManager);
}
return runTest(packageManager, root, options);
Expand Down
28 changes: 14 additions & 14 deletions test/acceptance/cli.acceptance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function (t) {
sinon.stub(plugins, 'loadPlugin');
t.teardown(plugins.loadPlugin.restore);
plugins.loadPlugin
.withArgs('golang')
.withArgs('golangdep')
.returns(plugin);

return cli.test('golang-app', {
Expand All @@ -469,12 +469,12 @@ function (t) {
.then(function () {
var req = server.popRequest();
t.equal(req.method, 'POST', 'makes POST request');
t.match(req.url, '/vuln/golang', 'posts to correct url');
t.match(req.url, '/vuln/golangdep', 'posts to correct url');
t.same(plugin.inspect.getCall(0).args,
['golang-app', 'Gopkg.lock', {
args: null,
file: 'Gopkg.lock',
packageManager: 'golang',
packageManager: 'golangdep',
},], 'calls golang plugin');
});
});
Expand Down Expand Up @@ -524,7 +524,7 @@ function (t) {
sinon.stub(plugins, 'loadPlugin');
t.teardown(plugins.loadPlugin.restore);
plugins.loadPlugin
.withArgs('golang')
.withArgs('govendor')
.returns(plugin);

return cli.test('golang-app', {
Expand All @@ -533,12 +533,12 @@ function (t) {
.then(function () {
var req = server.popRequest();
t.equal(req.method, 'POST', 'makes POST request');
t.match(req.url, '/vuln/golang', 'posts to correct url');
t.match(req.url, '/vuln/govendor', 'posts to correct url');
t.same(plugin.inspect.getCall(0).args,
['golang-app', 'vendor/vendor.json', {
args: null,
file: 'vendor/vendor.json',
packageManager: 'golang',
packageManager: 'govendor',
},], 'calls golang plugin');
});
});
Expand Down Expand Up @@ -855,7 +855,7 @@ function (t) {
sinon.stub(plugins, 'loadPlugin');
t.teardown(plugins.loadPlugin.restore);
plugins.loadPlugin
.withArgs('golang')
.withArgs('golangdep')
.returns(plugin);

return cli.monitor('golang-app', {
Expand All @@ -864,7 +864,7 @@ function (t) {
.then(function () {
var req = server.popRequest();
t.equal(req.method, 'PUT', 'makes PUT request');
t.match(req.url, '/monitor/golang', 'puts at correct url');
t.match(req.url, '/monitor/golangdep', 'puts at correct url');
t.equal(req.body.targetFile, 'Gopkg.lock', 'sends the targetFile');
t.same(plugin.inspect.getCall(0).args,
['golang-app', 'Gopkg.lock', {
Expand Down Expand Up @@ -892,7 +892,7 @@ function (t) {
sinon.stub(plugins, 'loadPlugin');
t.teardown(plugins.loadPlugin.restore);
plugins.loadPlugin
.withArgs('golang')
.withArgs('govendor')
.returns(plugin);

return cli.monitor('golang-app', {
Expand All @@ -901,7 +901,7 @@ function (t) {
.then(function () {
var req = server.popRequest();
t.equal(req.method, 'PUT', 'makes PUT request');
t.match(req.url, '/monitor/golang', 'puts at correct url');
t.match(req.url, '/monitor/govendor', 'puts at correct url');
t.equal(req.body.targetFile, 'vendor/vendor.json', 'sends the targetFile');
t.same(plugin.inspect.getCall(0).args,
['golang-app', 'vendor/vendor.json', {
Expand All @@ -928,8 +928,8 @@ test('`wizard` for unsupported package managers', function (t) {
{ file: 'pip-app/requirements.txt', type: 'Python' },
{ file: 'sbt-app/build.sbt', type: 'SBT' },
{ file: 'gradle-app/build.gradle', type: 'Gradle' },
{ file: 'golang-app/Gopkg.lock', type: 'Golang' },
{ file: 'golang-app/vendor/vendor.json', type: 'Golang' },
{ file: 'golang-app/Gopkg.lock', type: 'Golang/Dep' },
{ file: 'golang-app/vendor/vendor.json', type: 'Govendor' },
{ file: 'composer-app/composer.lock', type: 'Composer' },
];
return Promise.all(cases.map(testUnsupported))
Expand Down Expand Up @@ -958,8 +958,8 @@ test('`protect` for unsupported package managers', function (t) {
{ file: 'pip-app/requirements.txt', type: 'Python' },
{ file: 'sbt-app/build.sbt', type: 'SBT' },
{ file: 'gradle-app/build.gradle', type: 'Gradle' },
{ file: 'golang-app/Gopkg.lock', type: 'Golang' },
{ file: 'golang-app/vendor/vendor.json', type: 'Golang' },
{ file: 'golang-app/Gopkg.lock', type: 'Golang/Dep' },
{ file: 'golang-app/vendor/vendor.json', type: 'Govendor' },
{ file: 'composer-app/composer.lock', type: 'Composer' },
];
return Promise.all(cases.map(testUnsupported))
Expand Down

0 comments on commit 107d16b

Please sign in to comment.