Skip to content

Commit 730dec0

Browse files
committed
feat: update nuget plugin to handle NX build
1 parent e83a454 commit 730dec0

File tree

10 files changed

+149
-8
lines changed

10 files changed

+149
-8
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"snyk-mvn-plugin": "4.3.1",
125125
"snyk-nodejs-lockfile-parser": "2.3.1",
126126
"snyk-nodejs-plugin": "1.4.4",
127-
"snyk-nuget-plugin": "2.11.3",
127+
"snyk-nuget-plugin": "2.12.0",
128128
"snyk-php-plugin": "1.12.1",
129129
"snyk-policy": "^4.1.6",
130130
"snyk-python-plugin": "3.1.2",

src/lib/plugins/get-multi-plugin-result.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ export async function getMultiPluginResult(
144144

145145
allResults.push(...pluginResultWithCustomScannedProjects.scannedProjects);
146146
} catch (error) {
147+
if (
148+
error.name === 'NotSupportedEcosystem' ||
149+
error.constructor?.name === 'NotSupportedEcosystem'
150+
) {
151+
debug(
152+
chalk.bold.yellow(
153+
`\n${icon.INFO} Skipping unsupported ecosystem for ${targetFile}: ${error.message}`,
154+
),
155+
);
156+
continue;
157+
}
158+
147159
const errMessage =
148160
error.message ?? 'Something went wrong getting dependencies';
149161
// TODO: propagate this all the way back and include in --json output
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$schema": "./node_modules/nx/schemas/nx-schema.json"
3+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "with-vulnerable-lodash-dep",
3+
"$schema": "./node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "src",
5+
"projectType": "application",
6+
"targets": {
7+
"build": {
8+
"executor": "nx:run-commands",
9+
"options": {
10+
"command": "npm run build"
11+
},
12+
"inputs": ["default"],
13+
"outputs": ["{projectRoot}/dist"]
14+
},
15+
"test": {
16+
"executor": "nx:run-commands",
17+
"options": {
18+
"command": "npm test"
19+
},
20+
"inputs": ["default"]
21+
},
22+
"lint": {
23+
"executor": "nx:run-commands",
24+
"options": {
25+
"command": "npm run lint"
26+
},
27+
"inputs": ["default"]
28+
}
29+
},
30+
"tags": []
31+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$schema": "./node_modules/nx/schemas/nx-schema.json"
3+
}

test/fixtures/npm-nx-build-platform/package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "with-vulnerable-lodash-dep",
3+
"version": "1.2.3",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"license": "ISC",
11+
"dependencies": {
12+
"lodash": "4.17.15"
13+
}
14+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "with-vulnerable-lodash-dep",
3+
"$schema": "./node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "src",
5+
"projectType": "application",
6+
"targets": {
7+
"build": {
8+
"executor": "nx:run-commands",
9+
"options": {
10+
"command": "npm run build"
11+
},
12+
"inputs": ["default"],
13+
"outputs": ["{projectRoot}/dist"]
14+
},
15+
"test": {
16+
"executor": "nx:run-commands",
17+
"options": {
18+
"command": "npm test"
19+
},
20+
"inputs": ["default"]
21+
},
22+
"lint": {
23+
"executor": "nx:run-commands",
24+
"options": {
25+
"command": "npm run lint"
26+
},
27+
"inputs": ["default"]
28+
}
29+
},
30+
"tags": []
31+
}

test/jest/acceptance/snyk-test/all-projects.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,26 @@ describe('snyk test --all-projects (mocked server only)', () => {
263263
expect(stderr).toEqual('');
264264
});
265265

266+
test('`test npm NX Build Platform --all-projects --print-graph --json --fail-fast`', async () => {
267+
const project = await createProjectFromFixture('npm-nx-build-platform');
268+
269+
const { code } = await runSnykCLI(
270+
'test --print-graph --json --all-projects --fail-fast',
271+
{
272+
cwd: project.path(),
273+
env,
274+
},
275+
);
276+
277+
const backendRequests = server.getRequests().filter((req: any) => {
278+
return req.url.includes('/api/v1/test');
279+
});
280+
281+
expect(backendRequests).toHaveLength(0);
282+
283+
expect(code).toEqual(0);
284+
});
285+
266286
test('`test node workspaces --all-projects`', async () => {
267287
server.setFeatureFlag('enablePnpmCli', false);
268288
const project = await createProjectFromFixture('workspace-multi-type');

0 commit comments

Comments
 (0)