Skip to content

Commit

Permalink
update cdx version to 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
sahibamittal committed Jul 11, 2024
1 parent e19cf4a commit fb75e6b
Show file tree
Hide file tree
Showing 10 changed files with 2,262 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import alpine.Config;
import org.apache.kafka.common.serialization.Serde;
import org.apache.kafka.common.serialization.Serdes;
import org.cyclonedx.proto.v1_4.Bom;
import org.cyclonedx.proto.v1_6.Bom;
import org.dependencytrack.common.ConfigKey;
import org.dependencytrack.event.kafka.serialization.KafkaProtobufSerde;
import org.dependencytrack.proto.mirror.v1.EpssItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import io.github.nscuro.versatile.version.VersioningScheme;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.cyclonedx.proto.v1_4.Bom;
import org.cyclonedx.proto.v1_4.Component;
import org.cyclonedx.proto.v1_4.VulnerabilityAffects;
import org.cyclonedx.proto.v1_6.Bom;
import org.cyclonedx.proto.v1_6.Component;
import org.cyclonedx.proto.v1_6.VulnerabilityAffects;
import org.dependencytrack.event.kafka.processor.api.Processor;
import org.dependencytrack.model.Vulnerability;
import org.dependencytrack.model.VulnerableSoftware;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private void processScannerResult(final QueryManager qm, final Component compone
private Set<Vulnerability> syncVulnerabilities(final QueryManager qm, final ScanKey scanKey, final ScannerResult scannerResult) {
final var syncedVulns = new HashSet<Vulnerability>();

for (final org.cyclonedx.proto.v1_4.Vulnerability reportedVuln : scannerResult.getBom().getVulnerabilitiesList()) {
for (final org.cyclonedx.proto.v1_6.Vulnerability reportedVuln : scannerResult.getBom().getVulnerabilitiesList()) {
final Vulnerability vuln;
try {
vuln = ModelConverterCdxToVuln.convert(qm, scannerResult.getBom(), reportedVuln, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
package org.dependencytrack.parser.dependencytrack;

import org.apache.commons.lang3.StringUtils;
import org.cyclonedx.proto.v1_4.Bom;
import org.cyclonedx.proto.v1_4.ScoreMethod;
import org.cyclonedx.proto.v1_4.Source;
import org.cyclonedx.proto.v1_4.VulnerabilityRating;
import org.cyclonedx.proto.v1_4.VulnerabilityReference;
import org.cyclonedx.proto.v1_6.Bom;
import org.cyclonedx.proto.v1_6.ScoreMethod;
import org.cyclonedx.proto.v1_6.Source;
import org.cyclonedx.proto.v1_6.VulnerabilityRating;
import org.cyclonedx.proto.v1_6.VulnerabilityReference;
import org.dependencytrack.model.AnalyzerIdentity;
import org.dependencytrack.model.Severity;
import org.dependencytrack.model.Vulnerability;
Expand All @@ -46,17 +46,17 @@
import java.util.Objects;

import static org.apache.commons.lang3.StringUtils.trimToNull;
import static org.cyclonedx.proto.v1_4.ScoreMethod.SCORE_METHOD_CVSSV2;
import static org.cyclonedx.proto.v1_4.ScoreMethod.SCORE_METHOD_CVSSV3;
import static org.cyclonedx.proto.v1_4.ScoreMethod.SCORE_METHOD_CVSSV31;
import static org.cyclonedx.proto.v1_4.ScoreMethod.SCORE_METHOD_OWASP;
import static org.cyclonedx.proto.v1_6.ScoreMethod.SCORE_METHOD_CVSSV2;
import static org.cyclonedx.proto.v1_6.ScoreMethod.SCORE_METHOD_CVSSV3;
import static org.cyclonedx.proto.v1_6.ScoreMethod.SCORE_METHOD_CVSSV31;
import static org.cyclonedx.proto.v1_6.ScoreMethod.SCORE_METHOD_OWASP;

public final class ModelConverterCdxToVuln {

static final String TITLE_PROPERTY_NAME = "dependency-track:vuln:title";

public static Vulnerability convert(final QueryManager qm, final Bom bom,
final org.cyclonedx.proto.v1_4.Vulnerability cycloneVuln,
final org.cyclonedx.proto.v1_6.Vulnerability cycloneVuln,
boolean isAliasSyncEnabled) {
if (cycloneVuln == null) {
return null;
Expand Down Expand Up @@ -209,7 +209,7 @@ public static Vulnerability convert(final QueryManager qm, final Bom bom,
return vuln;
}

private static VulnerabilityAlias convert(final org.cyclonedx.proto.v1_4.Vulnerability cycloneVuln,
private static VulnerabilityAlias convert(final org.cyclonedx.proto.v1_6.Vulnerability cycloneVuln,
final VulnerabilityReference cycloneAlias) {
final var alias = new VulnerabilityAlias();
switch (cycloneVuln.getSource().getName()) {
Expand Down Expand Up @@ -244,7 +244,7 @@ private static VulnerabilityAlias convert(final org.cyclonedx.proto.v1_4.Vulnera
public static Severity calculateSeverity(Bom bom) {
if (bom.getVulnerabilitiesCount() > 0
&& bom.getVulnerabilities(0).getRatingsCount() > 0) {
org.cyclonedx.proto.v1_4.Severity severity =
org.cyclonedx.proto.v1_6.Severity severity =
bom.getVulnerabilities(0).getRatings(0).getSeverity();
final VulnerabilityRating rating = bom.getVulnerabilities(0).getRatings(0);
if (rating.hasSeverity()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/proto/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ name: github.com/DependencyTrack/hyades-apiserver
lint:
ignore:
- org/cyclonedx/v1_4/cyclonedx.proto
- org/cyclonedx/v1_6/cyclonedx.proto
Loading

0 comments on commit fb75e6b

Please sign in to comment.