diff --git a/gradle.properties b/gradle.properties index 6af431eb..409b10ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ description = Provides automatic scan of code by Checkmarx server and shows results summary and trend in Jenkins interface. group = com.checkmarx.jenkins -version = 2021.1.1 +version = 2021.1.2 repositoryVersion= diff --git a/src/main/java/com/checkmarx/jenkins/CxScanBuilder.java b/src/main/java/com/checkmarx/jenkins/CxScanBuilder.java index fb1f3815..bc98ab4a 100644 --- a/src/main/java/com/checkmarx/jenkins/CxScanBuilder.java +++ b/src/main/java/com/checkmarx/jenkins/CxScanBuilder.java @@ -1152,6 +1152,7 @@ private String getJenkinURLForTheJob(EnvVars env) { try { String jobName = env.get("JOB_NAME"); jobName = URLDecoder.decode(jobName, "UTF-8"); + jobName = jobName.replaceAll("[^.a-zA-Z0-9\\s]", " "); String jenURL = env.get("JENKINS_URL"); jenURL = jenURL.substring((jenURL.lastIndexOf("://")) + 3); String hostName = ""; @@ -1160,13 +1161,14 @@ private String getJenkinURLForTheJob(EnvVars env) { } else { hostName = jenURL; } - passedURL = hostName + " " + jobName; + passedURL = "Jenkins " + hostName + " " + jobName; + // 50 is the maximum number of characters allowed by SAST server if(passedURL.length()>50) passedURL=passedURL.substring(0,50); else passedURL=passedURL; } catch (UnsupportedEncodingException e) { - log.error("Failed to get jwnkin URL of the JOB: " + e.getMessage()); + log.error("Failed to get Jenkins URL of the JOB: " + e.getMessage()); } return passedURL; } @@ -1175,12 +1177,6 @@ private String getJenkinURLForTheJob(EnvVars env) { private String getCxOriginUrl(EnvVars env, CxLoggerAdapter log) { String jenURL = env.get("JENKINS_URL"); String jobName = env.get("JOB_NAME"); - try { - jobName = URLDecoder.decode(jobName, "UTF-8"); - } catch (UnsupportedEncodingException e) { - log.error("Failed to get jenkin URL of the JOB: " + e.getMessage()); - } - String originUrl = jenURL+"job/"+jobName; return originUrl; }