From 4c85ab9d567d3376dcedc9ca675ee61ef989334c Mon Sep 17 00:00:00 2001 From: Anna Karyakina Date: Wed, 25 Oct 2023 09:57:07 -0700 Subject: [PATCH] Update wording on Fortify SSC in plugin logs --- .../plugin/jenkins/steps/FortifyStep.java | 21 +++++++++++------- .../plugin/jenkins/steps/FortifyUpload.java | 22 +++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/fortify/plugin/jenkins/steps/FortifyStep.java b/src/main/java/com/fortify/plugin/jenkins/steps/FortifyStep.java index d3fa88b..aa69370 100644 --- a/src/main/java/com/fortify/plugin/jenkins/steps/FortifyStep.java +++ b/src/main/java/com/fortify/plugin/jenkins/steps/FortifyStep.java @@ -129,15 +129,20 @@ protected String resolve(String param, TaskListener listener) { if (lastBuild == null) { return param; } - listener = listener == null ? new StreamBuildListener(System.out, Charset.defaultCharset()) : listener; try { - // TODO: see at lastBuild.getBuildVariableResolver() - final EnvVars vars = lastBuild.getEnvironment(listener); - return vars.expand(param); - } catch (IOException e) { - // do nothing - } catch (InterruptedException e) { - // do nothing + // if we can parse it as an Integer, then there's no need to resolve the variable + Integer.parseInt(param); + } catch (NumberFormatException e1) { + listener = listener == null ? new StreamBuildListener(System.out, Charset.defaultCharset()) : listener; + try { + // TODO: see at lastBuild.getBuildVariableResolver() + final EnvVars vars = lastBuild.getEnvironment(listener); + return vars.expand(param); + } catch (IOException e2) { + // do nothing + } catch (InterruptedException e3) { + // do nothing + } } return param; } diff --git a/src/main/java/com/fortify/plugin/jenkins/steps/FortifyUpload.java b/src/main/java/com/fortify/plugin/jenkins/steps/FortifyUpload.java index 6346d4a..af0b426 100644 --- a/src/main/java/com/fortify/plugin/jenkins/steps/FortifyUpload.java +++ b/src/main/java/com/fortify/plugin/jenkins/steps/FortifyUpload.java @@ -225,7 +225,7 @@ public Integer performAndReturnIssueCount(Run run, FilePath workspace, Env Long artifactId = uploadToSSC(summary, workspace, listener); pollFprProcessing(run, artifactId, listener); - log.println("Retrieving build statistics from SSC"); + log.println("Retrieving build statistics from Fortify Software Security Center"); calculateFprStatistics(summary, listener); log.printf("Calculated NVS=%f, failedCount=%d%n", summary.getNvs(), summary.getFailedCount()); @@ -291,7 +291,7 @@ private Long uploadToSSC(FPRSummary summary, FilePath workspace, TaskListener li if (!StringUtils.isBlank(getResolvedAppName(listener)) && !StringUtils.isBlank(getResolvedAppVersion(listener)) && FortifyPlugin.DESCRIPTOR.canUploadToSsc()) { // the FPR may be in remote slave, we need to call launcher to do this for me - log.printf("Uploading analysis results file to SSC at %s to application '%s' and application version '%s'%n", + log.printf("Uploading analysis results file to Fortify Software Security Center at %s to application '%s' and application version '%s'%n", FortifyPlugin.DESCRIPTOR.getUrl(), getResolvedAppName(listener), getResolvedAppVersion(listener)); try { final Long projectId = createNewOrGetProject(listener); @@ -306,11 +306,11 @@ public Long runWith(FortifyClient client) throws Exception { log.printf("Analysis results uploaded successfully. artifact id = %d%n", artifactId); return artifactId; } catch (Throwable t) { - log.println("Error uploading to SSC: " + FortifyPlugin.DESCRIPTOR.getUrl()); + log.println("Error uploading to Fortify Software Security Center: " + FortifyPlugin.DESCRIPTOR.getUrl()); String message = t.getMessage(); log.println(message); t.printStackTrace(log); - throw new AbortException("Error uploading to SSC: " + message); + throw new AbortException("Error uploading to Fortify Software Security Center: " + message); } finally { // if this is a remote FPR, I need to delete the local temp FPR after use if (summary.getFprFile().isRemote()) { @@ -378,15 +378,15 @@ public Artifact.StatusEnum runWith(FortifyClient client) throws Exception { isProcessingComplete = true; break; case ERROR_PROCESSING: - throw new AbortException("SSC encountered an error processing the artifact"); + throw new AbortException("Fortify Software Security Center encountered an error processing the artifact"); case REQUIRE_AUTH: - log.println("The artifact needs to be approved for processing in SSC. Will continue to wait..."); + log.println("The artifact needs to be approved for processing in Fortify Software Security Center. Will continue to wait..."); break; case SCHED_PROCESSING: - log.println("The artifact was scheduled for processing on SSC. Will continue to wait..."); + log.println("The artifact was scheduled for processing on Fortify Software Security Center. Will continue to wait..."); break; case PROCESSING: - log.println("The artifact is being processed by SSC. Will continue to wait..."); + log.println("The artifact is being processed by Fortify Software Security Center. Will continue to wait..."); break; default: log.println("Unexpected artifact status: " + status.name()); @@ -400,7 +400,7 @@ public Artifact.StatusEnum runWith(FortifyClient client) throws Exception { String message = t.getMessage(); log.println("Error checking artifact status. " + message); t.printStackTrace(log); - throw new AbortException("Failed to retrieve artifact statistics from SSC. " + message); + throw new AbortException("Failed to retrieve artifact statistics from Fortify Software Security Center. " + message); } if (timeoutInMinutes > 0) { @@ -417,8 +417,8 @@ private void setBuildUncompleted(Run run, PrintStream log, int timeoutInMi final String appArtifactsURL = getAppArtifactsURL(projectVersionId); run.setResult(Result.NOT_BUILT); - run.setDescription("A timeout has been reached when checking SSC for status of artifacts, this could happen " + - "on long running processing jobs and does not mean that the build failed. You can check the status in SSC here: " + + run.setDescription("A timeout has been reached when checking Fortify Software Security Center for status of artifacts, this could happen " + + "on long running processing jobs and does not mean that the build failed. You can check the status in Fortify Software Security Center here: " + appArtifactsURL); throw new AbortException("Timeout of " + timeoutInMinutes + " minute(s) is reached."); }