forked from zaproxy/zap-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
188 lines (160 loc) · 8.76 KB
/
script.py
File metadata and controls
188 lines (160 loc) · 8.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Zed Attack Proxy (ZAP) and its related class files.
#
# ZAP is an HTTP/HTTPS proxy for assessing web application security.
#
# Copyright 2017 the ZAP development team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This file was automatically generated.
"""
import six
class script(object):
def __init__(self, zap):
self.zap = zap
@property
def list_engines(self):
"""
Lists the script engines available
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/listEngines/')))
@property
def list_types(self):
"""
Lists the script types available.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/listTypes/')))
@property
def list_scripts(self):
"""
Lists the scripts available, with its engine, name, description, type and error state.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/listScripts/')))
def global_var(self, varkey):
"""
Gets the value of the global variable with the given key. Returns an API error (DOES_NOT_EXIST) if no value was previously set.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/globalVar/', {'varKey': varkey})))
def global_custom_var(self, varkey):
"""
Gets the value (string representation) of a global custom variable. Returns an API error (DOES_NOT_EXIST) if no value was previously set.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/globalCustomVar/', {'varKey': varkey})))
@property
def global_vars(self):
"""
Gets all the global variables (key/value pairs).
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/globalVars/')))
@property
def global_custom_vars(self):
"""
Gets all the global custom variables (key/value pairs, the value is the string representation).
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/globalCustomVars/')))
def script_var(self, scriptname, varkey):
"""
Gets the value of the variable with the given key for the given script. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists or if no value was previously set.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/scriptVar/', {'scriptName': scriptname, 'varKey': varkey})))
def script_custom_var(self, scriptname, varkey):
"""
Gets the value (string representation) of a custom variable. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists or if no value was previously set.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/scriptCustomVar/', {'scriptName': scriptname, 'varKey': varkey})))
def script_vars(self, scriptname):
"""
Gets all the variables (key/value pairs) of the given script. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/scriptVars/', {'scriptName': scriptname})))
def script_custom_vars(self, scriptname):
"""
Gets all the custom variables (key/value pairs, the value is the string representation) of a script. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/scriptCustomVars/', {'scriptName': scriptname})))
def enable(self, scriptname, apikey=''):
"""
Enables the script with the given name
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/enable/', {'scriptName': scriptname, 'apikey': apikey})))
def disable(self, scriptname, apikey=''):
"""
Disables the script with the given name
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/disable/', {'scriptName': scriptname, 'apikey': apikey})))
def load(self, scriptname, scripttype, scriptengine, filename, scriptdescription=None, charset=None, apikey=''):
"""
Loads a script into ZAP from the given local file, with the given name, type and engine, optionally with a description, and a charset name to read the script (the charset name is required if the script is not in UTF-8, for example, in ISO-8859-1).
"""
params = {'scriptName': scriptname, 'scriptType': scripttype, 'scriptEngine': scriptengine, 'fileName': filename, 'apikey': apikey}
if scriptdescription is not None:
params['scriptDescription'] = scriptdescription
if charset is not None:
params['charset'] = charset
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/load/', params)))
def remove(self, scriptname, apikey=''):
"""
Removes the script with the given name
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/remove/', {'scriptName': scriptname, 'apikey': apikey})))
def run_stand_alone_script(self, scriptname, apikey=''):
"""
Runs the stand alone script with the given name
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/runStandAloneScript/', {'scriptName': scriptname, 'apikey': apikey})))
def clear_global_var(self, varkey, apikey=''):
"""
Clears the global variable with the given key.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/clearGlobalVar/', {'varKey': varkey, 'apikey': apikey})))
def clear_global_custom_var(self, varkey, apikey=''):
"""
Clears a global custom variable.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/clearGlobalCustomVar/', {'varKey': varkey, 'apikey': apikey})))
def clear_global_vars(self, apikey=''):
"""
Clears the global variables.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/clearGlobalVars/', {'apikey': apikey})))
def clear_script_var(self, scriptname, varkey, apikey=''):
"""
Clears the variable with the given key of the given script. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/clearScriptVar/', {'scriptName': scriptname, 'varKey': varkey, 'apikey': apikey})))
def clear_script_custom_var(self, scriptname, varkey, apikey=''):
"""
Clears a script custom variable.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/clearScriptCustomVar/', {'scriptName': scriptname, 'varKey': varkey, 'apikey': apikey})))
def clear_script_vars(self, scriptname, apikey=''):
"""
Clears the variables of the given script. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists.
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/clearScriptVars/', {'scriptName': scriptname, 'apikey': apikey})))
def set_script_var(self, scriptname, varkey, varvalue=None, apikey=''):
"""
Sets the value of the variable with the given key of the given script. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists.
"""
params = {'scriptName': scriptname, 'varKey': varkey, 'apikey': apikey}
if varvalue is not None:
params['varValue'] = varvalue
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/setScriptVar/', params)))
def set_global_var(self, varkey, varvalue=None, apikey=''):
"""
Sets the value of the global variable with the given key.
"""
params = {'varKey': varkey, 'apikey': apikey}
if varvalue is not None:
params['varValue'] = varvalue
return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/setGlobalVar/', params)))