Package org.zaproxy.clientapi.core
Class ClientApi
- java.lang.Object
-
- org.zaproxy.clientapi.core.ClientApi
-
public class ClientApi extends java.lang.Object
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ClientApi(java.lang.String zapAddress, int zapPort)
ClientApi(java.lang.String zapAddress, int zapPort, boolean debug)
ClientApi(java.lang.String zapAddress, int zapPort, java.lang.String apiKey)
Constructs aClientApi
with the given ZAP address/port and with the given API key, to be sent with all API requests.ClientApi(java.lang.String zapAddress, int zapPort, java.lang.String apiKey, boolean debug)
Constructs aClientApi
with the given ZAP address/port and with the given API key, to be sent with all API requests.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
accessUrl(java.lang.String url)
void
activeScanSiteInScope(java.lang.String url)
Active scans the given site, that's in scope.void
activeScanSiteInScope(java.lang.String apiKey, java.lang.String url)
Deprecated.(1.1.0) UseactiveScanSiteInScope(String)
instead, the API key should be set using one of theClientApi
constructors.void
addExcludeFromContext(java.lang.String apiKey, java.lang.String contextName, java.lang.String regex)
Deprecated.(1.1.0) UseContext.excludeFromContext(String, String)
instead.void
addIncludeInContext(java.lang.String apiKey, java.lang.String contextName, java.lang.String regex)
Deprecated.(1.1.0) UseContext.includeInContext(String, String)
instead.ApiResponse
callApi(java.lang.String requestMethod, java.lang.String component, java.lang.String type, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> params)
ApiResponse
callApi(java.lang.String component, java.lang.String type, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> params)
byte[]
callApiOther(java.lang.String requestMethod, java.lang.String component, java.lang.String type, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> params)
byte[]
callApiOther(java.lang.String component, java.lang.String type, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> params)
void
checkAlerts(java.util.List<Alert> ignoreAlerts, java.util.List<Alert> requireAlerts)
void
checkAlerts(java.util.List<Alert> ignoreAlerts, java.util.List<Alert> requireAlerts, java.io.File outputFile)
java.util.List<Alert>
getAlerts(java.lang.String baseUrl, int start, int count)
void
includeOneMatchingNodeInContext(java.lang.String contextName, java.lang.String regex)
Includes just one of the nodes that match the given regular expression in the context with the given name.void
includeOneMatchingNodeInContext(java.lang.String apiKey, java.lang.String contextName, java.lang.String regex)
Deprecated.(1.1.0) UseincludeOneMatchingNodeInContext(String, String)
instead.void
setDebugStream(java.io.PrintStream debugStream)
void
waitForSuccessfulConnectionToZap(int timeoutInSeconds)
Convenience method to wait for ZAP to be ready to receive API calls, when started programmatically.void
waitForSuccessfulConnectionToZap(int timeoutInSeconds, int pollingIntervalInMs)
Convenience method to wait for ZAP to be ready to receive API calls, when started programmatically.
-
-
-
Field Detail
-
accessControl
public AccessControl accessControl
-
acsrf
public Acsrf acsrf
-
ajaxSpider
public AjaxSpider ajaxSpider
-
alertFilter
public AlertFilter alertFilter
-
alert
public Alert alert
-
ascan
public Ascan ascan
-
authentication
public Authentication authentication
-
authorization
public Authorization authorization
-
automation
public Automation automation
-
autoupdate
public Autoupdate autoupdate
-
brk
public Break brk
-
context
public Context context
-
core
public Core core
-
exim
public Exim exim
-
exportreport
public Exportreport exportreport
-
forcedUser
public ForcedUser forcedUser
-
graphql
public Graphql graphql
-
httpSessions
public HttpSessions httpSessions
-
logImportFiles
public ImportLogFiles logImportFiles
-
importurls
public Importurls importurls
-
localProxies
public LocalProxies localProxies
-
network
public Network network
-
openapi
public Openapi openapi
-
params
public Params params
-
pnh
public Pnh pnh
-
pscan
public Pscan pscan
-
replacer
public Replacer replacer
-
reports
public Reports reports
-
retest
public Retest retest
-
reveal
public Reveal reveal
-
revisit
public Revisit revisit
-
ruleConfig
public RuleConfig ruleConfig
-
search
public Search search
-
script
public Script script
-
selenium
public Selenium selenium
-
sessionManagement
public SessionManagement sessionManagement
-
soap
public Soap soap
-
spider
public Spider spider
-
stats
public Stats stats
-
users
public Users users
-
wappalyzer
public Wappalyzer wappalyzer
-
websocket
public Websocket websocket
-
-
Constructor Detail
-
ClientApi
public ClientApi(java.lang.String zapAddress, int zapPort)
-
ClientApi
public ClientApi(java.lang.String zapAddress, int zapPort, java.lang.String apiKey)
Constructs aClientApi
with the given ZAP address/port and with the given API key, to be sent with all API requests.- Parameters:
zapAddress
- ZAP's addresszapPort
- ZAP's listening portapiKey
- the ZAP API key, might benull
or empty in which case is not used/sent.- Since:
- 1.1.0
-
ClientApi
public ClientApi(java.lang.String zapAddress, int zapPort, boolean debug)
-
ClientApi
public ClientApi(java.lang.String zapAddress, int zapPort, java.lang.String apiKey, boolean debug)
Constructs aClientApi
with the given ZAP address/port and with the given API key, to be sent with all API requests. Also, sets whether or not client API debug information should be written to thedebug stream
(by default the standard output stream).- Parameters:
zapAddress
- ZAP's addresszapPort
- ZAP's listening portapiKey
- the ZAP API key, might benull
or empty in which case is not used/sent.debug
-true
if debug information should be written to debug stream,false
otherwise.- Since:
- 1.1.0
-
-
Method Detail
-
setDebugStream
public void setDebugStream(java.io.PrintStream debugStream)
-
accessUrl
public void accessUrl(java.lang.String url) throws ClientApiException
- Throws:
ClientApiException
-
checkAlerts
public void checkAlerts(java.util.List<Alert> ignoreAlerts, java.util.List<Alert> requireAlerts) throws ClientApiException
- Throws:
ClientApiException
-
checkAlerts
public void checkAlerts(java.util.List<Alert> ignoreAlerts, java.util.List<Alert> requireAlerts, java.io.File outputFile) throws ClientApiException
- Throws:
ClientApiException
-
getAlerts
public java.util.List<Alert> getAlerts(java.lang.String baseUrl, int start, int count) throws ClientApiException
- Throws:
ClientApiException
-
callApi
public ApiResponse callApi(java.lang.String component, java.lang.String type, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> params) throws ClientApiException
- Throws:
ClientApiException
-
callApi
public ApiResponse callApi(java.lang.String requestMethod, java.lang.String component, java.lang.String type, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> params) throws ClientApiException
- Throws:
ClientApiException
-
callApiOther
public byte[] callApiOther(java.lang.String component, java.lang.String type, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> params) throws ClientApiException
- Throws:
ClientApiException
-
callApiOther
public byte[] callApiOther(java.lang.String requestMethod, java.lang.String component, java.lang.String type, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> params) throws ClientApiException
- Throws:
ClientApiException
-
addExcludeFromContext
@Deprecated public void addExcludeFromContext(java.lang.String apiKey, java.lang.String contextName, java.lang.String regex) throws java.lang.Exception
Deprecated.(1.1.0) UseContext.excludeFromContext(String, String)
instead.Adds the given regular expression to the exclusion list of the given context.- Parameters:
apiKey
- the API key, might benull
.contextName
- the name of the context.regex
- the regular expression to add.- Throws:
java.lang.Exception
- if an error occurred while calling the API.- See Also:
context
-
addIncludeInContext
@Deprecated public void addIncludeInContext(java.lang.String apiKey, java.lang.String contextName, java.lang.String regex) throws java.lang.Exception
Deprecated.(1.1.0) UseContext.includeInContext(String, String)
instead.Adds the given regular expression to the inclusion list of the given context.- Parameters:
apiKey
- the API key, might benull
.contextName
- the name of the context.regex
- the regular expression to add.- Throws:
java.lang.Exception
- if an error occurred while calling the API.- See Also:
context
-
includeOneMatchingNodeInContext
@Deprecated public void includeOneMatchingNodeInContext(java.lang.String apiKey, java.lang.String contextName, java.lang.String regex) throws java.lang.Exception
Deprecated.(1.1.0) UseincludeOneMatchingNodeInContext(String, String)
instead.Includes just one of the nodes that match the given regular expression in the context with the given name.Nodes that do not match the regular expression are excluded.
- Parameters:
apiKey
- the API key, might benull
.contextName
- the name of the context.regex
- the regular expression to match the node/URL.- Throws:
java.lang.Exception
- if an error occurred while calling the API.
-
includeOneMatchingNodeInContext
public void includeOneMatchingNodeInContext(java.lang.String contextName, java.lang.String regex) throws java.lang.Exception
Includes just one of the nodes that match the given regular expression in the context with the given name.Nodes that do not match the regular expression are excluded.
- Parameters:
contextName
- the name of the context.regex
- the regular expression to match the node/URL.- Throws:
java.lang.Exception
- if an error occurred while calling the API.
-
activeScanSiteInScope
@Deprecated public void activeScanSiteInScope(java.lang.String apiKey, java.lang.String url) throws java.lang.Exception
Deprecated.(1.1.0) UseactiveScanSiteInScope(String)
instead, the API key should be set using one of theClientApi
constructors.Active scans the given site, that's in scope.The method returns only after the scan has finished.
- Parameters:
apiKey
- the API key, might benull
.url
- the site to scan- Throws:
java.lang.Exception
- if an error occurred while calling the API.
-
activeScanSiteInScope
public void activeScanSiteInScope(java.lang.String url) throws java.lang.Exception
Active scans the given site, that's in scope.The method returns only after the scan has finished.
- Parameters:
url
- the site to scan- Throws:
java.lang.Exception
- if an error occurred while calling the API.- Since:
- 1.1.0
-
waitForSuccessfulConnectionToZap
public void waitForSuccessfulConnectionToZap(int timeoutInSeconds) throws ClientApiException
Convenience method to wait for ZAP to be ready to receive API calls, when started programmatically.It attempts to establish a connection to ZAP's proxy, in the given time, throwing an exception if the connection is not successful. The connection attempts might be polled in one second interval.
- Parameters:
timeoutInSeconds
- the (maximum) number of seconds to wait for ZAP to start- Throws:
ClientApiException
- if the timeout was reached or if the thread was interrupted while waiting- See Also:
waitForSuccessfulConnectionToZap(int, int)
-
waitForSuccessfulConnectionToZap
public void waitForSuccessfulConnectionToZap(int timeoutInSeconds, int pollingIntervalInMs) throws ClientApiException
Convenience method to wait for ZAP to be ready to receive API calls, when started programmatically.It attempts to establish a connection to ZAP's proxy, in the given time, throwing an exception if the connection is not successful. The connection attempts are done with the given polling interval.
- Parameters:
timeoutInSeconds
- the (maximum) number of seconds to wait for ZAP to startpollingIntervalInMs
- the interval, in milliseconds, for connection polling- Throws:
ClientApiException
- if the timeout was reached or if the thread was interrupted while waiting.java.lang.IllegalArgumentException
- if the interval for connection polling is negative.- See Also:
waitForSuccessfulConnectionToZap(int)
-
-