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

fix: bad version string interpolation #5421

Merged
merged 3 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,12 @@ public static boolean setPomEvidence(Dependency dependency, Model pom,
}
boolean foundSomething = false;
boolean addAsIdentifier = true;
String groupid = pom.getGroupId();
String parentGroupId = pom.getParentGroupId();
String artifactid = pom.getArtifactId();
String parentArtifactId = pom.getParentArtifactId();
String version = pom.getVersion();
String parentVersion = pom.getParentVersion();
String groupid = intepolationFailCheck(pom.getGroupId());
String parentGroupId = intepolationFailCheck(pom.getParentGroupId());
String artifactid = intepolationFailCheck(pom.getArtifactId());
String parentArtifactId = intepolationFailCheck(pom.getParentArtifactId());
String version = intepolationFailCheck(pom.getVersion());
String parentVersion = intepolationFailCheck(pom.getParentVersion());

if (("org.sonatype.oss".equals(parentGroupId) && "oss-parent".equals(parentArtifactId))
|| ("org.springframework.boot".equals(parentGroupId) && "spring-boot-starter-parent".equals(parentArtifactId))) {
Expand Down Expand Up @@ -1288,6 +1288,19 @@ private boolean isPackage(String key, String value) {

}

/**
* Returns null if the value starts with `${` and ends with `}`.
*
* @param value the value to check
* @return the correct value which may be null
*/
private static String intepolationFailCheck(String value) {
if (value != null && value.startsWith("${") && value.endsWith("}")) {
jeremylong marked this conversation as resolved.
Show resolved Hide resolved
return null;
}
return value;
}

/**
* Extracts the license information from the pom and adds it to the
* dependency.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,7 @@ protected ExceptionCollection scanPlugins(MavenProject project, Engine engine, E
pluginCoordinate.setArtifactId(resolved.getArtifactId());
pluginCoordinate.setVersion(resolved.getVersion());

//TOOD - convert this to a packageURl instead of GAV
final String parent = resolved.getGroupId() + ":" + resolved.getArtifactId() + ":" + resolved.getVersion();
final String parent = buildReference(resolved.getGroupId(), resolved.getArtifactId(), resolved.getVersion());
for (Artifact artifact : resolveArtifactDependencies(pluginCoordinate, project)) {
exCol = addPluginToDependencies(project, engine, artifact, parent, exCol);
}
Expand Down Expand Up @@ -2789,18 +2788,23 @@ && addSnapshotReactorDependency(engine, dependencyNode.getArtifact(), project))
}

/**
* Try resolution of artifacts once, allowing for DependencyResolutionException due to reactor-dependencies not
* being resolvable.
* Try resolution of artifacts once, allowing for
* DependencyResolutionException due to reactor-dependencies not being
* resolvable.
* <br>
* The resolution is attempted only if allResolvedDeps is still empty. The assumption is that for any given project
* at least one of the dependencies will successfully resolve. If not, resolution will be attempted once for every
* dependency (as allResolvedDeps remains empty).
* The resolution is attempted only if allResolvedDeps is still empty. The
* assumption is that for any given project at least one of the dependencies
* will successfully resolve. If not, resolution will be attempted once for
* every dependency (as allResolvedDeps remains empty).
*
* @param project The project to dependencies for
* @param allResolvedDeps The collection of successfully resolved dependencies, will be filled with the successfully
* resolved dependencies, even in case of resolution failures.
* @param buildingRequest The buildingRequest to hand to Maven's DependencyResolver.
* @throws DependencyResolverException For any DependencyResolverException other than an Eclipse Aether DependencyResolutionException
* @param allResolvedDeps The collection of successfully resolved
* dependencies, will be filled with the successfully resolved dependencies,
* even in case of resolution failures.
* @param buildingRequest The buildingRequest to hand to Maven's
* DependencyResolver.
* @throws DependencyResolverException For any DependencyResolverException
* other than an Eclipse Aether DependencyResolutionException
*/
private void tryResolutionOnce(MavenProject project, List<ArtifactResult> allResolvedDeps, ProjectBuildingRequest buildingRequest) throws DependencyResolverException {
if (allResolvedDeps.isEmpty()) { // no (partially successful) resolution attempt done
Expand Down