From 4588cb31e90d1e25119a09c776b4d5bd2f5a33bd Mon Sep 17 00:00:00 2001 From: "zxBCN Valeriu_Tuguran,Constantin (IT EDP) EXTERNAL" Date: Fri, 13 Sep 2024 10:34:14 +0200 Subject: [PATCH] Fix codenarc violation. --- src/org/ods/component/ScanWithAquaStage.groovy | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/org/ods/component/ScanWithAquaStage.groovy b/src/org/ods/component/ScanWithAquaStage.groovy index c30341b8f..df5e06f0e 100644 --- a/src/org/ods/component/ScanWithAquaStage.groovy +++ b/src/org/ods/component/ScanWithAquaStage.groovy @@ -137,12 +137,7 @@ class ScanWithAquaStage extends Stage { notifyAquaProblem(alertEmails, errorMessages) if (actionableVulnerabilities?.size() > 0) { // We need to mark the pipeline and delete the image - context.addArtifactURI('aquaCriticalVulnerability', actionableVulnerabilities) - context.addArtifactURI('jiraComponentId', context.getComponentId()) - context.addArtifactURI('gitUrl', context.getGitUrl()) - context.addArtifactURI('gitBranch', context.getGitBranch()) - context.addArtifactURI('repoName', context.getRepoName()) - context.addArtifactURI('nexusReportLink', nexusReportLink) + addAquaVulnerabilityObjectsToContext(actionableVulnerabilities, nexusReportLink) String response = openShift.deleteImage(context.getComponentId() + ":" + context.getShortGitCommit()) logger.debug("Delete image response: " + response) throw new AquaRemoteCriticalVulnerabilityWithSolutionException( @@ -154,6 +149,15 @@ class ScanWithAquaStage extends Stage { return } + private void addAquaVulnerabilityObjectsToContext(List actionableVulnerabilities, String nexusReportLink) { + context.addArtifactURI('aquaCriticalVulnerability', actionableVulnerabilities) + context.addArtifactURI('jiraComponentId', context.getComponentId()) + context.addArtifactURI('gitUrl', context.getGitUrl()) + context.addArtifactURI('gitBranch', context.getGitBranch()) + context.addArtifactURI('repoName', context.getRepoName()) + context.addArtifactURI('nexusReportLink', nexusReportLink) + } + private String buildActionableMessageForAquaVulnerabilities(Map args) { StringBuilder message = new StringBuilder(); message.append("We detected remotely exploitable critical vulnerabilities in ${args.gitUrl} " +