Merge branch 'DependencyTrack:master' into master

This commit is contained in:
Mikael Carneholm 2024-11-29 13:43:26 +01:00 committed by GitHub
commit 3450de7f0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 249 additions and 91 deletions

View file

@ -186,7 +186,7 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
public List<Project> getAllProjects(boolean excludeInactive) {
final Query<Project> query = pm.newQuery(Project.class);
if (excludeInactive) {
query.setFilter("active == true || active == null");
query.setFilter("active");
}
query.setOrdering("id asc");
return query.executeList();
@ -477,9 +477,6 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
if (project.getParent() != null && !Boolean.TRUE.equals(project.getParent().isActive())){
throw new IllegalArgumentException("An inactive Parent cannot be selected as parent");
}
if (project.isActive() == null) {
project.setActive(Boolean.TRUE);
}
final Project oldLatestProject = project.isLatest() ? getLatestProjectVersion(project.getName()) : null;
final Project result = callInTransaction(() -> {
// Remove isLatest flag from current latest project version, if the new project will be the latest
@ -715,7 +712,19 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
String directDependencies = project.getDirectDependencies();
for (final UUID sourceComponentUuid : projectDirectDepsSourceComponentUuids) {
final UUID clonedComponentUuid = clonedComponentUuidBySourceComponentUuid.get(sourceComponentUuid);
directDependencies = directDependencies.replace(sourceComponentUuid.toString(), clonedComponentUuid.toString());
if (clonedComponentUuid != null) {
directDependencies = directDependencies.replace(
sourceComponentUuid.toString(), clonedComponentUuid.toString());
} else {
// NB: This may happen when the source project itself is a clone,
// and it was cloned before DT v4.12.0.
// https://github.com/DependencyTrack/dependency-track/pull/4171
LOGGER.warn("""
The source project's directDependencies refer to a component with UUID \
%s, which does not exist in the project. The cloned project's dependency graph \
may be broken as a result. A BOM upload will resolve the issue.\
""".formatted(sourceComponentUuid));
}
}
project.setDirectDependencies(directDependencies);
@ -728,7 +737,16 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
String directDependencies = component.getDirectDependencies();
for (final UUID sourceComponentUuid : sourceComponentUuids) {
final UUID clonedComponentUuid = clonedComponentUuidBySourceComponentUuid.get(sourceComponentUuid);
directDependencies = directDependencies.replace(sourceComponentUuid.toString(), clonedComponentUuid.toString());
if (clonedComponentUuid != null) {
directDependencies = directDependencies.replace(
sourceComponentUuid.toString(), clonedComponentUuid.toString());
} else {
LOGGER.warn("""
The directDependencies of component %s refer to a component with UUID \
%s, which does not exist in the source project. The cloned project's dependency graph \
may be broken as a result. A BOM upload will resolve the issue.\
""".formatted(component, sourceComponentUuid));
}
}
component.setDirectDependencies(directDependencies);