Skip to content

Commit

Permalink
Initial commit for addressing Issue DependencyTrack#2737
Browse files Browse the repository at this point in the history
Signed-off-by: Melba Lopez <[email protected]>
  • Loading branch information
melba-lopez committed Jun 29, 2023
1 parent 9058275 commit a3a3534
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/dependencytrack/model/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public enum FetchGroup {
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The publisher may only contain printable characters")
private String publisher;

@Persistent /**Issue #2373, #2737 */
@Column(name = "SUPPLIER", jdbcType = "VARCHAR")
@Size(max = 255)
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The supplier may only contain printable characters")
private String supplier;

@Persistent
@Column(name = "GROUP", jdbcType = "VARCHAR")
@Index(name = "COMPONENT_GROUP_IDX")
Expand Down Expand Up @@ -382,6 +388,14 @@ public void setPublisher(String publisher) {
this.publisher = publisher;
}

public String getSupplier() {/**Issue #2373, #2737 */
return supplier;
}

public void setSupplier(String supplier) {/**Issue #2373, #2737 */
this.supplier = supplier;
}

public String getGroup() {
return group;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public static Component convert(final QueryManager qm, final org.cyclonedx.model
component.setAuthor(StringUtils.trimToNull(cycloneDxComponent.getAuthor()));
component.setBomRef(StringUtils.trimToNull(cycloneDxComponent.getBomRef()));
component.setPublisher(StringUtils.trimToNull(cycloneDxComponent.getPublisher()));
component.setSupplier(StringUtils.trimToNull(cycloneDxComponent.getSupplier()));/**Issue #2373, #2737 */
component.setGroup(StringUtils.trimToNull(cycloneDxComponent.getGroup()));
component.setName(StringUtils.trimToNull(cycloneDxComponent.getName()));
component.setVersion(StringUtils.trimToNull(cycloneDxComponent.getVersion()));
Expand Down Expand Up @@ -313,6 +314,7 @@ public static org.cyclonedx.model.Metadata createMetadata(final Project project)
cycloneComponent.setBomRef(project.getUuid().toString());
cycloneComponent.setAuthor(StringUtils.trimToNull(project.getAuthor()));
cycloneComponent.setPublisher(StringUtils.trimToNull(project.getPublisher()));
cycloneComponent.setSupplier(StringUtils.trimToNull(project.getSupplier()));/**Issue #2373, #2737 */
cycloneComponent.setGroup(StringUtils.trimToNull(project.getGroup()));
cycloneComponent.setName(StringUtils.trimToNull(project.getName()));
if (StringUtils.trimToNull(project.getVersion()) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ public void inform(final Event e) {
if (project.getClassifier() == null) {
final var classifier = Optional.ofNullable(cycloneDxBom.getMetadata())
.map(org.cyclonedx.model.Metadata::getComponent)
.map(org.cyclonedx.model.Metadata::getSupplier) /**Issue #2373, #2737 */
.map(org.cyclonedx.model.Metadata::getManufacture)
.map(org.cyclonedx.model.Component::getType)
.map(org.cyclonedx.model.Component.Type::name)
.map(org.cyclonedx.model.Component::getSupplier) /**Issue #2373, #2737 */
.map(Classifier::valueOf)
.orElse(Classifier.APPLICATION);
project.setClassifier(classifier);
Expand Down

0 comments on commit a3a3534

Please sign in to comment.