Skip to content

Commit 82b13e6

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

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public class ClientSpiderApi extends ApiImplementor {
6363
private static final String PARAM_USER_NAME = "userName";
6464
private static final String PARAM_MAX_CRAWL_DEPTH = "maxCrawlDepth";
6565
private static final String PARAM_PAGE_LOAD_TIME = "pageLoadTime";
66+
private static final String PARAM_NUMBER_OF_BROWSERS = "numberOfBrowsers";
67+
private static final String PARAM_SCOPE_CHECK = "scopeCheck";
6668

6769
private final ExtensionClientIntegration extension;
6870

@@ -84,7 +86,9 @@ public ClientSpiderApi(ExtensionClientIntegration extension) {
8486
PARAM_USER_NAME,
8587
PARAM_SUBTREE_ONLY,
8688
PARAM_MAX_CRAWL_DEPTH,
87-
PARAM_PAGE_LOAD_TIME)));
89+
PARAM_PAGE_LOAD_TIME,
90+
PARAM_NUMBER_OF_BROWSERS,
91+
PARAM_SCOPE_CHECK)));
8892

8993
addApiAction(new ApiAction(ACTION_STOP_SCAN, List.of(PARAM_SCAN_ID)));
9094

@@ -152,6 +156,12 @@ private ApiResponse startScan(String name, JSONObject params) throws ApiExceptio
152156
if (params.containsKey(PARAM_PAGE_LOAD_TIME)) {
153157
options.setPageLoadTimeInSecs(ApiUtils.getIntParam(params, PARAM_PAGE_LOAD_TIME));
154158
}
159+
if (params.containsKey(PARAM_NUMBER_OF_BROWSERS)) {
160+
options.setThreadCount(ApiUtils.getIntParam(params, PARAM_NUMBER_OF_BROWSERS));
161+
}
162+
if (params.containsKey(PARAM_SCOPE_CHECK)) {
163+
options.setScopeCheck(params.getString(PARAM_SCOPE_CHECK));
164+
}
155165

156166
User user = getUser(params, context);
157167

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)