Skip to content

Commit 8674916

Browse files
committed
Add Number of Browsers and Scope check to the client spider API
1 parent 0bc2adb commit 8674916

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

addOns/client/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111
- Edge recorder link to help.
1212
- Support for stopping the spiderCient automation job.
1313
- Support for configuring the client passive scan rules via the passiveScan-config Automation Framework job. This add-on now depends on the pscan add-on.
14+
- Optional `numberOfBrowsers` parameter for the Client Spider API action `scan` to control concurrency (number of browser windows).
15+
- Optional `scopeCheck` parameter for the Client Spider API action `scan` to select Scope Check (Flexible or Strict).
1416

1517
### Changed
1618
- Updated Chrome and Firefox extensions to v0.1.6.

addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpiderApi.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
package org.zaproxy.addon.client.spider;
2121

2222
import java.util.List;
23+
2324
import net.sf.json.JSONObject;
25+
2426
import org.apache.commons.httpclient.URI;
2527
import org.apache.commons.httpclient.URIException;
2628
import org.apache.logging.log4j.LogManager;
@@ -29,6 +31,7 @@
2931
import org.parosproxy.paros.model.Model;
3032
import org.parosproxy.paros.model.SiteNode;
3133
import org.zaproxy.addon.client.ClientOptions;
34+
import org.zaproxy.addon.client.ClientOptions.ScopeCheck;
3235
import org.zaproxy.addon.client.ExtensionClientIntegration;
3336
import org.zaproxy.zap.extension.api.ApiAction;
3437
import org.zaproxy.zap.extension.api.ApiException;
@@ -63,6 +66,8 @@ public class ClientSpiderApi extends ApiImplementor {
6366
private static final String PARAM_USER_NAME = "userName";
6467
private static final String PARAM_MAX_CRAWL_DEPTH = "maxCrawlDepth";
6568
private static final String PARAM_PAGE_LOAD_TIME = "pageLoadTime";
69+
private static final String PARAM_NUMBER_OF_BROWSERS = "numberOfBrowsers";
70+
private static final String PARAM_SCOPE_CHECK = "scopeCheck";
6671

6772
private final ExtensionClientIntegration extension;
6873

@@ -84,7 +89,9 @@ public ClientSpiderApi(ExtensionClientIntegration extension) {
8489
PARAM_USER_NAME,
8590
PARAM_SUBTREE_ONLY,
8691
PARAM_MAX_CRAWL_DEPTH,
87-
PARAM_PAGE_LOAD_TIME)));
92+
PARAM_PAGE_LOAD_TIME,
93+
PARAM_NUMBER_OF_BROWSERS,
94+
PARAM_SCOPE_CHECK)));
8895

8996
addApiAction(new ApiAction(ACTION_STOP_SCAN, List.of(PARAM_SCAN_ID)));
9097

@@ -152,6 +159,12 @@ private ApiResponse startScan(String name, JSONObject params) throws ApiExceptio
152159
if (params.containsKey(PARAM_PAGE_LOAD_TIME)) {
153160
options.setPageLoadTimeInSecs(ApiUtils.getIntParam(params, PARAM_PAGE_LOAD_TIME));
154161
}
162+
if (params.containsKey(PARAM_NUMBER_OF_BROWSERS)) {
163+
options.setThreadCount(ApiUtils.getIntParam(params, PARAM_NUMBER_OF_BROWSERS));
164+
}
165+
if (params.containsKey(PARAM_SCOPE_CHECK)) {
166+
options.setScopeCheck(ApiUtils.getOptionalEnumParam(params, PARAM_SCOPE_CHECK, ScopeCheck.class));
167+
}
155168

156169
User user = getUser(params, context);
157170

addOns/client/src/main/javahelp/org/zaproxy/addon/client/resources/help/contents/spider-api.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <H2>Views</H2>
1919

2020
<H2>Actions</H2>
2121
<ul>
22-
<li><code>scan (browser url contextName userName subtreeOnly maxCrawlDepth pageLoadTime)</code>: Runs the Client Spider against the given URL and/or context. Returns the scanId.</li>
22+
<li><code>scan (browser url contextName userName subtreeOnly maxCrawlDepth pageLoadTime numberOfBrowsers scopeCheck)</code>: Runs the Client Spider against the given URL and/or context. Returns the scanId.</li>
2323
<li><code>stop (scanId*)</code>: Stops a Client Spider scan.</li>
2424
</ul>
2525

@@ -32,13 +32,15 @@ <H2>Parameters</H2>
3232
<li><code>subtreeOnly</code>: If set to 'true', the spider will only scan URLs under the specified URL. Default: 'false'.</li>
3333
<li><code>maxCrawlDepth</code>: The maximum depth the spider should crawl, where 0 is unlimited. Defaults to client options.</li>
3434
<li><code>pageLoadTime</code>: The time in seconds to wait for a page to load. Defaults to client options.</li>
35+
<li><code>numberOfBrowsers</code>: Number of Browser Windows to Open (concurrency). Integer, defaults to client options.</li>
36+
<li><code>scopeCheck</code>: Scope Check mode, either <code>FLEXIBLE</code> (default) or <code>STRICT</code>.</li>
3537
<li><code>scanId</code>: The ID of the scan to query or manage.</li>
3638
</ul>
3739

3840
<H2>Examples</H2>
3941
<H3>Start a scan:</H3>
4042
<pre><code>
41-
https://zap/JSON/clientSpider/action/scan/?url=https://example.com&maxCrawlDepth=5&pageLoadTime=30
43+
https://zap/JSON/clientSpider/action/scan/?url=https://example.com&maxCrawlDepth=5&pageLoadTime=30&numberOfBrowsers=1&scopeCheck=STRICT
4244
</code></pre>
4345

4446
<H3>Check status:</H3>

addOns/client/src/main/resources/org/zaproxy/addon/client/resources/Messages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ client.clientSpider.api.action.scan = Starts a client spider scan.
3131
client.clientSpider.api.action.scan.param.browser = The ID of the browser. See Selenium documentation for valid IDs.
3232
client.clientSpider.api.action.scan.param.contextName = The name of the context.
3333
client.clientSpider.api.action.scan.param.maxCrawlDepth = Maximum Crawl Depth (0 is unlimited).
34+
client.clientSpider.api.action.scan.param.numberOfBrowsers = Number of Browser Windows to Open (concurrency).
3435
client.clientSpider.api.action.scan.param.pageLoadTime = Page Load Time (seconds).
36+
client.clientSpider.api.action.scan.param.scopeCheck = Scope Check (FLEXIBLE or STRICT).
3537
client.clientSpider.api.action.scan.param.subtreeOnly = true to spider only under the subtree, false otherwise.
3638
client.clientSpider.api.action.scan.param.url = The URL from where to start the spider.
3739
client.clientSpider.api.action.scan.param.userName = The name of the user.

0 commit comments

Comments
 (0)