From 55dfebf3ece23eb11e9d2ea9b862b6fad3dbbfbc Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 5 Sep 2024 17:29:35 +0200 Subject: SONAR-22914 Add a Sensor to import FOSSA results --- .../main/java/org/sonar/scanner/issue/IssuePublisher.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/issue') diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java index 66329f4e6ac..d09209bb2c7 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java @@ -37,6 +37,7 @@ import org.sonar.api.batch.sensor.issue.Issue; import org.sonar.api.batch.sensor.issue.Issue.Flow; import org.sonar.api.batch.sensor.issue.MessageFormatting; import org.sonar.api.batch.sensor.issue.NewIssue.FlowType; +import org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue; import org.sonar.api.batch.sensor.issue.internal.DefaultIssueFlow; import org.sonar.api.issue.impact.SoftwareQuality; import org.sonar.api.rules.CleanCodeAttribute; @@ -88,9 +89,9 @@ public class IssuePublisher { private static boolean noSonar(DefaultInputComponent inputComponent, Issue issue) { TextRange textRange = issue.primaryLocation().textRange(); return inputComponent.isFile() - && textRange != null - && ((DefaultInputFile) inputComponent).hasNoSonarAt(textRange.start().line()) - && !StringUtils.containsIgnoreCase(issue.ruleKey().rule(), "nosonar"); + && textRange != null + && ((DefaultInputFile) inputComponent).hasNoSonarAt(textRange.start().line()) + && !StringUtils.containsIgnoreCase(issue.ruleKey().rule(), "nosonar"); } public void initAndAddExternalIssue(ExternalIssue issue) { @@ -176,7 +177,11 @@ public class IssuePublisher { locationBuilder.setComponentRef(componentRef); TextRange primaryTextRange = issue.primaryLocation().textRange(); - //nullable fields + // nullable fields + var cveId = ((DefaultExternalIssue) issue).cveId(); + if (cveId != null) { + builder.setCveId(cveId); + } CleanCodeAttribute cleanCodeAttribute = issue.cleanCodeAttribute(); if (cleanCodeAttribute != null) { builder.setCleanCodeAttribute(cleanCodeAttribute.name()); -- cgit v1.2.3