Skip to content

Commit 8b3e7f3

Browse files
authored
Merge pull request #80 from thc202/add-core-apis
Add more core APIs
2 parents 2e8ef71 + 2ff0a1a commit 8b3e7f3

File tree

4 files changed

+151
-1
lines changed

4 files changed

+151
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8-
8+
### Added
9+
- Core APIs from ZAP version 2.8.0.
910

1011
## [1.7.0] - 2019-06-13
1112
### Added

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@
6161
import org.zaproxy.clientapi.gen.HttpSessions;
6262
import org.zaproxy.clientapi.gen.ImportLogFiles;
6363
import org.zaproxy.clientapi.gen.Importurls;
64+
import org.zaproxy.clientapi.gen.LocalProxies;
6465
import org.zaproxy.clientapi.gen.Openapi;
6566
import org.zaproxy.clientapi.gen.Params;
6667
import org.zaproxy.clientapi.gen.Pnh;
6768
import org.zaproxy.clientapi.gen.Pscan;
6869
import org.zaproxy.clientapi.gen.Replacer;
6970
import org.zaproxy.clientapi.gen.Reveal;
71+
import org.zaproxy.clientapi.gen.RuleConfig;
7072
import org.zaproxy.clientapi.gen.Script;
7173
import org.zaproxy.clientapi.gen.Search;
7274
import org.zaproxy.clientapi.gen.Selenium;
@@ -111,12 +113,14 @@ public class ClientApi {
111113
public HttpSessions httpSessions = new HttpSessions(this);
112114
public ImportLogFiles logImportFiles = new ImportLogFiles(this);
113115
public Importurls importurls = new Importurls(this);
116+
public LocalProxies localProxies = new LocalProxies(this);
114117
public Openapi openapi = new Openapi(this);
115118
public Params params = new Params(this);
116119
public Pnh pnh = new Pnh(this);
117120
public Pscan pscan = new Pscan(this);
118121
public Replacer replacer = new Replacer(this);
119122
public Reveal reveal = new Reveal(this);
123+
public RuleConfig ruleConfig = new RuleConfig(this);
120124
public Search search = new Search(this);
121125
public Script script = new Script(this);
122126
public Selenium selenium = new Selenium(this);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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 LocalProxies {
31+
32+
private final ClientApi api;
33+
34+
public LocalProxies(ClientApi api) {
35+
this.api = api;
36+
}
37+
38+
/** Gets all of the additional proxies that have been configured. */
39+
public ApiResponse additionalProxies() throws ClientApiException {
40+
return api.callApi("localProxies", "view", "additionalProxies", null);
41+
}
42+
43+
/** Adds an new proxy using the details supplied. */
44+
public ApiResponse addAdditionalProxy(
45+
String address,
46+
String port,
47+
String behindnat,
48+
String alwaysdecodezip,
49+
String removeunsupportedencodings)
50+
throws ClientApiException {
51+
Map<String, String> map = new HashMap<>();
52+
map.put("address", address);
53+
map.put("port", port);
54+
if (behindnat != null) {
55+
map.put("behindNat", behindnat);
56+
}
57+
if (alwaysdecodezip != null) {
58+
map.put("alwaysDecodeZip", alwaysdecodezip);
59+
}
60+
if (removeunsupportedencodings != null) {
61+
map.put("removeUnsupportedEncodings", removeunsupportedencodings);
62+
}
63+
return api.callApi("localProxies", "action", "addAdditionalProxy", map);
64+
}
65+
66+
/** Removes the additional proxy with the specified address and port. */
67+
public ApiResponse removeAdditionalProxy(String address, String port)
68+
throws ClientApiException {
69+
Map<String, String> map = new HashMap<>();
70+
map.put("address", address);
71+
map.put("port", port);
72+
return api.callApi("localProxies", "action", "removeAdditionalProxy", map);
73+
}
74+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 RuleConfig {
31+
32+
private final ClientApi api;
33+
34+
public RuleConfig(ClientApi api) {
35+
this.api = api;
36+
}
37+
38+
/** Show the specified rule configuration */
39+
public ApiResponse ruleConfigValue(String key) throws ClientApiException {
40+
Map<String, String> map = new HashMap<>();
41+
map.put("key", key);
42+
return api.callApi("ruleConfig", "view", "ruleConfigValue", map);
43+
}
44+
45+
/** Show all of the rule configurations */
46+
public ApiResponse allRuleConfigs() throws ClientApiException {
47+
return api.callApi("ruleConfig", "view", "allRuleConfigs", null);
48+
}
49+
50+
/** Reset the specified rule configuration, which must already exist */
51+
public ApiResponse resetRuleConfigValue(String key) throws ClientApiException {
52+
Map<String, String> map = new HashMap<>();
53+
map.put("key", key);
54+
return api.callApi("ruleConfig", "action", "resetRuleConfigValue", map);
55+
}
56+
57+
/** Reset all of the rule configurations */
58+
public ApiResponse resetAllRuleConfigValues() throws ClientApiException {
59+
return api.callApi("ruleConfig", "action", "resetAllRuleConfigValues", null);
60+
}
61+
62+
/** Set the specified rule configuration, which must already exist */
63+
public ApiResponse setRuleConfigValue(String key, String value) throws ClientApiException {
64+
Map<String, String> map = new HashMap<>();
65+
map.put("key", key);
66+
if (value != null) {
67+
map.put("value", value);
68+
}
69+
return api.callApi("ruleConfig", "action", "setRuleConfigValue", map);
70+
}
71+
}

0 commit comments

Comments
 (0)