diff options
author | Wojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com> | 2023-06-12 14:39:49 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-06-12 20:02:49 +0000 |
commit | a86f840b160eeeca5c712689321cf4b205da8256 (patch) | |
tree | f4357240a2b6e5b5ef1fda888743490aaa355a5f /sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue | |
parent | 3996ed944ec1471f43b6b9aff485c9e31a8bf2b6 (diff) | |
download | sonarqube-a86f840b160eeeca5c712689321cf4b205da8256.tar.gz sonarqube-a86f840b160eeeca5c712689321cf4b205da8256.zip |
SONAR-19309 Improve SARIF logs in case of failure. (#8503)
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java index 7bb05650617..346cb727f7d 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensor.java @@ -27,6 +27,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.sonar.api.CoreProperties; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; @@ -35,15 +37,13 @@ import org.sonar.api.config.PropertyDefinition; import org.sonar.api.resources.Qualifiers; import org.sonar.api.scanner.ScannerSide; import org.sonar.api.scanner.sensor.ProjectSensor; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; import org.sonar.core.sarif.Sarif210; import org.sonar.core.sarif.SarifSerializer; @ScannerSide public class SarifIssuesImportSensor implements ProjectSensor { - private static final Logger LOG = Loggers.get(SarifIssuesImportSensor.class); + private static final Logger LOG = LoggerFactory.getLogger(SarifIssuesImportSensor.class); static final String SARIF_REPORT_PATHS_PROPERTY_KEY = "sonar.sarifReportPaths"; private final SarifSerializer sarifSerializer; @@ -100,7 +100,16 @@ public class SarifIssuesImportSensor implements ProjectSensor { } private static void displayResults(String filePath, SarifImportResults sarifImportResults) { - LOG.info("File {}: successfully imported {} vulnerabilities spread in {} runs. {} failed run(s).", - filePath, sarifImportResults.getSuccessFullyImportedIssues(), sarifImportResults.getSuccessFullyImportedRuns(), sarifImportResults.getFailedRuns()); + if (sarifImportResults.getFailedRuns() > 0 && sarifImportResults.getSuccessFullyImportedRuns() > 0) { + LOG.warn("File {}: {} run(s) could not be imported (see warning above) and {} run(s) successfully imported ({} vulnerabilities in total).", + filePath, sarifImportResults.getFailedRuns(), sarifImportResults.getSuccessFullyImportedRuns(), sarifImportResults.getSuccessFullyImportedIssues()); + + } else if (sarifImportResults.getFailedRuns() > 0) { + LOG.warn("File {}: {} run(s) could not be imported (see warning above).", + filePath, sarifImportResults.getFailedRuns()); + } else { + LOG.info("File {}: {} run(s) successfully imported ({} vulnerabilities in total).", + filePath, sarifImportResults.getSuccessFullyImportedRuns(), sarifImportResults.getSuccessFullyImportedIssues()); + } } } |