Skip to content

Commit 019bc45

Browse files
committed
feat: scan maven aggregate projects
1 parent 756e9aa commit 019bc45

File tree

7 files changed

+32
-9
lines changed

7 files changed

+32
-9
lines changed

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"snyk-go-plugin": "1.19.0",
119119
"snyk-gradle-plugin": "3.21.1",
120120
"snyk-module": "3.1.0",
121-
"snyk-mvn-plugin": "2.30.0",
121+
"snyk-mvn-plugin": "2.31.0",
122122
"snyk-nodejs-lockfile-parser": "1.38.0",
123123
"snyk-nuget-plugin": "1.23.5",
124124
"snyk-php-plugin": "1.9.2",

src/cli/args.ts

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export function args(rawArgv: string[]): Args {
219219
'fail-on',
220220
'all-projects',
221221
'yarn-workspaces',
222+
'maven-aggregate-project',
222223
'detection-depth',
223224
'reachable',
224225
'reachable-vulns',

src/lib/formatters/show-multi-scan-tip.ts

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ export function showMultiScanTip(
1717
if (gradleSubProjectsTip) {
1818
return gradleSubProjectsTip;
1919
}
20+
if (
21+
projectType === 'maven' &&
22+
foundProjectCount &&
23+
foundProjectCount > 1 &&
24+
!options.allProjects &&
25+
!options.mavenAggregateProject
26+
) {
27+
return (
28+
'Tip: Detected Maven project, are you using modules? ' +
29+
'Use --maven-aggregate-project to scan each project. ' +
30+
'Alternatively use --all-projects to scan Maven and other types of projects.'
31+
);
32+
}
2033
const allProjectsTip = showAllProjectsTip(
2134
projectType,
2235
options,

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

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export async function getMultiPluginResult(
5151
} = await processYarnWorkspacesProjects(root, options, targetFiles);
5252
allResults.push(...scannedProjects);
5353
debug(`Not part of a workspace: ${unprocessedFiles.join(', ')}}`);
54+
5455
// process the rest 1 by 1 sent to relevant plugins
5556
for (const targetFile of unprocessedFiles) {
5657
const optionsClone = cloneDeep(options);

src/lib/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface Options {
5454
insecure?: boolean;
5555
'dry-run'?: boolean;
5656
allSubProjects?: boolean;
57+
mavenAggregateProject?: boolean;
5758
'project-name'?: string;
5859
'show-vulnerable-paths'?: string;
5960
packageManager?: SupportedPackageManagers;
@@ -231,7 +232,8 @@ export type SupportedUserReachableFacingCliArgs =
231232
| 'strict-out-of-sync'
232233
| 'sub-project'
233234
| 'trust-policies'
234-
| 'yarn-workspaces';
235+
| 'yarn-workspaces'
236+
| 'maven-aggregate-project';
235237

236238
export enum SupportedCliCommands {
237239
version = 'version',

test/jest/unit/lib/formatters/show-multi-scan-tip.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ describe('showMultiScanTip', () => {
4444
),
4545
).toEqual('');
4646
});
47+
48+
it('maven without options and more than 1 file detected shows tip', () => {
49+
expect(
50+
showMultiScanTip('maven', { path: 'src', showVulnPaths: 'none' }, 2),
51+
).toMatch('Tip: Detected Maven project, are you using modules?');
52+
});
4753
});

0 commit comments

Comments
 (0)