diff options
author | OrlovAlexander <alexander.orlov@sonarsource.com> | 2024-11-20 10:42:34 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-11-27 20:02:58 +0000 |
commit | b9c3c8716b6ed268b0a0b321f7b69bd4fa1d335a (patch) | |
tree | 5126dd5a3a65b783b2cc3e069de61bfee8e3f4a8 /server | |
parent | 67779bbfb3c304bdfd658accc0b4e05c5511ce7b (diff) | |
download | sonarqube-b9c3c8716b6ed268b0a0b321f7b69bd4fa1d335a.tar.gz sonarqube-b9c3c8716b6ed268b0a0b321f7b69bd4fa1d335a.zip |
SONAR-23637 Export of CSV finding files includes impacts
Diffstat (limited to 'server')
3 files changed, 20 insertions, 1 deletions
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/report/RegulatoryReportDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/report/RegulatoryReportDaoIT.java index 713435a1d9f..b1332a4afed 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/report/RegulatoryReportDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/report/RegulatoryReportDaoIT.java @@ -24,10 +24,13 @@ import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import org.sonar.api.issue.impact.Severity; +import org.sonar.api.issue.impact.SoftwareQuality; import org.sonar.api.rules.RuleType; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; +import org.sonar.db.issue.ImpactDto; import org.sonar.db.issue.IssueDto; import org.sonar.db.rule.RuleDto; @@ -63,7 +66,8 @@ class RegulatoryReportDaoIT { @Test void scrollIssues_returns_all_non_closed_issues_for_project() { - IssueDto issue1 = db.issues().insertIssue(rule, project, file, i -> i.setType(RuleType.BUG).setStatus("OPEN").setResolution(null)); + IssueDto issue1 = db.issues().insertIssue(rule, project, file, i -> i.setType(RuleType.BUG).setStatus("OPEN").setResolution(null) + .replaceAllImpacts(List.of(new ImpactDto(SoftwareQuality.MAINTAINABILITY, Severity.MEDIUM)))); IssueDto issue2 = db.issues().insertIssue(rule, project, file, i -> i.setType(RuleType.VULNERABILITY).setStatus("CONFIRMED").setResolution(null)); IssueDto issue3 = db.issues().insertHotspot(hotspotRule, project, file, @@ -105,5 +109,6 @@ class RegulatoryReportDaoIT { assertThat(issue.getResolution()).isEqualTo(issue1.getResolution()); assertThat(issue.getStatus()).isEqualTo(issue1.getStatus()); assertThat(issue.getComments()).containsExactly("c1", "c2"); + assertThat(issue.getImpacts()).containsExactly(new ImpactDto(SoftwareQuality.MAINTAINABILITY, Severity.MEDIUM)); } } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/report/IssueFindingDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/report/IssueFindingDto.java index 64dca7db25b..c53fedf0919 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/report/IssueFindingDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/report/IssueFindingDto.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Set; import javax.annotation.CheckForNull; import org.sonar.api.rules.RuleType; +import org.sonar.db.issue.ImpactDto; import org.sonar.db.rule.RuleDto; public class IssueFindingDto { @@ -42,6 +43,7 @@ public class IssueFindingDto { private boolean isNewCodeReferenceIssue; private long creationDate; private List<String> comments; + private Set<ImpactDto> impacts; public String getStatus() { return status; @@ -111,4 +113,8 @@ public class IssueFindingDto { public List<String> getComments() { return comments; } + + public Set<ImpactDto> getImpacts() { + return impacts; + } } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/report/RegulatoryReportMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/report/RegulatoryReportMapper.xml index dc9cb020b2e..7506b52f060 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/report/RegulatoryReportMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/report/RegulatoryReportMapper.xml @@ -27,6 +27,12 @@ </case> </discriminator> </collection> + <collection property="impacts" column="ii_softwareQuality" notNullColumn="ii_softwareQuality" + javaType="java.util.Set" ofType="Impact"> + <result property="softwareQuality" column="ii_softwareQuality"/> + <result property="severity" column="ii_severity"/> + <result property="manualSeverity" column="ii_manualSeverity"/> + </collection> </resultMap> <sql id="issueColumns"> @@ -44,6 +50,7 @@ r.security_standards as securityStandards, r.name as ruleName, i.issue_creation_date as creationDate, + <include refid="org.sonar.db.issue.IssueMapper.issueImpactsColumns"/> <include refid="org.sonar.db.issue.IssueMapper.isNewCodeReferenceIssue"/> </sql> @@ -59,6 +66,7 @@ inner join components p on p.uuid=i.component_uuid left join issue_changes ic on ic.issue_key = i.kee left join new_code_reference_issues n on i.kee = n.issue_key + left outer join issues_impacts ii on i.kee = ii.issue_key where i.project_uuid=#{branchUuid,jdbcType=VARCHAR} and i.status !='CLOSED' <!--BUG, VULNERABILITY, SECURITY_HOTSPOT --> |