Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use maven dependency analyzer to set scope automatically #65

Merged
merged 1 commit into from
Oct 12, 2020
Merged

Use maven dependency analyzer to set scope automatically #65

merged 1 commit into from
Oct 12, 2020

Conversation

prabhu
Copy link

@prabhu prabhu commented Oct 12, 2020

maven-dependency-analyzer use .class based analysis to classify packages into few used, untest and test sets.
This is then used to set the component scope to required or optional.

The idea is that this information could then be used by tools such as depscan to prioritize vulnerabilities based on the scope.

Key logic (excluding all glue code) is shown below:

// Is the artifact used?
if (usedDeclaredArtifacts.contains(artifact) || usedUndeclaredArtifacts.contains(artifact)) {
    return Component.Scope.REQUIRED;
}
// Is the artifact unused or test?
if (unusedDeclaredArtifacts.contains(artifact) || testArtifactsWithNonTestScope.contains(artifact)) {
    return Component.Scope.OPTIONAL;
}
return null;

@stevespringett
Copy link
Member

Thanks for the quality PR!

Is this ready to merge on your end or do you think there's more to add prior to merge and release?

@prabhu
Copy link
Author

prabhu commented Oct 12, 2020

Thank you @stevespringett! This is ready and tested with few apps.

@stevespringett stevespringett merged commit 98707a0 into CycloneDX:master Oct 12, 2020
@prabhu
Copy link
Author

prabhu commented Oct 13, 2020

Thanks for merging and releasing this PR! Below is a screenshot from the latest depscan that makes use of the builtin scope.

java-depscan

As we can see, for the test HelloShiftLeft project, only 5 out of 59 findings needs action. This kind of filtering should help the community with VM and prioritization effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants