mirror of
https://github.com/DependencyTrack/dependency-track.git
synced 2025-10-19 16:03:19 +00:00
parent
550ff64632
commit
3f97987d85
7 changed files with 168 additions and 6 deletions
|
@ -39,6 +39,7 @@ import org.dependencytrack.model.Classifier;
|
|||
import org.dependencytrack.model.Component;
|
||||
import org.dependencytrack.model.ConfigPropertyConstants;
|
||||
import org.dependencytrack.model.FindingAttribution;
|
||||
import org.dependencytrack.model.PolicyViolation;
|
||||
import org.dependencytrack.model.Project;
|
||||
import org.dependencytrack.model.ProjectMetadata;
|
||||
import org.dependencytrack.model.ProjectProperty;
|
||||
|
@ -568,7 +569,7 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
@Override
|
||||
public Project clone(UUID from, String newVersion, boolean includeTags, boolean includeProperties,
|
||||
boolean includeComponents, boolean includeServices, boolean includeAuditHistory,
|
||||
boolean includeACL) {
|
||||
boolean includeACL, boolean includePolicyViolations) {
|
||||
final Project source = getObjectByUuid(Project.class, from, Project.FetchGroup.ALL.name());
|
||||
if (source == null) {
|
||||
LOGGER.warn("Project with UUID %s was supposed to be cloned, but it does not exist anymore".formatted(from));
|
||||
|
@ -694,6 +695,19 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if(includeComponents && includePolicyViolations){
|
||||
final List<PolicyViolation> sourcePolicyViolations = getAllPolicyViolations(source);
|
||||
if(sourcePolicyViolations != null){
|
||||
for(final PolicyViolation policyViolation: sourcePolicyViolations){
|
||||
final Component destinationComponent = clonedComponents.get(policyViolation.getComponent().getId());
|
||||
final PolicyViolation clonedPolicyViolation = clonePolicyViolation(policyViolation, destinationComponent);
|
||||
persist(clonedPolicyViolation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
project = getObjectById(Project.class, project.getId());
|
||||
Event.dispatch(new IndexEvent(IndexEvent.Action.CREATE, project));
|
||||
commitSearchIndex(true, Project.class);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue