zaproxy 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.rubocop.yml +213 -0
- data/README.md +36 -1
- data/Rakefile +21 -0
- data/SECURITY.md +21 -0
- data/lib/zap/result.rb +13 -0
- data/lib/zap/v2apis/_template.rb +13 -0
- data/lib/zap/v2apis/access_control.rb +25 -0
- data/lib/zap/v2apis/acsrf.rb +33 -0
- data/lib/zap/v2apis/ajax_spider.rb +153 -0
- data/lib/zap/v2apis/alert.rb +61 -0
- data/lib/zap/v2apis/alert_filter.rb +57 -0
- data/lib/zap/v2apis/ascan.rb +361 -0
- data/lib/zap/v2apis/authentication.rb +41 -0
- data/lib/zap/v2apis/authorization.rb +17 -0
- data/lib/zap/v2apis/automation.rb +21 -0
- data/lib/zap/v2apis/autoupdate.rb +133 -0
- data/lib/zap/v2apis/break.rb +57 -0
- data/lib/zap/v2apis/client.rb +25 -0
- data/lib/zap/v2apis/context.rb +93 -0
- data/lib/zap/v2apis/core.rb +389 -0
- data/lib/zap/v2apis/exim.rb +37 -0
- data/lib/zap/v2apis/forced_user.rb +25 -0
- data/lib/zap/v2apis/graphql.rb +89 -0
- data/lib/zap/v2apis/http_sessions.rb +73 -0
- data/lib/zap/v2apis/hud.rb +157 -0
- data/lib/zap/v2apis/import_urls.rb +13 -0
- data/lib/zap/v2apis/keyboard.rb +17 -0
- data/lib/zap/v2apis/local_proxies.rb +21 -0
- data/lib/zap/v2apis/network.rb +201 -0
- data/lib/zap/v2apis/openapi.rb +17 -0
- data/lib/zap/v2apis/params.rb +13 -0
- data/lib/zap/v2apis/pnh.rb +41 -0
- data/lib/zap/v2apis/postman.rb +17 -0
- data/lib/zap/v2apis/pscan.rb +77 -0
- data/lib/zap/v2apis/quickstartlaunch.rb +13 -0
- data/lib/zap/v2apis/replacer.rb +25 -0
- data/lib/zap/v2apis/reports.rb +21 -0
- data/lib/zap/v2apis/retest.rb +13 -0
- data/lib/zap/v2apis/reveal.rb +17 -0
- data/lib/zap/v2apis/revisit.rb +21 -0
- data/lib/zap/v2apis/rule_config.rb +29 -0
- data/lib/zap/v2apis/script.rb +105 -0
- data/lib/zap/v2apis/search.rb +57 -0
- data/lib/zap/v2apis/selenium.rb +93 -0
- data/lib/zap/v2apis/session_management.rb +29 -0
- data/lib/zap/v2apis/soap.rb +17 -0
- data/lib/zap/v2apis/spider.rb +293 -0
- data/lib/zap/v2apis/stats.rb +61 -0
- data/lib/zap/v2apis/users.rb +69 -0
- data/lib/zap/v2apis/wappalyzer.rb +21 -0
- data/lib/zap/v2apis/websocket.rb +33 -0
- data/lib/zap/zap.rb +77 -0
- data/lib/zap/zapv2.rb +102 -0
- data/lib/zaproxy.rb +3 -0
- data/openapi.yaml +11314 -0
- data/zaproxy.gemspec +4 -3
- metadata +60 -5
- data/lib/zap.rb +0 -8
@@ -0,0 +1,293 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ZAPv2 < ZAP
|
4
|
+
class Spider
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def added_nodes(scan_id)
|
10
|
+
@client.get("/JSON/spider/view/addedNodes/?scanId=#{scan_id}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def all_urls
|
14
|
+
@client.get('/JSON/spider/view/allUrls/')
|
15
|
+
end
|
16
|
+
|
17
|
+
def domains_always_in_scope
|
18
|
+
@client.get('/JSON/spider/view/domainsAlwaysInScope/')
|
19
|
+
end
|
20
|
+
|
21
|
+
def excluded_from_scan
|
22
|
+
@client.get('/JSON/spider/view/excludedFromScan/')
|
23
|
+
end
|
24
|
+
|
25
|
+
def full_results(scan_id)
|
26
|
+
@client.get("/JSON/spider/view/fullResults/?scanId=#{scan_id}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def option_accept_cookies
|
30
|
+
@client.get('/JSON/spider/view/optionAcceptCookies/')
|
31
|
+
end
|
32
|
+
|
33
|
+
def option_domains_always_in_scope
|
34
|
+
@client.get('/JSON/spider/view/optionDomainsAlwaysInScope/')
|
35
|
+
end
|
36
|
+
|
37
|
+
def option_domains_always_in_scope_enabled
|
38
|
+
@client.get('/JSON/spider/view/optionDomainsAlwaysInScopeEnabled/')
|
39
|
+
end
|
40
|
+
|
41
|
+
def option_handle_odata_parameters_visited
|
42
|
+
@client.get('/JSON/spider/view/optionHandleODataParametersVisited/')
|
43
|
+
end
|
44
|
+
|
45
|
+
def option_handle_parameters
|
46
|
+
@client.get('/JSON/spider/view/optionHandleParameters/')
|
47
|
+
end
|
48
|
+
|
49
|
+
def option_max_children
|
50
|
+
@client.get('/JSON/spider/view/optionMaxChildren/')
|
51
|
+
end
|
52
|
+
|
53
|
+
def option_max_depth
|
54
|
+
@client.get('/JSON/spider/view/optionMaxDepth/')
|
55
|
+
end
|
56
|
+
|
57
|
+
def option_max_duration
|
58
|
+
@client.get('/JSON/spider/view/optionMaxDuration/')
|
59
|
+
end
|
60
|
+
|
61
|
+
def option_max_parse_size_bytes
|
62
|
+
@client.get('/JSON/spider/view/optionMaxParseSizeBytes/')
|
63
|
+
end
|
64
|
+
|
65
|
+
def option_max_scans_in_ui
|
66
|
+
@client.get('/JSON/spider/view/optionMaxScansInUI/')
|
67
|
+
end
|
68
|
+
|
69
|
+
def option_parse_comments
|
70
|
+
@client.get('/JSON/spider/view/optionParseComments/')
|
71
|
+
end
|
72
|
+
|
73
|
+
def option_parse_ds_store
|
74
|
+
@client.get('/JSON/spider/view/optionParseDsStore/')
|
75
|
+
end
|
76
|
+
|
77
|
+
def option_parse_git
|
78
|
+
@client.get('/JSON/spider/view/optionParseGit/')
|
79
|
+
end
|
80
|
+
|
81
|
+
def option_parse_robots_txt
|
82
|
+
@client.get('/JSON/spider/view/optionParseRobotsTxt/')
|
83
|
+
end
|
84
|
+
|
85
|
+
def option_parse_svn_entries
|
86
|
+
@client.get('/JSON/spider/view/optionParseSVNEntries/')
|
87
|
+
end
|
88
|
+
|
89
|
+
def option_parse_sitemap_xml
|
90
|
+
@client.get('/JSON/spider/view/optionParseSitemapXml/')
|
91
|
+
end
|
92
|
+
|
93
|
+
def option_post_form
|
94
|
+
@client.get('/JSON/spider/view/optionPostForm/')
|
95
|
+
end
|
96
|
+
|
97
|
+
def option_process_form
|
98
|
+
@client.get('/JSON/spider/view/optionProcessForm/')
|
99
|
+
end
|
100
|
+
|
101
|
+
def option_request_wait_time
|
102
|
+
@client.get('/JSON/spider/view/optionRequestWaitTime/')
|
103
|
+
end
|
104
|
+
|
105
|
+
def option_send_referer_header
|
106
|
+
@client.get('/JSON/spider/view/optionSendRefererHeader/')
|
107
|
+
end
|
108
|
+
|
109
|
+
def option_show_advanced_dialog
|
110
|
+
@client.get('/JSON/spider/view/optionShowAdvancedDialog/')
|
111
|
+
end
|
112
|
+
|
113
|
+
def option_skip_url_string
|
114
|
+
@client.get('/JSON/spider/view/optionSkipURLString/')
|
115
|
+
end
|
116
|
+
|
117
|
+
def option_thread_count
|
118
|
+
@client.get('/JSON/spider/view/optionThreadCount/')
|
119
|
+
end
|
120
|
+
|
121
|
+
def option_user_agent
|
122
|
+
@client.get('/JSON/spider/view/optionUserAgent/')
|
123
|
+
end
|
124
|
+
|
125
|
+
def results(scan_id)
|
126
|
+
@client.get("/JSON/spider/view/results/?scanId=#{scan_id}")
|
127
|
+
end
|
128
|
+
|
129
|
+
def scans
|
130
|
+
@client.get('/JSON/spider/view/scans/')
|
131
|
+
end
|
132
|
+
|
133
|
+
def status(scan_id)
|
134
|
+
@client.get("/JSON/spider/view/status/?scanId=#{scan_id}")
|
135
|
+
end
|
136
|
+
|
137
|
+
def add_domain_always_in_scope(value, is_regex, is_enabled)
|
138
|
+
@client.get("/JSON/spider/action/addDomainAlwaysInScope/?value=#{value}&isRegex=#{is_regex}&isEnabled=#{is_enabled}")
|
139
|
+
end
|
140
|
+
|
141
|
+
def clear_excluded_from_scan
|
142
|
+
@client.get('/JSON/spider/action/clearExcludedFromScan/')
|
143
|
+
end
|
144
|
+
|
145
|
+
def disable_all_domains_always_in_scope
|
146
|
+
@client.get('/JSON/spider/action/disableAllDomainsAlwaysInScope/')
|
147
|
+
end
|
148
|
+
|
149
|
+
def enable_all_domains_always_in_scope
|
150
|
+
@client.get('/JSON/spider/action/enableAllDomainsAlwaysInScope/')
|
151
|
+
end
|
152
|
+
|
153
|
+
def exclude_from_scan(regex)
|
154
|
+
@client.get("/JSON/spider/action/excludeFromScan/?regex=#{regex}")
|
155
|
+
end
|
156
|
+
|
157
|
+
def modify_domain_always_in_scope(index, value, is_regex, is_enabled)
|
158
|
+
@client.get("/JSON/spider/action/modifyDomainAlwaysInScope/?idx=#{index}&value=#{value}&isRegex=#{is_regex}&isEnabled=#{is_enabled}")
|
159
|
+
end
|
160
|
+
|
161
|
+
def pause(scan_id)
|
162
|
+
@client.get("/JSON/spider/action/pause/?scanId=#{scan_id}")
|
163
|
+
end
|
164
|
+
|
165
|
+
def pause_all_scans
|
166
|
+
@client.get('/JSON/spider/action/pauseAllScans/')
|
167
|
+
end
|
168
|
+
|
169
|
+
def remove_all_scans
|
170
|
+
@client.get('/JSON/spider/action/removeAllScans/')
|
171
|
+
end
|
172
|
+
|
173
|
+
def remove_domain_always_in_scope(index)
|
174
|
+
@client.get("/JSON/spider/action/removeDomainAlwaysInScope/?idx=#{index}")
|
175
|
+
end
|
176
|
+
|
177
|
+
def remove_scan(scan_id)
|
178
|
+
@client.get("/JSON/spider/action/removeScan/?scanId=#{scan_id}")
|
179
|
+
end
|
180
|
+
|
181
|
+
def resume(scan_id)
|
182
|
+
@client.get("/JSON/spider/action/resume/?scanId=#{scan_id}")
|
183
|
+
end
|
184
|
+
|
185
|
+
def resume_all_scans
|
186
|
+
@client.get('/JSON/spider/action/resumeAllScans/')
|
187
|
+
end
|
188
|
+
|
189
|
+
def scan(url, max_children, recurse, context_name, subtree_only)
|
190
|
+
@client.get("/JSON/spider/action/scan/?url=#{url}&maxChildren=#{max_children}&recurse=#{recurse}&contextName=#{context_name}&subtreeOnly=#{subtree_only}")
|
191
|
+
end
|
192
|
+
|
193
|
+
def scan_as_user(context_id, user_id, url, max_children, recurse, subtree_only)
|
194
|
+
@client.get("/JSON/spider/action/scanAsUser/?contextId=#{context_id}&userId=#{user_id}&url=#{url}&maxChildren=#{max_children}&recurse=#{recurse}&subtreeOnly=#{subtree_only}")
|
195
|
+
end
|
196
|
+
|
197
|
+
def set_option_accept_cookies(boolean)
|
198
|
+
@client.get("/JSON/spider/action/setOptionAcceptCookies/?Boolean=#{boolean}")
|
199
|
+
end
|
200
|
+
|
201
|
+
def set_option_handle_odata_parameters_visited(boolean)
|
202
|
+
@client.get("/JSON/spider/action/setOptionHandleODataParametersVisited/?Boolean=#{boolean}")
|
203
|
+
end
|
204
|
+
|
205
|
+
def set_option_handle_parameters(string)
|
206
|
+
@client.get("/JSON/spider/action/setOptionHandleParameters/?String=#{string}")
|
207
|
+
end
|
208
|
+
|
209
|
+
def set_option_max_children(integer)
|
210
|
+
@client.get("/JSON/spider/action/setOptionMaxChildren/?Integer=#{integer}")
|
211
|
+
end
|
212
|
+
|
213
|
+
def set_option_max_depth(integer)
|
214
|
+
@client.get("/JSON/spider/action/setOptionMaxDepth/?Integer=#{integer}")
|
215
|
+
end
|
216
|
+
|
217
|
+
def set_option_max_duration(integer)
|
218
|
+
@client.get("/JSON/spider/action/setOptionMaxDuration/?Integer=#{integer}")
|
219
|
+
end
|
220
|
+
|
221
|
+
def set_option_max_parse_size_bytes(integer)
|
222
|
+
@client.get("/JSON/spider/action/setOptionMaxParseSizeBytes/?Integer=#{integer}")
|
223
|
+
end
|
224
|
+
|
225
|
+
def set_option_max_scans_in_ui(integer)
|
226
|
+
@client.get("/JSON/spider/action/setOptionMaxScansInUI/?Integer=#{integer}")
|
227
|
+
end
|
228
|
+
|
229
|
+
def set_option_parse_comments(boolean)
|
230
|
+
@client.get("/JSON/spider/action/setOptionParseComments/?Boolean=#{boolean}")
|
231
|
+
end
|
232
|
+
|
233
|
+
def set_option_parse_ds_store(boolean)
|
234
|
+
@client.get("/JSON/spider/action/setOptionParseDsStore/?Boolean=#{boolean}")
|
235
|
+
end
|
236
|
+
|
237
|
+
def set_option_parse_git(boolean)
|
238
|
+
@client.get("/JSON/spider/action/setOptionParseGit/?Boolean=#{boolean}")
|
239
|
+
end
|
240
|
+
|
241
|
+
def set_option_parse_robots_txt(boolean)
|
242
|
+
@client.get("/JSON/spider/action/setOptionParseRobotsTxt/?Boolean=#{boolean}")
|
243
|
+
end
|
244
|
+
|
245
|
+
def set_option_parse_svn_entries(boolean)
|
246
|
+
@client.get("/JSON/spider/action/setOptionParseSVNEntries/?Boolean=#{boolean}")
|
247
|
+
end
|
248
|
+
|
249
|
+
def set_option_parse_sitemap_xml(boolean)
|
250
|
+
@client.get("/JSON/spider/action/setOptionParseSitemapXml/?Boolean=#{boolean}")
|
251
|
+
end
|
252
|
+
|
253
|
+
def set_option_post_form(boolean)
|
254
|
+
@client.get("/JSON/spider/action/setOptionPostForm/?Boolean=#{boolean}")
|
255
|
+
end
|
256
|
+
|
257
|
+
def set_option_process_form(boolean)
|
258
|
+
@client.get("/JSON/spider/action/setOptionProcessForm/?Boolean=#{boolean}")
|
259
|
+
end
|
260
|
+
|
261
|
+
def set_option_request_wait_time(integer)
|
262
|
+
@client.get("/JSON/spider/action/setOptionRequestWaitTime/?Integer=#{integer}")
|
263
|
+
end
|
264
|
+
|
265
|
+
def set_option_send_referer_header(boolean)
|
266
|
+
@client.get("/JSON/spider/action/setOptionSendRefererHeader/?Boolean=#{boolean}")
|
267
|
+
end
|
268
|
+
|
269
|
+
def set_option_show_advanced_dialog(boolean)
|
270
|
+
@client.get("/JSON/spider/action/setOptionShowAdvancedDialog/?Boolean=#{boolean}")
|
271
|
+
end
|
272
|
+
|
273
|
+
def set_option_skip_url_string(string)
|
274
|
+
@client.get("/JSON/spider/action/setOptionSkipURLString/?String=#{string}")
|
275
|
+
end
|
276
|
+
|
277
|
+
def set_option_thread_count(integer)
|
278
|
+
@client.get("/JSON/spider/action/setOptionThreadCount/?Integer=#{integer}")
|
279
|
+
end
|
280
|
+
|
281
|
+
def set_option_user_agent(string)
|
282
|
+
@client.get("/JSON/spider/action/setOptionUserAgent/?String=#{string}")
|
283
|
+
end
|
284
|
+
|
285
|
+
def stop(scan_id)
|
286
|
+
@client.get("/JSON/spider/action/stop/?scanId=#{scan_id}")
|
287
|
+
end
|
288
|
+
|
289
|
+
def stop_all_scans
|
290
|
+
@client.get('/JSON/spider/action/stopAllScans/')
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ZAPv2 < ZAP
|
4
|
+
class Stats
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def all_sites_stats(key_prefix)
|
10
|
+
@client.get("/JSON/stats/view/allSitesStats/?keyPrefix=#{key_prefix}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def option_in_memory_enabled
|
14
|
+
@client.get('/JSON/stats/view/optionInMemoryEnabled/')
|
15
|
+
end
|
16
|
+
|
17
|
+
def option_statsd_enabled
|
18
|
+
@client.get('/JSON/stats/view/optionStatsdEnabled/')
|
19
|
+
end
|
20
|
+
|
21
|
+
def option_statsd_host
|
22
|
+
@client.get('/JSON/stats/view/optionStatsdHost/')
|
23
|
+
end
|
24
|
+
|
25
|
+
def option_statsd_port
|
26
|
+
@client.get('/JSON/stats/view/optionStatsdPort/')
|
27
|
+
end
|
28
|
+
|
29
|
+
def option_statsd_prefix
|
30
|
+
@client.get('/JSON/stats/view/optionStatsdPrefix/')
|
31
|
+
end
|
32
|
+
|
33
|
+
def site_stats(site, key_prefix)
|
34
|
+
@client.get("/JSON/stats/view/siteStats/?site=#{site}&keyPrefix=#{key_prefix}")
|
35
|
+
end
|
36
|
+
|
37
|
+
def stats(key_prefix)
|
38
|
+
@client.get("/JSON/stats/view/stats/?keyPrefix=#{key_prefix}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def clear_stats(key_prefix)
|
42
|
+
@client.get("/JSON/stats/action/clearStats/?keyPrefix=#{key_prefix}")
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_option_in_memory_enabled(boolean)
|
46
|
+
@client.get("/JSON/stats/action/setOptionInMemoryEnabled/?boolean=#{boolean}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_option_statsd_host(string)
|
50
|
+
@client.get("/JSON/stats/action/setOptionStatsdHost/?String=#{string}")
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_option_statsd_port(integer)
|
54
|
+
@client.get("/JSON/stats/action/setOptionStatsdPort/?Integer=#{integer}")
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_option_statsd_prefix(string)
|
58
|
+
@client.get("/JSON/stats/action/setOptionStatsdPrefix/?String=#{string}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ZAPv2 < ZAP
|
4
|
+
class Users
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_authentication_credentials(contextid, userid)
|
10
|
+
@client.get("/JSON/users/view/getAuthenticationCredentials/?contextId=#{contextid}&userId=#{userid}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_authentication_credentials_config_params(contextid)
|
14
|
+
@client.get("/JSON/users/view/getAuthenticationCredentialsConfigParams/?contextId=#{contextid}")
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_authentication_session(contextid, userid)
|
18
|
+
@client.get("/JSON/users/view/getAuthenticationSession/?contextId=#{contextid}&userId=#{userid}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_authentication_state(contextid, userid)
|
22
|
+
@client.get("/JSON/users/view/getAuthenticationState/?contextId=#{contextid}&userId=#{userid}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_user_by_id(contextid, userid)
|
26
|
+
@client.get("/JSON/users/view/getUserById/?contextId=#{contextid}&userId=#{userid}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def users_list(contextid)
|
30
|
+
@client.get("/JSON/users/view/usersList/?contextId=#{contextid}")
|
31
|
+
end
|
32
|
+
|
33
|
+
def authenticate_as_user(contextid, userid)
|
34
|
+
@client.get("/JSON/users/action/authenticateAsUser/?contextId=#{contextid}&userId=#{userid}")
|
35
|
+
end
|
36
|
+
|
37
|
+
def new_user(contextid, name)
|
38
|
+
@client.get("/JSON/users/action/newUser/?contextId=#{contextid}&name=#{name}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def poll_as_user(contextid, userid)
|
42
|
+
@client.get("/JSON/users/action/pollAsUser/?contextId=#{contextid}&userId=#{userid}")
|
43
|
+
end
|
44
|
+
|
45
|
+
def remove_user(contextid, userid)
|
46
|
+
@client.get("/JSON/users/action/removeUser/?contextId=#{contextid}&userId=#{userid}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_authentication_credentials(contextid, userid, authcredentialsconfigparams)
|
50
|
+
@client.get("/JSON/users/action/setAuthenticationCredentials/?contextId=#{contextid}&userId=#{userid}&authCredentialsConfigParams=#{authcredentialsconfigparams}")
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_authentication_state(contextid, userid, lastpollresult, lastpolltimeinms, requestssincelastpoll)
|
54
|
+
@client.get("/JSON/users/action/setAuthenticationState/?contextId=#{contextid}&userId=#{userid}&lastPollResult=#{lastpollresult}&lastPollTimeInMs=#{lastpolltimeinms}&requestsSinceLastPoll=#{requestssincelastpoll}")
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_cookie(contextid, userid, domain, name, value, path, secure)
|
58
|
+
@client.get("/JSON/users/action/setCookie/?contextId=#{contextid}&userId=#{userid}&domain=#{domain}&name=#{name}&value=#{value}&path=#{path}&secure=#{secure}")
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_user_enabled(contextid, userid, enabled)
|
62
|
+
@client.get("/JSON/users/action/setUserEnabled/?contextId=#{contextid}&userId=#{userid}&enabled=#{enabled}")
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_user_name(contextid, userid, name)
|
66
|
+
@client.get("/JSON/users/action/setUserName/?contextId=#{contextid}&userId=#{userid}&name=#{name}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ZAPv2 < ZAP
|
4
|
+
class Wappalyzer
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_all
|
10
|
+
@client.get('/JSON/wappalyzer/view/listAll/')
|
11
|
+
end
|
12
|
+
|
13
|
+
def list_site(site)
|
14
|
+
@client.get("/JSON/wappalyzer/view/listSite/?site=#{site}")
|
15
|
+
end
|
16
|
+
|
17
|
+
def list_sites
|
18
|
+
@client.get('/JSON/wappalyzer/view/listSites/')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ZAPv2 < ZAP
|
4
|
+
class Websocket
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def break_text_message
|
10
|
+
@client.get('/JSON/websocket/view/breakTextMessage/')
|
11
|
+
end
|
12
|
+
|
13
|
+
def channels
|
14
|
+
@client.get('/JSON/websocket/view/channels/')
|
15
|
+
end
|
16
|
+
|
17
|
+
def message(channelid, messageid)
|
18
|
+
@client.get("/JSON/websocket/view/message/?channelId=#{channelid}&messageId=#{messageid}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def messages(channelid, start, count, payloadpreviewlength)
|
22
|
+
@client.get("/JSON/websocket/view/messages/?channelId=#{channelid}&start=#{start}&count=#{count}&payloadPreviewLength=#{payloadpreviewlength}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def send_text_message(channelid, outgoing, message)
|
26
|
+
@client.get("/JSON/websocket/action/sendTextMessage/?channelId=#{channelid}&outgoing=#{outgoing}&message=#{message}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def set_break_text_message(message, outgoing)
|
30
|
+
@client.get("/JSON/websocket/action/setBreakTextMessage/?message=#{message}&outgoing=#{outgoing}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/zap/zap.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require_relative 'result'
|
5
|
+
|
6
|
+
class ZAP
|
7
|
+
API_KEY_DEFAULT = ''
|
8
|
+
|
9
|
+
def initialize(endpoint: 'http://localhost:8080', apikey: API_KEY_DEFAULT)
|
10
|
+
@endpoint = endpoint
|
11
|
+
@api_client = API.new(endpoint, apikey)
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :api
|
15
|
+
|
16
|
+
class API
|
17
|
+
def initialize(endpoint, apikey)
|
18
|
+
@url = URI.parse(endpoint)
|
19
|
+
@http = Net::HTTP.new(@url.host, @url.port)
|
20
|
+
@apikey = apikey
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(path)
|
24
|
+
request = build_request(Net::HTTP::Get, path)
|
25
|
+
response = send_request(request)
|
26
|
+
if response.code == '200'
|
27
|
+
Result.new(true, response.body)
|
28
|
+
else
|
29
|
+
Result.new(false, response.body)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def post(path, data)
|
34
|
+
request = build_request(Net::HTTP::Post, path)
|
35
|
+
request.set_form_data(data)
|
36
|
+
response = send_request(request)
|
37
|
+
if response.code == '200'
|
38
|
+
Result.new(true, response.body)
|
39
|
+
else
|
40
|
+
Result.new(false, response.body)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete(path)
|
45
|
+
request = build_request(Net::HTTP::Delete, path)
|
46
|
+
response = send_request(request)
|
47
|
+
if response.code == '200'
|
48
|
+
Result.new(true, response.body)
|
49
|
+
else
|
50
|
+
Result.new(false, response.body)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def put(path, data)
|
55
|
+
request = build_request(Net::HTTP::Put, path)
|
56
|
+
request.set_form_data(data)
|
57
|
+
response = send_request(request)
|
58
|
+
if response.code == '200'
|
59
|
+
Result.new(true, response.body)
|
60
|
+
else
|
61
|
+
Result.new(false, response.body)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def build_request(request_type, path)
|
68
|
+
request = request_type.new(path)
|
69
|
+
request['X-ZAP-API-Key'] = @apikey unless @apikey.empty?
|
70
|
+
request
|
71
|
+
end
|
72
|
+
|
73
|
+
def send_request(request)
|
74
|
+
@http.request(request)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/zap/zapv2.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'zap'
|
4
|
+
require_relative 'v2apis/access_control'
|
5
|
+
require_relative 'v2apis/acsrf'
|
6
|
+
require_relative 'v2apis/ajax_spider'
|
7
|
+
require_relative 'v2apis/alert'
|
8
|
+
require_relative 'v2apis/alert_filter'
|
9
|
+
require_relative 'v2apis/ascan'
|
10
|
+
require_relative 'v2apis/authentication'
|
11
|
+
require_relative 'v2apis/authorization'
|
12
|
+
require_relative 'v2apis/automation'
|
13
|
+
require_relative 'v2apis/autoupdate'
|
14
|
+
require_relative 'v2apis/break'
|
15
|
+
require_relative 'v2apis/client'
|
16
|
+
require_relative 'v2apis/context'
|
17
|
+
require_relative 'v2apis/core'
|
18
|
+
require_relative 'v2apis/exim'
|
19
|
+
require_relative 'v2apis/forced_user'
|
20
|
+
require_relative 'v2apis/graphql'
|
21
|
+
require_relative 'v2apis/http_sessions'
|
22
|
+
require_relative 'v2apis/hud'
|
23
|
+
require_relative 'v2apis/import_urls'
|
24
|
+
require_relative 'v2apis/keyboard'
|
25
|
+
require_relative 'v2apis/local_proxies'
|
26
|
+
require_relative 'v2apis/network'
|
27
|
+
require_relative 'v2apis/openapi'
|
28
|
+
require_relative 'v2apis/params'
|
29
|
+
require_relative 'v2apis/pnh'
|
30
|
+
require_relative 'v2apis/postman'
|
31
|
+
require_relative 'v2apis/pscan'
|
32
|
+
require_relative 'v2apis/quickstartlaunch'
|
33
|
+
require_relative 'v2apis/replacer'
|
34
|
+
require_relative 'v2apis/reports'
|
35
|
+
require_relative 'v2apis/reveal'
|
36
|
+
require_relative 'v2apis/retest'
|
37
|
+
require_relative 'v2apis/revisit'
|
38
|
+
require_relative 'v2apis/rule_config'
|
39
|
+
require_relative 'v2apis/script'
|
40
|
+
require_relative 'v2apis/search'
|
41
|
+
require_relative 'v2apis/selenium'
|
42
|
+
require_relative 'v2apis/session_management'
|
43
|
+
require_relative 'v2apis/soap'
|
44
|
+
require_relative 'v2apis/spider'
|
45
|
+
require_relative 'v2apis/stats'
|
46
|
+
require_relative 'v2apis/users'
|
47
|
+
require_relative 'v2apis/wappalyzer'
|
48
|
+
require_relative 'v2apis/websocket'
|
49
|
+
|
50
|
+
class ZAPv2 < ZAP
|
51
|
+
attr_reader :access_control, :acsrf, :ajax_spider, :alert, :alert_filter, :ascan, :authentication, :authorization, :automation, :autoupdate, :break, :client, :context, :core, :exim, :forced_user, :graphql, :http_sessions, :hud, :import_urls, :keyboard, :local_proxies, :network, :openapi, :params, :pnh, :postman, :pscan, :quickstartlaunch, :replacer, :reports, :reveal, :retest, :revisit, :rule_config, :script, :search, :selenium, :session_management, :soap, :spider, :stats, :users, :wappalyzer, :websocket
|
52
|
+
|
53
|
+
def initialize(endpoint: 'http://localhost:8080', apikey: API_KEY_DEFAULT)
|
54
|
+
super endpoint: endpoint, apikey: apikey
|
55
|
+
|
56
|
+
@access_control = AccessControl.new @api_client
|
57
|
+
@acsrf = Acsrf.new @api_client
|
58
|
+
@ajax_spider = AjaxSpider.new @api_client
|
59
|
+
@alert = Alert.new @api_client
|
60
|
+
@alert_filter = AlertFilter.new @api_client
|
61
|
+
@ascan = Ascan.new @api_client
|
62
|
+
@authentication = Authentication.new @api_client
|
63
|
+
@authorization = Authorization.new @api_client
|
64
|
+
@automation = Automation.new @api_client
|
65
|
+
@autoupdate = Autoupdate.new @api_client
|
66
|
+
@break = Break.new @api_client
|
67
|
+
@client = Client.new @api_client
|
68
|
+
@context = Context.new @api_client
|
69
|
+
@core = Core.new @api_client
|
70
|
+
@exim = Exim.new @api_client
|
71
|
+
@forced_user = ForcedUser.new @api_client
|
72
|
+
@graphql = GraphQL.new @api_client
|
73
|
+
@http_sessions = HTTPSessions.new @api_client
|
74
|
+
@hud = HUD.new @api_client
|
75
|
+
@import_urls = ImportURLs.new @api_client
|
76
|
+
@keyboard = Keyboard.new @api_client
|
77
|
+
@local_proxies = LocalProxies.new @api_client
|
78
|
+
@network = Network.new @api_client
|
79
|
+
@openapi = OpenAPI.new @api_client
|
80
|
+
@params = Params.new @api_client
|
81
|
+
@pnh = PnH.new @api_client
|
82
|
+
@postman = Postman.new @api_client
|
83
|
+
@pscan = Pscan.new @api_client
|
84
|
+
@quickstartlaunch = QuickStartLaunch.new @api_client
|
85
|
+
@replacer = Replacer.new @api_client
|
86
|
+
@reports = Reports.new @api_client
|
87
|
+
@retest = Retest.new @api_client
|
88
|
+
@reveal = Reveal.new @api_client
|
89
|
+
@revisit = Revisit.new @api_client
|
90
|
+
@rule_config = RuleConfig.new @api_client
|
91
|
+
@script = Script.new @api_client
|
92
|
+
@search = Search.new @api_client
|
93
|
+
@selenium = Selenium.new @api_client
|
94
|
+
@session_management = SessionManagement.new @api_client
|
95
|
+
@soap = Soap.new @api_client
|
96
|
+
@spider = Spider.new @api_client
|
97
|
+
@stats = Stats.new @api_client
|
98
|
+
@users = Users.new @api_client
|
99
|
+
@wappalyzer = Wappalyzer.new @api_client
|
100
|
+
@websocket = Websocket.new @api_client
|
101
|
+
end
|
102
|
+
end
|
data/lib/zaproxy.rb
ADDED