Skip to content

Commit d16efe4

Browse files
committed
Warn on duplicate service BOM refs during BOM processing
1 parent ca0524b commit d16efe4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/org/dependencytrack/tasks/BomUploadProcessingTask.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,13 @@ private static Predicate<ServiceComponent> distinctServicesByIdentity(
675675
final var identitiesSeen = new HashSet<ComponentIdentity>();
676676
return service -> {
677677
final var componentIdentity = new ComponentIdentity(service);
678-
identitiesByBomRef.putIfAbsent(service.getBomRef(), componentIdentity);
678+
final boolean isBomRefUnique = identitiesByBomRef.putIfAbsent(service.getBomRef(), componentIdentity) == null;
679+
if (!isBomRefUnique) {
680+
LOGGER.warn("""
681+
BOM ref %s is associated with multiple services in the BOM; \
682+
BOM refs are required to be unique; Please report this to the vendor \
683+
of the tool that generated the BOM""".formatted(service.getBomRef()));
684+
}
679685
bomRefsByIdentity.put(componentIdentity, service.getBomRef());
680686
final boolean isSeenBefore = !identitiesSeen.add(componentIdentity);
681687
if (LOGGER.isDebugEnabled() && isSeenBefore) {

0 commit comments

Comments
 (0)