aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2024-09-05 17:29:35 +0200
committersonartech <sonartech@sonarsource.com>2024-09-12 20:02:54 +0000
commit55dfebf3ece23eb11e9d2ea9b862b6fad3dbbfbc (patch)
tree1dd5101d80aad8a0ad309aac649f9fa3a52ef8ab /sonar-scanner-engine
parent574637dc96a0655344a0623fa1aae861fe073a86 (diff)
downloadsonarqube-55dfebf3ece23eb11e9d2ea9b862b6fad3dbbfbc.tar.gz
sonarqube-55dfebf3ece23eb11e9d2ea9b862b6fad3dbbfbc.zip
SONAR-22914 Add a Sensor to import FOSSA results
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/IssuePublisher.java13
-rw-r--r--sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/AnalysisResult.java4
2 files changed, 13 insertions, 4 deletions
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());
diff --git a/sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/AnalysisResult.java b/sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/AnalysisResult.java
index e3f282977fa..5751aada0f8 100644
--- a/sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/AnalysisResult.java
+++ b/sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/AnalysisResult.java
@@ -199,6 +199,10 @@ public class AnalysisResult implements AnalysisObserver {
return readFromReport(ScannerReportReader::readAdHocRules);
}
+ public List<ScannerReport.Cve> cves() {
+ return readFromReport(ScannerReportReader::readCves);
+ }
+
@NotNull
private <G> List<G> readFromReport(InputComponent component, BiFunction<ScannerReportReader, Integer, CloseableIterator<G>> readerMethod) {
int ref = ((DefaultInputComponent) component).scannerId();