diff --git a/README.md b/README.md index 68eabd2..d6c5407 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=mc1arke_sonarqube-community-branch-plugin&metric=alert_status)](https://sonarcloud.io/dashboard?id=mc1arke_sonarqube-community-branch-plugin) -[![Build Status](https://img.shields.io/github/actions/workflow/status/mc1arke/sonarqube-community-branch-plugin/.github/workflows/build.yml?branch=master&logo=github)](https://github.com/mc1arke/sonarqube-community-branch-plugin?workflow=build) +[![Build Status](https://img.shields.io/github/actions/workflow/status/soramitsu/soramitsu-sonarqube-community-branch-plugin/.github/workflows/build.yml?branch=master&logo=github)](https://github.com/mc1arke/sonarqube-community-branch-plugin?workflow=build) # Sonarqube Community Branch Plugin @@ -23,6 +22,12 @@ Use the following table to find the correct plugin version for each SonarQube ve SonarQube Version | Plugin Version ------------------|--------------- +10.4 | 1.17.2 +10.3 | 1.16.1 +10.2 | 1.16.0 +10.1 | 1.15.0 +10.0 | 1.15.0 +9.9 (LTS) | 1.14.0 9.8+ | 1.14.0 9.7 | 1.13.0 9.1 - 9.6 | 1.12.0 @@ -35,6 +40,8 @@ SonarQube Version | Plugin Version 7.8 - 8.0 | 1.3.2 7.4 - 7.7 | 1.0.2 +Older versions are listed on the Github release page but are no longer supported. + # Features The plugin is intended to support the @@ -71,6 +78,13 @@ __Note:__ If you're setting the `SONAR_WEB_JAVAADDITIONALOPTS` or `SONAR_CE_JAVA your container launch then you'll need to add the `javaagent` configuration to your overrides to match what's in the provided Dockerfile. +## Docker Compose + +A `docker-compose.yml` file is provided. +It uses the env variables available in `.env`. + +To use it, clone the repository and execute `docker-compose up`. Note that you need to have docker-compose installed in your system and added to your PATH + ## Kubernetes with official Helm Chart When using diff --git a/build.gradle b/build.gradle index 4e8e3c5..6a047db 100644 --- a/build.gradle +++ b/build.gradle @@ -62,17 +62,17 @@ tasks.withType(JavaCompile) { dependencies { compileOnly(fileTree(dir: sonarLibraries, include: '**/*.jar', exclude: 'extensions/*.jar')) testImplementation(fileTree(dir: sonarLibraries, include: '**/*.jar', exclude: 'extensions/*.jar')) - testImplementation('org.mockito:mockito-core:5.8.0') - testImplementation('org.assertj:assertj-core:3.25.1') - testImplementation('org.wiremock:wiremock:3.3.1') + testImplementation('org.mockito:mockito-core:5.11.0') + testImplementation('org.assertj:assertj-core:3.25.3') + testImplementation('org.wiremock:wiremock:3.5.2') zip("sonarqube:sonarqube:${sonarqubeVersion}@zip") implementation('org.bouncycastle:bcpkix-jdk15on:1.70') implementation(files('lib/nodes-0.5.0.jar')) - runtimeOnly('com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.1') + runtimeOnly('com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.0') compileOnly('com.google.code.findbugs:jsr305:3.0.2') implementation('org.javassist:javassist:3.30.2-GA') implementation('com.squareup.okhttp3:logging-interceptor:4.12.0') - testImplementation(platform('org.junit:junit-bom:5.10.1')) + testImplementation(platform('org.junit:junit-bom:5.10.2')) testImplementation('org.junit.jupiter:junit-jupiter') testImplementation('junit:junit:4.13.2') testRuntimeOnly('org.junit.vintage:junit-vintage-engine') diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/model/CheckRunDetails.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/model/CheckRunDetails.java index 47a4974..502598b 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/model/CheckRunDetails.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/model/CheckRunDetails.java @@ -36,6 +36,7 @@ public class CheckRunDetails { private final List annotations; private final CheckConclusionState checkConclusionState; private final int pullRequestId; + private final String projectKey; private CheckRunDetails(Builder builder) { summary = builder.summary; @@ -49,6 +50,7 @@ private CheckRunDetails(Builder builder) { annotations = builder.annotations; checkConclusionState = builder.checkConclusionState; pullRequestId = builder.pullRequestId; + projectKey = builder.projectKey; } public String getSummary() { @@ -95,6 +97,10 @@ public int getPullRequestId() { return pullRequestId; } + public String getProjectKey() { + return projectKey; + } + public static Builder builder() { return new Builder(); } @@ -111,6 +117,7 @@ public static final class Builder { private List annotations; private CheckConclusionState checkConclusionState; private int pullRequestId; + private String projectKey; private Builder() { super(); @@ -171,6 +178,11 @@ public Builder withPullRequestId(int pullRequestId) { return this; } + public Builder withProjectKey(String projectKey) { + this.projectKey = projectKey; + return this; + } + public CheckRunDetails build() { return new CheckRunDetails(this); } diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v3/RestApplicationAuthenticationProvider.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v3/RestApplicationAuthenticationProvider.java index 5555506..40f8c60 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v3/RestApplicationAuthenticationProvider.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v3/RestApplicationAuthenticationProvider.java @@ -78,12 +78,9 @@ public RepositoryAuthenticationToken getInstallationToken(String apiUrl, String Instant issued = clock.instant().minus(10, ChronoUnit.SECONDS); Instant expiry = issued.plus(2, ChronoUnit.MINUTES); - String jwtToken = new DefaultJwtBuilder() - .expiration(Date.from(expiry)) - .issuedAt(Date.from(issued)) - .claim("iss", appId) - .signWith(createPrivateKey(apiPrivateKey), Jwts.SIG.RS256) - .compact(); + String jwtToken = new DefaultJwtBuilder().issuedAt(Date.from(issued)).expiration(Date.from(expiry)) + .claim("iss", appId).signWith(createPrivateKey(apiPrivateKey), Jwts.SIG.RS256).compact(); + Optional repositoryAuthenticationToken = findTokenFromAppInstallationList(getV3Url(apiUrl) + "/app/installations", jwtToken, projectPath); return repositoryAuthenticationToken.orElseThrow(() -> new InvalidConfigurationException(InvalidConfigurationException.Scope.PROJECT, diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/Comments.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/Comments.java index 5bb595f..7331a7b 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/Comments.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/Comments.java @@ -49,12 +49,14 @@ public static class CommentNode { private final Actor author; @GraphQLProperty(name = "isMinimized") private final boolean minimized; + private final String body; @JsonCreator - public CommentNode(@JsonProperty("id") String id, @JsonProperty("author") Actor author, @JsonProperty("isMinimized") boolean minimized) { + public CommentNode(@JsonProperty("id") String id, @JsonProperty("author") Actor author, @JsonProperty("isMinimized") boolean minimized, @JsonProperty("body") String body) { this.id = id; this.author = author; this.minimized = minimized; + this.body = body; } public String getId() { @@ -68,5 +70,9 @@ public Actor getAuthor() { public boolean isMinimized() { return minimized; } + + public String getBody() { + return body; + } } } diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClient.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClient.java index abcbae8..4b40d70 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClient.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClient.java @@ -116,7 +116,7 @@ public String createCheckRun(CheckRunDetails checkRunDetails, boolean postSummar if (postSummaryComment) { - postSummaryComment(graphqlUrl, headers, checkRunDetails.getPullRequestId(), checkRunDetails.getSummary()); + postSummaryComment(graphqlUrl, headers, checkRunDetails.getPullRequestId(), checkRunDetails.getSummary(), checkRunDetails.getProjectKey()); } return graphQLResponseEntity.getResponse().getCheckRun().getId(); @@ -128,7 +128,7 @@ public String getRepositoryUrl() { return repositoryAuthenticationToken.getRepositoryUrl(); } - private void postSummaryComment(String graphqlUrl, Map headers, int pullRequestKey, String summary) throws IOException { + private void postSummaryComment(String graphqlUrl, Map headers, int pullRequestKey, String summary, String projectId) throws IOException { String login = getLogin(graphqlUrl, headers); GetRepository.PullRequest pullRequest = getPullRequest(graphqlUrl, headers, pullRequestKey); @@ -137,6 +137,7 @@ private void postSummaryComment(String graphqlUrl, Map headers, getComments(pullRequest, graphqlUrl, headers, pullRequestKey).stream() .filter(c -> "Bot".equalsIgnoreCase(c.getAuthor().getType()) && login.equalsIgnoreCase(c.getAuthor().getLogin())) .filter(c -> !c.isMinimized()) + .filter(c -> c.getBody().contains(String.format("**Project ID:** %s\r\n", projectId))) .map(Comments.CommentNode::getId) .forEach(commentId -> this.minimizeComment(graphqlUrl, headers, commentId)); diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java index 197702e..bacf7dc 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecorator.java @@ -79,6 +79,7 @@ public DecorationResult decorateQualityGateStatus(AnalysisDetails analysisDetail .withExternalId(analysisDetails.getAnalysisId()) .withName(String.format("%s Sonarqube Results", analysisDetails.getAnalysisProjectName())) .withTitle("Quality Gate " + (analysisDetails.getQualityGateStatus() == QualityGate.Status.OK ? "success" : "failed")) + .withProjectKey(analysisDetails.getAnalysisProjectKey()) .build(); try { diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java index c1237ef..e17b25b 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGenerator.java @@ -90,9 +90,9 @@ public AnalysisIssueSummary createAnalysisIssueSummary(PostAnalysisIssueVisitor. .withProjectKey(analysisDetails.getAnalysisProjectKey()) .withResolution(issue.resolution()) .withSeverity(issue.severity()) - .withSeverityImageUrl(String.format("%s/checks/Severity/%s.svg?sanitize=true", baseImageUrl, issue.severity().toLowerCase())) + .withSeverityImageUrl(String.format("%s/checks/Severity/%s.png", baseImageUrl, issue.severity().toLowerCase())) .withType(issue.type().name()) - .withTypeImageUrl(String.format("%s/checks/IssueType/%s.svg?sanitize=true", baseImageUrl, issue.type().name().toLowerCase())) + .withTypeImageUrl(String.format("%s/checks/IssueType/%s.png", baseImageUrl, issue.type().name().toLowerCase())) .build(); } @@ -131,10 +131,10 @@ public AnalysisSummary createAnalysisSummary(AnalysisDetails analysisDetails) { .withSummaryImageUrl(baseImageUrl + "/common/icon.png") .withBugCount(issueCounts.get(RuleType.BUG)) .withBugUrl(getIssuesUrlForRuleType(analysisDetails, RuleType.BUG)) - .withBugImageUrl(baseImageUrl + "/common/bug.svg?sanitize=true") + .withBugImageUrl(baseImageUrl + "/common/bug.png") .withCodeSmellCount(issueCounts.get(RuleType.CODE_SMELL)) .withCodeSmellUrl(getIssuesUrlForRuleType(analysisDetails, RuleType.CODE_SMELL)) - .withCodeSmellImageUrl(baseImageUrl + "/common/code_smell.svg?sanitize=true") + .withCodeSmellImageUrl(baseImageUrl + "/common/code_smell.png") .withCoverage(coverage) .withNewCoverage(newCoverage) .withCoverageUrl(getComponentMeasuresUrlForCodeMetrics(analysisDetails, CoreMetrics.NEW_COVERAGE_KEY)) @@ -149,13 +149,13 @@ public AnalysisSummary createAnalysisSummary(AnalysisDetails analysisDetails) { .collect(Collectors.toList())) .withStatusDescription(QualityGate.Status.OK == analysisDetails.getQualityGateStatus() ? "Passed" : "Failed") .withStatusImageUrl(QualityGate.Status.OK == analysisDetails.getQualityGateStatus() - ? baseImageUrl + "/checks/QualityGateBadge/passed.svg?sanitize=true" - : baseImageUrl + "/checks/QualityGateBadge/failed.svg?sanitize=true") + ? baseImageUrl + "/checks/QualityGateBadge/passed.png" + : baseImageUrl + "/checks/QualityGateBadge/failed.png") .withTotalIssueCount(issueTotal) .withSecurityHotspotCount(issueCounts.get(RuleType.SECURITY_HOTSPOT)) .withVulnerabilityCount(issueCounts.get(RuleType.VULNERABILITY)) .withVulnerabilityUrl(getIssuesUrlForRuleType(analysisDetails, RuleType.VULNERABILITY)) - .withVulnerabilityImageUrl(baseImageUrl + "/common/vulnerability.svg?sanitize=true") + .withVulnerabilityImageUrl(baseImageUrl + "/common/vulnerability.png") .build(); } @@ -201,7 +201,7 @@ private String getDashboardUrl(AnalysisDetails analysisDetails) { private static String createCoverageImage(BigDecimal coverage, String baseImageUrl) { if (null == coverage) { - return baseImageUrl + "/checks/CoverageChart/NoCoverageInfo.svg?sanitize=true"; + return baseImageUrl + "/checks/CoverageChart/NoCoverageInfo.png"; } BigDecimal matchedLevel = BigDecimal.ZERO; for (BigDecimal level : COVERAGE_LEVELS) { @@ -210,12 +210,12 @@ private static String createCoverageImage(BigDecimal coverage, String baseImageU break; } } - return baseImageUrl + "/checks/CoverageChart/" + matchedLevel + ".svg?sanitize=true"; + return baseImageUrl + "/checks/CoverageChart/" + matchedLevel + ".png"; } private static String createDuplicateImage(BigDecimal duplications, String baseImageUrl) { if (null == duplications) { - return baseImageUrl + "/checks/Duplications/NoDuplicationInfo.svg?sanitize=true"; + return baseImageUrl + "/checks/Duplications/NoDuplicationInfo.png"; } String matchedLevel = "20plus"; for (DuplicationMapping level : DUPLICATION_LEVELS) { @@ -224,7 +224,7 @@ private static String createDuplicateImage(BigDecimal duplications, String baseI break; } } - return baseImageUrl + "/checks/Duplications/" + matchedLevel + ".svg?sanitize=true"; + return baseImageUrl + "/checks/Duplications/" + matchedLevel + ".png"; } private static String formatQualityGateCondition(QualityGate.Condition condition) { diff --git a/src/main/resources/static/checks/CoverageChart/0.png b/src/main/resources/static/checks/CoverageChart/0.png new file mode 100644 index 0000000..1ca414a Binary files /dev/null and b/src/main/resources/static/checks/CoverageChart/0.png differ diff --git a/src/main/resources/static/checks/CoverageChart/100.png b/src/main/resources/static/checks/CoverageChart/100.png new file mode 100644 index 0000000..71b20b9 Binary files /dev/null and b/src/main/resources/static/checks/CoverageChart/100.png differ diff --git a/src/main/resources/static/checks/CoverageChart/25.png b/src/main/resources/static/checks/CoverageChart/25.png new file mode 100644 index 0000000..2e041a2 Binary files /dev/null and b/src/main/resources/static/checks/CoverageChart/25.png differ diff --git a/src/main/resources/static/checks/CoverageChart/40.png b/src/main/resources/static/checks/CoverageChart/40.png new file mode 100644 index 0000000..849d4df Binary files /dev/null and b/src/main/resources/static/checks/CoverageChart/40.png differ diff --git a/src/main/resources/static/checks/CoverageChart/50.png b/src/main/resources/static/checks/CoverageChart/50.png new file mode 100644 index 0000000..ca91670 Binary files /dev/null and b/src/main/resources/static/checks/CoverageChart/50.png differ diff --git a/src/main/resources/static/checks/CoverageChart/60.png b/src/main/resources/static/checks/CoverageChart/60.png new file mode 100644 index 0000000..17dae4e Binary files /dev/null and b/src/main/resources/static/checks/CoverageChart/60.png differ diff --git a/src/main/resources/static/checks/CoverageChart/90.png b/src/main/resources/static/checks/CoverageChart/90.png new file mode 100644 index 0000000..50a0307 Binary files /dev/null and b/src/main/resources/static/checks/CoverageChart/90.png differ diff --git a/src/main/resources/static/checks/CoverageChart/NoCoverageInfo.png b/src/main/resources/static/checks/CoverageChart/NoCoverageInfo.png new file mode 100644 index 0000000..f2adfb2 Binary files /dev/null and b/src/main/resources/static/checks/CoverageChart/NoCoverageInfo.png differ diff --git a/src/main/resources/static/checks/Duplications/10.png b/src/main/resources/static/checks/Duplications/10.png new file mode 100644 index 0000000..662960b Binary files /dev/null and b/src/main/resources/static/checks/Duplications/10.png differ diff --git a/src/main/resources/static/checks/Duplications/20.png b/src/main/resources/static/checks/Duplications/20.png new file mode 100644 index 0000000..dfc515b Binary files /dev/null and b/src/main/resources/static/checks/Duplications/20.png differ diff --git a/src/main/resources/static/checks/Duplications/20plus.png b/src/main/resources/static/checks/Duplications/20plus.png new file mode 100644 index 0000000..ba63c82 Binary files /dev/null and b/src/main/resources/static/checks/Duplications/20plus.png differ diff --git a/src/main/resources/static/checks/Duplications/3.png b/src/main/resources/static/checks/Duplications/3.png new file mode 100644 index 0000000..71b20b9 Binary files /dev/null and b/src/main/resources/static/checks/Duplications/3.png differ diff --git a/src/main/resources/static/checks/Duplications/5.png b/src/main/resources/static/checks/Duplications/5.png new file mode 100644 index 0000000..c584cc2 Binary files /dev/null and b/src/main/resources/static/checks/Duplications/5.png differ diff --git a/src/main/resources/static/checks/Duplications/NoDuplicationInfo.png b/src/main/resources/static/checks/Duplications/NoDuplicationInfo.png new file mode 100644 index 0000000..f2adfb2 Binary files /dev/null and b/src/main/resources/static/checks/Duplications/NoDuplicationInfo.png differ diff --git a/src/main/resources/static/checks/FailedConditionIcon.png b/src/main/resources/static/checks/FailedConditionIcon.png new file mode 100644 index 0000000..d627d67 Binary files /dev/null and b/src/main/resources/static/checks/FailedConditionIcon.png differ diff --git a/src/main/resources/static/checks/IssueType/bug.png b/src/main/resources/static/checks/IssueType/bug.png new file mode 100644 index 0000000..4e9b85d Binary files /dev/null and b/src/main/resources/static/checks/IssueType/bug.png differ diff --git a/src/main/resources/static/checks/IssueType/code_smell.png b/src/main/resources/static/checks/IssueType/code_smell.png new file mode 100644 index 0000000..4c83b22 Binary files /dev/null and b/src/main/resources/static/checks/IssueType/code_smell.png differ diff --git a/src/main/resources/static/checks/IssueType/security_hotspot.png b/src/main/resources/static/checks/IssueType/security_hotspot.png new file mode 100644 index 0000000..57109b5 Binary files /dev/null and b/src/main/resources/static/checks/IssueType/security_hotspot.png differ diff --git a/src/main/resources/static/checks/IssueType/vulnerability.png b/src/main/resources/static/checks/IssueType/vulnerability.png new file mode 100644 index 0000000..58e13e2 Binary files /dev/null and b/src/main/resources/static/checks/IssueType/vulnerability.png differ diff --git a/src/main/resources/static/checks/QualityGateBadge/failed.png b/src/main/resources/static/checks/QualityGateBadge/failed.png new file mode 100644 index 0000000..d0add99 Binary files /dev/null and b/src/main/resources/static/checks/QualityGateBadge/failed.png differ diff --git a/src/main/resources/static/checks/QualityGateBadge/passed.png b/src/main/resources/static/checks/QualityGateBadge/passed.png new file mode 100644 index 0000000..6bee57b Binary files /dev/null and b/src/main/resources/static/checks/QualityGateBadge/passed.png differ diff --git a/src/main/resources/static/checks/RatingBadge/A.png b/src/main/resources/static/checks/RatingBadge/A.png new file mode 100644 index 0000000..d354145 Binary files /dev/null and b/src/main/resources/static/checks/RatingBadge/A.png differ diff --git a/src/main/resources/static/checks/RatingBadge/B.png b/src/main/resources/static/checks/RatingBadge/B.png new file mode 100644 index 0000000..d700ae6 Binary files /dev/null and b/src/main/resources/static/checks/RatingBadge/B.png differ diff --git a/src/main/resources/static/checks/RatingBadge/C.png b/src/main/resources/static/checks/RatingBadge/C.png new file mode 100644 index 0000000..711a58e Binary files /dev/null and b/src/main/resources/static/checks/RatingBadge/C.png differ diff --git a/src/main/resources/static/checks/RatingBadge/D.png b/src/main/resources/static/checks/RatingBadge/D.png new file mode 100644 index 0000000..e9f1efe Binary files /dev/null and b/src/main/resources/static/checks/RatingBadge/D.png differ diff --git a/src/main/resources/static/checks/RatingBadge/E.png b/src/main/resources/static/checks/RatingBadge/E.png new file mode 100644 index 0000000..1272b0c Binary files /dev/null and b/src/main/resources/static/checks/RatingBadge/E.png differ diff --git a/src/main/resources/static/checks/Severity/blocker.png b/src/main/resources/static/checks/Severity/blocker.png new file mode 100644 index 0000000..31e4890 Binary files /dev/null and b/src/main/resources/static/checks/Severity/blocker.png differ diff --git a/src/main/resources/static/checks/Severity/critical.png b/src/main/resources/static/checks/Severity/critical.png new file mode 100644 index 0000000..a5cac74 Binary files /dev/null and b/src/main/resources/static/checks/Severity/critical.png differ diff --git a/src/main/resources/static/checks/Severity/info.png b/src/main/resources/static/checks/Severity/info.png new file mode 100644 index 0000000..e632089 Binary files /dev/null and b/src/main/resources/static/checks/Severity/info.png differ diff --git a/src/main/resources/static/checks/Severity/major.png b/src/main/resources/static/checks/Severity/major.png new file mode 100644 index 0000000..80ae9b1 Binary files /dev/null and b/src/main/resources/static/checks/Severity/major.png differ diff --git a/src/main/resources/static/checks/Severity/minor.png b/src/main/resources/static/checks/Severity/minor.png new file mode 100644 index 0000000..abcd48b Binary files /dev/null and b/src/main/resources/static/checks/Severity/minor.png differ diff --git a/src/main/resources/static/common/bug.png b/src/main/resources/static/common/bug.png new file mode 100644 index 0000000..4510855 Binary files /dev/null and b/src/main/resources/static/common/bug.png differ diff --git a/src/main/resources/static/common/code_smell.png b/src/main/resources/static/common/code_smell.png new file mode 100644 index 0000000..5f26f0c Binary files /dev/null and b/src/main/resources/static/common/code_smell.png differ diff --git a/src/main/resources/static/common/security_hotspot.png b/src/main/resources/static/common/security_hotspot.png new file mode 100644 index 0000000..3dba066 Binary files /dev/null and b/src/main/resources/static/common/security_hotspot.png differ diff --git a/src/main/resources/static/common/vulnerability.png b/src/main/resources/static/common/vulnerability.png new file mode 100644 index 0000000..e3e400f Binary files /dev/null and b/src/main/resources/static/common/vulnerability.png differ diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClientTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClientTest.java index 8efd476..5699cca 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClientTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/almclient/github/v4/GraphqlGithubClientTest.java @@ -159,6 +159,7 @@ void verifyCheckRunSubmitsCorrectAnnotations() throws IOException { " {" + " \"id\": \"MDEyOklzc3VlQ29tbWVudDE1MDE3\"," + " \"isMinimized\": false," + + " \"body\": \"**Project ID:** project-key-test\\r\\n\"," + " \"author\": {" + " \"__typename\": \"Bot\"," + " \"login\": \"test-sonar\"" + @@ -207,6 +208,7 @@ void verifyCheckRunSubmitsCorrectAnnotations() throws IOException { .withName("Name") .withTitle("Title") .withPullRequestId(999) + .withProjectKey("project-key-test") .build(); @@ -299,7 +301,7 @@ void verifyCheckRunSubmitsCorrectAnnotations() throws IOException { assertEquals(requestEntities.get(2), getPullRequestRequestEntityArgumentCaptor.getValue()); assertEquals( "query { repository (owner:\"owner\",name:\"repository\") { url pullRequest : pullRequest (number:999) { comments : comments (first:100) { nodes" + - " { author { type : __typename login } id minimized : isMinimized } pageInfo { hasNextPage endCursor } } id } } } ", + " { author { type : __typename login } id minimized : isMinimized body } pageInfo { hasNextPage endCursor } } id } } } ", getPullRequestRequestEntityArgumentCaptor.getValue().getRequest() ); diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecoratorTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecoratorTest.java index 10f595b..b60b401 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecoratorTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/GithubPullRequestDecoratorTest.java @@ -147,6 +147,7 @@ void verifyCorrectArgumentsAndReturnValuesUsed() throws IOException { .withSeverity(i % 5 < 1 ? CheckAnnotationLevel.NOTICE : i % 5 > 2 ? CheckAnnotationLevel.FAILURE : CheckAnnotationLevel.WARNING) .build()).collect(Collectors.toList())) .withCheckConclusionState(CheckConclusionState.SUCCESS) + .withProjectKey(analysisDetails.getAnalysisProjectKey()) .build()); assertThat(decorationResult).usingRecursiveComparison().isEqualTo(expectedResult); } diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGeneratorTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGeneratorTest.java index 3ee31f3..373f8c6 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGeneratorTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/report/ReportGeneratorTest.java @@ -55,9 +55,9 @@ class ReportGeneratorTest { - @CsvSource({"12, 0.svg?sanitize=true, 21, 20plus.svg?sanitize=true", - "98, 90.svg?sanitize=true, 1, 3.svg?sanitize=true", - ",NoCoverageInfo.svg?sanitize=true,,NoDuplicationInfo.svg?sanitize=true"}) + @CsvSource({"12, 0.png, 21, 20plus.png", + "98, 90.png, 1, 3.png", + ",NoCoverageInfo.png,,NoDuplicationInfo.png"}) @ParameterizedTest void shouldProduceCorrectAnalysisSummary(String coverage, String coverageImage, String duplications, String duplicationsImage) { AnalysisDetails analysisDetails = mock(AnalysisDetails.class); @@ -182,7 +182,7 @@ void shouldProduceCorrectAnalysisSummary(String coverage, String coverageImage, AnalysisSummary expected = AnalysisSummary.builder() .withBugCount(2) .withBugUrl("http://localhost:9000/project/issues?pullRequest=5&resolved=false&types=BUG&inNewCodePeriod=true&id=projectKey") - .withBugImageUrl("http://localhost:9000/static/communityBranchPlugin/common/bug.svg?sanitize=true") + .withBugImageUrl("http://localhost:9000/static/communityBranchPlugin/common/bug.png") .withCoverage(null == coverage ? null : new BigDecimal(coverage)) .withCoverageUrl("http://localhost:9000/component_measures?id=projectKey&metric=new_coverage&pullRequest=5&view=list") .withCoverageImageUrl("http://localhost:9000/static/communityBranchPlugin/checks/CoverageChart/" + coverageImage) @@ -193,16 +193,16 @@ void shouldProduceCorrectAnalysisSummary(String coverage, String coverageImage, .withNewDuplications(null == duplications ? null : new BigDecimal(duplications)) .withCodeSmellCount(1) .withCodeSmellUrl("http://localhost:9000/project/issues?pullRequest=5&resolved=false&types=CODE_SMELL&inNewCodePeriod=true&id=projectKey") - .withCodeSmellImageUrl("http://localhost:9000/static/communityBranchPlugin/common/code_smell.svg?sanitize=true") + .withCodeSmellImageUrl("http://localhost:9000/static/communityBranchPlugin/common/code_smell.png") .withDashboardUrl("http://localhost:9000/dashboard?id=projectKey&pullRequest=5") .withProjectKey("projectKey") .withSummaryImageUrl("http://localhost:9000/static/communityBranchPlugin/common/icon.png") .withSecurityHotspotCount(1) .withVulnerabilityCount(1) .withVulnerabilityUrl("http://localhost:9000/project/issues?pullRequest=5&resolved=false&types=VULNERABILITY&inNewCodePeriod=true&id=projectKey") - .withVulnerabilityImageUrl("http://localhost:9000/static/communityBranchPlugin/common/vulnerability.svg?sanitize=true") + .withVulnerabilityImageUrl("http://localhost:9000/static/communityBranchPlugin/common/vulnerability.png") .withStatusDescription("Failed") - .withStatusImageUrl("http://localhost:9000/static/communityBranchPlugin/checks/QualityGateBadge/failed.svg?sanitize=true") + .withStatusImageUrl("http://localhost:9000/static/communityBranchPlugin/checks/QualityGateBadge/failed.png") .withTotalIssueCount(5) .withFailedQualityGateConditions(List.of("19 Lines to Cover (is less than 20)", "2 Code Smells (is greater than 0)", @@ -235,9 +235,9 @@ void shouldProduceCorrectAnalysisIssueSummary(RuleType ruleType, String issueUrl .withMessage("message") .withResolution("FIXED") .withSeverity("CRITICAL") - .withSeverityImageUrl("http://target.host:port/path/to/root/static/communityBranchPlugin/checks/Severity/critical.svg?sanitize=true") + .withSeverityImageUrl("http://target.host:port/path/to/root/static/communityBranchPlugin/checks/Severity/critical.png") .withType(ruleType.name()) - .withTypeImageUrl("http://target.host:port/path/to/root/static/communityBranchPlugin/checks/IssueType/" + ruleType.name().toLowerCase(Locale.ENGLISH) + ".svg?sanitize=true") + .withTypeImageUrl("http://target.host:port/path/to/root/static/communityBranchPlugin/checks/IssueType/" + ruleType.name().toLowerCase(Locale.ENGLISH) + ".png") .withProjectKey("project-key") .build(); diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/classloader/ReflectiveElevatedClassLoaderFactoryTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/classloader/ReflectiveElevatedClassLoaderFactoryTest.java index 5dbefda..633f8f2 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/classloader/ReflectiveElevatedClassLoaderFactoryTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/classloader/ReflectiveElevatedClassLoaderFactoryTest.java @@ -38,7 +38,7 @@ * @author Michael Clarke */ public class ReflectiveElevatedClassLoaderFactoryTest { - + private static final String TARGET_PLUGIN_CLASS = "org.sonar.plugins.java.JavaPlugin"; private static final String BUNDLED_PLUGINS_DIRECTORY = "lib/extensions"; private static final String SONARQUBE_LIB_DIRECTORY = "sonarqube-lib/";