@@ -33,7 +33,7 @@ def __init__(self, zap: ZAPv2, config: ZapConfiguration):
3333 self .__zap = zap
3434 self .__config = config
3535
36- def start_spider_by_url (self , url : str , ajax : bool ) -> int :
36+ def start_spider_by_url (self , url : str ) -> int :
3737 """ Starts a ZAP Spider for the given url, based on the given configuration and ZAP instance.
3838
3939 Parameters
@@ -44,24 +44,26 @@ def start_spider_by_url(self, url: str, ajax: bool) -> int:
4444 True if the ajax spider must be used instead of the traditional spider, otherwise false.
4545 """
4646 spiderId = - 1
47+ ajax_config = False
4748
4849 if self .__config .has_spider_configurations :
49- logging .info ('Trying to start Spider (Ajax: %s) by configuration target url %s' , str (ajax ), url )
5050
5151 context = self .__config .get_context_by_url (url )
5252
5353 spider_config = None
5454 if "name" in context :
55- spider_config = self .__config .get_spider_by_context_name (str (context ["name" ]))
55+ spider_config = self .__config .get_spider_by_context_name (str (context ["name" ]))
56+ ajax = bool (spider_config ["ajax" ]) if "ajax" in spider_config else False
5657
57- spiderId = self ._start_spider (spider_config = spider_config , ajax = ajax )
58+ logging .info ('Trying to start Spider (Ajax: %s) by configuration target url %s' , str (ajax ), url )
59+ spiderId = self ._start_spider (spider_config = spider_config , ajax = ajax_config )
5860 else :
5961 logging .error ("There is no spider specific configuration found." )
6062
6163
6264 return int (spiderId )
6365
64- def start_spider_by_index (self , index : int , ajax : bool ) -> int :
66+ def start_spider_by_index (self , index : int ) -> int :
6567 """ Starts a ZAP Spider with the given index for the spiders configuration, based on the given configuration and ZAP instance.
6668
6769 Parameters
@@ -72,14 +74,18 @@ def start_spider_by_index(self, index: int, ajax: bool) -> int:
7274 True if the ajax spider must be used instead of the traditional spider, otherwise false.
7375 """
7476 spiderId = - 1
77+ ajax_config = False
7578
7679 if self .__config .has_spider_configurations :
80+ spider_config = self .__config .get_spider_by_index (index )
81+ ajax = bool (spider_config ["ajax" ]) if "ajax" in spider_config else False
82+
7783 logging .debug ('Trying to start Spider (Ajax: %s) by configuration index %s' , str (ajax ), str (index ))
78- spiderId = self ._start_spider (spider_config = self . __config . get_spider_by_index ( index ) , ajax = ajax )
84+ spiderId = self ._start_spider (spider_config = spider_config , ajax = ajax )
7985
8086 return int (spiderId )
8187
82- def start_spider_by_name (self , name : str , ajax : bool ) -> int :
88+ def start_spider_by_name (self , name : str ) -> int :
8389 """ Starts a ZAP Spider with the given name for the spiders configuration, based on the given configuration and ZAP instance.
8490
8591 Parameters
@@ -90,8 +96,16 @@ def start_spider_by_name(self, name: str, ajax: bool) -> int:
9096 True if the ajax spider must be used instead of the traditional spider, otherwise false.
9197 """
9298
99+ spiderId = - 1
100+
93101 if self .__config .has_spider_configurations :
94- self ._start_spider (spider_config = self .__config .get_spider_by_name (name ), ajax = ajax )
102+ spider_config = self .__config .get_spider_by_name (name )
103+ ajax = bool (spider_config ["ajax" ]) if "ajax" in spider_config else False
104+
105+ logging .debug ('Trying to start Spider (Ajax: %s) by configuration index %s' , str (ajax ), str (index ))
106+ spiderId = self ._start_spider (spider_config = spider_config , ajax = ajax )
107+
108+ return int (spiderId )
95109
96110 def wait_until_http_spider_finished (self , spider_id : int ):
97111 """ Wait until the running ZAP Spider finished and log results.
0 commit comments