-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Filter out the reactorprojects in the dependencies for the MSHARED-998 workaround attempting to resolve a dependency with a classifier #3736
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4f92f4a
Properly initialize exceptionCollection to avoid duplicate addition o…
aikebah 9e726a3
Add testcase that demonstrates the current issue
aikebah 8096ee3
Filter out reactorprojects when trying to resolve dependencies with c…
aikebah 9e2f151
Previous solution for duplicate exception collected was suppressing t…
aikebah 83c765a
Add additional debugging info to the log message
aikebah 0019218
Extend IT to cover both direct reactor project dependencies and trans…
aikebah 165deeb
Resolve remaining known cases of regressions due to switchover to Dep…
aikebah b5bfe8d
Add missing version to dependencyManagement
aikebah 4d9272b
Add missing javadoc signalled by Checkstyle
aikebah 66d18f3
Process Checkstyle findings on the new code
aikebah 5b9f60b
make checkstyle happier
jeremylong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
maven/src/it/3730-classifier-in-dependency-aggregate/childOne/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
This file is part of dependency-check-maven. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
Copyright (c) 2017 Jeremy Long. All Rights Reserved. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.owasp.test</groupId> | ||
<artifactId>3730-classifier-in-dependency-aggregate</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>3730-classifier-in-dependency-aggregate-childOne</artifactId> | ||
<packaging>jar</packaging> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
<classifier>no_aop</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.owasp.test</groupId> | ||
<artifactId>3730-classifier-in-dependency-aggregate-childTwo</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
35 changes: 35 additions & 0 deletions
35
maven/src/it/3730-classifier-in-dependency-aggregate/childTwo/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
This file is part of dependency-check-maven. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
Copyright (c) 2017 Jeremy Long. All Rights Reserved. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.owasp.test</groupId> | ||
<artifactId>3730-classifier-in-dependency-aggregate</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>3730-classifier-in-dependency-aggregate-childTwo</artifactId> | ||
<packaging>jar</packaging> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
<classifier>classes</classifier> | ||
</dependency> | ||
</dependencies> | ||
</project> |
19 changes: 19 additions & 0 deletions
19
maven/src/it/3730-classifier-in-dependency-aggregate/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# This file is part of dependency-check-maven. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Copyright (c) 2014 Jeremy Long. All Rights Reserved. | ||
# | ||
|
||
invoker.goals = --no-transfer-progress --batch-mode -Danalyzer.ossindex.enabled=false -Danalyzer.central.enabled=false ${project.groupId}:${project.artifactId}:${project.version}:aggregate -Dformat=XML -Dcve.startyear=2018 |
47 changes: 47 additions & 0 deletions
47
maven/src/it/3730-classifier-in-dependency-aggregate/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
This file is part of dependency-check-maven. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
Copyright (c) 2017 Jeremy Long. All Rights Reserved. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.owasp.test</groupId> | ||
<artifactId>3730-classifier-in-dependency-aggregate</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
<modules> | ||
<module>childOne</module> | ||
<module>childTwo</module> | ||
</modules> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
<version>4.2.2</version> | ||
<classifier>no_aop</classifier> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
<version>4.2.2</version> | ||
<classifier>classes</classifier> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
</project> |
43 changes: 43 additions & 0 deletions
43
maven/src/it/3730-classifier-in-dependency-aggregate/postbuild.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* This file is part of dependency-check-maven. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Copyright (c) 2014 Jeremy Long. All Rights Reserved. | ||
*/ | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.w3c.dom.NodeList; | ||
|
||
import java.nio.charset.Charset; | ||
import javax.xml.xpath.* | ||
import javax.xml.parsers.DocumentBuilderFactory | ||
|
||
// Check to see if jackson-databind-2.5.3.jar was identified with a known CVE - using CVE-2018-7489. | ||
|
||
def countMatches(String xml, String xpathQuery) { | ||
def xpath = XPathFactory.newInstance().newXPath() | ||
def builder = DocumentBuilderFactory.newInstance().newDocumentBuilder() | ||
def inputStream = new ByteArrayInputStream( xml.bytes ) | ||
def records = builder.parse(inputStream).documentElement | ||
NodeList nodes = xpath.evaluate( xpathQuery, records, XPathConstants.NODESET ) as NodeList | ||
nodes.getLength(); | ||
} | ||
|
||
String log = FileUtils.readFileToString(new File(basedir, "target/dependency-check-report.xml"), Charset.defaultCharset().name()); | ||
int count = countMatches(log,"/analysis/dependencies/dependency[./fileName = 'guice-4.2.2-no_aop.jar']"); | ||
if (count != 1){ | ||
System.out.println(String.format("google guice no_aop was identified %s times, expected 1", count)); | ||
return false; | ||
} | ||
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
maven/src/main/java/org/owasp/dependencycheck/maven/Mshared998Util.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* This file is part of dependency-check-maven. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Copyright (c) 2021 Jeremy Long. All Rights Reserved. | ||
*/ | ||
package org.owasp.dependencycheck.maven; | ||
|
||
import org.apache.maven.RepositoryUtils; | ||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate; | ||
import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; | ||
import org.eclipse.aether.resolution.ArtifactResult; | ||
import org.eclipse.aether.resolution.DependencyResolutionException; | ||
import org.eclipse.aether.resolution.DependencyResult; | ||
|
||
import java.util.Objects; | ||
|
||
public final class Mshared998Util { | ||
/** | ||
* Empty constructor to prevent instantiation of utility-class. | ||
*/ | ||
private Mshared998Util() { | ||
} | ||
|
||
/** | ||
* Find the artifact for the given coordinate among the available succesfull resolution attempts contained within the | ||
* DependencyResolverException | ||
* @param dre The DependencyResolverException that might have embedded successful resolution results | ||
* @param coordinate The coordinates of the artifact we're interested in | ||
* @return The resolved artifact matching {@code coordinate} or {@code null} if not found | ||
*/ | ||
public static Artifact findArtifactInAetherDREResult(final DependencyResolverException dre, | ||
final ArtifactCoordinate coordinate) { | ||
Artifact result = null; | ||
if (dre.getCause() instanceof DependencyResolutionException) { | ||
final DependencyResolutionException adre = (DependencyResolutionException) dre.getCause(); | ||
final DependencyResult dependencyResult = adre.getResult(); | ||
if (dependencyResult != null) { | ||
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) { | ||
if (matchesCoordinate(artifactResult, coordinate)) { | ||
result = RepositoryUtils.toArtifact(artifactResult.getArtifact()); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* Checks whether the given ArtifactResult contains an artifact that matches the coordinate | ||
* @param artifactResult The ArtifactResult to inspect | ||
* @param coordinate The coordinate to match with | ||
* @return {@code true} when the artifactresult contains an artifact that matches the coordinate on GAV_C_E, | ||
* false otherwise. | ||
*/ private static boolean matchesCoordinate(final ArtifactResult artifactResult, final ArtifactCoordinate coordinate) { | ||
if (artifactResult.getArtifact() == null) { | ||
return false; | ||
} else { | ||
final org.eclipse.aether.artifact.Artifact artifact = artifactResult.getArtifact(); | ||
boolean result = Objects.equals(artifact.getGroupId(), coordinate.getGroupId()); | ||
result &= Objects.equals(artifact.getArtifactId(), coordinate.getArtifactId()); | ||
result &= Objects.equals(artifact.getVersion(), coordinate.getVersion()); | ||
result &= Objects.equals(artifact.getClassifier(), coordinate.getClassifier()); | ||
result &= Objects.equals(artifact.getExtension(), coordinate.getExtension()); | ||
return result; | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reporter: Checkstyle
Rule: com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck
Severity: ERROR
File: maven/src/main/java/org/owasp/dependencycheck/maven/Mshared998Util.java L37
First sentence should end with a period.