diff --git a/src/main/java/org/dependencytrack/persistence/ComponentQueryManager.java b/src/main/java/org/dependencytrack/persistence/ComponentQueryManager.java index 1d0223ceb..353516b2c 100644 --- a/src/main/java/org/dependencytrack/persistence/ComponentQueryManager.java +++ b/src/main/java/org/dependencytrack/persistence/ComponentQueryManager.java @@ -370,6 +370,7 @@ public Component cloneComponent(Component sourceComponent, Project destinationPr component.setCpe(sourceComponent.getCpe()); component.setPurl(sourceComponent.getPurl()); component.setPurlCoordinates(sourceComponent.getPurlCoordinates()); + component.setSwidTagId(sourceComponent.getSwidTagId()); component.setInternal(sourceComponent.isInternal()); component.setDescription(sourceComponent.getDescription()); component.setCopyright(sourceComponent.getCopyright()); diff --git a/src/test/java/org/dependencytrack/resources/v1/ProjectResourceTest.java b/src/test/java/org/dependencytrack/resources/v1/ProjectResourceTest.java index ddd7363ae..850be551f 100644 --- a/src/test/java/org/dependencytrack/resources/v1/ProjectResourceTest.java +++ b/src/test/java/org/dependencytrack/resources/v1/ProjectResourceTest.java @@ -1907,6 +1907,7 @@ public void cloneProjectTest() { componentA.setProject(project); componentA.setName("acme-lib-a"); componentA.setVersion("2.0.0"); + componentA.setSwidTagId("swidTagId"); componentA.setSupplier(componentSupplier); qm.persist(componentA); @@ -1976,7 +1977,8 @@ public void cloneProjectTest() { "objectType": "COMPONENT", "uuid": "${json-unit.matches:notSourceComponentUuid}", "name": "acme-lib-a", - "version": "2.0.0" + "version": "2.0.0", + "swidTagId":"swidTagId" } ] """); @@ -2006,6 +2008,7 @@ public void cloneProjectTest() { assertThat(clonedComponent.getUuid()).isNotEqualTo(componentA.getUuid()); assertThat(clonedComponent.getName()).isEqualTo("acme-lib-a"); assertThat(clonedComponent.getVersion()).isEqualTo("2.0.0"); + assertThat(clonedComponent.getSwidTagId()).isEqualTo("swidTagId"); assertThat(clonedComponent.getSupplier()).isNotNull(); assertThat(clonedComponent.getSupplier().getName()).isEqualTo("componentSupplier"); assertThatJson(clonedComponent.getDirectDependencies())