4747from stats import stats
4848from users import users
4949
50- class ZapError (Exception ):
51- """
52- Base ZAP exception.
53- """
54- pass
55-
5650
5751class ZAPv2 (object ):
5852 """
5953 Client API implementation for integrating with ZAP v2.
6054 """
61-
6255 # base JSON api url
6356 base = 'http://zap/JSON/'
57+
6458 # base OTHER api url
6559 base_other = 'http://zap/OTHER/'
6660
@@ -71,12 +65,12 @@ def __init__(self, proxies={'http': 'http://127.0.0.1:8080',
7165
7266 :Parameters:
7367 - `proxies`: dictionary of ZAP proxies to use.
74-
68+
7569 Note that all of the other classes in this directory are generated
7670 new ones will need to be manually added to this file
7771 """
7872 self .__proxies = proxies
79-
73+
8074 self .acsrf = acsrf (self )
8175 self .ajaxSpider = ajaxSpider (self )
8276 self .ascan = ascan (self )
@@ -101,17 +95,6 @@ def __init__(self, proxies={'http': 'http://127.0.0.1:8080',
10195 self .stats = stats (self )
10296 self .users = users (self )
10397
104- def _expect_ok (self , json_data ):
105- """
106- Checks that we have an OK response, else raises an exception.
107-
108- :Parameters:
109- - `json_data`: the json data to look at.
110- """
111- if type (json_data ) == type (list ()) and json_data [0 ] == u'OK' :
112- return json_data
113- raise ZapError (* json_data .values ())
114-
11598 def urlopen (self , * args , ** kwargs ):
11699 """
117100 Opens a url forcing the proxies to be used.
@@ -123,26 +106,15 @@ def urlopen(self, *args, **kwargs):
123106 kwargs ['proxies' ] = self .__proxies
124107 return urllib .urlopen (* args , ** kwargs ).read ()
125108
126- def status_code (self , * args , ** kwargs ):
127- """
128- Open a url forcing the proxies to be used.
129-
130- :Parameters:
131- - `args`: all non-keyword arguments.
132- - `kwargs`: all other keyword arguments.
133- """
134- kwargs ['proxies' ] = self .__proxies
135- return urllib .urlopen (* args , ** kwargs ).getcode ()
136-
137- def _request (self , url , get = {}):
109+ def _request (self , url , get = None ):
138110 """
139111 Shortcut for a GET request.
140112
141113 :Parameters:
142114 - `url`: the url to GET at.
143115 - `get`: the disctionary to turn into GET variables.
144116 """
145- return json .loads (self .urlopen (url + '?' + urllib .urlencode (get )))
117+ return json .loads (self .urlopen (url + '?' + urllib .urlencode (get or {} )))
146118
147119 def _request_other (self , url , get = {}):
148120 """
@@ -152,4 +124,4 @@ def _request_other(self, url, get={}):
152124 - `url`: the url to GET at.
153125 - `get`: the disctionary to turn into GET variables.
154126 """
155- return self .urlopen (url + '?' + urllib .urlencode (get ))
127+ return self .urlopen (url + '?' + urllib .urlencode (get or {} ))
0 commit comments