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 void
disablePassiveScanners(List<Integer> ids)
void
enablePassiveScanners(List<Integer> ids)
List<String>
getAdditionalConfigurations()
List<String>
getAllowedHosts()
HashMap<Integer,Integer>
getFailBuild()
FilePath
getZapDir()
String
getZapHost()
int
getZapPort()
String
getZapReport()
String
getZapReportXML()
String
getZapRootCaFile()
int
getZapTimeout()
void
importUrls(String path)
Imports URLs from a text filevoid
loadPolicy(String policy)
Loads a ZAP policy from a file pathvoid
loadSession(String sessionPath)
Verifies ZAP sessionvoid
setAdditionalConfigurations(List<String> additionalConfigurations)
void
setAllowedHosts(List<String> allowedHosts)
void
setFailBuild(int all, int high, int med, int low)
void
setLogger(PrintStream logger)
Sets the current logger.void
setZapDir(FilePath dir)
void
setZapHost(String zapHost)
void
setZapMode(String mode)
void
setZapPort(int zapPort)
void
setZapRootCaFile(String rootCaFile)
void
setZapTimeout(int timeout)
void
shutdownZap()
void
startZapCrawler(RunZapCrawlerParameters zcp)
Starts the ZAP crawler on a specified URLvoid
startZapProcess(String zapHome, FilePath ws, Launcher launcher)
Starts the ZAP processvoid
zapAliveCheck()
boolean
zapAttack(RunZapAttackStepParameters zsp)
Starts the ZAP attack.List<PluginProgress>
zapAttackProgress()
Gets the current progress of the attackint
zapAttackStatus()
Gets the current status of the started attacks (average of all)int
zapCrawlerStatus()
Gets the current status of the started attacks (average of all)void
zapCrawlerSuccess()
int
zapRecordsToScan()
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:
shutdownZap
in interfaceZapDriver
- Throws:
ZapExecutionException
-
setZapMode
public void setZapMode(String mode) throws ZapExecutionException
- Specified by:
setZapMode
in interfaceZapDriver
- Throws:
ZapExecutionException
-
startZapCrawler
public void startZapCrawler(RunZapCrawlerParameters zcp) throws ZapExecutionException
Starts the ZAP crawler on a specified URL- Specified by:
startZapCrawler
in 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:
zapCrawlerStatus
in interfaceZapDriver
- Returns:
- The % complete
-
zapCrawlerSuccess
public void zapCrawlerSuccess() throws InterruptedException, ZapExecutionException
- Specified by:
zapCrawlerSuccess
in interfaceZapDriver
- Throws:
InterruptedException
ZapExecutionException
-
importUrls
public void importUrls(String path) throws ZapExecutionException
Imports URLs from a text file- Specified by:
importUrls
in interfaceZapDriver
- Parameters:
path
- - The path to load from- Throws:
ZapExecutionException
-
loadSession
public void loadSession(String sessionPath) throws ZapExecutionException
Verifies ZAP session- Specified by:
loadSession
in 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:
loadPolicy
in 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:
zapAttack
in interfaceZapDriver
- Parameters:
zsp
- The parameters from the groovy step- Returns:
- Success
- Throws:
ZapExecutionException
URISyntaxException
-
zapAttackStatus
public int zapAttackStatus()
Gets the current status of the started attacks (average of all)- Specified by:
zapAttackStatus
in interfaceZapDriver
- Returns:
- The % complete
-
zapAttackProgress
public List<PluginProgress> zapAttackProgress()
Gets the current progress of the attack- Specified by:
zapAttackProgress
in interfaceZapDriver
-
startZapProcess
public void startZapProcess(String zapHome, FilePath ws, Launcher launcher) throws IOException
Starts the ZAP process- Specified by:
startZapProcess
in 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:
enablePassiveScanners
in interfaceZapDriver
- Throws:
ZapExecutionException
-
disablePassiveScanners
public void disablePassiveScanners(List<Integer> ids) throws ZapExecutionException
- Specified by:
disablePassiveScanners
in interfaceZapDriver
- Throws:
ZapExecutionException
-
zapAliveCheck
public void zapAliveCheck() throws ZapExecutionException
- Specified by:
zapAliveCheck
in interfaceZapDriver
- Throws:
ZapExecutionException
-
getZapReport
public String getZapReport() throws IOException, com.mashape.unirest.http.exceptions.UnirestException, URISyntaxException
- Specified by:
getZapReport
in interfaceZapDriver
- Throws:
IOException
com.mashape.unirest.http.exceptions.UnirestException
URISyntaxException
-
getZapReportXML
public String getZapReportXML() throws IOException, com.mashape.unirest.http.exceptions.UnirestException, URISyntaxException
- Specified by:
getZapReportXML
in interfaceZapDriver
- Throws:
IOException
com.mashape.unirest.http.exceptions.UnirestException
URISyntaxException
-
setZapHost
public void setZapHost(String zapHost)
- Specified by:
setZapHost
in interfaceZapDriver
-
setZapPort
public void setZapPort(int zapPort)
- Specified by:
setZapPort
in interfaceZapDriver
-
setFailBuild
public void setFailBuild(int all, int high, int med, int low)
- Specified by:
setFailBuild
in interfaceZapDriver
-
setZapTimeout
public void setZapTimeout(int timeout)
- Specified by:
setZapTimeout
in interfaceZapDriver
-
setAllowedHosts
public void setAllowedHosts(List<String> allowedHosts)
- Specified by:
setAllowedHosts
in interfaceZapDriver
-
getZapTimeout
public int getZapTimeout()
- Specified by:
getZapTimeout
in interfaceZapDriver
-
getZapPort
public int getZapPort()
- Specified by:
getZapPort
in interfaceZapDriver
-
getFailBuild
public HashMap<Integer,Integer> getFailBuild()
- Specified by:
getFailBuild
in interfaceZapDriver
-
getZapHost
public String getZapHost()
- Specified by:
getZapHost
in interfaceZapDriver
-
getAllowedHosts
public List<String> getAllowedHosts()
- Specified by:
getAllowedHosts
in interfaceZapDriver
-
zapRecordsToScan
public int zapRecordsToScan() throws ZapExecutionException
Gets the number of records the passive scanner still has to scan- Specified by:
zapRecordsToScan
in interfaceZapDriver
- Returns:
- The number of records the passive scanner still has so scan
- Throws:
ZapExecutionException
-
setZapRootCaFile
public void setZapRootCaFile(String rootCaFile)
- Specified by:
setZapRootCaFile
in interfaceZapDriver
-
getZapRootCaFile
public String getZapRootCaFile()
- Specified by:
getZapRootCaFile
in interfaceZapDriver
-
setAdditionalConfigurations
public void setAdditionalConfigurations(List<String> additionalConfigurations)
- Specified by:
setAdditionalConfigurations
in interfaceZapDriver
-
getAdditionalConfigurations
public List<String> getAdditionalConfigurations()
- Specified by:
getAdditionalConfigurations
in interfaceZapDriver
-
-