From 55dfebf3ece23eb11e9d2ea9b862b6fad3dbbfbc Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 5 Sep 2024 17:29:35 +0200 Subject: [PATCH] SONAR-22914 Add a Sensor to import FOSSA results --- .../sensor/issue/internal/DefaultExternalIssue.java | 10 ++++++++++ .../org/sonar/scanner/issue/IssuePublisher.java | 13 +++++++++---- .../sonar/scanner/mediumtest/AnalysisResult.java | 4 ++++ .../src/main/protobuf/scanner_report.proto | 6 +++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java index 449c272c8df..6a904f15ee5 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssue.java @@ -44,6 +44,7 @@ public class DefaultExternalIssue extends AbstractDefaultIssue impacts = new EnumMap<>(SoftwareQuality.class); private CleanCodeAttribute cleanCodeAttribute; @@ -84,6 +85,10 @@ public class DefaultExternalIssue extends AbstractDefaultIssue cves() { + return readFromReport(ScannerReportReader::readCves); + } + @NotNull private List readFromReport(InputComponent component, BiFunction> readerMethod) { int ref = ((DefaultInputComponent) component).scannerId(); diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto index fddf8881f31..0a3fa17c4ee 100644 --- a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto +++ b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto @@ -216,7 +216,7 @@ message ExternalIssue { repeated MessageFormatting msgFormatting = 9; repeated Impact impacts = 10; optional string cleanCodeAttribute = 11; - + optional string cve_id = 12; } message AdHocRule { @@ -234,8 +234,8 @@ message Cve { string cve_id = 1; string description = 2; float cvss_score = 3; - float epss_score = 4; - float epss_percentile = 5; + optional float epss_score = 4; + optional float epss_percentile = 5; int64 published_date = 6; int64 last_modified_date = 7; repeated string cwe = 8; -- 2.39.5