From b7e1b56d4204d72bb94b66c64836a3ce468f948c Mon Sep 17 00:00:00 2001 From: Matt Murphy Date: Mon, 24 Jul 2017 13:54:40 -0400 Subject: [PATCH] Get results from ScanManager --- src/main/java/com/hcl/appscan/sdk/messages.properties | 2 +- src/main/java/com/hcl/appscan/sdk/scan/IScanManager.java | 9 ++++++++- .../hcl/appscan/sdk/scanners/sast/SASTScanManager.java | 9 +++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hcl/appscan/sdk/messages.properties b/src/main/java/com/hcl/appscan/sdk/messages.properties index e300a667..eaac316c 100644 --- a/src/main/java/com/hcl/appscan/sdk/messages.properties +++ b/src/main/java/com/hcl/appscan/sdk/messages.properties @@ -17,7 +17,7 @@ message.extracting.client=Extracting the SAClientUtil package... message.download.complete=Download complete. message.preparing.irx=Preparing the IRX file using SAClientUtil version {0}... message.saclient.old=A newer version of the SAClientUtil package is available:\nCurrent Version: {0}\nAvailable Version: {1} - +message.results.unavailable=Scan results are not available. error.authenticating=An error occurred authenticating with the service. error.download.client=An error occurred downloading the SAClientUtil package. {0} diff --git a/src/main/java/com/hcl/appscan/sdk/scan/IScanManager.java b/src/main/java/com/hcl/appscan/sdk/scan/IScanManager.java index 41c2c960..bafea15a 100644 --- a/src/main/java/com/hcl/appscan/sdk/scan/IScanManager.java +++ b/src/main/java/com/hcl/appscan/sdk/scan/IScanManager.java @@ -6,11 +6,11 @@ package com.hcl.appscan.sdk.scan; +import java.io.File; import java.util.Map; import com.hcl.appscan.sdk.error.AppScanException; import com.hcl.appscan.sdk.logging.IProgress; -import com.hcl.appscan.sdk.scan.IScanServiceProvider; public interface IScanManager { @@ -36,4 +36,11 @@ public interface IScanManager { * @param target */ void addScanTarget(ITarget target); + + /** + * Retrieves the scan results as a file. + * @return A file containing the results. + * @throws AppScanException if there are no results available. + */ + void getScanResults(File destination, String format) throws AppScanException; } diff --git a/src/main/java/com/hcl/appscan/sdk/scanners/sast/SASTScanManager.java b/src/main/java/com/hcl/appscan/sdk/scanners/sast/SASTScanManager.java index 782bc768..c6d06a3f 100644 --- a/src/main/java/com/hcl/appscan/sdk/scanners/sast/SASTScanManager.java +++ b/src/main/java/com/hcl/appscan/sdk/scanners/sast/SASTScanManager.java @@ -15,6 +15,7 @@ import javax.xml.transform.TransformerException; import com.hcl.appscan.sdk.CoreConstants; +import com.hcl.appscan.sdk.Messages; import com.hcl.appscan.sdk.error.AppScanException; import com.hcl.appscan.sdk.error.InvalidTargetException; import com.hcl.appscan.sdk.error.ScannerException; @@ -65,6 +66,14 @@ public void addScanTarget(ITarget target) { m_targets.add((ISASTTarget)target); } + @Override + public void getScanResults(File destination, String format) throws AppScanException { + if(m_scan != null && m_scan.getResultsProvider() != null) + m_scan.getResultsProvider().getResultsFile(destination, format); + else + throw new AppScanException(Messages.getMessage("message.results.unavailable")); //$NON-NLS-1$ + } + private void run(IProgress progress,Map properties, IScanServiceProvider provider) throws AppScanException { try { m_scan = new SASTScan(properties, progress, provider);