Skip to content

Commit

Permalink
Merge pull request #3568 from snyk/feat/scan-maven-aggregate-projects
Browse files Browse the repository at this point in the history
feat: scan maven aggregate projects
  • Loading branch information
gitphill authored Aug 15, 2022
2 parents 756e9aa + 019bc45 commit f586333
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"snyk-go-plugin": "1.19.0",
"snyk-gradle-plugin": "3.21.1",
"snyk-module": "3.1.0",
"snyk-mvn-plugin": "2.30.0",
"snyk-mvn-plugin": "2.31.0",
"snyk-nodejs-lockfile-parser": "1.38.0",
"snyk-nuget-plugin": "1.23.5",
"snyk-php-plugin": "1.9.2",
Expand Down
1 change: 1 addition & 0 deletions src/cli/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export function args(rawArgv: string[]): Args {
'fail-on',
'all-projects',
'yarn-workspaces',
'maven-aggregate-project',
'detection-depth',
'reachable',
'reachable-vulns',
Expand Down
13 changes: 13 additions & 0 deletions src/lib/formatters/show-multi-scan-tip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ export function showMultiScanTip(
if (gradleSubProjectsTip) {
return gradleSubProjectsTip;
}
if (
projectType === 'maven' &&
foundProjectCount &&
foundProjectCount > 1 &&
!options.allProjects &&
!options.mavenAggregateProject
) {
return (
'Tip: Detected Maven project, are you using modules? ' +
'Use --maven-aggregate-project to scan each project. ' +
'Alternatively use --all-projects to scan Maven and other types of projects.'
);
}
const allProjectsTip = showAllProjectsTip(
projectType,
options,
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 @@ -51,6 +51,7 @@ export async function getMultiPluginResult(
} = await processYarnWorkspacesProjects(root, options, targetFiles);
allResults.push(...scannedProjects);
debug(`Not part of a workspace: ${unprocessedFiles.join(', ')}}`);

// process the rest 1 by 1 sent to relevant plugins
for (const targetFile of unprocessedFiles) {
const optionsClone = cloneDeep(options);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface Options {
insecure?: boolean;
'dry-run'?: boolean;
allSubProjects?: boolean;
mavenAggregateProject?: boolean;
'project-name'?: string;
'show-vulnerable-paths'?: string;
packageManager?: SupportedPackageManagers;
Expand Down Expand Up @@ -231,7 +232,8 @@ export type SupportedUserReachableFacingCliArgs =
| 'strict-out-of-sync'
| 'sub-project'
| 'trust-policies'
| 'yarn-workspaces';
| 'yarn-workspaces'
| 'maven-aggregate-project';

export enum SupportedCliCommands {
version = 'version',
Expand Down
6 changes: 6 additions & 0 deletions test/jest/unit/lib/formatters/show-multi-scan-tip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ describe('showMultiScanTip', () => {
),
).toEqual('');
});

it('maven without options and more than 1 file detected shows tip', () => {
expect(
showMultiScanTip('maven', { path: 'src', showVulnPaths: 'none' }, 2),
).toMatch('Tip: Detected Maven project, are you using modules?');
});
});

0 comments on commit f586333

Please sign in to comment.