From eca79028f8a0b9b9b8ca26df72053913a83bc203 Mon Sep 17 00:00:00 2001 From: Vishal Chaudhary <102226698+vishalhcl-5960@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:04:01 +0530 Subject: [PATCH] ASA 8329 (#208) (#209) personal scan support --- .../jenkins/plugin/builders/AppScanBuildStep.java | 15 ++++++++++++++- .../plugin/builders/AppScanBuildStep/config.jelly | 4 ++++ .../AppScanBuildStep/config_en.properties | 1 + .../AppScanBuildStep/help-personalScan.jelly | 4 ++++ .../help-personalScan_en.properties | 4 ++++ 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/help-personalScan.jelly create mode 100644 src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/help-personalScan_en.properties diff --git a/src/main/java/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep.java b/src/main/java/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep.java index ba20c13a..29f135a3 100644 --- a/src/main/java/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep.java +++ b/src/main/java/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep.java @@ -94,6 +94,7 @@ public class AppScanBuildStep extends Builder implements SimpleBuildStep, Serial private String m_credentials; private List m_failureConditions; private boolean m_emailNotification; + private boolean m_personalScan; private boolean m_intervention; private boolean m_wait; private boolean m_failBuildNonCompliance; @@ -103,7 +104,7 @@ public class AppScanBuildStep extends Builder implements SimpleBuildStep, Serial private static final File JENKINS_INSTALL_DIR=new File(System.getProperty("user.dir"),".appscan");//$NON-NLS-1$ //$NON-NLS-2$ @Deprecated - public AppScanBuildStep(Scanner scanner, String name, String type, String target, String application, String credentials, List failureConditions, boolean failBuildNonCompliance, boolean failBuild, boolean wait, boolean email, boolean intervention) { + public AppScanBuildStep(Scanner scanner, String name, String type, String target, String application, String credentials, List failureConditions, boolean failBuildNonCompliance, boolean failBuild, boolean wait, boolean email, boolean personalScan, boolean intervention) { m_scanner = scanner; m_name = (name == null || name.trim().equals("")) ? application.replaceAll(" ", "") + ThreadLocalRandom.current().nextInt(0, 10000) : name; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ m_type = scanner.getType(); @@ -112,6 +113,7 @@ public AppScanBuildStep(Scanner scanner, String name, String type, String target m_credentials = credentials; m_failureConditions = failureConditions; m_emailNotification = email; + m_personalScan = personalScan; m_intervention = intervention; m_wait = wait; m_failBuildNonCompliance=failBuildNonCompliance; @@ -127,6 +129,7 @@ public AppScanBuildStep(Scanner scanner, String name, String type, String applic m_application = application; m_credentials = credentials; m_emailNotification = false; + m_personalScan = false; m_intervention = true; m_wait = false; m_failBuildNonCompliance=false; @@ -217,6 +220,15 @@ public void setEmail(boolean emailNotification) { public boolean getEmail() { return m_emailNotification; } + + @DataBoundSetter + public void setPersonalScan(boolean personalScan) { + m_personalScan = personalScan; + } + + public boolean getPersonalScan() { + return m_personalScan; + } @Override public DescriptorImpl getDescriptor() { @@ -258,6 +270,7 @@ private Map getScanProperties(Run build, TaskListener liste properties.put(CoreConstants.APP_ID, m_application); properties.put(CoreConstants.SCAN_NAME, resolver == null ? m_name : Util.replaceMacro(m_name, resolver) + "_" + SystemUtil.getTimeStamp()); //$NON-NLS-1$ properties.put(CoreConstants.EMAIL_NOTIFICATION, Boolean.toString(m_emailNotification)); + properties.put(CoreConstants.PERSONAL_SCAN, Boolean.toString(m_personalScan)); properties.put("FullyAutomatic", Boolean.toString(!m_intervention)); properties.put("APPSCAN_IRGEN_CLIENT", "Jenkins"); properties.put("APPSCAN_CLIENT_VERSION", Jenkins.VERSION); diff --git a/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/config.jelly b/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/config.jelly index 6216b4fc..2ad619e2 100644 --- a/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/config.jelly +++ b/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/config.jelly @@ -23,6 +23,10 @@ LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 + + + + diff --git a/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/config_en.properties b/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/config_en.properties index 8b173158..10040dcf 100644 --- a/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/config_en.properties +++ b/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/config_en.properties @@ -6,6 +6,7 @@ label.application=Application label.name=Test Name label.type=Test Type label.email=Email Notification +label.personalScan=Run as a personal scan label.intervention=Allow intervention by scan enablement team label.wait=Suspend job until security analysis completes label.fail.build=Fail build if: diff --git a/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/help-personalScan.jelly b/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/help-personalScan.jelly new file mode 100644 index 00000000..4c24045c --- /dev/null +++ b/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/help-personalScan.jelly @@ -0,0 +1,4 @@ + +
+ ${%description.personal.scan} +
diff --git a/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/help-personalScan_en.properties b/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/help-personalScan_en.properties new file mode 100644 index 00000000..22eb5753 --- /dev/null +++ b/src/main/resources/com/hcl/appscan/jenkins/plugin/builders/AppScanBuildStep/help-personalScan_en.properties @@ -0,0 +1,4 @@ +#NLS_MESSAGEFORMAT_ALL +#NLS_ENCODING=UTF8 + +description.personal.scan=A personal scan does not affect the application data and compliance until it is promoted. If not promoted it is deleted after 30 days.
Learn more