From f0f5a141fe89dcfbd7b08f004b8404b6f8a4cadf Mon Sep 17 00:00:00 2001 From: nscuro Date: Mon, 4 Sep 2023 13:40:51 +0200 Subject: [PATCH] Fix grammatical number of `vulnerabilities` in `ProjectVulnAnalysisCompleteSubject` Signed-off-by: nscuro --- .../parser/hyades/NotificationModelConverter.java | 2 +- .../org/hyades/notification/v1/notification.proto | 7 ++++--- .../event/kafka/KafkaStreamsTopologyTest.java | 12 ++++++------ .../hyades/NotificationModelConverterTest.java | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/dependencytrack/parser/hyades/NotificationModelConverter.java b/src/main/java/org/dependencytrack/parser/hyades/NotificationModelConverter.java index 21b7a92ef..eb07e09f0 100644 --- a/src/main/java/org/dependencytrack/parser/hyades/NotificationModelConverter.java +++ b/src/main/java/org/dependencytrack/parser/hyades/NotificationModelConverter.java @@ -310,7 +310,7 @@ private static ComponentVulnAnalysisCompleteSubject convert(ComponentVulnAnalysi ComponentVulnAnalysisCompleteSubject.Builder builder = ComponentVulnAnalysisCompleteSubject.newBuilder(); builder.setComponent(component); List vulnerabilities = componentVulnAnalysisComplete.getVulnerabilityList().stream().map(NotificationModelConverter::convert).toList(); - builder.addAllVulnerability(vulnerabilities); + builder.addAllVulnerabilities(vulnerabilities); return builder.build(); } diff --git a/src/main/proto/org/hyades/notification/v1/notification.proto b/src/main/proto/org/hyades/notification/v1/notification.proto index b955edbba..0fa68b95b 100644 --- a/src/main/proto/org/hyades/notification/v1/notification.proto +++ b/src/main/proto/org/hyades/notification/v1/notification.proto @@ -198,12 +198,13 @@ message Vulnerability { string name = 2; } } -message ComponentVulnAnalysisCompleteSubject{ + +message ComponentVulnAnalysisCompleteSubject { Component component = 1; - repeated Vulnerability vulnerability = 2; + repeated Vulnerability vulnerabilities = 2; } -message ProjectVulnAnalysisCompleteSubject{ +message ProjectVulnAnalysisCompleteSubject { Project project = 1; repeated ComponentVulnAnalysisCompleteSubject findings = 2; ProjectVulnAnalysisStatus status = 3; diff --git a/src/test/java/org/dependencytrack/event/kafka/KafkaStreamsTopologyTest.java b/src/test/java/org/dependencytrack/event/kafka/KafkaStreamsTopologyTest.java index 7d6095c39..62c3a49c5 100644 --- a/src/test/java/org/dependencytrack/event/kafka/KafkaStreamsTopologyTest.java +++ b/src/test/java/org/dependencytrack/event/kafka/KafkaStreamsTopologyTest.java @@ -244,15 +244,15 @@ public void vulnScanResultProcessingTest() throws Exception { assertThat(subject.getFindingsList()).satisfiesExactlyInAnyOrder( finding -> { assertThat(finding.getComponent().getUuid()).isEqualTo(componentA.getUuid().toString()); - assertThat(finding.getVulnerabilityCount()).isEqualTo(1); - assertThat(finding.getVulnerability(0).getVulnId()).isEqualTo("SNYK-001"); - assertThat(finding.getVulnerability(0).getSource()).isEqualTo("SNYK"); + assertThat(finding.getVulnerabilitiesCount()).isEqualTo(1); + assertThat(finding.getVulnerabilities(0).getVulnId()).isEqualTo("SNYK-001"); + assertThat(finding.getVulnerabilities(0).getSource()).isEqualTo("SNYK"); }, finding -> { assertThat(finding.getComponent().getUuid()).isEqualTo(componentB.getUuid().toString()); - assertThat(finding.getVulnerabilityCount()).isEqualTo(1); - assertThat(finding.getVulnerability(0).getVulnId()).isEqualTo("SONATYPE-001"); - assertThat(finding.getVulnerability(0).getSource()).isEqualTo("OSSINDEX"); + assertThat(finding.getVulnerabilitiesCount()).isEqualTo(1); + assertThat(finding.getVulnerabilities(0).getVulnId()).isEqualTo("SONATYPE-001"); + assertThat(finding.getVulnerabilities(0).getSource()).isEqualTo("OSSINDEX"); } ); } diff --git a/src/test/java/org/dependencytrack/parser/hyades/NotificationModelConverterTest.java b/src/test/java/org/dependencytrack/parser/hyades/NotificationModelConverterTest.java index f197c2a0b..8421c2b0c 100644 --- a/src/test/java/org/dependencytrack/parser/hyades/NotificationModelConverterTest.java +++ b/src/test/java/org/dependencytrack/parser/hyades/NotificationModelConverterTest.java @@ -744,7 +744,7 @@ public void testConvertComponentVulnAnalysisCompleteSubject() throws Exception { final var subject = notification.getSubject().unpack(ProjectVulnAnalysisCompleteSubject.class); assertProject(subject.getProject()); assertComponent(subject.getFindingsList().get(0).getComponent()); - assertVulnerability(subject.getFindingsList().get(0).getVulnerability(0)); + assertVulnerability(subject.getFindingsList().get(0).getVulnerabilities(0)); assertThat(subject.getStatus()).isEqualTo(ProjectVulnAnalysisStatus.PROJECT_VULN_ANALYSIS_STATUS_COMPLETED); } } \ No newline at end of file