Package com.vrondakis.zap
Class ZapDriverImpl
- java.lang.Object
-
- com.vrondakis.zap.ZapDriverImpl
-
-
Field Summary
-
Fields inherited from interface com.vrondakis.zap.ZapDriver
COMPLETED_PERCENTAGE, ZAP_INITIALIZE_TIMEOUT, ZAP_INITIALIZE_WAIT, ZAP_SCAN_SLEEP, ZAP_SCAN_STATUS_PRINT_INTERVAL
-
-
Constructor Summary
Constructors Constructor Description ZapDriverImpl()
-
Method Summary
Modifier and Type Method Description voiddisablePassiveScanners(List<Integer> ids)voidenablePassiveScanners(List<Integer> ids)List<String>getAdditionalConfigurations()List<String>getAllowedHosts()HashMap<Integer,Integer>getFailBuild()FilePathgetZapDir()StringgetZapHost()intgetZapPort()StringgetZapReport()StringgetZapReportXML()StringgetZapRootCaFile()intgetZapTimeout()voidimportUrls(String path)Imports URLs from a text filevoidloadPolicy(String policy)Loads a ZAP policy from a file pathvoidloadSession(String sessionPath)Verifies ZAP sessionvoidsetAdditionalConfigurations(List<String> additionalConfigurations)voidsetAllowedHosts(List<String> allowedHosts)voidsetFailBuild(int all, int high, int med, int low)voidsetLogger(PrintStream logger)Sets the current logger.voidsetZapDir(FilePath dir)voidsetZapHost(String zapHost)voidsetZapMode(String mode)voidsetZapPort(int zapPort)voidsetZapRootCaFile(String rootCaFile)voidsetZapTimeout(int timeout)voidshutdownZap()voidstartZapCrawler(RunZapCrawlerParameters zcp)Starts the ZAP crawler on a specified URLvoidstartZapProcess(String zapHome, FilePath ws, Launcher launcher)Starts the ZAP processvoidzapAliveCheck()booleanzapAttack(RunZapAttackStepParameters zsp)Starts the ZAP attack.List<PluginProgress>zapAttackProgress()Gets the current progress of the attackintzapAttackStatus()Gets the current status of the started attacks (average of all)intzapCrawlerStatus()Gets the current status of the started attacks (average of all)voidzapCrawlerSuccess()intzapRecordsToScan()Gets the number of records the passive scanner still has to scan
-
-
-
Method Detail
-
setLogger
public void setLogger(PrintStream logger)
Sets the current logger.
-
shutdownZap
public void shutdownZap() throws ZapExecutionException- Specified by:
shutdownZapin interfaceZapDriver- Throws:
ZapExecutionException
-
setZapMode
public void setZapMode(String mode) throws ZapExecutionException
- Specified by:
setZapModein interfaceZapDriver- Throws:
ZapExecutionException
-
startZapCrawler
public void startZapCrawler(RunZapCrawlerParameters zcp) throws ZapExecutionException
Starts the ZAP crawler on a specified URL- Specified by:
startZapCrawlerin interfaceZapDriver- Parameters:
zcp- The Zap Crawler Parameters to run with- Throws:
ZapExecutionException
-
zapCrawlerStatus
public int zapCrawlerStatus()
Gets the current status of the started attacks (average of all)- Specified by:
zapCrawlerStatusin interfaceZapDriver- Returns:
- The % complete
-
zapCrawlerSuccess
public void zapCrawlerSuccess() throws InterruptedException, ZapExecutionException- Specified by:
zapCrawlerSuccessin interfaceZapDriver- Throws:
InterruptedExceptionZapExecutionException
-
importUrls
public void importUrls(String path) throws ZapExecutionException
Imports URLs from a text file- Specified by:
importUrlsin interfaceZapDriver- Parameters:
path- - The path to load from- Throws:
ZapExecutionException
-
loadSession
public void loadSession(String sessionPath) throws ZapExecutionException
Verifies ZAP session- Specified by:
loadSessionin interfaceZapDriver- Parameters:
sessionPath- - The path of the .session file- Throws:
ZapExecutionException
-
loadPolicy
public void loadPolicy(String policy) throws ZapExecutionException
Loads a ZAP policy from a file path- Specified by:
loadPolicyin interfaceZapDriver- Parameters:
policy- - The path to load from- Throws:
ZapExecutionException
-
zapAttack
public boolean zapAttack(RunZapAttackStepParameters zsp) throws ZapExecutionException, URISyntaxException
Starts the ZAP attack. If allowedHosts is not provided in jenkinsfile, it will scan only hosts that are local- Specified by:
zapAttackin interfaceZapDriver- Parameters:
zsp- The parameters from the groovy step- Returns:
- Success
- Throws:
ZapExecutionExceptionURISyntaxException
-
zapAttackStatus
public int zapAttackStatus()
Gets the current status of the started attacks (average of all)- Specified by:
zapAttackStatusin interfaceZapDriver- Returns:
- The % complete
-
zapAttackProgress
public List<PluginProgress> zapAttackProgress()
Gets the current progress of the attack- Specified by:
zapAttackProgressin interfaceZapDriver
-
startZapProcess
public void startZapProcess(String zapHome, FilePath ws, Launcher launcher) throws IOException
Starts the ZAP process- Specified by:
startZapProcessin interfaceZapDriver- Parameters:
zapHome- - The location of the zap.sh filews- - Passed by steplauncher- - Passed by step- Throws:
IOException
-
enablePassiveScanners
public void enablePassiveScanners(List<Integer> ids) throws ZapExecutionException
- Specified by:
enablePassiveScannersin interfaceZapDriver- Throws:
ZapExecutionException
-
disablePassiveScanners
public void disablePassiveScanners(List<Integer> ids) throws ZapExecutionException
- Specified by:
disablePassiveScannersin interfaceZapDriver- Throws:
ZapExecutionException
-
zapAliveCheck
public void zapAliveCheck() throws ZapExecutionException- Specified by:
zapAliveCheckin interfaceZapDriver- Throws:
ZapExecutionException
-
getZapReport
public String getZapReport() throws IOException, com.mashape.unirest.http.exceptions.UnirestException, URISyntaxException
- Specified by:
getZapReportin interfaceZapDriver- Throws:
IOExceptioncom.mashape.unirest.http.exceptions.UnirestExceptionURISyntaxException
-
getZapReportXML
public String getZapReportXML() throws IOException, com.mashape.unirest.http.exceptions.UnirestException, URISyntaxException
- Specified by:
getZapReportXMLin interfaceZapDriver- Throws:
IOExceptioncom.mashape.unirest.http.exceptions.UnirestExceptionURISyntaxException
-
setZapHost
public void setZapHost(String zapHost)
- Specified by:
setZapHostin interfaceZapDriver
-
setZapPort
public void setZapPort(int zapPort)
- Specified by:
setZapPortin interfaceZapDriver
-
setFailBuild
public void setFailBuild(int all, int high, int med, int low)- Specified by:
setFailBuildin interfaceZapDriver
-
setZapTimeout
public void setZapTimeout(int timeout)
- Specified by:
setZapTimeoutin interfaceZapDriver
-
setAllowedHosts
public void setAllowedHosts(List<String> allowedHosts)
- Specified by:
setAllowedHostsin interfaceZapDriver
-
getZapTimeout
public int getZapTimeout()
- Specified by:
getZapTimeoutin interfaceZapDriver
-
getZapPort
public int getZapPort()
- Specified by:
getZapPortin interfaceZapDriver
-
getFailBuild
public HashMap<Integer,Integer> getFailBuild()
- Specified by:
getFailBuildin interfaceZapDriver
-
getZapHost
public String getZapHost()
- Specified by:
getZapHostin interfaceZapDriver
-
getAllowedHosts
public List<String> getAllowedHosts()
- Specified by:
getAllowedHostsin interfaceZapDriver
-
zapRecordsToScan
public int zapRecordsToScan() throws ZapExecutionExceptionGets the number of records the passive scanner still has to scan- Specified by:
zapRecordsToScanin interfaceZapDriver- Returns:
- The number of records the passive scanner still has so scan
- Throws:
ZapExecutionException
-
setZapRootCaFile
public void setZapRootCaFile(String rootCaFile)
- Specified by:
setZapRootCaFilein interfaceZapDriver
-
getZapRootCaFile
public String getZapRootCaFile()
- Specified by:
getZapRootCaFilein interfaceZapDriver
-
setAdditionalConfigurations
public void setAdditionalConfigurations(List<String> additionalConfigurations)
- Specified by:
setAdditionalConfigurationsin interfaceZapDriver
-
getAdditionalConfigurations
public List<String> getAdditionalConfigurations()
- Specified by:
getAdditionalConfigurationsin interfaceZapDriver
-
-