aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol/src/main
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2024-10-10 16:18:16 +0200
committersonartech <sonartech@sonarsource.com>2024-10-21 20:03:59 +0000
commit67768656bfe3462a6554ffc236da801cffd20f54 (patch)
tree679a49a4e06a84fe9f18c81eae578959fdf0d0e9 /sonar-scanner-protocol/src/main
parentdd9ebd6a6f4b59c38ce1f1ca494f1d4231291513 (diff)
downloadsonarqube-67768656bfe3462a6554ffc236da801cffd20f54.tar.gz
sonarqube-67768656bfe3462a6554ffc236da801cffd20f54.zip
SONAR-23098 Add dependencies to the scanner report
Diffstat (limited to 'sonar-scanner-protocol/src/main')
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java4
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java8
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java5
-rw-r--r--sonar-scanner-protocol/src/main/protobuf/scanner_report.proto10
4 files changed, 27 insertions, 0 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
index 686b7d20066..5c59f112838 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
@@ -102,6 +102,10 @@ public class FileStructure {
return new File(dir, "analysis-warnings.pb");
}
+ public File dependencies() {
+ return new File(dir, "dependencies.pb");
+ }
+
public File root() {
return dir;
}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
index 807509a83fb..6e48f5b7809 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
@@ -226,6 +226,14 @@ public class ScannerReportReader {
return Protobuf.readStream(file, ScannerReport.AnalysisWarning.parser());
}
+ public CloseableIterator<ScannerReport.Dependency> readDependencies() {
+ File file = fileStructure.dependencies();
+ if (!fileExists(file)) {
+ return emptyCloseableIterator();
+ }
+ return Protobuf.readStream(file, ScannerReport.Dependency.parser());
+ }
+
private static boolean fileExists(File file) {
return file.exists() && file.isFile();
}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
index ad4720cbb5f..1c202ab8605 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
@@ -169,6 +169,11 @@ public class ScannerReportWriter {
return file;
}
+ public void appendDependency(ScannerReport.Dependency dependency) {
+ File file = fileStructure.dependencies();
+ appendDelimitedTo(file, dependency, "dependency");
+ }
+
public File getSourceFile(int componentRef) {
return fileStructure.fileFor(FileStructure.Domain.SOURCE, componentRef);
}
diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
index b7c1d3d5064..fb7ebb72f7f 100644
--- a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
+++ b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
@@ -388,3 +388,13 @@ message Impact {
string software_quality = 1;
string severity = 2;
}
+
+message Dependency {
+ string key = 1;
+ string name = 2;
+ optional string package_manager = 3;
+ optional string full_name = 4;
+ optional string description = 5;
+ optional string version = 6;
+ repeated string parent_dependency_key = 7;
+} \ No newline at end of file