Skip to content

Commit 4390a4a

Browse files
authored
Merge pull request #74 from thc202/regen-2.8.0
Regenerate core APIs for 2.8.0
2 parents dd14e2f + 8afa79a commit 4390a4a

File tree

16 files changed

+580
-77
lines changed

16 files changed

+580
-77
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Add API for SOAP Scanner add-on, version 3.
1010

1111
### Changed
12+
- Core APIs updated for ZAP version 2.8.0.
1213
- Update Replacer API, per release of version 7.
1314
- Add description to Importurls API endpoint.
1415

subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApi.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public class ClientApi {
9999
public Acsrf acsrf = new Acsrf(this);
100100
public AjaxSpider ajaxSpider = new AjaxSpider(this);
101101
public AlertFilter alertFilter = new AlertFilter(this);
102+
public org.zaproxy.clientapi.gen.Alert alert = new org.zaproxy.clientapi.gen.Alert(this);
102103
public Ascan ascan = new Ascan(this);
103104
public Authentication authentication = new Authentication(this);
104105
public Authorization authorization = new Authorization(this);
@@ -246,7 +247,8 @@ public void checkAlerts(List<Alert> ignoreAlerts, List<Alert> requireAlerts, Fil
246247

247248
public List<Alert> getAlerts(String baseUrl, int start, int count) throws ClientApiException {
248249
List<Alert> alerts = new ArrayList<Alert>();
249-
ApiResponse response = core.alerts(baseUrl, String.valueOf(start), String.valueOf(count));
250+
ApiResponse response =
251+
alert.alerts(baseUrl, String.valueOf(start), String.valueOf(count), null);
250252
if (response != null && response instanceof ApiResponseList) {
251253
ApiResponseList alertList = (ApiResponseList) response;
252254
for (ApiResponse resp : alertList.getItems()) {
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
* Zed Attack Proxy (ZAP) and its related class files.
3+
*
4+
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
5+
*
6+
* Copyright 2019 The ZAP Development Team
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package org.zaproxy.clientapi.gen;
21+
22+
import java.util.HashMap;
23+
import java.util.Map;
24+
import org.zaproxy.clientapi.core.ApiResponse;
25+
import org.zaproxy.clientapi.core.ClientApi;
26+
import org.zaproxy.clientapi.core.ClientApiException;
27+
28+
/** This file was automatically generated. */
29+
@SuppressWarnings("javadoc")
30+
public class Alert {
31+
32+
private final ClientApi api;
33+
34+
public Alert(ClientApi api) {
35+
this.api = api;
36+
}
37+
38+
/**
39+
* Gets the alert with the given ID, the corresponding HTTP message can be obtained with the
40+
* 'messageId' field and 'message' API method
41+
*/
42+
public ApiResponse alert(String id) throws ClientApiException {
43+
Map<String, String> map = new HashMap<>();
44+
map.put("id", id);
45+
return api.callApi("alert", "view", "alert", map);
46+
}
47+
48+
/**
49+
* Gets the alerts raised by ZAP, optionally filtering by URL or riskId, and paginating with
50+
* 'start' position and 'count' of alerts
51+
*/
52+
public ApiResponse alerts(String baseurl, String start, String count, String riskid)
53+
throws ClientApiException {
54+
Map<String, String> map = new HashMap<>();
55+
if (baseurl != null) {
56+
map.put("baseurl", baseurl);
57+
}
58+
if (start != null) {
59+
map.put("start", start);
60+
}
61+
if (count != null) {
62+
map.put("count", count);
63+
}
64+
if (riskid != null) {
65+
map.put("riskId", riskid);
66+
}
67+
return api.callApi("alert", "view", "alerts", map);
68+
}
69+
70+
/** Gets number of alerts grouped by each risk level, optionally filtering by URL */
71+
public ApiResponse alertsSummary(String baseurl) throws ClientApiException {
72+
Map<String, String> map = new HashMap<>();
73+
if (baseurl != null) {
74+
map.put("baseurl", baseurl);
75+
}
76+
return api.callApi("alert", "view", "alertsSummary", map);
77+
}
78+
79+
/** Gets the number of alerts, optionally filtering by URL or riskId */
80+
public ApiResponse numberOfAlerts(String baseurl, String riskid) throws ClientApiException {
81+
Map<String, String> map = new HashMap<>();
82+
if (baseurl != null) {
83+
map.put("baseurl", baseurl);
84+
}
85+
if (riskid != null) {
86+
map.put("riskId", riskid);
87+
}
88+
return api.callApi("alert", "view", "numberOfAlerts", map);
89+
}
90+
91+
/**
92+
* Gets a summary of the alerts, optionally filtered by a 'url'. If 'recurse' is true then all
93+
* alerts that apply to urls that start with the specified 'url' will be returned, otherwise
94+
* only those on exactly the same 'url' (ignoring url parameters)
95+
*/
96+
public ApiResponse alertsByRisk(String url, String recurse) throws ClientApiException {
97+
Map<String, String> map = new HashMap<>();
98+
if (url != null) {
99+
map.put("url", url);
100+
}
101+
if (recurse != null) {
102+
map.put("recurse", recurse);
103+
}
104+
return api.callApi("alert", "view", "alertsByRisk", map);
105+
}
106+
107+
/** Gets a count of the alerts, optionally filtered as per alertsPerRisk */
108+
public ApiResponse alertCountsByRisk(String url, String recurse) throws ClientApiException {
109+
Map<String, String> map = new HashMap<>();
110+
if (url != null) {
111+
map.put("url", url);
112+
}
113+
if (recurse != null) {
114+
map.put("recurse", recurse);
115+
}
116+
return api.callApi("alert", "view", "alertCountsByRisk", map);
117+
}
118+
119+
/** Deletes all alerts of the current session. */
120+
public ApiResponse deleteAllAlerts() throws ClientApiException {
121+
return api.callApi("alert", "action", "deleteAllAlerts", null);
122+
}
123+
124+
/** Deletes the alert with the given ID. */
125+
public ApiResponse deleteAlert(String id) throws ClientApiException {
126+
Map<String, String> map = new HashMap<>();
127+
map.put("id", id);
128+
return api.callApi("alert", "action", "deleteAlert", map);
129+
}
130+
}

subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Ascan.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public ApiResponse excludedFromScan() throws ClientApiException {
8585
return api.callApi("ascan", "view", "excludedFromScan", null);
8686
}
8787

88+
/**
89+
* Gets the scanners, optionally, of the given scan policy and/or scanner policy/category ID.
90+
*/
8891
public ApiResponse scanners(String scanpolicyname, String policyid) throws ClientApiException {
8992
Map<String, String> map = new HashMap<>();
9093
if (scanpolicyname != null) {
@@ -189,6 +192,14 @@ public ApiResponse optionThreadPerHost() throws ClientApiException {
189192
return api.callApi("ascan", "view", "optionThreadPerHost", null);
190193
}
191194

195+
/**
196+
* Tells whether or not the active scanner should add a query parameter to GET request that
197+
* don't have parameters to start with.
198+
*/
199+
public ApiResponse optionAddQueryParam() throws ClientApiException {
200+
return api.callApi("ascan", "view", "optionAddQueryParam", null);
201+
}
202+
192203
public ApiResponse optionAllowAttackOnStart() throws ClientApiException {
193204
return api.callApi("ascan", "view", "optionAllowAttackOnStart", null);
194205
}
@@ -368,6 +379,9 @@ public ApiResponse excludeFromScan(String regex) throws ClientApiException {
368379
return api.callApi("ascan", "action", "excludeFromScan", map);
369380
}
370381

382+
/**
383+
* Enables all scanners of the scan policy with the given name, or the default if none given.
384+
*/
371385
public ApiResponse enableAllScanners(String scanpolicyname) throws ClientApiException {
372386
Map<String, String> map = new HashMap<>();
373387
if (scanpolicyname != null) {
@@ -376,6 +390,9 @@ public ApiResponse enableAllScanners(String scanpolicyname) throws ClientApiExce
376390
return api.callApi("ascan", "action", "enableAllScanners", map);
377391
}
378392

393+
/**
394+
* Disables all scanners of the scan policy with the given name, or the default if none given.
395+
*/
379396
public ApiResponse disableAllScanners(String scanpolicyname) throws ClientApiException {
380397
Map<String, String> map = new HashMap<>();
381398
if (scanpolicyname != null) {
@@ -384,6 +401,10 @@ public ApiResponse disableAllScanners(String scanpolicyname) throws ClientApiExc
384401
return api.callApi("ascan", "action", "disableAllScanners", map);
385402
}
386403

404+
/**
405+
* Enables the scanners with the given IDs (comma separated list of IDs) of the scan policy with
406+
* the given name, or the default if none given.
407+
*/
387408
public ApiResponse enableScanners(String ids, String scanpolicyname) throws ClientApiException {
388409
Map<String, String> map = new HashMap<>();
389410
map.put("ids", ids);
@@ -393,6 +414,10 @@ public ApiResponse enableScanners(String ids, String scanpolicyname) throws Clie
393414
return api.callApi("ascan", "action", "enableScanners", map);
394415
}
395416

417+
/**
418+
* Disables the scanners with the given IDs (comma separated list of IDs) of the scan policy
419+
* with the given name, or the default if none given.
420+
*/
396421
public ApiResponse disableScanners(String ids, String scanpolicyname)
397422
throws ClientApiException {
398423
Map<String, String> map = new HashMap<>();
@@ -572,6 +597,16 @@ public ApiResponse setOptionDefaultPolicy(String string) throws ClientApiExcepti
572597
return api.callApi("ascan", "action", "setOptionDefaultPolicy", map);
573598
}
574599

600+
/**
601+
* Sets whether or not the active scanner should add a query param to GET requests which do not
602+
* have parameters to start with.
603+
*/
604+
public ApiResponse setOptionAddQueryParam(boolean bool) throws ClientApiException {
605+
Map<String, String> map = new HashMap<>();
606+
map.put("Boolean", Boolean.toString(bool));
607+
return api.callApi("ascan", "action", "setOptionAddQueryParam", map);
608+
}
609+
575610
public ApiResponse setOptionAllowAttackOnStart(boolean bool) throws ClientApiException {
576611
Map<String, String> map = new HashMap<>();
577612
map.put("Boolean", Boolean.toString(bool));

subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authentication.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,41 @@ public Authentication(ClientApi api) {
3636
this.api = api;
3737
}
3838

39+
/** Gets the name of the authentication methods. */
3940
public ApiResponse getSupportedAuthenticationMethods() throws ClientApiException {
4041
return api.callApi("authentication", "view", "getSupportedAuthenticationMethods", null);
4142
}
4243

44+
/** Gets the configuration parameters for the authentication method with the given name. */
4345
public ApiResponse getAuthenticationMethodConfigParams(String authmethodname)
4446
throws ClientApiException {
4547
Map<String, String> map = new HashMap<>();
4648
map.put("authMethodName", authmethodname);
4749
return api.callApi("authentication", "view", "getAuthenticationMethodConfigParams", map);
4850
}
4951

52+
/** Gets the name of the authentication method for the context with the given ID. */
5053
public ApiResponse getAuthenticationMethod(String contextid) throws ClientApiException {
5154
Map<String, String> map = new HashMap<>();
5255
map.put("contextId", contextid);
5356
return api.callApi("authentication", "view", "getAuthenticationMethod", map);
5457
}
5558

59+
/** Gets the logged in indicator for the context with the given ID. */
5660
public ApiResponse getLoggedInIndicator(String contextid) throws ClientApiException {
5761
Map<String, String> map = new HashMap<>();
5862
map.put("contextId", contextid);
5963
return api.callApi("authentication", "view", "getLoggedInIndicator", map);
6064
}
6165

66+
/** Gets the logged out indicator for the context with the given ID. */
6267
public ApiResponse getLoggedOutIndicator(String contextid) throws ClientApiException {
6368
Map<String, String> map = new HashMap<>();
6469
map.put("contextId", contextid);
6570
return api.callApi("authentication", "view", "getLoggedOutIndicator", map);
6671
}
6772

73+
/** Sets the authentication method for the context with the given ID. */
6874
public ApiResponse setAuthenticationMethod(
6975
String contextid, String authmethodname, String authmethodconfigparams)
7076
throws ClientApiException {
@@ -77,6 +83,7 @@ public ApiResponse setAuthenticationMethod(
7783
return api.callApi("authentication", "action", "setAuthenticationMethod", map);
7884
}
7985

86+
/** Sets the logged in indicator for the context with the given ID. */
8087
public ApiResponse setLoggedInIndicator(String contextid, String loggedinindicatorregex)
8188
throws ClientApiException {
8289
Map<String, String> map = new HashMap<>();
@@ -85,6 +92,7 @@ public ApiResponse setLoggedInIndicator(String contextid, String loggedinindicat
8592
return api.callApi("authentication", "action", "setLoggedInIndicator", map);
8693
}
8794

95+
/** Sets the logged out indicator for the context with the given ID. */
8896
public ApiResponse setLoggedOutIndicator(String contextid, String loggedoutindicatorregex)
8997
throws ClientApiException {
9098
Map<String, String> map = new HashMap<>();

subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Autoupdate.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public ApiResponse installedAddons() throws ClientApiException {
5151
return api.callApi("autoupdate", "view", "installedAddons", null);
5252
}
5353

54+
/** Returns a list with all local add-ons, installed or not. */
55+
public ApiResponse localAddons() throws ClientApiException {
56+
return api.callApi("autoupdate", "view", "localAddons", null);
57+
}
58+
5459
/**
5560
* Return a list of any add-ons that have been added to the Marketplace since the last check for
5661
* updates
@@ -139,6 +144,12 @@ public ApiResponse installAddon(String id) throws ClientApiException {
139144
return api.callApi("autoupdate", "action", "installAddon", map);
140145
}
141146

147+
public ApiResponse installLocalAddon(String file) throws ClientApiException {
148+
Map<String, String> map = new HashMap<>();
149+
map.put("file", file);
150+
return api.callApi("autoupdate", "action", "installLocalAddon", map);
151+
}
152+
142153
/** Uninstalls the specified add-on */
143154
public ApiResponse uninstallAddon(String id) throws ClientApiException {
144155
Map<String, String> map = new HashMap<>();

subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Context.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ public ApiResponse excludedTechnologyList(String contextname) throws ClientApiEx
8181
return api.callApi("context", "view", "excludedTechnologyList", map);
8282
}
8383

84+
/** Lists the URLs accessed through/by ZAP, that belong to the context with the given name. */
85+
public ApiResponse urls(String contextname) throws ClientApiException {
86+
Map<String, String> map = new HashMap<>();
87+
map.put("contextName", contextname);
88+
return api.callApi("context", "view", "urls", map);
89+
}
90+
8491
/** Add exclude regex to context */
8592
public ApiResponse excludeFromContext(String contextname, String regex)
8693
throws ClientApiException {
@@ -99,6 +106,16 @@ public ApiResponse includeInContext(String contextname, String regex)
99106
return api.callApi("context", "action", "includeInContext", map);
100107
}
101108

109+
/** Set the regexs to include and exclude for a context, both supplied as JSON string arrays */
110+
public ApiResponse setContextRegexs(String contextname, String incregexs, String excregexs)
111+
throws ClientApiException {
112+
Map<String, String> map = new HashMap<>();
113+
map.put("contextName", contextname);
114+
map.put("incRegexs", incregexs);
115+
map.put("excRegexs", excregexs);
116+
return api.callApi("context", "action", "setContextRegexs", map);
117+
}
118+
102119
/** Creates a new context with the given name in the current session */
103120
public ApiResponse newContext(String contextname) throws ClientApiException {
104121
Map<String, String> map = new HashMap<>();

0 commit comments

Comments
 (0)