Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions scanners/zap-advanced/scanner/zapclient/spider/zap_spider_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ def configure_spider(self, spider_config: collections.OrderedDict):
method_name="set_option_random_inputs",
)

if self._is_not_empty_integer("failIfFoundUrlsLessThan", spider_config):
self.failIfFoundUrlsLessThan = spider_config["failIfFoundUrlsLessThan"]
else:
self.failIfFoundUrlsLessThan = 0 # Default value

if self._is_not_empty_integer("warnIfFoundUrlsLessThan", spider_config):
self.warnIfFoundUrlsLessThan = spider_config["warnIfFoundUrlsLessThan"]
else:
self.warnIfFoundUrlsLessThan = 0 # Default value

def check_if_spider_completed(self):
finished = self.get_zap_spider.status != "running"
logging.info(
Expand All @@ -215,6 +225,19 @@ def print_spider_summary(self):
raise RuntimeError(
"No URLs found by ZAP Spider :-( - is the target URL accessible? Local services may not be accessible from the Docker container"
)
elif num_urls < self.failIfFoundUrlsLessThan:
logging.error(
"Found URLs are less than {failIfFoundUrlsLessThan}, failing process."
)
raise RuntimeError(
"Found URLs are less than {failIfFoundUrlsLessThan} by ZAP Spider, failing process."
)

elif num_urls < self.warnIfFoundUrlsLessThan:
logging.warning(
"Found URLs are less than {warnIfFoundUrlsLessThan}, continuing process."
)

else:
logging.info("Ajax Spider found total: %s URLs", str(num_urls))
for url in self.get_zap_spider.results():
Expand Down
23 changes: 23 additions & 0 deletions scanners/zap-advanced/scanner/zapclient/spider/zap_spider_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ def configure_spider(self, spider_config: collections.OrderedDict):
method_name="set_option_user_agent",
)

if self._is_not_empty_integer("failIfFoundUrlsLessThan", spider_config):
self.failIfFoundUrlsLessThan = spider_config["failIfFoundUrlsLessThan"]
else:
self.failIfFoundUrlsLessThan = 0 # Default value

if self._is_not_empty_integer("warnIfFoundUrlsLessThan", spider_config):
self.warnIfFoundUrlsLessThan = spider_config["warnIfFoundUrlsLessThan"]
else:
self.warnIfFoundUrlsLessThan = 0 # Default value

def check_if_spider_completed(self):
progress = int(self.get_zap_spider.status(self.get_spider_id))
logging.info("HTTP Spider(%d) progress: %d", self.get_spider_id, progress)
Expand All @@ -318,6 +328,19 @@ def print_spider_summary(self):
raise RuntimeError(
"No URLs found by ZAP Spider :-( - is the target URL accessible? Local services may not be accessible from the Docker container."
)

elif num_urls < self.failIfFoundUrlsLessThan:
logging.error(
"Found URLs are less than {self.failIfFoundUrlsLessThan}, failing process."
)
raise RuntimeError(
"Found URLs are less than {self.failIfFoundUrlsLessThan} by ZAP Spider, failing process."
)

elif num_urls < self.warnIfFoundUrlsLessThan:
logging.warning(
"Found URLs are less than {self.warnIfFoundUrlsLessThan}, continuing process."
)
else:
for url in self.get_zap_spider.results(scanid=self.get_spider_id):
logging.info("Spidered URL: %s", url)
Expand Down