Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
"snyk-gradle-plugin": "7.0.0",
"snyk-module": "3.1.0",
"snyk-mvn-plugin": "4.8.0",
"snyk-nodejs-lockfile-parser": "2.8.1",
"snyk-nodejs-plugin": "^2.0.1",
"snyk-nodejs-lockfile-parser": "2.9.0",
"snyk-nodejs-plugin": "^2.1.0",
"snyk-nuget-plugin": "4.2.3",
"snyk-php-plugin": "1.12.1",
"snyk-policy": "^4.1.6",
Expand Down
1 change: 1 addition & 0 deletions src/lib/plugins/get-multi-plugin-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ async function processWorkspacesProjects(
dev: options.dev,
exclude: options.exclude,
showNpmScope: featureFlags.has(SHOW_NPM_SCOPE),
includeComponentMetadata: options['include-component-metadata'],
},
targetFiles,
);
Expand Down
10 changes: 6 additions & 4 deletions src/lib/plugins/get-single-plugin-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export async function getSinglePluginResult(
),
// Internal/undocumented flag: surfaced to the plugin in camelCase here
// rather than via the user-facing arg transform list, so it stays off the
// documented CLI surface. Single convergence point for single- and
// multi-project (all-projects/aggregate) scans. Only added when set so the
// default plugin-options shape is unchanged (the flag is gateway-driven
// and absent for the vast majority of scans).
// documented CLI surface. Convergence point for single-project scans and
// the non-workspace files of all-projects/aggregate scans; npm workspace
// projects are handled earlier in getMultiPluginResult and forward the
// flag themselves (component metadata is currently npm-only). Only added
// when set so the default plugin-options shape is unchanged (the flag is
// gateway-driven and absent for the vast majority of scans).
...(options['include-component-metadata'] !== undefined && {
includeComponentMetadata: options['include-component-metadata'],
}),
Expand Down
5 changes: 5 additions & 0 deletions src/lib/plugins/nodejs-plugin/npm-lock-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
import { Options } from '../types';
import { DepGraph } from '@snyk/dep-graph';

const defaultIncludeComponentMetadata = false;

export async function parse(
root: string,
targetFile: string,
Expand Down Expand Up @@ -75,6 +77,8 @@ export async function parse(
pruneCycles: true,
honorAliases: true,
showNpmScope: options.showNpmScope,
includeComponentMetadata:
options.includeComponentMetadata || defaultIncludeComponentMetadata,
},
);
}
Expand All @@ -89,6 +93,7 @@ export async function parse(
strictOutOfSync,
true,
options.showNpmScope,
options.includeComponentMetadata || defaultIncludeComponentMetadata,
);
} finally {
await spinner.clear<void>(resolveModuleSpinnerLabel)();
Expand Down
6 changes: 4 additions & 2 deletions src/lib/plugins/nodejs-plugin/npm-workspaces-parser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as baseDebug from 'debug';
import * as pathUtil from 'path';
const sortBy = require('lodash.sortby');
const groupBy = require('lodash.groupby');
import * as sortBy from 'lodash.sortby';
import * as groupBy from 'lodash.groupby';
import * as micromatch from 'micromatch';

const debug = baseDebug('snyk-npm-workspaces');
Expand All @@ -20,6 +20,7 @@ export async function processNpmWorkspaces(
dev?: boolean;
yarnWorkspaces?: boolean;
showNpmScope?: boolean;
includeComponentMetadata?: boolean;
},
targetFiles: string[],
): Promise<MultiProjectResultCustom> {
Expand Down Expand Up @@ -103,6 +104,7 @@ export async function processNpmWorkspaces(
includeOptionalDeps: false,
pruneCycles: true,
showNpmScope: settings.showNpmScope,
includeComponentMetadata: settings.includeComponentMetadata || false,
},
);

Expand Down
1 change: 1 addition & 0 deletions src/lib/plugins/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Options {
scanAllUnmanaged?: boolean;
showNpmScope?: boolean;
allProjects?: boolean;
includeComponentMetadata?: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this hold values such as null and undefined? Just a sanity question

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectively yes, in the vast majority of cases it won't be getting set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/snyk/cli/pull/6948/changes#diff-eb8513f7e557af1081e96db6b6603ca292cc0c2bf383fb00c5f914431372cee3 is where we build the Options object that gets passed in to the plugin inspect method. So can be undefined

}

export interface Plugin {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "npm-component-metadata-v1",
"version": "1.0.0",
"dependencies": {
"lodash": "4.17.15"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "npm-component-metadata-v2",
"version": "1.0.0",
"dependencies": {
"lodash": "4.17.15"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "npm-component-metadata-v3",
"version": "1.0.0",
"dependencies": {
"lodash": "4.17.15"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "npm-workspace-component-metadata",
"version": "1.0.0",
"license": "MIT",
"private": true,
"workspaces": [
"packages/a",
"packages/b"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "a",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"ms": "2.1.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "b",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"is-number": "7.0.0",
"a": "^1.0.0"
}
}
Loading