Skip to content

Commit

Permalink
feat: adding .csproj file recognition as nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
eavichay committed Nov 8, 2017
1 parent 7c6335f commit 7c2d48f
Show file tree
Hide file tree
Showing 4 changed files with 512 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var DETECTABLE_PACKAGE_MANAGERS = {
'vendor.json': 'golang',
'project.json': 'nuget',
'packages.config': 'nuget',
'.csproj': 'nuget',
};

function detectPackageManager(root, options) {
Expand Down Expand Up @@ -84,6 +85,8 @@ function detectPackageManagerFromFile(file) {
var key = path.basename(file);
if (/\.gemspec$/.test(key)) {
key = '.gemspec';
} else if (/\.csproj$/.test(key)) {
key = '.csproj';
}
if (!(key in DETECTABLE_PACKAGE_MANAGERS)) {
throw new Error('Could not detect package manager for file: ' + file);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"snyk-gradle-plugin": "1.2.0",
"snyk-module": "1.8.1",
"snyk-mvn-plugin": "1.1.0",
"snyk-nuget-plugin": "1.0.3",
"snyk-nuget-plugin": "1.1.0",
"snyk-policy": "1.7.1",
"snyk-python-plugin": "1.4.0",
"snyk-recursive-readdir": "^2.0.0",
Expand Down
33 changes: 32 additions & 1 deletion test/acceptance/cli.acceptance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,37 @@ function (t) {
});
});

test('`test nuget-app --file=app.csproj`', function (t) {
chdirWorkspaces();
var plugin = {
inspect: function () {
return Promise.resolve({package: {}});
},
};
sinon.spy(plugin, 'inspect');

sinon.stub(plugins, 'loadPlugin');
t.teardown(plugins.loadPlugin.restore);
plugins.loadPlugin
.withArgs('nuget')
.returns(plugin);

return cli.test('nuget-app', {
file: 'app.csproj',
})
.then(function () {
var req = server.popRequest();
t.equal(req.method, 'POST', 'makes POST request');
t.match(req.url, '/vuln/nuget', 'posts to correct url');
t.same(plugin.inspect.getCall(0).args,
['nuget-app', 'app.csproj', {
args: null,
file: 'app.csproj',
packageManager: 'nuget',
},], 'calls nuget plugin');
});
});

test('`test nuget-app --file=project.json`', function (t) {
chdirWorkspaces();
var plugin = {
Expand Down Expand Up @@ -279,7 +310,7 @@ test('`test nuget-app --file=project.json`', function (t) {
packageManager: 'nuget',
},], 'calls nuget plugin');
});
})
});

test('`test golang-app --file=Gopkg.lock`',
function (t) {
Expand Down
Loading

0 comments on commit 7c2d48f

Please sign in to comment.