From 4ee49d64585ddeb2fbd282ec4e359d21f32f19a3 Mon Sep 17 00:00:00 2001 From: itsKedar <37594766+itsKedar@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:32:27 +0530 Subject: [PATCH] Fixed cx-summary property (#1291) * Fixed cx-summary property * Updated dockerfile * Updated test cases * Update Dockerfile --- Dockerfile | 2 +- .../com/checkmarx/flow/config/RepoProperties.java | 10 +++++++++- .../java/com/checkmarx/flow/utils/HTMLHelper.java | 11 ++++++----- .../UpdatePullRequestCommentsSteps.java | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index dedaf722d..bda46dac3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR app RUN apk update && \ apk upgrade && \ apk upgrade -RUN apk add openjdk8=8.372.07-r0 --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community +RUN apk add openjdk8=8.392.08-r0 --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk RUN apk add libstdc++ RUN apk add glib diff --git a/src/main/java/com/checkmarx/flow/config/RepoProperties.java b/src/main/java/com/checkmarx/flow/config/RepoProperties.java index 874a9fd27..a1293240f 100644 --- a/src/main/java/com/checkmarx/flow/config/RepoProperties.java +++ b/src/main/java/com/checkmarx/flow/config/RepoProperties.java @@ -24,7 +24,8 @@ public class RepoProperties { private boolean detailed = true; private boolean flowSummary = true; private String flowSummaryHeader = PullRequestCommentsHelper.COMMENT_TYPE_SAST_FINDINGS_2; - private boolean cxSummary = false; + private boolean cxSummary = true; + private boolean cxTableSummary = false; private String cxSummaryHeader = "Checkmarx Scan Summary"; private Map optionalInstances; private boolean scanSubmittedComment = true; @@ -108,6 +109,13 @@ public String getCloseTransition() { public void setCloseTransition(String closeTransition) { this.closeTransition = closeTransition; } + public boolean isCxTableSummary() { + return cxTableSummary; + } + + public void setCxTableSummary(boolean cxTableSummary) { + this.cxTableSummary = cxTableSummary; + } public String getFilePath() { return filePath; diff --git a/src/main/java/com/checkmarx/flow/utils/HTMLHelper.java b/src/main/java/com/checkmarx/flow/utils/HTMLHelper.java index 95f18522f..249db8201 100644 --- a/src/main/java/com/checkmarx/flow/utils/HTMLHelper.java +++ b/src/main/java/com/checkmarx/flow/utils/HTMLHelper.java @@ -710,12 +710,13 @@ private static void addOsaDetailesBody(ScanResults results, StringBuilder body, private static void addScanSummarySection(ScanRequest request, ScanResults results, RepoProperties properties, StringBuilder body) { setScannerLogoHeader(request, results, body); - setScannerSummaryHeader(results, body); - CxScanSummary summary = results.getScanSummary(); - setScannerTotalVulnerabilities(body, summary, request); - - if (properties.isCxSummary() && !request.getProduct().equals(ScanRequest.Product.CXOSA)) { + if(properties.isCxSummary()) + { + setScannerSummaryHeader(results, body); + setScannerTotalVulnerabilities(body, summary, request); + } + if (properties.isCxTableSummary() && !request.getProduct().equals(ScanRequest.Product.CXOSA)) { if (!ScanUtils.empty(properties.getCxSummaryHeader())) { appendAll(body, MarkDownHelper.getMdHeaderType(4, properties.getCxSummaryHeader()), CRLF); } diff --git a/src/test/java/com/checkmarx/flow/cucumber/integration/pullrequest/updatecomments/UpdatePullRequestCommentsSteps.java b/src/test/java/com/checkmarx/flow/cucumber/integration/pullrequest/updatecomments/UpdatePullRequestCommentsSteps.java index 748f2290e..fc63468b1 100644 --- a/src/test/java/com/checkmarx/flow/cucumber/integration/pullrequest/updatecomments/UpdatePullRequestCommentsSteps.java +++ b/src/test/java/com/checkmarx/flow/cucumber/integration/pullrequest/updatecomments/UpdatePullRequestCommentsSteps.java @@ -444,7 +444,7 @@ private ScanRequest getBasicRequest() { } private void initGitHubProperties() { - this.gitHubProperties.setCxSummary(false); + this.gitHubProperties.setCxSummary(true); this.gitHubProperties.setFlowSummary(false); this.gitHubProperties.setUrl(GITHUB_URL); this.gitHubProperties.setWebhookToken("1234");