mirror of
https://github.com/DependencyTrack/dependency-track.git
synced 2025-11-10 18:41:07 +00:00
Fix component properties not being cloned
Signed-off-by: nscuro <nscuro@protonmail.com>
This commit is contained in:
parent
965e09c934
commit
23afb5cbf3
2 changed files with 35 additions and 0 deletions
|
|
@ -45,6 +45,7 @@ import org.dependencytrack.model.Analysis;
|
|||
import org.dependencytrack.model.AnalysisComment;
|
||||
import org.dependencytrack.model.Classifier;
|
||||
import org.dependencytrack.model.Component;
|
||||
import org.dependencytrack.model.ComponentProperty;
|
||||
import org.dependencytrack.model.ConfigPropertyConstants;
|
||||
import org.dependencytrack.model.FindingAttribution;
|
||||
import org.dependencytrack.model.PolicyViolation;
|
||||
|
|
@ -745,6 +746,24 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
if (sourceComponents != null) {
|
||||
for (final Component sourceComponent : sourceComponents) {
|
||||
final Component clonedComponent = cloneComponent(sourceComponent, project, false);
|
||||
|
||||
if (sourceComponent.getProperties() != null && !sourceComponent.getProperties().isEmpty()) {
|
||||
final var clonedProperties = new ArrayList<ComponentProperty>(sourceComponent.getProperties().size());
|
||||
for (final ComponentProperty sourceProperty : sourceComponent.getProperties()) {
|
||||
final ComponentProperty clonedProperty = new ComponentProperty();
|
||||
clonedProperty.setComponent(clonedComponent);
|
||||
clonedProperty.setPropertyType(sourceProperty.getPropertyType());
|
||||
clonedProperty.setGroupName(sourceProperty.getGroupName());
|
||||
clonedProperty.setPropertyName(sourceProperty.getPropertyName());
|
||||
clonedProperty.setPropertyValue(sourceProperty.getPropertyValue());
|
||||
clonedProperty.setDescription(sourceProperty.getDescription());
|
||||
clonedProperties.add(clonedProperty);
|
||||
}
|
||||
|
||||
persist(clonedProperties);
|
||||
clonedComponent.setProperties(clonedProperties);
|
||||
}
|
||||
|
||||
// Add vulnerabilties and finding attribution from the source component to the cloned component
|
||||
for (Vulnerability vuln : sourceComponent.getVulnerabilities()) {
|
||||
final FindingAttribution sourceAttribution = this.getFindingAttribution(vuln, sourceComponent);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue