diff --git a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpider.java b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpider.java index 3fe6b2ea51..e6bf0f4a1d 100644 --- a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpider.java +++ b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpider.java @@ -79,6 +79,7 @@ import org.zaproxy.zap.model.ScanListenner2; import org.zaproxy.zap.network.HttpResponseBody; import org.zaproxy.zap.users.User; +import org.zaproxy.zap.utils.Stats; import org.zaproxy.zap.utils.ThreadUtils; public class ClientSpider implements EventConsumer, GenericScanner2 { @@ -367,6 +368,7 @@ public void eventReceived(Event event) { this.lastEventReceivedtime = System.currentTimeMillis(); if (maxTime > 0 && this.lastEventReceivedtime > maxTime) { LOGGER.debug("Exceeded max time, stopping"); + Stats.incCounter("stats.client.spider.event.max.time"); this.stopScan(); return; } @@ -374,9 +376,11 @@ public void eventReceived(Event event) { Map parameters = event.getParameters(); String url = parameters.get(ClientMap.URL_KEY); if (!isUrlInScope(url)) { + Stats.incCounter("stats.client.spider.event.scope.out"); return; } + Stats.incCounter("stats.client.spider.event.scope.in"); addUriToAddedNodesModel(url); if (options.getMaxDepth() > 0) { @@ -384,6 +388,7 @@ public void eventReceived(Event event) { if (depth > options.getMaxDepth()) { LOGGER.debug( "Ignoring URL - too deep {} > {} : {}", depth, options.getMaxDepth(), url); + Stats.incCounter("stats.client.spider.event.max.depth"); return; } } @@ -395,12 +400,15 @@ public void eventReceived(Event event) { siblings, options.getMaxChildren(), url); + Stats.incCounter("stats.client.spider.event.max.children"); return; } } if (ClientMap.MAP_COMPONENT_ADDED_EVENT.equals(event.getEventType())) { + Stats.incCounter("stats.client.spider.event.component"); if (ClickElement.isSupported(this::isUrlInScope, parameters)) { + Stats.incCounter("stats.client.spider.event.component.click"); addTask( url, openAction( @@ -409,6 +417,7 @@ url, new ClickElement(valueProvider, createUri(url), parameters)), Constant.messages.getString("client.spider.panel.table.action.click"), paramsToString(parameters)); } else if (SubmitForm.isSupported(parameters)) { + Stats.incCounter("stats.client.spider.event.component.form"); addTask( url, openAction(url, new SubmitForm(valueProvider, createUri(url), parameters)), @@ -417,6 +426,7 @@ url, new ClickElement(valueProvider, createUri(url), parameters)), paramsToString(parameters)); } } else { + Stats.incCounter("stats.client.spider.event.url"); addOpenUrlTask(url, options.getPageLoadTimeInSecs()); } } diff --git a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpiderTask.java b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpiderTask.java index 46b43cca14..f7fe178d27 100644 --- a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpiderTask.java +++ b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/ClientSpiderTask.java @@ -28,6 +28,7 @@ import org.openqa.selenium.WebDriver; import org.parosproxy.paros.Constant; import org.zaproxy.addon.client.spider.ClientSpider.WebDriverProcess; +import org.zaproxy.zap.utils.Stats; public class ClientSpiderTask implements Runnable { @@ -119,7 +120,9 @@ private void runImpl() { ok = true; this.status = Status.FINISHED; this.clientSpider.taskStateChange(this); + Stats.incCounter("stats.client.spider.task.finished"); } catch (Exception e) { + Stats.incCounter("stats.client.spider.task.failed"); LOGGER.warn("Task {} failed {}", id, e.getMessage(), e); this.status = Status.FAILED; this.error = e.getMessage(); diff --git a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/ClickElement.java b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/ClickElement.java index 29fb2148ea..cf985a2ff3 100644 --- a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/ClickElement.java +++ b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/ClickElement.java @@ -36,7 +36,7 @@ public class ClickElement extends BaseElementAction { private static final Logger LOGGER = LogManager.getLogger(ClickElement.class); - private static final String STATS_PREFIX = "client.spider.click"; + private static final String STATS_PREFIX = "stats.client.spider.click"; private final Map elementData; private final String tagName; diff --git a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/OpenUrl.java b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/OpenUrl.java index f9327c2fe8..48542de68f 100644 --- a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/OpenUrl.java +++ b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/OpenUrl.java @@ -26,7 +26,7 @@ public class OpenUrl implements SpiderAction { - private static final String STATS_PREFIX = "client.spider.url"; + private static final String STATS_PREFIX = "stats.client.spider.url"; private final String url; diff --git a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/SubmitForm.java b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/SubmitForm.java index 8357c06540..1d80514df0 100644 --- a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/SubmitForm.java +++ b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/actions/SubmitForm.java @@ -34,7 +34,7 @@ public class SubmitForm extends BaseElementAction { private static final Logger LOGGER = LogManager.getLogger(SubmitForm.class); - private static final String STATS_PREFIX = "client.spider.form"; + private static final String STATS_PREFIX = "stats.client.spider.form"; private final String tagName; private final int formIndex;