├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── examples └── main.rs └── src ├── acsrf.rs ├── ajax_spider.rs ├── alert.rs ├── alert_filter.rs ├── ascan.rs ├── authentication.rs ├── authorization.rs ├── autoupdate.rs ├── brk.rs ├── context.rs ├── core.rs ├── forced_user.rs ├── http_sessions.rs ├── import_log_files.rs ├── importurls.rs ├── lib.rs ├── openapi.rs ├── params.rs ├── pnh.rs ├── pscan.rs ├── replacer.rs ├── reveal.rs ├── script.rs ├── search.rs ├── selenium.rs ├── session_management.rs ├── soap.rs ├── spider.rs ├── stats.rs ├── users.rs └── websocket.rs /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [0.0.2] - 2019-06-18 8 | 9 | ### Added 10 | - Added the API endpoints for the non core add-ons 11 | - Updated to ZAP 2.8.0 12 | 13 | ### Fixed 14 | - Fixed the formating with `cargo fmt` 15 | 16 | ## [0.0.1] - 2019-05-23 17 | - First alpha release. 18 | 19 | [0.0.2]: https://github.com/zaproxy/zap-api-rust/compare/v0.0.1...v0.0.2 20 | [0.0.1]: https://github.com/zaproxy/zap-api-rust/compare/0d9df9634bbc2fceb6e07507f0601bd78b0bb4ab...v0.0.1 21 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "zap_api" 3 | version = "0.0.2" 4 | authors = ["Simon Bennetts "] 5 | edition = "2018" 6 | description = "The Rust implementation to access the ZAP API" 7 | repository = "https://github.com/zaproxy/zap-api-rust" 8 | keywords = ["zap", "zaproxy", "api"] 9 | license = "Apache-2.0" 10 | 11 | [dependencies] 12 | reqwest = "0.9.18" 13 | serde = { version = "1.0", features = ["derive"] } 14 | serde_json = "1.0" 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZAP Rust API 2 | 3 | The Rust implementation to access the [ZAP API](https://www.zaproxy.org/docs/api/). For more information 4 | about ZAP consult the (main) [ZAP project](https://github.com/zaproxy/zaproxy/). 5 | 6 | This project is at a very early stage and should not be used in production! 7 | 8 | ## Getting Help 9 | 10 | For help using ZAP API refer to: 11 | * [Examples](examples) - collection of examples using the library; 12 | * [API Documentation](https://www.zaproxy.org/docs/api/); 13 | * [ZAP User Group](https://groups.google.com/group/zaproxy-users) - for asking questions; 14 | 15 | ## Issues 16 | 17 | To report issues related to ZAP API, bugs and enhancements requests, use the [issue tracker of the main ZAP project](https://github.com/zaproxy/zaproxy/issues). 18 | 19 | ## Building 20 | 21 | This project uses Cargo: 22 | 23 | cargo build 24 | 25 | ### Installing 26 | 27 | This API is available via https://crates.io/crates/zap_api 28 | -------------------------------------------------------------------------------- /examples/main.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use std::{thread, time}; 21 | use zap_api::ZapApiError; 22 | use zap_api::ZapService; 23 | 24 | fn main() -> Result<(), ZapApiError> { 25 | /* 26 | * These examples assume: 27 | * ZAP is running on http://localhost:8090 28 | * ZAP has an API key of "ChangeMe" (or its disabled) 29 | * Theres a suitable target app listening on localhost:8080 30 | */ 31 | // You will need a ZAP instance running for these API calls to work. 32 | // Change the URL if your ZAP instance is listening on another host / port and the API key if you are using one. 33 | 34 | let zap_url = "http://localhost:8090".to_string(); 35 | let zap_api_key = "ChangeMe".to_string(); 36 | let target_url = "http://localhost:8080".to_string(); 37 | 38 | let service = ZapService { 39 | url: zap_url, 40 | api_key: zap_api_key, 41 | }; 42 | 43 | // Get the ZAP version 44 | let res = zap_api::core::version(&service); 45 | let zap_version; 46 | match res { 47 | Ok(v) => zap_version = v["version"].to_string(), 48 | Err(e) => return Err(e), 49 | } 50 | 51 | println!("ZAP version : {}", zap_version); 52 | 53 | // Start the ZAP (std) spider 54 | println!("Starting the std spider"); 55 | let res = zap_api::spider::scan( 56 | &service, 57 | target_url, 58 | "-1".to_string(), // max children 59 | "true".to_string(), // recurse 60 | "".to_string(), // context name 61 | "false".to_string(), // subtree only 62 | ); 63 | let scan_id; 64 | match res { 65 | Ok(v) => scan_id = v["scan"].to_string(), 66 | Err(e) => return Err(e), 67 | } 68 | println!("Scan id : {}", scan_id); 69 | 70 | // Loop until the spider has completed 71 | let mut status: i32 = 0; 72 | while status < 100 { 73 | thread::sleep(time::Duration::from_secs(1)); 74 | 75 | let res = zap_api::spider::status(&service, scan_id.clone()); 76 | match res { 77 | Ok(v) => { 78 | let res_status = &v["status"].as_str().unwrap(); 79 | status = res_status.parse::().unwrap(); 80 | } 81 | Err(e) => return Err(e), 82 | } 83 | println!("Scan status : {}", status); 84 | } 85 | 86 | // TODO run active scanner 87 | 88 | // TODO display alerts 89 | 90 | Ok(()) 91 | } 92 | -------------------------------------------------------------------------------- /src/acsrf.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Lists the names of all anti-CSRF tokens 30 | */ 31 | pub fn option_tokens_names(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call(service, "acsrf", "view", "optionTokensNames", params) 34 | } 35 | 36 | /** 37 | * Adds an anti-CSRF token with the given name, enabled by default 38 | */ 39 | pub fn add_option_token(service: &ZapService, string: String) -> Result { 40 | let mut params = HashMap::new(); 41 | params.insert("String".to_string(), string); 42 | super::call(service, "acsrf", "action", "addOptionToken", params) 43 | } 44 | 45 | /** 46 | * Removes the anti-CSRF token with the given name 47 | */ 48 | pub fn remove_option_token(service: &ZapService, string: String) -> Result { 49 | let mut params = HashMap::new(); 50 | params.insert("String".to_string(), string); 51 | super::call(service, "acsrf", "action", "removeOptionToken", params) 52 | } 53 | 54 | /** 55 | * Generate a form for testing lack of anti-CSRF tokens - typically invoked via ZAP 56 | */ 57 | pub fn gen_form(service: &ZapService, hrefid: String) -> Result { 58 | let mut params = HashMap::new(); 59 | params.insert("hrefId".to_string(), hrefid); 60 | super::call(service, "acsrf", "other", "genForm", params) 61 | } 62 | -------------------------------------------------------------------------------- /src/ajax_spider.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * This component is optional and therefore the API will only work if it is installed 30 | */ 31 | pub fn status(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call(service, "ajaxSpider", "view", "status", params) 34 | } 35 | 36 | /** 37 | * This component is optional and therefore the API will only work if it is installed 38 | */ 39 | pub fn results(service: &ZapService, start: String, count: String) -> Result { 40 | let mut params = HashMap::new(); 41 | params.insert("start".to_string(), start); 42 | params.insert("count".to_string(), count); 43 | super::call(service, "ajaxSpider", "view", "results", params) 44 | } 45 | 46 | /** 47 | * This component is optional and therefore the API will only work if it is installed 48 | */ 49 | pub fn number_of_results(service: &ZapService) -> Result { 50 | let params = HashMap::new(); 51 | super::call(service, "ajaxSpider", "view", "numberOfResults", params) 52 | } 53 | 54 | /** 55 | * This component is optional and therefore the API will only work if it is installed 56 | */ 57 | pub fn full_results(service: &ZapService) -> Result { 58 | let params = HashMap::new(); 59 | super::call(service, "ajaxSpider", "view", "fullResults", params) 60 | } 61 | 62 | /** 63 | * This component is optional and therefore the API will only work if it is installed 64 | */ 65 | pub fn option_browser_id(service: &ZapService) -> Result { 66 | let params = HashMap::new(); 67 | super::call(service, "ajaxSpider", "view", "optionBrowserId", params) 68 | } 69 | 70 | /** 71 | * This component is optional and therefore the API will only work if it is installed 72 | */ 73 | pub fn option_event_wait(service: &ZapService) -> Result { 74 | let params = HashMap::new(); 75 | super::call(service, "ajaxSpider", "view", "optionEventWait", params) 76 | } 77 | 78 | /** 79 | * This component is optional and therefore the API will only work if it is installed 80 | */ 81 | pub fn option_max_crawl_depth(service: &ZapService) -> Result { 82 | let params = HashMap::new(); 83 | super::call(service, "ajaxSpider", "view", "optionMaxCrawlDepth", params) 84 | } 85 | 86 | /** 87 | * This component is optional and therefore the API will only work if it is installed 88 | */ 89 | pub fn option_max_crawl_states(service: &ZapService) -> Result { 90 | let params = HashMap::new(); 91 | super::call( 92 | service, 93 | "ajaxSpider", 94 | "view", 95 | "optionMaxCrawlStates", 96 | params, 97 | ) 98 | } 99 | 100 | /** 101 | * This component is optional and therefore the API will only work if it is installed 102 | */ 103 | pub fn option_max_duration(service: &ZapService) -> Result { 104 | let params = HashMap::new(); 105 | super::call(service, "ajaxSpider", "view", "optionMaxDuration", params) 106 | } 107 | 108 | /** 109 | * This component is optional and therefore the API will only work if it is installed 110 | */ 111 | pub fn option_number_of_browsers(service: &ZapService) -> Result { 112 | let params = HashMap::new(); 113 | super::call( 114 | service, 115 | "ajaxSpider", 116 | "view", 117 | "optionNumberOfBrowsers", 118 | params, 119 | ) 120 | } 121 | 122 | /** 123 | * This component is optional and therefore the API will only work if it is installed 124 | */ 125 | pub fn option_reload_wait(service: &ZapService) -> Result { 126 | let params = HashMap::new(); 127 | super::call(service, "ajaxSpider", "view", "optionReloadWait", params) 128 | } 129 | 130 | /** 131 | * This component is optional and therefore the API will only work if it is installed 132 | */ 133 | pub fn option_click_default_elems(service: &ZapService) -> Result { 134 | let params = HashMap::new(); 135 | super::call( 136 | service, 137 | "ajaxSpider", 138 | "view", 139 | "optionClickDefaultElems", 140 | params, 141 | ) 142 | } 143 | 144 | /** 145 | * This component is optional and therefore the API will only work if it is installed 146 | */ 147 | pub fn option_click_elems_once(service: &ZapService) -> Result { 148 | let params = HashMap::new(); 149 | super::call( 150 | service, 151 | "ajaxSpider", 152 | "view", 153 | "optionClickElemsOnce", 154 | params, 155 | ) 156 | } 157 | 158 | /** 159 | * This component is optional and therefore the API will only work if it is installed 160 | */ 161 | pub fn option_random_inputs(service: &ZapService) -> Result { 162 | let params = HashMap::new(); 163 | super::call(service, "ajaxSpider", "view", "optionRandomInputs", params) 164 | } 165 | 166 | /** 167 | * Runs the spider against the given URL and/or context, optionally, spidering everything in scope. The parameter 'contextName' can be used to constrain the scan to a Context, the option 'in scope' is ignored if a context was also specified. The parameter 'subtreeOnly' allows to restrict the spider under a site's subtree (using the specified 'url'). 168 | *

169 | * This component is optional and therefore the API will only work if it is installed 170 | */ 171 | pub fn scan( 172 | service: &ZapService, 173 | url: String, 174 | inscope: String, 175 | contextname: String, 176 | subtreeonly: String, 177 | ) -> Result { 178 | let mut params = HashMap::new(); 179 | params.insert("url".to_string(), url); 180 | params.insert("inScope".to_string(), inscope); 181 | params.insert("contextName".to_string(), contextname); 182 | params.insert("subtreeOnly".to_string(), subtreeonly); 183 | super::call(service, "ajaxSpider", "action", "scan", params) 184 | } 185 | 186 | /** 187 | * Runs the spider from the perspective of a User, obtained using the given context name and user name. The parameter 'url' allows to specify the starting point for the spider, otherwise it's used an existing URL from the context (if any). The parameter 'subtreeOnly' allows to restrict the spider under a site's subtree (using the specified 'url'). 188 | *

189 | * This component is optional and therefore the API will only work if it is installed 190 | */ 191 | pub fn scan_as_user( 192 | service: &ZapService, 193 | contextname: String, 194 | username: String, 195 | url: String, 196 | subtreeonly: String, 197 | ) -> Result { 198 | let mut params = HashMap::new(); 199 | params.insert("contextName".to_string(), contextname); 200 | params.insert("userName".to_string(), username); 201 | params.insert("url".to_string(), url); 202 | params.insert("subtreeOnly".to_string(), subtreeonly); 203 | super::call(service, "ajaxSpider", "action", "scanAsUser", params) 204 | } 205 | 206 | /** 207 | * This component is optional and therefore the API will only work if it is installed 208 | */ 209 | pub fn stop(service: &ZapService) -> Result { 210 | let params = HashMap::new(); 211 | super::call(service, "ajaxSpider", "action", "stop", params) 212 | } 213 | 214 | /** 215 | * This component is optional and therefore the API will only work if it is installed 216 | */ 217 | pub fn set_option_browser_id(service: &ZapService, string: String) -> Result { 218 | let mut params = HashMap::new(); 219 | params.insert("String".to_string(), string); 220 | super::call( 221 | service, 222 | "ajaxSpider", 223 | "action", 224 | "setOptionBrowserId", 225 | params, 226 | ) 227 | } 228 | 229 | /** 230 | * This component is optional and therefore the API will only work if it is installed 231 | */ 232 | pub fn set_option_click_default_elems( 233 | service: &ZapService, 234 | boolean: String, 235 | ) -> Result { 236 | let mut params = HashMap::new(); 237 | params.insert("Boolean".to_string(), boolean); 238 | super::call( 239 | service, 240 | "ajaxSpider", 241 | "action", 242 | "setOptionClickDefaultElems", 243 | params, 244 | ) 245 | } 246 | 247 | /** 248 | * This component is optional and therefore the API will only work if it is installed 249 | */ 250 | pub fn set_option_click_elems_once( 251 | service: &ZapService, 252 | boolean: String, 253 | ) -> Result { 254 | let mut params = HashMap::new(); 255 | params.insert("Boolean".to_string(), boolean); 256 | super::call( 257 | service, 258 | "ajaxSpider", 259 | "action", 260 | "setOptionClickElemsOnce", 261 | params, 262 | ) 263 | } 264 | 265 | /** 266 | * This component is optional and therefore the API will only work if it is installed 267 | */ 268 | pub fn set_option_event_wait(service: &ZapService, integer: String) -> Result { 269 | let mut params = HashMap::new(); 270 | params.insert("Integer".to_string(), integer); 271 | super::call( 272 | service, 273 | "ajaxSpider", 274 | "action", 275 | "setOptionEventWait", 276 | params, 277 | ) 278 | } 279 | 280 | /** 281 | * This component is optional and therefore the API will only work if it is installed 282 | */ 283 | pub fn set_option_max_crawl_depth( 284 | service: &ZapService, 285 | integer: String, 286 | ) -> Result { 287 | let mut params = HashMap::new(); 288 | params.insert("Integer".to_string(), integer); 289 | super::call( 290 | service, 291 | "ajaxSpider", 292 | "action", 293 | "setOptionMaxCrawlDepth", 294 | params, 295 | ) 296 | } 297 | 298 | /** 299 | * This component is optional and therefore the API will only work if it is installed 300 | */ 301 | pub fn set_option_max_crawl_states( 302 | service: &ZapService, 303 | integer: String, 304 | ) -> Result { 305 | let mut params = HashMap::new(); 306 | params.insert("Integer".to_string(), integer); 307 | super::call( 308 | service, 309 | "ajaxSpider", 310 | "action", 311 | "setOptionMaxCrawlStates", 312 | params, 313 | ) 314 | } 315 | 316 | /** 317 | * This component is optional and therefore the API will only work if it is installed 318 | */ 319 | pub fn set_option_max_duration( 320 | service: &ZapService, 321 | integer: String, 322 | ) -> Result { 323 | let mut params = HashMap::new(); 324 | params.insert("Integer".to_string(), integer); 325 | super::call( 326 | service, 327 | "ajaxSpider", 328 | "action", 329 | "setOptionMaxDuration", 330 | params, 331 | ) 332 | } 333 | 334 | /** 335 | * This component is optional and therefore the API will only work if it is installed 336 | */ 337 | pub fn set_option_number_of_browsers( 338 | service: &ZapService, 339 | integer: String, 340 | ) -> Result { 341 | let mut params = HashMap::new(); 342 | params.insert("Integer".to_string(), integer); 343 | super::call( 344 | service, 345 | "ajaxSpider", 346 | "action", 347 | "setOptionNumberOfBrowsers", 348 | params, 349 | ) 350 | } 351 | 352 | /** 353 | * This component is optional and therefore the API will only work if it is installed 354 | */ 355 | pub fn set_option_random_inputs( 356 | service: &ZapService, 357 | boolean: String, 358 | ) -> Result { 359 | let mut params = HashMap::new(); 360 | params.insert("Boolean".to_string(), boolean); 361 | super::call( 362 | service, 363 | "ajaxSpider", 364 | "action", 365 | "setOptionRandomInputs", 366 | params, 367 | ) 368 | } 369 | 370 | /** 371 | * This component is optional and therefore the API will only work if it is installed 372 | */ 373 | pub fn set_option_reload_wait(service: &ZapService, integer: String) -> Result { 374 | let mut params = HashMap::new(); 375 | params.insert("Integer".to_string(), integer); 376 | super::call( 377 | service, 378 | "ajaxSpider", 379 | "action", 380 | "setOptionReloadWait", 381 | params, 382 | ) 383 | } 384 | -------------------------------------------------------------------------------- /src/alert.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Gets the alert with the given ID, the corresponding HTTP message can be obtained with the 'messageId' field and 'message' API method 30 | */ 31 | pub fn alert(service: &ZapService, id: String) -> Result { 32 | let mut params = HashMap::new(); 33 | params.insert("id".to_string(), id); 34 | super::call(service, "alert", "view", "alert", params) 35 | } 36 | 37 | /** 38 | * Gets the alerts raised by ZAP, optionally filtering by URL or riskId, and paginating with 'start' position and 'count' of alerts 39 | */ 40 | pub fn alerts( 41 | service: &ZapService, 42 | baseurl: String, 43 | start: String, 44 | count: String, 45 | riskid: String, 46 | ) -> Result { 47 | let mut params = HashMap::new(); 48 | params.insert("baseurl".to_string(), baseurl); 49 | params.insert("start".to_string(), start); 50 | params.insert("count".to_string(), count); 51 | params.insert("riskId".to_string(), riskid); 52 | super::call(service, "alert", "view", "alerts", params) 53 | } 54 | 55 | /** 56 | * Gets number of alerts grouped by each risk level, optionally filtering by URL 57 | */ 58 | pub fn alerts_summary(service: &ZapService, baseurl: String) -> Result { 59 | let mut params = HashMap::new(); 60 | params.insert("baseurl".to_string(), baseurl); 61 | super::call(service, "alert", "view", "alertsSummary", params) 62 | } 63 | 64 | /** 65 | * Gets the number of alerts, optionally filtering by URL or riskId 66 | */ 67 | pub fn number_of_alerts( 68 | service: &ZapService, 69 | baseurl: String, 70 | riskid: String, 71 | ) -> Result { 72 | let mut params = HashMap::new(); 73 | params.insert("baseurl".to_string(), baseurl); 74 | params.insert("riskId".to_string(), riskid); 75 | super::call(service, "alert", "view", "numberOfAlerts", params) 76 | } 77 | 78 | /** 79 | * Gets a summary of the alerts, optionally filtered by a 'url'. If 'recurse' is true then all alerts that apply to urls that start with the specified 'url' will be returned, otherwise only those on exactly the same 'url' (ignoring url parameters) 80 | */ 81 | pub fn alerts_by_risk( 82 | service: &ZapService, 83 | url: String, 84 | recurse: String, 85 | ) -> Result { 86 | let mut params = HashMap::new(); 87 | params.insert("url".to_string(), url); 88 | params.insert("recurse".to_string(), recurse); 89 | super::call(service, "alert", "view", "alertsByRisk", params) 90 | } 91 | 92 | /** 93 | * Gets a count of the alerts, optionally filtered as per alertsPerRisk 94 | */ 95 | pub fn alert_counts_by_risk( 96 | service: &ZapService, 97 | url: String, 98 | recurse: String, 99 | ) -> Result { 100 | let mut params = HashMap::new(); 101 | params.insert("url".to_string(), url); 102 | params.insert("recurse".to_string(), recurse); 103 | super::call(service, "alert", "view", "alertCountsByRisk", params) 104 | } 105 | 106 | /** 107 | * Deletes all alerts of the current session. 108 | */ 109 | pub fn delete_all_alerts(service: &ZapService) -> Result { 110 | let params = HashMap::new(); 111 | super::call(service, "alert", "action", "deleteAllAlerts", params) 112 | } 113 | 114 | /** 115 | * Deletes the alert with the given ID. 116 | */ 117 | pub fn delete_alert(service: &ZapService, id: String) -> Result { 118 | let mut params = HashMap::new(); 119 | params.insert("id".to_string(), id); 120 | super::call(service, "alert", "action", "deleteAlert", params) 121 | } 122 | -------------------------------------------------------------------------------- /src/alert_filter.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Lists the alert filters of the context with the given ID. 30 | *

31 | * This component is optional and therefore the API will only work if it is installed 32 | */ 33 | pub fn alert_filter_list(service: &ZapService, contextid: String) -> Result { 34 | let mut params = HashMap::new(); 35 | params.insert("contextId".to_string(), contextid); 36 | super::call(service, "alertFilter", "view", "alertFilterList", params) 37 | } 38 | 39 | /** 40 | * Adds a new alert filter for the context with the given ID. 41 | *

42 | * This component is optional and therefore the API will only work if it is installed 43 | */ 44 | #[allow(clippy::too_many_arguments)] 45 | pub fn add_alert_filter( 46 | service: &ZapService, 47 | contextid: String, 48 | ruleid: String, 49 | newlevel: String, 50 | url: String, 51 | urlisregex: String, 52 | parameter: String, 53 | enabled: String, 54 | ) -> Result { 55 | let mut params = HashMap::new(); 56 | params.insert("contextId".to_string(), contextid); 57 | params.insert("ruleId".to_string(), ruleid); 58 | params.insert("newLevel".to_string(), newlevel); 59 | params.insert("url".to_string(), url); 60 | params.insert("urlIsRegex".to_string(), urlisregex); 61 | params.insert("parameter".to_string(), parameter); 62 | params.insert("enabled".to_string(), enabled); 63 | super::call(service, "alertFilter", "action", "addAlertFilter", params) 64 | } 65 | 66 | /** 67 | * Removes an alert filter from the context with the given ID. 68 | *

69 | * This component is optional and therefore the API will only work if it is installed 70 | */ 71 | #[allow(clippy::too_many_arguments)] 72 | pub fn remove_alert_filter( 73 | service: &ZapService, 74 | contextid: String, 75 | ruleid: String, 76 | newlevel: String, 77 | url: String, 78 | urlisregex: String, 79 | parameter: String, 80 | enabled: String, 81 | ) -> Result { 82 | let mut params = HashMap::new(); 83 | params.insert("contextId".to_string(), contextid); 84 | params.insert("ruleId".to_string(), ruleid); 85 | params.insert("newLevel".to_string(), newlevel); 86 | params.insert("url".to_string(), url); 87 | params.insert("urlIsRegex".to_string(), urlisregex); 88 | params.insert("parameter".to_string(), parameter); 89 | params.insert("enabled".to_string(), enabled); 90 | super::call( 91 | service, 92 | "alertFilter", 93 | "action", 94 | "removeAlertFilter", 95 | params, 96 | ) 97 | } 98 | -------------------------------------------------------------------------------- /src/ascan.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | pub fn status(service: &ZapService, scanid: String) -> Result { 29 | let mut params = HashMap::new(); 30 | params.insert("scanId".to_string(), scanid); 31 | super::call(service, "ascan", "view", "status", params) 32 | } 33 | 34 | pub fn scan_progress(service: &ZapService, scanid: String) -> Result { 35 | let mut params = HashMap::new(); 36 | params.insert("scanId".to_string(), scanid); 37 | super::call(service, "ascan", "view", "scanProgress", params) 38 | } 39 | 40 | /** 41 | * Gets the IDs of the messages sent during the scan with the given ID. A message can be obtained with 'message' core view. 42 | */ 43 | pub fn messages_ids(service: &ZapService, scanid: String) -> Result { 44 | let mut params = HashMap::new(); 45 | params.insert("scanId".to_string(), scanid); 46 | super::call(service, "ascan", "view", "messagesIds", params) 47 | } 48 | 49 | /** 50 | * Gets the IDs of the alerts raised during the scan with the given ID. An alert can be obtained with 'alert' core view. 51 | */ 52 | pub fn alerts_ids(service: &ZapService, scanid: String) -> Result { 53 | let mut params = HashMap::new(); 54 | params.insert("scanId".to_string(), scanid); 55 | super::call(service, "ascan", "view", "alertsIds", params) 56 | } 57 | 58 | pub fn scans(service: &ZapService) -> Result { 59 | let params = HashMap::new(); 60 | super::call(service, "ascan", "view", "scans", params) 61 | } 62 | 63 | pub fn scan_policy_names(service: &ZapService) -> Result { 64 | let params = HashMap::new(); 65 | super::call(service, "ascan", "view", "scanPolicyNames", params) 66 | } 67 | 68 | /** 69 | * Gets the regexes of URLs excluded from the active scans. 70 | */ 71 | pub fn excluded_from_scan(service: &ZapService) -> Result { 72 | let params = HashMap::new(); 73 | super::call(service, "ascan", "view", "excludedFromScan", params) 74 | } 75 | 76 | /** 77 | * Gets the scanners, optionally, of the given scan policy and/or scanner policy/category ID. 78 | */ 79 | pub fn scanners( 80 | service: &ZapService, 81 | scanpolicyname: String, 82 | policyid: String, 83 | ) -> Result { 84 | let mut params = HashMap::new(); 85 | params.insert("scanPolicyName".to_string(), scanpolicyname); 86 | params.insert("policyId".to_string(), policyid); 87 | super::call(service, "ascan", "view", "scanners", params) 88 | } 89 | 90 | pub fn policies( 91 | service: &ZapService, 92 | scanpolicyname: String, 93 | policyid: String, 94 | ) -> Result { 95 | let mut params = HashMap::new(); 96 | params.insert("scanPolicyName".to_string(), scanpolicyname); 97 | params.insert("policyId".to_string(), policyid); 98 | super::call(service, "ascan", "view", "policies", params) 99 | } 100 | 101 | pub fn attack_mode_queue(service: &ZapService) -> Result { 102 | let params = HashMap::new(); 103 | super::call(service, "ascan", "view", "attackModeQueue", params) 104 | } 105 | 106 | /** 107 | * Gets all the parameters that are excluded. For each parameter the following are shown: the name, the URL, and the parameter type. 108 | */ 109 | pub fn excluded_params(service: &ZapService) -> Result { 110 | let params = HashMap::new(); 111 | super::call(service, "ascan", "view", "excludedParams", params) 112 | } 113 | 114 | /** 115 | * Use view excludedParams instead. 116 | * Deprecated 117 | */ 118 | pub fn option_excluded_param_list(service: &ZapService) -> Result { 119 | let params = HashMap::new(); 120 | super::call(service, "ascan", "view", "optionExcludedParamList", params) 121 | } 122 | 123 | /** 124 | * Gets all the types of excluded parameters. For each type the following are shown: the ID and the name. 125 | */ 126 | pub fn excluded_param_types(service: &ZapService) -> Result { 127 | let params = HashMap::new(); 128 | super::call(service, "ascan", "view", "excludedParamTypes", params) 129 | } 130 | 131 | pub fn option_attack_policy(service: &ZapService) -> Result { 132 | let params = HashMap::new(); 133 | super::call(service, "ascan", "view", "optionAttackPolicy", params) 134 | } 135 | 136 | pub fn option_default_policy(service: &ZapService) -> Result { 137 | let params = HashMap::new(); 138 | super::call(service, "ascan", "view", "optionDefaultPolicy", params) 139 | } 140 | 141 | pub fn option_delay_in_ms(service: &ZapService) -> Result { 142 | let params = HashMap::new(); 143 | super::call(service, "ascan", "view", "optionDelayInMs", params) 144 | } 145 | 146 | pub fn option_handle_anti_csrf_tokens(service: &ZapService) -> Result { 147 | let params = HashMap::new(); 148 | super::call( 149 | service, 150 | "ascan", 151 | "view", 152 | "optionHandleAntiCSRFTokens", 153 | params, 154 | ) 155 | } 156 | 157 | pub fn option_host_per_scan(service: &ZapService) -> Result { 158 | let params = HashMap::new(); 159 | super::call(service, "ascan", "view", "optionHostPerScan", params) 160 | } 161 | 162 | pub fn option_max_chart_time_in_mins(service: &ZapService) -> Result { 163 | let params = HashMap::new(); 164 | super::call(service, "ascan", "view", "optionMaxChartTimeInMins", params) 165 | } 166 | 167 | pub fn option_max_results_to_list(service: &ZapService) -> Result { 168 | let params = HashMap::new(); 169 | super::call(service, "ascan", "view", "optionMaxResultsToList", params) 170 | } 171 | 172 | pub fn option_max_rule_duration_in_mins(service: &ZapService) -> Result { 173 | let params = HashMap::new(); 174 | super::call( 175 | service, 176 | "ascan", 177 | "view", 178 | "optionMaxRuleDurationInMins", 179 | params, 180 | ) 181 | } 182 | 183 | pub fn option_max_scan_duration_in_mins(service: &ZapService) -> Result { 184 | let params = HashMap::new(); 185 | super::call( 186 | service, 187 | "ascan", 188 | "view", 189 | "optionMaxScanDurationInMins", 190 | params, 191 | ) 192 | } 193 | 194 | pub fn option_max_scans_in_ui(service: &ZapService) -> Result { 195 | let params = HashMap::new(); 196 | super::call(service, "ascan", "view", "optionMaxScansInUI", params) 197 | } 198 | 199 | pub fn option_target_params_enabled_rpc(service: &ZapService) -> Result { 200 | let params = HashMap::new(); 201 | super::call( 202 | service, 203 | "ascan", 204 | "view", 205 | "optionTargetParamsEnabledRPC", 206 | params, 207 | ) 208 | } 209 | 210 | pub fn option_target_params_injectable(service: &ZapService) -> Result { 211 | let params = HashMap::new(); 212 | super::call( 213 | service, 214 | "ascan", 215 | "view", 216 | "optionTargetParamsInjectable", 217 | params, 218 | ) 219 | } 220 | 221 | pub fn option_thread_per_host(service: &ZapService) -> Result { 222 | let params = HashMap::new(); 223 | super::call(service, "ascan", "view", "optionThreadPerHost", params) 224 | } 225 | 226 | /** 227 | * Tells whether or not the active scanner should add a query parameter to GET request that don't have parameters to start with. 228 | */ 229 | pub fn option_add_query_param(service: &ZapService) -> Result { 230 | let params = HashMap::new(); 231 | super::call(service, "ascan", "view", "optionAddQueryParam", params) 232 | } 233 | 234 | pub fn option_allow_attack_on_start(service: &ZapService) -> Result { 235 | let params = HashMap::new(); 236 | super::call(service, "ascan", "view", "optionAllowAttackOnStart", params) 237 | } 238 | 239 | /** 240 | * Tells whether or not the active scanner should inject the HTTP request header X-ZAP-Scan-ID, with the ID of the scanner that's sending the requests. 241 | */ 242 | pub fn option_inject_plugin_id_in_header(service: &ZapService) -> Result { 243 | let params = HashMap::new(); 244 | super::call( 245 | service, 246 | "ascan", 247 | "view", 248 | "optionInjectPluginIdInHeader", 249 | params, 250 | ) 251 | } 252 | 253 | pub fn option_prompt_in_attack_mode(service: &ZapService) -> Result { 254 | let params = HashMap::new(); 255 | super::call(service, "ascan", "view", "optionPromptInAttackMode", params) 256 | } 257 | 258 | pub fn option_prompt_to_clear_finished_scans(service: &ZapService) -> Result { 259 | let params = HashMap::new(); 260 | super::call( 261 | service, 262 | "ascan", 263 | "view", 264 | "optionPromptToClearFinishedScans", 265 | params, 266 | ) 267 | } 268 | 269 | pub fn option_rescan_in_attack_mode(service: &ZapService) -> Result { 270 | let params = HashMap::new(); 271 | super::call(service, "ascan", "view", "optionRescanInAttackMode", params) 272 | } 273 | 274 | /** 275 | * Tells whether or not the HTTP Headers of all requests should be scanned. Not just requests that send parameters, through the query or request body. 276 | */ 277 | pub fn option_scan_headers_all_requests(service: &ZapService) -> Result { 278 | let params = HashMap::new(); 279 | super::call( 280 | service, 281 | "ascan", 282 | "view", 283 | "optionScanHeadersAllRequests", 284 | params, 285 | ) 286 | } 287 | 288 | pub fn option_show_advanced_dialog(service: &ZapService) -> Result { 289 | let params = HashMap::new(); 290 | super::call(service, "ascan", "view", "optionShowAdvancedDialog", params) 291 | } 292 | 293 | /** 294 | * Runs the active scanner against the given URL and/or Context. Optionally, the 'recurse' parameter can be used to scan URLs under the given URL, the parameter 'inScopeOnly' can be used to constrain the scan to URLs that are in scope (ignored if a Context is specified), the parameter 'scanPolicyName' allows to specify the scan policy (if none is given it uses the default scan policy), the parameters 'method' and 'postData' allow to select a given request in conjunction with the given URL. 295 | */ 296 | #[allow(clippy::too_many_arguments)] 297 | pub fn scan( 298 | service: &ZapService, 299 | url: String, 300 | recurse: String, 301 | inscopeonly: String, 302 | scanpolicyname: String, 303 | method: String, 304 | postdata: String, 305 | contextid: String, 306 | ) -> Result { 307 | let mut params = HashMap::new(); 308 | params.insert("url".to_string(), url); 309 | params.insert("recurse".to_string(), recurse); 310 | params.insert("inScopeOnly".to_string(), inscopeonly); 311 | params.insert("scanPolicyName".to_string(), scanpolicyname); 312 | params.insert("method".to_string(), method); 313 | params.insert("postData".to_string(), postdata); 314 | params.insert("contextId".to_string(), contextid); 315 | super::call(service, "ascan", "action", "scan", params) 316 | } 317 | 318 | /** 319 | * Active Scans from the perspective of a User, obtained using the given Context ID and User ID. See 'scan' action for more details. 320 | */ 321 | #[allow(clippy::too_many_arguments)] 322 | pub fn scan_as_user( 323 | service: &ZapService, 324 | url: String, 325 | contextid: String, 326 | userid: String, 327 | recurse: String, 328 | scanpolicyname: String, 329 | method: String, 330 | postdata: String, 331 | ) -> Result { 332 | let mut params = HashMap::new(); 333 | params.insert("url".to_string(), url); 334 | params.insert("contextId".to_string(), contextid); 335 | params.insert("userId".to_string(), userid); 336 | params.insert("recurse".to_string(), recurse); 337 | params.insert("scanPolicyName".to_string(), scanpolicyname); 338 | params.insert("method".to_string(), method); 339 | params.insert("postData".to_string(), postdata); 340 | super::call(service, "ascan", "action", "scanAsUser", params) 341 | } 342 | 343 | pub fn pause(service: &ZapService, scanid: String) -> Result { 344 | let mut params = HashMap::new(); 345 | params.insert("scanId".to_string(), scanid); 346 | super::call(service, "ascan", "action", "pause", params) 347 | } 348 | 349 | pub fn resume(service: &ZapService, scanid: String) -> Result { 350 | let mut params = HashMap::new(); 351 | params.insert("scanId".to_string(), scanid); 352 | super::call(service, "ascan", "action", "resume", params) 353 | } 354 | 355 | pub fn stop(service: &ZapService, scanid: String) -> Result { 356 | let mut params = HashMap::new(); 357 | params.insert("scanId".to_string(), scanid); 358 | super::call(service, "ascan", "action", "stop", params) 359 | } 360 | 361 | pub fn remove_scan(service: &ZapService, scanid: String) -> Result { 362 | let mut params = HashMap::new(); 363 | params.insert("scanId".to_string(), scanid); 364 | super::call(service, "ascan", "action", "removeScan", params) 365 | } 366 | 367 | pub fn pause_all_scans(service: &ZapService) -> Result { 368 | let params = HashMap::new(); 369 | super::call(service, "ascan", "action", "pauseAllScans", params) 370 | } 371 | 372 | pub fn resume_all_scans(service: &ZapService) -> Result { 373 | let params = HashMap::new(); 374 | super::call(service, "ascan", "action", "resumeAllScans", params) 375 | } 376 | 377 | pub fn stop_all_scans(service: &ZapService) -> Result { 378 | let params = HashMap::new(); 379 | super::call(service, "ascan", "action", "stopAllScans", params) 380 | } 381 | 382 | pub fn remove_all_scans(service: &ZapService) -> Result { 383 | let params = HashMap::new(); 384 | super::call(service, "ascan", "action", "removeAllScans", params) 385 | } 386 | 387 | /** 388 | * Clears the regexes of URLs excluded from the active scans. 389 | */ 390 | pub fn clear_excluded_from_scan(service: &ZapService) -> Result { 391 | let params = HashMap::new(); 392 | super::call(service, "ascan", "action", "clearExcludedFromScan", params) 393 | } 394 | 395 | /** 396 | * Adds a regex of URLs that should be excluded from the active scans. 397 | */ 398 | pub fn exclude_from_scan(service: &ZapService, regex: String) -> Result { 399 | let mut params = HashMap::new(); 400 | params.insert("regex".to_string(), regex); 401 | super::call(service, "ascan", "action", "excludeFromScan", params) 402 | } 403 | 404 | /** 405 | * Enables all scanners of the scan policy with the given name, or the default if none given. 406 | */ 407 | pub fn enable_all_scanners( 408 | service: &ZapService, 409 | scanpolicyname: String, 410 | ) -> Result { 411 | let mut params = HashMap::new(); 412 | params.insert("scanPolicyName".to_string(), scanpolicyname); 413 | super::call(service, "ascan", "action", "enableAllScanners", params) 414 | } 415 | 416 | /** 417 | * Disables all scanners of the scan policy with the given name, or the default if none given. 418 | */ 419 | pub fn disable_all_scanners( 420 | service: &ZapService, 421 | scanpolicyname: String, 422 | ) -> Result { 423 | let mut params = HashMap::new(); 424 | params.insert("scanPolicyName".to_string(), scanpolicyname); 425 | super::call(service, "ascan", "action", "disableAllScanners", params) 426 | } 427 | 428 | /** 429 | * Enables the scanners with the given IDs (comma separated list of IDs) of the scan policy with the given name, or the default if none given. 430 | */ 431 | pub fn enable_scanners( 432 | service: &ZapService, 433 | ids: String, 434 | scanpolicyname: String, 435 | ) -> Result { 436 | let mut params = HashMap::new(); 437 | params.insert("ids".to_string(), ids); 438 | params.insert("scanPolicyName".to_string(), scanpolicyname); 439 | super::call(service, "ascan", "action", "enableScanners", params) 440 | } 441 | 442 | /** 443 | * Disables the scanners with the given IDs (comma separated list of IDs) of the scan policy with the given name, or the default if none given. 444 | */ 445 | pub fn disable_scanners( 446 | service: &ZapService, 447 | ids: String, 448 | scanpolicyname: String, 449 | ) -> Result { 450 | let mut params = HashMap::new(); 451 | params.insert("ids".to_string(), ids); 452 | params.insert("scanPolicyName".to_string(), scanpolicyname); 453 | super::call(service, "ascan", "action", "disableScanners", params) 454 | } 455 | 456 | pub fn set_enabled_policies( 457 | service: &ZapService, 458 | ids: String, 459 | scanpolicyname: String, 460 | ) -> Result { 461 | let mut params = HashMap::new(); 462 | params.insert("ids".to_string(), ids); 463 | params.insert("scanPolicyName".to_string(), scanpolicyname); 464 | super::call(service, "ascan", "action", "setEnabledPolicies", params) 465 | } 466 | 467 | pub fn set_policy_attack_strength( 468 | service: &ZapService, 469 | id: String, 470 | attackstrength: String, 471 | scanpolicyname: String, 472 | ) -> Result { 473 | let mut params = HashMap::new(); 474 | params.insert("id".to_string(), id); 475 | params.insert("attackStrength".to_string(), attackstrength); 476 | params.insert("scanPolicyName".to_string(), scanpolicyname); 477 | super::call( 478 | service, 479 | "ascan", 480 | "action", 481 | "setPolicyAttackStrength", 482 | params, 483 | ) 484 | } 485 | 486 | pub fn set_policy_alert_threshold( 487 | service: &ZapService, 488 | id: String, 489 | alertthreshold: String, 490 | scanpolicyname: String, 491 | ) -> Result { 492 | let mut params = HashMap::new(); 493 | params.insert("id".to_string(), id); 494 | params.insert("alertThreshold".to_string(), alertthreshold); 495 | params.insert("scanPolicyName".to_string(), scanpolicyname); 496 | super::call( 497 | service, 498 | "ascan", 499 | "action", 500 | "setPolicyAlertThreshold", 501 | params, 502 | ) 503 | } 504 | 505 | pub fn set_scanner_attack_strength( 506 | service: &ZapService, 507 | id: String, 508 | attackstrength: String, 509 | scanpolicyname: String, 510 | ) -> Result { 511 | let mut params = HashMap::new(); 512 | params.insert("id".to_string(), id); 513 | params.insert("attackStrength".to_string(), attackstrength); 514 | params.insert("scanPolicyName".to_string(), scanpolicyname); 515 | super::call( 516 | service, 517 | "ascan", 518 | "action", 519 | "setScannerAttackStrength", 520 | params, 521 | ) 522 | } 523 | 524 | pub fn set_scanner_alert_threshold( 525 | service: &ZapService, 526 | id: String, 527 | alertthreshold: String, 528 | scanpolicyname: String, 529 | ) -> Result { 530 | let mut params = HashMap::new(); 531 | params.insert("id".to_string(), id); 532 | params.insert("alertThreshold".to_string(), alertthreshold); 533 | params.insert("scanPolicyName".to_string(), scanpolicyname); 534 | super::call( 535 | service, 536 | "ascan", 537 | "action", 538 | "setScannerAlertThreshold", 539 | params, 540 | ) 541 | } 542 | 543 | pub fn add_scan_policy( 544 | service: &ZapService, 545 | scanpolicyname: String, 546 | alertthreshold: String, 547 | attackstrength: String, 548 | ) -> Result { 549 | let mut params = HashMap::new(); 550 | params.insert("scanPolicyName".to_string(), scanpolicyname); 551 | params.insert("alertThreshold".to_string(), alertthreshold); 552 | params.insert("attackStrength".to_string(), attackstrength); 553 | super::call(service, "ascan", "action", "addScanPolicy", params) 554 | } 555 | 556 | pub fn remove_scan_policy( 557 | service: &ZapService, 558 | scanpolicyname: String, 559 | ) -> Result { 560 | let mut params = HashMap::new(); 561 | params.insert("scanPolicyName".to_string(), scanpolicyname); 562 | super::call(service, "ascan", "action", "removeScanPolicy", params) 563 | } 564 | 565 | pub fn update_scan_policy( 566 | service: &ZapService, 567 | scanpolicyname: String, 568 | alertthreshold: String, 569 | attackstrength: String, 570 | ) -> Result { 571 | let mut params = HashMap::new(); 572 | params.insert("scanPolicyName".to_string(), scanpolicyname); 573 | params.insert("alertThreshold".to_string(), alertthreshold); 574 | params.insert("attackStrength".to_string(), attackstrength); 575 | super::call(service, "ascan", "action", "updateScanPolicy", params) 576 | } 577 | 578 | /** 579 | * Imports a Scan Policy using the given file system path. 580 | */ 581 | pub fn import_scan_policy(service: &ZapService, path: String) -> Result { 582 | let mut params = HashMap::new(); 583 | params.insert("path".to_string(), path); 584 | super::call(service, "ascan", "action", "importScanPolicy", params) 585 | } 586 | 587 | /** 588 | * Adds a new parameter excluded from the scan, using the specified name. Optionally sets if the new entry applies to a specific URL (default, all URLs) and sets the ID of the type of the parameter (default, ID of any type). The type IDs can be obtained with the view excludedParamTypes. 589 | */ 590 | pub fn add_excluded_param( 591 | service: &ZapService, 592 | name: String, 593 | typ: String, 594 | url: String, 595 | ) -> Result { 596 | let mut params = HashMap::new(); 597 | params.insert("name".to_string(), name); 598 | params.insert("type".to_string(), typ); 599 | params.insert("url".to_string(), url); 600 | super::call(service, "ascan", "action", "addExcludedParam", params) 601 | } 602 | 603 | /** 604 | * Modifies a parameter excluded from the scan. Allows to modify the name, the URL and the type of parameter. The parameter is selected with its index, which can be obtained with the view excludedParams. 605 | */ 606 | pub fn modify_excluded_param( 607 | service: &ZapService, 608 | idx: String, 609 | name: String, 610 | typ: String, 611 | url: String, 612 | ) -> Result { 613 | let mut params = HashMap::new(); 614 | params.insert("idx".to_string(), idx); 615 | params.insert("name".to_string(), name); 616 | params.insert("type".to_string(), typ); 617 | params.insert("url".to_string(), url); 618 | super::call(service, "ascan", "action", "modifyExcludedParam", params) 619 | } 620 | 621 | /** 622 | * Removes a parameter excluded from the scan, with the given index. The index can be obtained with the view excludedParams. 623 | */ 624 | pub fn remove_excluded_param(service: &ZapService, idx: String) -> Result { 625 | let mut params = HashMap::new(); 626 | params.insert("idx".to_string(), idx); 627 | super::call(service, "ascan", "action", "removeExcludedParam", params) 628 | } 629 | 630 | /** 631 | * Skips the scanner using the given IDs of the scan and the scanner. 632 | */ 633 | pub fn skip_scanner( 634 | service: &ZapService, 635 | scanid: String, 636 | scannerid: String, 637 | ) -> Result { 638 | let mut params = HashMap::new(); 639 | params.insert("scanId".to_string(), scanid); 640 | params.insert("scannerId".to_string(), scannerid); 641 | super::call(service, "ascan", "action", "skipScanner", params) 642 | } 643 | 644 | pub fn set_option_attack_policy( 645 | service: &ZapService, 646 | string: String, 647 | ) -> Result { 648 | let mut params = HashMap::new(); 649 | params.insert("String".to_string(), string); 650 | super::call(service, "ascan", "action", "setOptionAttackPolicy", params) 651 | } 652 | 653 | pub fn set_option_default_policy( 654 | service: &ZapService, 655 | string: String, 656 | ) -> Result { 657 | let mut params = HashMap::new(); 658 | params.insert("String".to_string(), string); 659 | super::call(service, "ascan", "action", "setOptionDefaultPolicy", params) 660 | } 661 | 662 | /** 663 | * Sets whether or not the active scanner should add a query param to GET requests which do not have parameters to start with. 664 | */ 665 | pub fn set_option_add_query_param( 666 | service: &ZapService, 667 | boolean: String, 668 | ) -> Result { 669 | let mut params = HashMap::new(); 670 | params.insert("Boolean".to_string(), boolean); 671 | super::call(service, "ascan", "action", "setOptionAddQueryParam", params) 672 | } 673 | 674 | pub fn set_option_allow_attack_on_start( 675 | service: &ZapService, 676 | boolean: String, 677 | ) -> Result { 678 | let mut params = HashMap::new(); 679 | params.insert("Boolean".to_string(), boolean); 680 | super::call( 681 | service, 682 | "ascan", 683 | "action", 684 | "setOptionAllowAttackOnStart", 685 | params, 686 | ) 687 | } 688 | 689 | pub fn set_option_delay_in_ms(service: &ZapService, integer: String) -> Result { 690 | let mut params = HashMap::new(); 691 | params.insert("Integer".to_string(), integer); 692 | super::call(service, "ascan", "action", "setOptionDelayInMs", params) 693 | } 694 | 695 | pub fn set_option_handle_anti_csrf_tokens( 696 | service: &ZapService, 697 | boolean: String, 698 | ) -> Result { 699 | let mut params = HashMap::new(); 700 | params.insert("Boolean".to_string(), boolean); 701 | super::call( 702 | service, 703 | "ascan", 704 | "action", 705 | "setOptionHandleAntiCSRFTokens", 706 | params, 707 | ) 708 | } 709 | 710 | pub fn set_option_host_per_scan( 711 | service: &ZapService, 712 | integer: String, 713 | ) -> Result { 714 | let mut params = HashMap::new(); 715 | params.insert("Integer".to_string(), integer); 716 | super::call(service, "ascan", "action", "setOptionHostPerScan", params) 717 | } 718 | 719 | /** 720 | * Sets whether or not the active scanner should inject the HTTP request header X-ZAP-Scan-ID, with the ID of the scanner that's sending the requests. 721 | */ 722 | pub fn set_option_inject_plugin_id_in_header( 723 | service: &ZapService, 724 | boolean: String, 725 | ) -> Result { 726 | let mut params = HashMap::new(); 727 | params.insert("Boolean".to_string(), boolean); 728 | super::call( 729 | service, 730 | "ascan", 731 | "action", 732 | "setOptionInjectPluginIdInHeader", 733 | params, 734 | ) 735 | } 736 | 737 | pub fn set_option_max_chart_time_in_mins( 738 | service: &ZapService, 739 | integer: String, 740 | ) -> Result { 741 | let mut params = HashMap::new(); 742 | params.insert("Integer".to_string(), integer); 743 | super::call( 744 | service, 745 | "ascan", 746 | "action", 747 | "setOptionMaxChartTimeInMins", 748 | params, 749 | ) 750 | } 751 | 752 | pub fn set_option_max_results_to_list( 753 | service: &ZapService, 754 | integer: String, 755 | ) -> Result { 756 | let mut params = HashMap::new(); 757 | params.insert("Integer".to_string(), integer); 758 | super::call( 759 | service, 760 | "ascan", 761 | "action", 762 | "setOptionMaxResultsToList", 763 | params, 764 | ) 765 | } 766 | 767 | pub fn set_option_max_rule_duration_in_mins( 768 | service: &ZapService, 769 | integer: String, 770 | ) -> Result { 771 | let mut params = HashMap::new(); 772 | params.insert("Integer".to_string(), integer); 773 | super::call( 774 | service, 775 | "ascan", 776 | "action", 777 | "setOptionMaxRuleDurationInMins", 778 | params, 779 | ) 780 | } 781 | 782 | pub fn set_option_max_scan_duration_in_mins( 783 | service: &ZapService, 784 | integer: String, 785 | ) -> Result { 786 | let mut params = HashMap::new(); 787 | params.insert("Integer".to_string(), integer); 788 | super::call( 789 | service, 790 | "ascan", 791 | "action", 792 | "setOptionMaxScanDurationInMins", 793 | params, 794 | ) 795 | } 796 | 797 | pub fn set_option_max_scans_in_ui( 798 | service: &ZapService, 799 | integer: String, 800 | ) -> Result { 801 | let mut params = HashMap::new(); 802 | params.insert("Integer".to_string(), integer); 803 | super::call(service, "ascan", "action", "setOptionMaxScansInUI", params) 804 | } 805 | 806 | pub fn set_option_prompt_in_attack_mode( 807 | service: &ZapService, 808 | boolean: String, 809 | ) -> Result { 810 | let mut params = HashMap::new(); 811 | params.insert("Boolean".to_string(), boolean); 812 | super::call( 813 | service, 814 | "ascan", 815 | "action", 816 | "setOptionPromptInAttackMode", 817 | params, 818 | ) 819 | } 820 | 821 | pub fn set_option_prompt_to_clear_finished_scans( 822 | service: &ZapService, 823 | boolean: String, 824 | ) -> Result { 825 | let mut params = HashMap::new(); 826 | params.insert("Boolean".to_string(), boolean); 827 | super::call( 828 | service, 829 | "ascan", 830 | "action", 831 | "setOptionPromptToClearFinishedScans", 832 | params, 833 | ) 834 | } 835 | 836 | pub fn set_option_rescan_in_attack_mode( 837 | service: &ZapService, 838 | boolean: String, 839 | ) -> Result { 840 | let mut params = HashMap::new(); 841 | params.insert("Boolean".to_string(), boolean); 842 | super::call( 843 | service, 844 | "ascan", 845 | "action", 846 | "setOptionRescanInAttackMode", 847 | params, 848 | ) 849 | } 850 | 851 | /** 852 | * Sets whether or not the HTTP Headers of all requests should be scanned. Not just requests that send parameters, through the query or request body. 853 | */ 854 | pub fn set_option_scan_headers_all_requests( 855 | service: &ZapService, 856 | boolean: String, 857 | ) -> Result { 858 | let mut params = HashMap::new(); 859 | params.insert("Boolean".to_string(), boolean); 860 | super::call( 861 | service, 862 | "ascan", 863 | "action", 864 | "setOptionScanHeadersAllRequests", 865 | params, 866 | ) 867 | } 868 | 869 | pub fn set_option_show_advanced_dialog( 870 | service: &ZapService, 871 | boolean: String, 872 | ) -> Result { 873 | let mut params = HashMap::new(); 874 | params.insert("Boolean".to_string(), boolean); 875 | super::call( 876 | service, 877 | "ascan", 878 | "action", 879 | "setOptionShowAdvancedDialog", 880 | params, 881 | ) 882 | } 883 | 884 | pub fn set_option_target_params_enabled_rpc( 885 | service: &ZapService, 886 | integer: String, 887 | ) -> Result { 888 | let mut params = HashMap::new(); 889 | params.insert("Integer".to_string(), integer); 890 | super::call( 891 | service, 892 | "ascan", 893 | "action", 894 | "setOptionTargetParamsEnabledRPC", 895 | params, 896 | ) 897 | } 898 | 899 | pub fn set_option_target_params_injectable( 900 | service: &ZapService, 901 | integer: String, 902 | ) -> Result { 903 | let mut params = HashMap::new(); 904 | params.insert("Integer".to_string(), integer); 905 | super::call( 906 | service, 907 | "ascan", 908 | "action", 909 | "setOptionTargetParamsInjectable", 910 | params, 911 | ) 912 | } 913 | 914 | pub fn set_option_thread_per_host( 915 | service: &ZapService, 916 | integer: String, 917 | ) -> Result { 918 | let mut params = HashMap::new(); 919 | params.insert("Integer".to_string(), integer); 920 | super::call(service, "ascan", "action", "setOptionThreadPerHost", params) 921 | } 922 | -------------------------------------------------------------------------------- /src/authentication.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Gets the name of the authentication methods. 30 | */ 31 | pub fn get_supported_authentication_methods(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call( 34 | service, 35 | "authentication", 36 | "view", 37 | "getSupportedAuthenticationMethods", 38 | params, 39 | ) 40 | } 41 | 42 | /** 43 | * Gets the configuration parameters for the authentication method with the given name. 44 | */ 45 | pub fn get_authentication_method_config_params( 46 | service: &ZapService, 47 | authmethodname: String, 48 | ) -> Result { 49 | let mut params = HashMap::new(); 50 | params.insert("authMethodName".to_string(), authmethodname); 51 | super::call( 52 | service, 53 | "authentication", 54 | "view", 55 | "getAuthenticationMethodConfigParams", 56 | params, 57 | ) 58 | } 59 | 60 | /** 61 | * Gets the name of the authentication method for the context with the given ID. 62 | */ 63 | pub fn get_authentication_method( 64 | service: &ZapService, 65 | contextid: String, 66 | ) -> Result { 67 | let mut params = HashMap::new(); 68 | params.insert("contextId".to_string(), contextid); 69 | super::call( 70 | service, 71 | "authentication", 72 | "view", 73 | "getAuthenticationMethod", 74 | params, 75 | ) 76 | } 77 | 78 | /** 79 | * Gets the logged in indicator for the context with the given ID. 80 | */ 81 | pub fn get_logged_in_indicator( 82 | service: &ZapService, 83 | contextid: String, 84 | ) -> Result { 85 | let mut params = HashMap::new(); 86 | params.insert("contextId".to_string(), contextid); 87 | super::call( 88 | service, 89 | "authentication", 90 | "view", 91 | "getLoggedInIndicator", 92 | params, 93 | ) 94 | } 95 | 96 | /** 97 | * Gets the logged out indicator for the context with the given ID. 98 | */ 99 | pub fn get_logged_out_indicator( 100 | service: &ZapService, 101 | contextid: String, 102 | ) -> Result { 103 | let mut params = HashMap::new(); 104 | params.insert("contextId".to_string(), contextid); 105 | super::call( 106 | service, 107 | "authentication", 108 | "view", 109 | "getLoggedOutIndicator", 110 | params, 111 | ) 112 | } 113 | 114 | /** 115 | * Sets the authentication method for the context with the given ID. 116 | */ 117 | pub fn set_authentication_method( 118 | service: &ZapService, 119 | contextid: String, 120 | authmethodname: String, 121 | authmethodconfigparams: String, 122 | ) -> Result { 123 | let mut params = HashMap::new(); 124 | params.insert("contextId".to_string(), contextid); 125 | params.insert("authMethodName".to_string(), authmethodname); 126 | params.insert("authMethodConfigParams".to_string(), authmethodconfigparams); 127 | super::call( 128 | service, 129 | "authentication", 130 | "action", 131 | "setAuthenticationMethod", 132 | params, 133 | ) 134 | } 135 | 136 | /** 137 | * Sets the logged in indicator for the context with the given ID. 138 | */ 139 | pub fn set_logged_in_indicator( 140 | service: &ZapService, 141 | contextid: String, 142 | loggedinindicatorregex: String, 143 | ) -> Result { 144 | let mut params = HashMap::new(); 145 | params.insert("contextId".to_string(), contextid); 146 | params.insert("loggedInIndicatorRegex".to_string(), loggedinindicatorregex); 147 | super::call( 148 | service, 149 | "authentication", 150 | "action", 151 | "setLoggedInIndicator", 152 | params, 153 | ) 154 | } 155 | 156 | /** 157 | * Sets the logged out indicator for the context with the given ID. 158 | */ 159 | pub fn set_logged_out_indicator( 160 | service: &ZapService, 161 | contextid: String, 162 | loggedoutindicatorregex: String, 163 | ) -> Result { 164 | let mut params = HashMap::new(); 165 | params.insert("contextId".to_string(), contextid); 166 | params.insert( 167 | "loggedOutIndicatorRegex".to_string(), 168 | loggedoutindicatorregex, 169 | ); 170 | super::call( 171 | service, 172 | "authentication", 173 | "action", 174 | "setLoggedOutIndicator", 175 | params, 176 | ) 177 | } 178 | -------------------------------------------------------------------------------- /src/authorization.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Obtains all the configuration of the authorization detection method that is currently set for a context. 30 | */ 31 | pub fn get_authorization_detection_method( 32 | service: &ZapService, 33 | contextid: String, 34 | ) -> Result { 35 | let mut params = HashMap::new(); 36 | params.insert("contextId".to_string(), contextid); 37 | super::call( 38 | service, 39 | "authorization", 40 | "view", 41 | "getAuthorizationDetectionMethod", 42 | params, 43 | ) 44 | } 45 | 46 | /** 47 | * Sets the authorization detection method for a context as one that identifies un-authorized messages based on: the message's status code or a regex pattern in the response's header or body. Also, whether all conditions must match or just some can be specified via the logicalOperator parameter, which accepts two values: "AND" (default), "OR". 48 | */ 49 | pub fn set_basic_authorization_detection_method( 50 | service: &ZapService, 51 | contextid: String, 52 | headerregex: String, 53 | bodyregex: String, 54 | statuscode: String, 55 | logicaloperator: String, 56 | ) -> Result { 57 | let mut params = HashMap::new(); 58 | params.insert("contextId".to_string(), contextid); 59 | params.insert("headerRegex".to_string(), headerregex); 60 | params.insert("bodyRegex".to_string(), bodyregex); 61 | params.insert("statusCode".to_string(), statuscode); 62 | params.insert("logicalOperator".to_string(), logicaloperator); 63 | super::call( 64 | service, 65 | "authorization", 66 | "action", 67 | "setBasicAuthorizationDetectionMethod", 68 | params, 69 | ) 70 | } 71 | -------------------------------------------------------------------------------- /src/autoupdate.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Returns the latest version number 30 | */ 31 | pub fn latest_version_number(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call(service, "autoupdate", "view", "latestVersionNumber", params) 34 | } 35 | 36 | /** 37 | * Returns 'true' if ZAP is on the latest version 38 | */ 39 | pub fn is_latest_version(service: &ZapService) -> Result { 40 | let params = HashMap::new(); 41 | super::call(service, "autoupdate", "view", "isLatestVersion", params) 42 | } 43 | 44 | /** 45 | * Return a list of all of the installed add-ons 46 | */ 47 | pub fn installed_addons(service: &ZapService) -> Result { 48 | let params = HashMap::new(); 49 | super::call(service, "autoupdate", "view", "installedAddons", params) 50 | } 51 | 52 | /** 53 | * Returns a list with all local add-ons, installed or not. 54 | */ 55 | pub fn local_addons(service: &ZapService) -> Result { 56 | let params = HashMap::new(); 57 | super::call(service, "autoupdate", "view", "localAddons", params) 58 | } 59 | 60 | /** 61 | * Return a list of any add-ons that have been added to the Marketplace since the last check for updates 62 | */ 63 | pub fn new_addons(service: &ZapService) -> Result { 64 | let params = HashMap::new(); 65 | super::call(service, "autoupdate", "view", "newAddons", params) 66 | } 67 | 68 | /** 69 | * Return a list of any add-ons that have been changed in the Marketplace since the last check for updates 70 | */ 71 | pub fn updated_addons(service: &ZapService) -> Result { 72 | let params = HashMap::new(); 73 | super::call(service, "autoupdate", "view", "updatedAddons", params) 74 | } 75 | 76 | /** 77 | * Return a list of all of the add-ons on the ZAP Marketplace (this information is read once and then cached) 78 | */ 79 | pub fn marketplace_addons(service: &ZapService) -> Result { 80 | let params = HashMap::new(); 81 | super::call(service, "autoupdate", "view", "marketplaceAddons", params) 82 | } 83 | 84 | pub fn option_addon_directories(service: &ZapService) -> Result { 85 | let params = HashMap::new(); 86 | super::call( 87 | service, 88 | "autoupdate", 89 | "view", 90 | "optionAddonDirectories", 91 | params, 92 | ) 93 | } 94 | 95 | pub fn option_day_last_checked(service: &ZapService) -> Result { 96 | let params = HashMap::new(); 97 | super::call( 98 | service, 99 | "autoupdate", 100 | "view", 101 | "optionDayLastChecked", 102 | params, 103 | ) 104 | } 105 | 106 | pub fn option_day_last_install_warned(service: &ZapService) -> Result { 107 | let params = HashMap::new(); 108 | super::call( 109 | service, 110 | "autoupdate", 111 | "view", 112 | "optionDayLastInstallWarned", 113 | params, 114 | ) 115 | } 116 | 117 | pub fn option_day_last_update_warned(service: &ZapService) -> Result { 118 | let params = HashMap::new(); 119 | super::call( 120 | service, 121 | "autoupdate", 122 | "view", 123 | "optionDayLastUpdateWarned", 124 | params, 125 | ) 126 | } 127 | 128 | pub fn option_download_directory(service: &ZapService) -> Result { 129 | let params = HashMap::new(); 130 | super::call( 131 | service, 132 | "autoupdate", 133 | "view", 134 | "optionDownloadDirectory", 135 | params, 136 | ) 137 | } 138 | 139 | pub fn option_check_addon_updates(service: &ZapService) -> Result { 140 | let params = HashMap::new(); 141 | super::call( 142 | service, 143 | "autoupdate", 144 | "view", 145 | "optionCheckAddonUpdates", 146 | params, 147 | ) 148 | } 149 | 150 | pub fn option_check_on_start(service: &ZapService) -> Result { 151 | let params = HashMap::new(); 152 | super::call(service, "autoupdate", "view", "optionCheckOnStart", params) 153 | } 154 | 155 | pub fn option_download_new_release(service: &ZapService) -> Result { 156 | let params = HashMap::new(); 157 | super::call( 158 | service, 159 | "autoupdate", 160 | "view", 161 | "optionDownloadNewRelease", 162 | params, 163 | ) 164 | } 165 | 166 | pub fn option_install_addon_updates(service: &ZapService) -> Result { 167 | let params = HashMap::new(); 168 | super::call( 169 | service, 170 | "autoupdate", 171 | "view", 172 | "optionInstallAddonUpdates", 173 | params, 174 | ) 175 | } 176 | 177 | pub fn option_install_scanner_rules(service: &ZapService) -> Result { 178 | let params = HashMap::new(); 179 | super::call( 180 | service, 181 | "autoupdate", 182 | "view", 183 | "optionInstallScannerRules", 184 | params, 185 | ) 186 | } 187 | 188 | pub fn option_report_alpha_addons(service: &ZapService) -> Result { 189 | let params = HashMap::new(); 190 | super::call( 191 | service, 192 | "autoupdate", 193 | "view", 194 | "optionReportAlphaAddons", 195 | params, 196 | ) 197 | } 198 | 199 | pub fn option_report_beta_addons(service: &ZapService) -> Result { 200 | let params = HashMap::new(); 201 | super::call( 202 | service, 203 | "autoupdate", 204 | "view", 205 | "optionReportBetaAddons", 206 | params, 207 | ) 208 | } 209 | 210 | pub fn option_report_release_addons(service: &ZapService) -> Result { 211 | let params = HashMap::new(); 212 | super::call( 213 | service, 214 | "autoupdate", 215 | "view", 216 | "optionReportReleaseAddons", 217 | params, 218 | ) 219 | } 220 | 221 | /** 222 | * Downloads the latest release, if any 223 | */ 224 | pub fn download_latest_release(service: &ZapService) -> Result { 225 | let params = HashMap::new(); 226 | super::call( 227 | service, 228 | "autoupdate", 229 | "action", 230 | "downloadLatestRelease", 231 | params, 232 | ) 233 | } 234 | 235 | /** 236 | * Installs or updates the specified add-on, returning when complete (ie not asynchronously) 237 | */ 238 | pub fn install_addon(service: &ZapService, id: String) -> Result { 239 | let mut params = HashMap::new(); 240 | params.insert("id".to_string(), id); 241 | super::call(service, "autoupdate", "action", "installAddon", params) 242 | } 243 | 244 | pub fn install_local_addon(service: &ZapService, file: String) -> Result { 245 | let mut params = HashMap::new(); 246 | params.insert("file".to_string(), file); 247 | super::call(service, "autoupdate", "action", "installLocalAddon", params) 248 | } 249 | 250 | /** 251 | * Uninstalls the specified add-on 252 | */ 253 | pub fn uninstall_addon(service: &ZapService, id: String) -> Result { 254 | let mut params = HashMap::new(); 255 | params.insert("id".to_string(), id); 256 | super::call(service, "autoupdate", "action", "uninstallAddon", params) 257 | } 258 | 259 | pub fn set_option_check_addon_updates( 260 | service: &ZapService, 261 | boolean: String, 262 | ) -> Result { 263 | let mut params = HashMap::new(); 264 | params.insert("Boolean".to_string(), boolean); 265 | super::call( 266 | service, 267 | "autoupdate", 268 | "action", 269 | "setOptionCheckAddonUpdates", 270 | params, 271 | ) 272 | } 273 | 274 | pub fn set_option_check_on_start( 275 | service: &ZapService, 276 | boolean: String, 277 | ) -> Result { 278 | let mut params = HashMap::new(); 279 | params.insert("Boolean".to_string(), boolean); 280 | super::call( 281 | service, 282 | "autoupdate", 283 | "action", 284 | "setOptionCheckOnStart", 285 | params, 286 | ) 287 | } 288 | 289 | pub fn set_option_download_new_release( 290 | service: &ZapService, 291 | boolean: String, 292 | ) -> Result { 293 | let mut params = HashMap::new(); 294 | params.insert("Boolean".to_string(), boolean); 295 | super::call( 296 | service, 297 | "autoupdate", 298 | "action", 299 | "setOptionDownloadNewRelease", 300 | params, 301 | ) 302 | } 303 | 304 | pub fn set_option_install_addon_updates( 305 | service: &ZapService, 306 | boolean: String, 307 | ) -> Result { 308 | let mut params = HashMap::new(); 309 | params.insert("Boolean".to_string(), boolean); 310 | super::call( 311 | service, 312 | "autoupdate", 313 | "action", 314 | "setOptionInstallAddonUpdates", 315 | params, 316 | ) 317 | } 318 | 319 | pub fn set_option_install_scanner_rules( 320 | service: &ZapService, 321 | boolean: String, 322 | ) -> Result { 323 | let mut params = HashMap::new(); 324 | params.insert("Boolean".to_string(), boolean); 325 | super::call( 326 | service, 327 | "autoupdate", 328 | "action", 329 | "setOptionInstallScannerRules", 330 | params, 331 | ) 332 | } 333 | 334 | pub fn set_option_report_alpha_addons( 335 | service: &ZapService, 336 | boolean: String, 337 | ) -> Result { 338 | let mut params = HashMap::new(); 339 | params.insert("Boolean".to_string(), boolean); 340 | super::call( 341 | service, 342 | "autoupdate", 343 | "action", 344 | "setOptionReportAlphaAddons", 345 | params, 346 | ) 347 | } 348 | 349 | pub fn set_option_report_beta_addons( 350 | service: &ZapService, 351 | boolean: String, 352 | ) -> Result { 353 | let mut params = HashMap::new(); 354 | params.insert("Boolean".to_string(), boolean); 355 | super::call( 356 | service, 357 | "autoupdate", 358 | "action", 359 | "setOptionReportBetaAddons", 360 | params, 361 | ) 362 | } 363 | 364 | pub fn set_option_report_release_addons( 365 | service: &ZapService, 366 | boolean: String, 367 | ) -> Result { 368 | let mut params = HashMap::new(); 369 | params.insert("Boolean".to_string(), boolean); 370 | super::call( 371 | service, 372 | "autoupdate", 373 | "action", 374 | "setOptionReportReleaseAddons", 375 | params, 376 | ) 377 | } 378 | -------------------------------------------------------------------------------- /src/brk.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Returns True if ZAP will break on both requests and responses 30 | */ 31 | pub fn is_break_all(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call(service, "break", "view", "isBreakAll", params) 34 | } 35 | 36 | /** 37 | * Returns True if ZAP will break on requests 38 | */ 39 | pub fn is_break_request(service: &ZapService) -> Result { 40 | let params = HashMap::new(); 41 | super::call(service, "break", "view", "isBreakRequest", params) 42 | } 43 | 44 | /** 45 | * Returns True if ZAP will break on responses 46 | */ 47 | pub fn is_break_response(service: &ZapService) -> Result { 48 | let params = HashMap::new(); 49 | super::call(service, "break", "view", "isBreakResponse", params) 50 | } 51 | 52 | /** 53 | * Returns the HTTP message currently intercepted (if any) 54 | */ 55 | pub fn http_message(service: &ZapService) -> Result { 56 | let params = HashMap::new(); 57 | super::call(service, "break", "view", "httpMessage", params) 58 | } 59 | 60 | /** 61 | * Controls the global break functionality. The type may be one of: http-all, http-request or http-response. The state may be true (for turning break on for the specified type) or false (for turning break off). Scope is not currently used. 62 | */ 63 | pub fn brk( 64 | service: &ZapService, 65 | typ: String, 66 | state: String, 67 | scope: String, 68 | ) -> Result { 69 | let mut params = HashMap::new(); 70 | params.insert("type".to_string(), typ); 71 | params.insert("state".to_string(), state); 72 | params.insert("scope".to_string(), scope); 73 | super::call(service, "break", "action", "break", params) 74 | } 75 | 76 | /** 77 | * Overwrites the currently intercepted message with the data provided 78 | */ 79 | pub fn set_http_message( 80 | service: &ZapService, 81 | httpheader: String, 82 | httpbody: String, 83 | ) -> Result { 84 | let mut params = HashMap::new(); 85 | params.insert("httpHeader".to_string(), httpheader); 86 | params.insert("httpBody".to_string(), httpbody); 87 | super::call(service, "break", "action", "setHttpMessage", params) 88 | } 89 | 90 | /** 91 | * Submits the currently intercepted message and unsets the global request/response break points 92 | */ 93 | pub fn cont(service: &ZapService) -> Result { 94 | let params = HashMap::new(); 95 | super::call(service, "break", "action", "continue", params) 96 | } 97 | 98 | /** 99 | * Submits the currently intercepted message, the next request or response will automatically be intercepted 100 | */ 101 | pub fn step(service: &ZapService) -> Result { 102 | let params = HashMap::new(); 103 | super::call(service, "break", "action", "step", params) 104 | } 105 | 106 | /** 107 | * Drops the currently intercepted message 108 | */ 109 | pub fn drop(service: &ZapService) -> Result { 110 | let params = HashMap::new(); 111 | super::call(service, "break", "action", "drop", params) 112 | } 113 | 114 | /** 115 | * Adds a custom HTTP breakpont. The string is the string to match. Location may be one of: url, request_header, request_body, response_header or response_body. Match may be: contains or regex. Inverse (match) may be true or false. Lastly, ignorecase (when matching the string) may be true or false. 116 | */ 117 | pub fn add_http_breakpoint( 118 | service: &ZapService, 119 | string: String, 120 | location: String, 121 | mtch: String, 122 | inverse: String, 123 | ignorecase: String, 124 | ) -> Result { 125 | let mut params = HashMap::new(); 126 | params.insert("string".to_string(), string); 127 | params.insert("location".to_string(), location); 128 | params.insert("match".to_string(), mtch); 129 | params.insert("inverse".to_string(), inverse); 130 | params.insert("ignorecase".to_string(), ignorecase); 131 | super::call(service, "break", "action", "addHttpBreakpoint", params) 132 | } 133 | 134 | /** 135 | * Removes the specified break point 136 | */ 137 | pub fn remove_http_breakpoint( 138 | service: &ZapService, 139 | string: String, 140 | location: String, 141 | mtch: String, 142 | inverse: String, 143 | ignorecase: String, 144 | ) -> Result { 145 | let mut params = HashMap::new(); 146 | params.insert("string".to_string(), string); 147 | params.insert("location".to_string(), location); 148 | params.insert("match".to_string(), mtch); 149 | params.insert("inverse".to_string(), inverse); 150 | params.insert("ignorecase".to_string(), ignorecase); 151 | super::call(service, "break", "action", "removeHttpBreakpoint", params) 152 | } 153 | -------------------------------------------------------------------------------- /src/context.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * List context names of current session 30 | */ 31 | pub fn context_list(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call(service, "context", "view", "contextList", params) 34 | } 35 | 36 | /** 37 | * List excluded regexs for context 38 | */ 39 | pub fn exclude_regexs(service: &ZapService, contextname: String) -> Result { 40 | let mut params = HashMap::new(); 41 | params.insert("contextName".to_string(), contextname); 42 | super::call(service, "context", "view", "excludeRegexs", params) 43 | } 44 | 45 | /** 46 | * List included regexs for context 47 | */ 48 | pub fn include_regexs(service: &ZapService, contextname: String) -> Result { 49 | let mut params = HashMap::new(); 50 | params.insert("contextName".to_string(), contextname); 51 | super::call(service, "context", "view", "includeRegexs", params) 52 | } 53 | 54 | /** 55 | * List the information about the named context 56 | */ 57 | pub fn context(service: &ZapService, contextname: String) -> Result { 58 | let mut params = HashMap::new(); 59 | params.insert("contextName".to_string(), contextname); 60 | super::call(service, "context", "view", "context", params) 61 | } 62 | 63 | /** 64 | * Lists the names of all built in technologies 65 | */ 66 | pub fn technology_list(service: &ZapService) -> Result { 67 | let params = HashMap::new(); 68 | super::call(service, "context", "view", "technologyList", params) 69 | } 70 | 71 | /** 72 | * Lists the names of all technologies included in a context 73 | */ 74 | pub fn included_technology_list( 75 | service: &ZapService, 76 | contextname: String, 77 | ) -> Result { 78 | let mut params = HashMap::new(); 79 | params.insert("contextName".to_string(), contextname); 80 | super::call(service, "context", "view", "includedTechnologyList", params) 81 | } 82 | 83 | /** 84 | * Lists the names of all technologies excluded from a context 85 | */ 86 | pub fn excluded_technology_list( 87 | service: &ZapService, 88 | contextname: String, 89 | ) -> Result { 90 | let mut params = HashMap::new(); 91 | params.insert("contextName".to_string(), contextname); 92 | super::call(service, "context", "view", "excludedTechnologyList", params) 93 | } 94 | 95 | /** 96 | * Lists the URLs accessed through/by ZAP, that belong to the context with the given name. 97 | */ 98 | pub fn urls(service: &ZapService, contextname: String) -> Result { 99 | let mut params = HashMap::new(); 100 | params.insert("contextName".to_string(), contextname); 101 | super::call(service, "context", "view", "urls", params) 102 | } 103 | 104 | /** 105 | * Add exclude regex to context 106 | */ 107 | pub fn exclude_from_context( 108 | service: &ZapService, 109 | contextname: String, 110 | regex: String, 111 | ) -> Result { 112 | let mut params = HashMap::new(); 113 | params.insert("contextName".to_string(), contextname); 114 | params.insert("regex".to_string(), regex); 115 | super::call(service, "context", "action", "excludeFromContext", params) 116 | } 117 | 118 | /** 119 | * Add include regex to context 120 | */ 121 | pub fn include_in_context( 122 | service: &ZapService, 123 | contextname: String, 124 | regex: String, 125 | ) -> Result { 126 | let mut params = HashMap::new(); 127 | params.insert("contextName".to_string(), contextname); 128 | params.insert("regex".to_string(), regex); 129 | super::call(service, "context", "action", "includeInContext", params) 130 | } 131 | 132 | /** 133 | * Set the regexs to include and exclude for a context, both supplied as JSON string arrays 134 | */ 135 | pub fn set_context_regexs( 136 | service: &ZapService, 137 | contextname: String, 138 | incregexs: String, 139 | excregexs: String, 140 | ) -> Result { 141 | let mut params = HashMap::new(); 142 | params.insert("contextName".to_string(), contextname); 143 | params.insert("incRegexs".to_string(), incregexs); 144 | params.insert("excRegexs".to_string(), excregexs); 145 | super::call(service, "context", "action", "setContextRegexs", params) 146 | } 147 | 148 | /** 149 | * Creates a new context with the given name in the current session 150 | */ 151 | pub fn new_context(service: &ZapService, contextname: String) -> Result { 152 | let mut params = HashMap::new(); 153 | params.insert("contextName".to_string(), contextname); 154 | super::call(service, "context", "action", "newContext", params) 155 | } 156 | 157 | /** 158 | * Removes a context in the current session 159 | */ 160 | pub fn remove_context(service: &ZapService, contextname: String) -> Result { 161 | let mut params = HashMap::new(); 162 | params.insert("contextName".to_string(), contextname); 163 | super::call(service, "context", "action", "removeContext", params) 164 | } 165 | 166 | /** 167 | * Exports the context with the given name to a file. If a relative file path is specified it will be resolved against the "contexts" directory in ZAP "home" dir. 168 | */ 169 | pub fn export_context( 170 | service: &ZapService, 171 | contextname: String, 172 | contextfile: String, 173 | ) -> Result { 174 | let mut params = HashMap::new(); 175 | params.insert("contextName".to_string(), contextname); 176 | params.insert("contextFile".to_string(), contextfile); 177 | super::call(service, "context", "action", "exportContext", params) 178 | } 179 | 180 | /** 181 | * Imports a context from a file. If a relative file path is specified it will be resolved against the "contexts" directory in ZAP "home" dir. 182 | */ 183 | pub fn import_context(service: &ZapService, contextfile: String) -> Result { 184 | let mut params = HashMap::new(); 185 | params.insert("contextFile".to_string(), contextfile); 186 | super::call(service, "context", "action", "importContext", params) 187 | } 188 | 189 | /** 190 | * Includes technologies with the given names, separated by a comma, to a context 191 | */ 192 | pub fn include_context_technologies( 193 | service: &ZapService, 194 | contextname: String, 195 | technologynames: String, 196 | ) -> Result { 197 | let mut params = HashMap::new(); 198 | params.insert("contextName".to_string(), contextname); 199 | params.insert("technologyNames".to_string(), technologynames); 200 | super::call( 201 | service, 202 | "context", 203 | "action", 204 | "includeContextTechnologies", 205 | params, 206 | ) 207 | } 208 | 209 | /** 210 | * Includes all built in technologies in to a context 211 | */ 212 | pub fn include_all_context_technologies( 213 | service: &ZapService, 214 | contextname: String, 215 | ) -> Result { 216 | let mut params = HashMap::new(); 217 | params.insert("contextName".to_string(), contextname); 218 | super::call( 219 | service, 220 | "context", 221 | "action", 222 | "includeAllContextTechnologies", 223 | params, 224 | ) 225 | } 226 | 227 | /** 228 | * Excludes technologies with the given names, separated by a comma, from a context 229 | */ 230 | pub fn exclude_context_technologies( 231 | service: &ZapService, 232 | contextname: String, 233 | technologynames: String, 234 | ) -> Result { 235 | let mut params = HashMap::new(); 236 | params.insert("contextName".to_string(), contextname); 237 | params.insert("technologyNames".to_string(), technologynames); 238 | super::call( 239 | service, 240 | "context", 241 | "action", 242 | "excludeContextTechnologies", 243 | params, 244 | ) 245 | } 246 | 247 | /** 248 | * Excludes all built in technologies from a context 249 | */ 250 | pub fn exclude_all_context_technologies( 251 | service: &ZapService, 252 | contextname: String, 253 | ) -> Result { 254 | let mut params = HashMap::new(); 255 | params.insert("contextName".to_string(), contextname); 256 | super::call( 257 | service, 258 | "context", 259 | "action", 260 | "excludeAllContextTechnologies", 261 | params, 262 | ) 263 | } 264 | 265 | /** 266 | * Sets a context to in scope (contexts are in scope by default) 267 | */ 268 | pub fn set_context_in_scope( 269 | service: &ZapService, 270 | contextname: String, 271 | booleaninscope: String, 272 | ) -> Result { 273 | let mut params = HashMap::new(); 274 | params.insert("contextName".to_string(), contextname); 275 | params.insert("booleanInScope".to_string(), booleaninscope); 276 | super::call(service, "context", "action", "setContextInScope", params) 277 | } 278 | -------------------------------------------------------------------------------- /src/forced_user.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Returns 'true' if 'forced user' mode is enabled, 'false' otherwise 30 | */ 31 | pub fn is_forced_user_mode_enabled(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call( 34 | service, 35 | "forcedUser", 36 | "view", 37 | "isForcedUserModeEnabled", 38 | params, 39 | ) 40 | } 41 | 42 | /** 43 | * Gets the user (ID) set as 'forced user' for the given context (ID) 44 | */ 45 | pub fn get_forced_user(service: &ZapService, contextid: String) -> Result { 46 | let mut params = HashMap::new(); 47 | params.insert("contextId".to_string(), contextid); 48 | super::call(service, "forcedUser", "view", "getForcedUser", params) 49 | } 50 | 51 | /** 52 | * Sets the user (ID) that should be used in 'forced user' mode for the given context (ID) 53 | */ 54 | pub fn set_forced_user( 55 | service: &ZapService, 56 | contextid: String, 57 | userid: String, 58 | ) -> Result { 59 | let mut params = HashMap::new(); 60 | params.insert("contextId".to_string(), contextid); 61 | params.insert("userId".to_string(), userid); 62 | super::call(service, "forcedUser", "action", "setForcedUser", params) 63 | } 64 | 65 | /** 66 | * Sets if 'forced user' mode should be enabled or not 67 | */ 68 | pub fn set_forced_user_mode_enabled( 69 | service: &ZapService, 70 | boolean: String, 71 | ) -> Result { 72 | let mut params = HashMap::new(); 73 | params.insert("boolean".to_string(), boolean); 74 | super::call( 75 | service, 76 | "forcedUser", 77 | "action", 78 | "setForcedUserModeEnabled", 79 | params, 80 | ) 81 | } 82 | -------------------------------------------------------------------------------- /src/http_sessions.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Gets all of the sites that have sessions. 30 | */ 31 | pub fn sites(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call(service, "httpSessions", "view", "sites", params) 34 | } 35 | 36 | /** 37 | * Gets the sessions for the given site. Optionally returning just the session with the given name. 38 | */ 39 | pub fn sessions(service: &ZapService, site: String, session: String) -> Result { 40 | let mut params = HashMap::new(); 41 | params.insert("site".to_string(), site); 42 | params.insert("session".to_string(), session); 43 | super::call(service, "httpSessions", "view", "sessions", params) 44 | } 45 | 46 | /** 47 | * Gets the name of the active session for the given site. 48 | */ 49 | pub fn active_session(service: &ZapService, site: String) -> Result { 50 | let mut params = HashMap::new(); 51 | params.insert("site".to_string(), site); 52 | super::call(service, "httpSessions", "view", "activeSession", params) 53 | } 54 | 55 | /** 56 | * Gets the names of the session tokens for the given site. 57 | */ 58 | pub fn session_tokens(service: &ZapService, site: String) -> Result { 59 | let mut params = HashMap::new(); 60 | params.insert("site".to_string(), site); 61 | super::call(service, "httpSessions", "view", "sessionTokens", params) 62 | } 63 | 64 | /** 65 | * Gets the default session tokens. 66 | */ 67 | pub fn default_session_tokens(service: &ZapService) -> Result { 68 | let params = HashMap::new(); 69 | super::call( 70 | service, 71 | "httpSessions", 72 | "view", 73 | "defaultSessionTokens", 74 | params, 75 | ) 76 | } 77 | 78 | /** 79 | * Creates an empty session for the given site. Optionally with the given name. 80 | */ 81 | pub fn create_empty_session( 82 | service: &ZapService, 83 | site: String, 84 | session: String, 85 | ) -> Result { 86 | let mut params = HashMap::new(); 87 | params.insert("site".to_string(), site); 88 | params.insert("session".to_string(), session); 89 | super::call( 90 | service, 91 | "httpSessions", 92 | "action", 93 | "createEmptySession", 94 | params, 95 | ) 96 | } 97 | 98 | /** 99 | * Removes the session from the given site. 100 | */ 101 | pub fn remove_session( 102 | service: &ZapService, 103 | site: String, 104 | session: String, 105 | ) -> Result { 106 | let mut params = HashMap::new(); 107 | params.insert("site".to_string(), site); 108 | params.insert("session".to_string(), session); 109 | super::call(service, "httpSessions", "action", "removeSession", params) 110 | } 111 | 112 | /** 113 | * Sets the given session as active for the given site. 114 | */ 115 | pub fn set_active_session( 116 | service: &ZapService, 117 | site: String, 118 | session: String, 119 | ) -> Result { 120 | let mut params = HashMap::new(); 121 | params.insert("site".to_string(), site); 122 | params.insert("session".to_string(), session); 123 | super::call( 124 | service, 125 | "httpSessions", 126 | "action", 127 | "setActiveSession", 128 | params, 129 | ) 130 | } 131 | 132 | /** 133 | * Unsets the active session of the given site. 134 | */ 135 | pub fn unset_active_session(service: &ZapService, site: String) -> Result { 136 | let mut params = HashMap::new(); 137 | params.insert("site".to_string(), site); 138 | super::call( 139 | service, 140 | "httpSessions", 141 | "action", 142 | "unsetActiveSession", 143 | params, 144 | ) 145 | } 146 | 147 | /** 148 | * Adds the session token to the given site. 149 | */ 150 | pub fn add_session_token( 151 | service: &ZapService, 152 | site: String, 153 | sessiontoken: String, 154 | ) -> Result { 155 | let mut params = HashMap::new(); 156 | params.insert("site".to_string(), site); 157 | params.insert("sessionToken".to_string(), sessiontoken); 158 | super::call(service, "httpSessions", "action", "addSessionToken", params) 159 | } 160 | 161 | /** 162 | * Removes the session token from the given site. 163 | */ 164 | pub fn remove_session_token( 165 | service: &ZapService, 166 | site: String, 167 | sessiontoken: String, 168 | ) -> Result { 169 | let mut params = HashMap::new(); 170 | params.insert("site".to_string(), site); 171 | params.insert("sessionToken".to_string(), sessiontoken); 172 | super::call( 173 | service, 174 | "httpSessions", 175 | "action", 176 | "removeSessionToken", 177 | params, 178 | ) 179 | } 180 | 181 | /** 182 | * Sets the value of the session token of the given session for the given site. 183 | */ 184 | pub fn set_session_token_value( 185 | service: &ZapService, 186 | site: String, 187 | session: String, 188 | sessiontoken: String, 189 | tokenvalue: String, 190 | ) -> Result { 191 | let mut params = HashMap::new(); 192 | params.insert("site".to_string(), site); 193 | params.insert("session".to_string(), session); 194 | params.insert("sessionToken".to_string(), sessiontoken); 195 | params.insert("tokenValue".to_string(), tokenvalue); 196 | super::call( 197 | service, 198 | "httpSessions", 199 | "action", 200 | "setSessionTokenValue", 201 | params, 202 | ) 203 | } 204 | 205 | /** 206 | * Renames the session of the given site. 207 | */ 208 | pub fn rename_session( 209 | service: &ZapService, 210 | site: String, 211 | oldsessionname: String, 212 | newsessionname: String, 213 | ) -> Result { 214 | let mut params = HashMap::new(); 215 | params.insert("site".to_string(), site); 216 | params.insert("oldSessionName".to_string(), oldsessionname); 217 | params.insert("newSessionName".to_string(), newsessionname); 218 | super::call(service, "httpSessions", "action", "renameSession", params) 219 | } 220 | 221 | /** 222 | * Adds a default session token with the given name and enabled state. 223 | */ 224 | pub fn add_default_session_token( 225 | service: &ZapService, 226 | sessiontoken: String, 227 | tokenenabled: String, 228 | ) -> Result { 229 | let mut params = HashMap::new(); 230 | params.insert("sessionToken".to_string(), sessiontoken); 231 | params.insert("tokenEnabled".to_string(), tokenenabled); 232 | super::call( 233 | service, 234 | "httpSessions", 235 | "action", 236 | "addDefaultSessionToken", 237 | params, 238 | ) 239 | } 240 | 241 | /** 242 | * Sets whether or not the default session token with the given name is enabled. 243 | */ 244 | pub fn set_default_session_token_enabled( 245 | service: &ZapService, 246 | sessiontoken: String, 247 | tokenenabled: String, 248 | ) -> Result { 249 | let mut params = HashMap::new(); 250 | params.insert("sessionToken".to_string(), sessiontoken); 251 | params.insert("tokenEnabled".to_string(), tokenenabled); 252 | super::call( 253 | service, 254 | "httpSessions", 255 | "action", 256 | "setDefaultSessionTokenEnabled", 257 | params, 258 | ) 259 | } 260 | 261 | /** 262 | * Removes the default session token with the given name. 263 | */ 264 | pub fn remove_default_session_token( 265 | service: &ZapService, 266 | sessiontoken: String, 267 | ) -> Result { 268 | let mut params = HashMap::new(); 269 | params.insert("sessionToken".to_string(), sessiontoken); 270 | super::call( 271 | service, 272 | "httpSessions", 273 | "action", 274 | "removeDefaultSessionToken", 275 | params, 276 | ) 277 | } 278 | -------------------------------------------------------------------------------- /src/import_log_files.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * This component is optional and therefore the API will only work if it is installed 30 | */ 31 | pub fn import_zap_log_from_file( 32 | service: &ZapService, 33 | filepath: String, 34 | ) -> Result { 35 | let mut params = HashMap::new(); 36 | params.insert("FilePath".to_string(), filepath); 37 | super::call( 38 | service, 39 | "importLogFiles", 40 | "action", 41 | "ImportZAPLogFromFile", 42 | params, 43 | ) 44 | } 45 | 46 | /** 47 | * This component is optional and therefore the API will only work if it is installed 48 | */ 49 | pub fn import_mod_security_log_from_file( 50 | service: &ZapService, 51 | filepath: String, 52 | ) -> Result { 53 | let mut params = HashMap::new(); 54 | params.insert("FilePath".to_string(), filepath); 55 | super::call( 56 | service, 57 | "importLogFiles", 58 | "action", 59 | "ImportModSecurityLogFromFile", 60 | params, 61 | ) 62 | } 63 | 64 | /** 65 | * This component is optional and therefore the API will only work if it is installed 66 | */ 67 | pub fn import_zap_http_request_response_pair( 68 | service: &ZapService, 69 | httprequest: String, 70 | httpresponse: String, 71 | ) -> Result { 72 | let mut params = HashMap::new(); 73 | params.insert("HTTPRequest".to_string(), httprequest); 74 | params.insert("HTTPResponse".to_string(), httpresponse); 75 | super::call( 76 | service, 77 | "importLogFiles", 78 | "action", 79 | "ImportZAPHttpRequestResponsePair", 80 | params, 81 | ) 82 | } 83 | 84 | /** 85 | * This component is optional and therefore the API will only work if it is installed 86 | */ 87 | pub fn post_mod_security_audit_event( 88 | service: &ZapService, 89 | auditeventstring: String, 90 | ) -> Result { 91 | let mut params = HashMap::new(); 92 | params.insert("AuditEventString".to_string(), auditeventstring); 93 | super::call( 94 | service, 95 | "importLogFiles", 96 | "action", 97 | "PostModSecurityAuditEvent", 98 | params, 99 | ) 100 | } 101 | 102 | /** 103 | * This component is optional and therefore the API will only work if it is installed 104 | */ 105 | pub fn other_post_mod_security_audit_event( 106 | service: &ZapService, 107 | auditeventstring: String, 108 | ) -> Result { 109 | let mut params = HashMap::new(); 110 | params.insert("AuditEventString".to_string(), auditeventstring); 111 | super::call( 112 | service, 113 | "importLogFiles", 114 | "other", 115 | "OtherPostModSecurityAuditEvent", 116 | params, 117 | ) 118 | } 119 | -------------------------------------------------------------------------------- /src/importurls.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Imports URLs (one per line) from the file with the given file system path. 30 | *

31 | * This component is optional and therefore the API will only work if it is installed 32 | */ 33 | pub fn importurls(service: &ZapService, filepath: String) -> Result { 34 | let mut params = HashMap::new(); 35 | params.insert("filePath".to_string(), filepath); 36 | super::call(service, "importurls", "action", "importurls", params) 37 | } 38 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | use serde_json::Value; 20 | use std::collections::HashMap; 21 | trait Serialize {} 22 | 23 | pub mod acsrf; 24 | pub mod ajax_spider; 25 | pub mod alert; 26 | pub mod alert_filter; 27 | pub mod ascan; 28 | pub mod authentication; 29 | pub mod authorization; 30 | pub mod autoupdate; 31 | pub mod brk; 32 | pub mod context; 33 | pub mod core; 34 | pub mod forced_user; 35 | pub mod http_sessions; 36 | pub mod import_log_files; 37 | pub mod importurls; 38 | pub mod openapi; 39 | pub mod params; 40 | pub mod pnh; 41 | pub mod pscan; 42 | pub mod replacer; 43 | pub mod reveal; 44 | pub mod script; 45 | pub mod search; 46 | pub mod selenium; 47 | pub mod session_management; 48 | pub mod soap; 49 | pub mod spider; 50 | pub mod stats; 51 | pub mod users; 52 | pub mod websocket; 53 | 54 | #[derive(Debug)] 55 | pub struct ZapService { 56 | pub url: String, // base url of the ZAP API, eg http://localhost:8080 57 | pub api_key: String, // API key used for connecting securely to the API 58 | } 59 | 60 | #[derive(Debug)] 61 | pub struct ZapApiError { 62 | kind: String, // type of the error 63 | message: String, // error message 64 | } 65 | 66 | impl From for ZapApiError { 67 | fn from(error: reqwest::Error) -> Self { 68 | ZapApiError { 69 | kind: String::from("comms"), 70 | message: error.to_string(), 71 | } 72 | } 73 | } 74 | 75 | impl From for ZapApiError { 76 | fn from(error: serde_json::error::Error) -> Self { 77 | ZapApiError { 78 | kind: String::from("serde"), 79 | message: error.to_string(), 80 | } 81 | } 82 | } 83 | 84 | pub fn call( 85 | service: &ZapService, 86 | component: &str, 87 | calltype: &str, 88 | method: &str, 89 | _params: HashMap, 90 | ) -> Result { 91 | let mut url = [&service.url, "JSON", component, calltype, method, ""].join("/"); 92 | if _params.keys().len() > 0 { 93 | url.push_str("?"); 94 | for (key, value) in _params { 95 | url.push_str(&key); 96 | url.push_str("="); 97 | url.push_str(&value); 98 | url.push_str("&"); 99 | } 100 | } 101 | 102 | let client = reqwest::Client::new(); 103 | let text = client 104 | .get(&url) 105 | .header("X-ZAP-API-Key", &*service.api_key) 106 | .send()? 107 | .text()?; 108 | let json = serde_json::from_str(&text)?; 109 | Ok(json) 110 | } 111 | -------------------------------------------------------------------------------- /src/openapi.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Import an Open API definition from a local file. 30 | *

31 | * This component is optional and therefore the API will only work if it is installed 32 | */ 33 | pub fn import_file(service: &ZapService, file: String) -> Result { 34 | let mut params = HashMap::new(); 35 | params.insert("file".to_string(), file); 36 | super::call(service, "openapi", "action", "importFile", params) 37 | } 38 | 39 | /** 40 | * Import an Open API definition from a URL, hostOverride allows the host to be replaced 41 | *

42 | * This component is optional and therefore the API will only work if it is installed 43 | */ 44 | pub fn import_url( 45 | service: &ZapService, 46 | url: String, 47 | hostoverride: String, 48 | ) -> Result { 49 | let mut params = HashMap::new(); 50 | params.insert("url".to_string(), url); 51 | params.insert("hostOverride".to_string(), hostoverride); 52 | super::call(service, "openapi", "action", "importUrl", params) 53 | } 54 | -------------------------------------------------------------------------------- /src/params.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Shows the parameters for the specified site, or for all sites if the site is not specified 30 | */ 31 | pub fn params(service: &ZapService, site: String) -> Result { 32 | let mut params = HashMap::new(); 33 | params.insert("site".to_string(), site); 34 | super::call(service, "params", "view", "params", params) 35 | } 36 | -------------------------------------------------------------------------------- /src/pnh.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * This component is optional and therefore the API will only work if it is installed 30 | */ 31 | pub fn monitor(service: &ZapService, id: String, message: String) -> Result { 32 | let mut params = HashMap::new(); 33 | params.insert("id".to_string(), id); 34 | params.insert("message".to_string(), message); 35 | super::call(service, "pnh", "action", "monitor", params) 36 | } 37 | 38 | /** 39 | * This component is optional and therefore the API will only work if it is installed 40 | */ 41 | pub fn oracle(service: &ZapService, id: String) -> Result { 42 | let mut params = HashMap::new(); 43 | params.insert("id".to_string(), id); 44 | super::call(service, "pnh", "action", "oracle", params) 45 | } 46 | 47 | /** 48 | * This component is optional and therefore the API will only work if it is installed 49 | */ 50 | pub fn start_monitoring(service: &ZapService, url: String) -> Result { 51 | let mut params = HashMap::new(); 52 | params.insert("url".to_string(), url); 53 | super::call(service, "pnh", "action", "startMonitoring", params) 54 | } 55 | 56 | /** 57 | * This component is optional and therefore the API will only work if it is installed 58 | */ 59 | pub fn stop_monitoring(service: &ZapService, id: String) -> Result { 60 | let mut params = HashMap::new(); 61 | params.insert("id".to_string(), id); 62 | super::call(service, "pnh", "action", "stopMonitoring", params) 63 | } 64 | 65 | /** 66 | * This component is optional and therefore the API will only work if it is installed 67 | */ 68 | pub fn pnh(service: &ZapService) -> Result { 69 | let params = HashMap::new(); 70 | super::call(service, "pnh", "other", "pnh", params) 71 | } 72 | 73 | /** 74 | * This component is optional and therefore the API will only work if it is installed 75 | */ 76 | pub fn manifest(service: &ZapService) -> Result { 77 | let params = HashMap::new(); 78 | super::call(service, "pnh", "other", "manifest", params) 79 | } 80 | 81 | /** 82 | * This component is optional and therefore the API will only work if it is installed 83 | */ 84 | pub fn service(service: &ZapService) -> Result { 85 | let params = HashMap::new(); 86 | super::call(service, "pnh", "other", "service", params) 87 | } 88 | 89 | /** 90 | * This component is optional and therefore the API will only work if it is installed 91 | */ 92 | pub fn fx_pnh_xpi(service: &ZapService) -> Result { 93 | let params = HashMap::new(); 94 | super::call(service, "pnh", "other", "fx_pnh.xpi", params) 95 | } 96 | -------------------------------------------------------------------------------- /src/pscan.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Tells whether or not the passive scan should be performed only on messages that are in scope. 30 | */ 31 | pub fn scan_only_in_scope(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call(service, "pscan", "view", "scanOnlyInScope", params) 34 | } 35 | 36 | /** 37 | * The number of records the passive scanner still has to scan 38 | */ 39 | pub fn records_to_scan(service: &ZapService) -> Result { 40 | let params = HashMap::new(); 41 | super::call(service, "pscan", "view", "recordsToScan", params) 42 | } 43 | 44 | /** 45 | * Lists all passive scanners with its ID, name, enabled state and alert threshold. 46 | */ 47 | pub fn scanners(service: &ZapService) -> Result { 48 | let params = HashMap::new(); 49 | super::call(service, "pscan", "view", "scanners", params) 50 | } 51 | 52 | /** 53 | * Show information about the passive scan rule currently being run (if any). 54 | */ 55 | pub fn current_rule(service: &ZapService) -> Result { 56 | let params = HashMap::new(); 57 | super::call(service, "pscan", "view", "currentRule", params) 58 | } 59 | 60 | /** 61 | * Gets the maximum number of alerts a passive scan rule should raise. 62 | */ 63 | pub fn max_alerts_per_rule(service: &ZapService) -> Result { 64 | let params = HashMap::new(); 65 | super::call(service, "pscan", "view", "maxAlertsPerRule", params) 66 | } 67 | 68 | /** 69 | * Sets whether or not the passive scanning is enabled (Note: the enabled state is not persisted). 70 | */ 71 | pub fn set_enabled(service: &ZapService, enabled: String) -> Result { 72 | let mut params = HashMap::new(); 73 | params.insert("enabled".to_string(), enabled); 74 | super::call(service, "pscan", "action", "setEnabled", params) 75 | } 76 | 77 | /** 78 | * Sets whether or not the passive scan should be performed only on messages that are in scope. 79 | */ 80 | pub fn set_scan_only_in_scope( 81 | service: &ZapService, 82 | onlyinscope: String, 83 | ) -> Result { 84 | let mut params = HashMap::new(); 85 | params.insert("onlyInScope".to_string(), onlyinscope); 86 | super::call(service, "pscan", "action", "setScanOnlyInScope", params) 87 | } 88 | 89 | /** 90 | * Enables all passive scanners 91 | */ 92 | pub fn enable_all_scanners(service: &ZapService) -> Result { 93 | let params = HashMap::new(); 94 | super::call(service, "pscan", "action", "enableAllScanners", params) 95 | } 96 | 97 | /** 98 | * Disables all passive scanners 99 | */ 100 | pub fn disable_all_scanners(service: &ZapService) -> Result { 101 | let params = HashMap::new(); 102 | super::call(service, "pscan", "action", "disableAllScanners", params) 103 | } 104 | 105 | /** 106 | * Enables all passive scanners with the given IDs (comma separated list of IDs) 107 | */ 108 | pub fn enable_scanners(service: &ZapService, ids: String) -> Result { 109 | let mut params = HashMap::new(); 110 | params.insert("ids".to_string(), ids); 111 | super::call(service, "pscan", "action", "enableScanners", params) 112 | } 113 | 114 | /** 115 | * Disables all passive scanners with the given IDs (comma separated list of IDs) 116 | */ 117 | pub fn disable_scanners(service: &ZapService, ids: String) -> Result { 118 | let mut params = HashMap::new(); 119 | params.insert("ids".to_string(), ids); 120 | super::call(service, "pscan", "action", "disableScanners", params) 121 | } 122 | 123 | /** 124 | * Sets the alert threshold of the passive scanner with the given ID, accepted values for alert threshold: OFF, DEFAULT, LOW, MEDIUM and HIGH 125 | */ 126 | pub fn set_scanner_alert_threshold( 127 | service: &ZapService, 128 | id: String, 129 | alertthreshold: String, 130 | ) -> Result { 131 | let mut params = HashMap::new(); 132 | params.insert("id".to_string(), id); 133 | params.insert("alertThreshold".to_string(), alertthreshold); 134 | super::call( 135 | service, 136 | "pscan", 137 | "action", 138 | "setScannerAlertThreshold", 139 | params, 140 | ) 141 | } 142 | 143 | /** 144 | * Sets the maximum number of alerts a passive scan rule should raise. 145 | */ 146 | pub fn set_max_alerts_per_rule( 147 | service: &ZapService, 148 | maxalerts: String, 149 | ) -> Result { 150 | let mut params = HashMap::new(); 151 | params.insert("maxAlerts".to_string(), maxalerts); 152 | super::call(service, "pscan", "action", "setMaxAlertsPerRule", params) 153 | } 154 | -------------------------------------------------------------------------------- /src/replacer.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Returns full details of all of the rules 30 | *

31 | * This component is optional and therefore the API will only work if it is installed 32 | */ 33 | pub fn rules(service: &ZapService) -> Result { 34 | let params = HashMap::new(); 35 | super::call(service, "replacer", "view", "rules", params) 36 | } 37 | 38 | /** 39 | * Adds a replacer rule. For the parameters: desc is a user friendly description, enabled is true or false, matchType is one of [REQ_HEADER, REQ_HEADER_STR, REQ_BODY_STR, RESP_HEADER, RESP_HEADER_STR, RESP_BODY_STR], matchRegex should be true if the matchString should be treated as a regex otherwise false, matchString is the string that will be matched against, replacement is the replacement string, initiators may be blank (for all initiators) or a comma separated list of integers as defined in HttpSender 40 | *

41 | * This component is optional and therefore the API will only work if it is installed 42 | */ 43 | #[allow(clippy::too_many_arguments)] 44 | pub fn add_rule( 45 | service: &ZapService, 46 | description: String, 47 | enabled: String, 48 | matchtype: String, 49 | matchregex: String, 50 | matchstring: String, 51 | replacement: String, 52 | initiators: String, 53 | ) -> Result { 54 | let mut params = HashMap::new(); 55 | params.insert("description".to_string(), description); 56 | params.insert("enabled".to_string(), enabled); 57 | params.insert("matchType".to_string(), matchtype); 58 | params.insert("matchRegex".to_string(), matchregex); 59 | params.insert("matchString".to_string(), matchstring); 60 | params.insert("replacement".to_string(), replacement); 61 | params.insert("initiators".to_string(), initiators); 62 | super::call(service, "replacer", "action", "addRule", params) 63 | } 64 | 65 | /** 66 | * Removes the rule with the given description 67 | *

68 | * This component is optional and therefore the API will only work if it is installed 69 | */ 70 | pub fn remove_rule(service: &ZapService, description: String) -> Result { 71 | let mut params = HashMap::new(); 72 | params.insert("description".to_string(), description); 73 | super::call(service, "replacer", "action", "removeRule", params) 74 | } 75 | 76 | /** 77 | * Enables or disables the rule with the given description based on the bool parameter 78 | *

79 | * This component is optional and therefore the API will only work if it is installed 80 | */ 81 | pub fn set_enabled( 82 | service: &ZapService, 83 | description: String, 84 | bool: String, 85 | ) -> Result { 86 | let mut params = HashMap::new(); 87 | params.insert("description".to_string(), description); 88 | params.insert("bool".to_string(), bool); 89 | super::call(service, "replacer", "action", "setEnabled", params) 90 | } 91 | -------------------------------------------------------------------------------- /src/reveal.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Tells if shows hidden fields and enables disabled fields 30 | *

31 | * This component is optional and therefore the API will only work if it is installed 32 | */ 33 | pub fn reveal(service: &ZapService) -> Result { 34 | let params = HashMap::new(); 35 | super::call(service, "reveal", "view", "reveal", params) 36 | } 37 | 38 | /** 39 | * Sets if shows hidden fields and enables disabled fields 40 | *

41 | * This component is optional and therefore the API will only work if it is installed 42 | */ 43 | pub fn set_reveal(service: &ZapService, reveal: String) -> Result { 44 | let mut params = HashMap::new(); 45 | params.insert("reveal".to_string(), reveal); 46 | super::call(service, "reveal", "action", "setReveal", params) 47 | } 48 | -------------------------------------------------------------------------------- /src/script.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Lists the script engines available 30 | */ 31 | pub fn list_engines(service: &ZapService) -> Result { 32 | let params = HashMap::new(); 33 | super::call(service, "script", "view", "listEngines", params) 34 | } 35 | 36 | /** 37 | * Lists the script types available. 38 | */ 39 | pub fn list_types(service: &ZapService) -> Result { 40 | let params = HashMap::new(); 41 | super::call(service, "script", "view", "listTypes", params) 42 | } 43 | 44 | /** 45 | * Lists the scripts available, with its engine, name, description, type and error state. 46 | */ 47 | pub fn list_scripts(service: &ZapService) -> Result { 48 | let params = HashMap::new(); 49 | super::call(service, "script", "view", "listScripts", params) 50 | } 51 | 52 | /** 53 | * Gets the value of the global variable with the given key. Returns an API error (DOES_NOT_EXIST) if no value was previously set. 54 | */ 55 | pub fn global_var(service: &ZapService, varkey: String) -> Result { 56 | let mut params = HashMap::new(); 57 | params.insert("varKey".to_string(), varkey); 58 | super::call(service, "script", "view", "globalVar", params) 59 | } 60 | 61 | /** 62 | * Gets all the global variables (key/value pairs). 63 | */ 64 | pub fn global_vars(service: &ZapService) -> Result { 65 | let params = HashMap::new(); 66 | super::call(service, "script", "view", "globalVars", params) 67 | } 68 | 69 | /** 70 | * 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. 71 | */ 72 | pub fn script_var( 73 | service: &ZapService, 74 | scriptname: String, 75 | varkey: String, 76 | ) -> Result { 77 | let mut params = HashMap::new(); 78 | params.insert("scriptName".to_string(), scriptname); 79 | params.insert("varKey".to_string(), varkey); 80 | super::call(service, "script", "view", "scriptVar", params) 81 | } 82 | 83 | /** 84 | * 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. 85 | */ 86 | pub fn script_vars(service: &ZapService, scriptname: String) -> Result { 87 | let mut params = HashMap::new(); 88 | params.insert("scriptName".to_string(), scriptname); 89 | super::call(service, "script", "view", "scriptVars", params) 90 | } 91 | 92 | /** 93 | * Enables the script with the given name 94 | */ 95 | pub fn enable(service: &ZapService, scriptname: String) -> Result { 96 | let mut params = HashMap::new(); 97 | params.insert("scriptName".to_string(), scriptname); 98 | super::call(service, "script", "action", "enable", params) 99 | } 100 | 101 | /** 102 | * Disables the script with the given name 103 | */ 104 | pub fn disable(service: &ZapService, scriptname: String) -> Result { 105 | let mut params = HashMap::new(); 106 | params.insert("scriptName".to_string(), scriptname); 107 | super::call(service, "script", "action", "disable", params) 108 | } 109 | 110 | /** 111 | * 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). 112 | */ 113 | pub fn load( 114 | service: &ZapService, 115 | scriptname: String, 116 | scripttype: String, 117 | scriptengine: String, 118 | filename: String, 119 | scriptdescription: String, 120 | charset: String, 121 | ) -> Result { 122 | let mut params = HashMap::new(); 123 | params.insert("scriptName".to_string(), scriptname); 124 | params.insert("scriptType".to_string(), scripttype); 125 | params.insert("scriptEngine".to_string(), scriptengine); 126 | params.insert("fileName".to_string(), filename); 127 | params.insert("scriptDescription".to_string(), scriptdescription); 128 | params.insert("charset".to_string(), charset); 129 | super::call(service, "script", "action", "load", params) 130 | } 131 | 132 | /** 133 | * Removes the script with the given name 134 | */ 135 | pub fn remove(service: &ZapService, scriptname: String) -> Result { 136 | let mut params = HashMap::new(); 137 | params.insert("scriptName".to_string(), scriptname); 138 | super::call(service, "script", "action", "remove", params) 139 | } 140 | 141 | /** 142 | * Runs the stand alone script with the given name 143 | */ 144 | pub fn run_stand_alone_script( 145 | service: &ZapService, 146 | scriptname: String, 147 | ) -> Result { 148 | let mut params = HashMap::new(); 149 | params.insert("scriptName".to_string(), scriptname); 150 | super::call(service, "script", "action", "runStandAloneScript", params) 151 | } 152 | 153 | /** 154 | * Clears the global variable with the given key. 155 | */ 156 | pub fn clear_global_var(service: &ZapService, varkey: String) -> Result { 157 | let mut params = HashMap::new(); 158 | params.insert("varKey".to_string(), varkey); 159 | super::call(service, "script", "action", "clearGlobalVar", params) 160 | } 161 | 162 | /** 163 | * Clears the global variables. 164 | */ 165 | pub fn clear_global_vars(service: &ZapService) -> Result { 166 | let params = HashMap::new(); 167 | super::call(service, "script", "action", "clearGlobalVars", params) 168 | } 169 | 170 | /** 171 | * 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. 172 | */ 173 | pub fn clear_script_var( 174 | service: &ZapService, 175 | scriptname: String, 176 | varkey: String, 177 | ) -> Result { 178 | let mut params = HashMap::new(); 179 | params.insert("scriptName".to_string(), scriptname); 180 | params.insert("varKey".to_string(), varkey); 181 | super::call(service, "script", "action", "clearScriptVar", params) 182 | } 183 | 184 | /** 185 | * Clears the variables of the given script. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists. 186 | */ 187 | pub fn clear_script_vars(service: &ZapService, scriptname: String) -> Result { 188 | let mut params = HashMap::new(); 189 | params.insert("scriptName".to_string(), scriptname); 190 | super::call(service, "script", "action", "clearScriptVars", params) 191 | } 192 | 193 | /** 194 | * 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. 195 | */ 196 | pub fn set_script_var( 197 | service: &ZapService, 198 | scriptname: String, 199 | varkey: String, 200 | varvalue: String, 201 | ) -> Result { 202 | let mut params = HashMap::new(); 203 | params.insert("scriptName".to_string(), scriptname); 204 | params.insert("varKey".to_string(), varkey); 205 | params.insert("varValue".to_string(), varvalue); 206 | super::call(service, "script", "action", "setScriptVar", params) 207 | } 208 | 209 | /** 210 | * Sets the value of the global variable with the given key. 211 | */ 212 | pub fn set_global_var( 213 | service: &ZapService, 214 | varkey: String, 215 | varvalue: String, 216 | ) -> Result { 217 | let mut params = HashMap::new(); 218 | params.insert("varKey".to_string(), varkey); 219 | params.insert("varValue".to_string(), varvalue); 220 | super::call(service, "script", "action", "setGlobalVar", params) 221 | } 222 | -------------------------------------------------------------------------------- /src/search.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Returns the URLs of the HTTP messages that match the given regular expression in the URL optionally filtered by URL and paginated with 'start' position and 'count' of messages. 30 | */ 31 | pub fn urls_by_url_regex( 32 | service: &ZapService, 33 | regex: String, 34 | baseurl: String, 35 | start: String, 36 | count: String, 37 | ) -> Result { 38 | let mut params = HashMap::new(); 39 | params.insert("regex".to_string(), regex); 40 | params.insert("baseurl".to_string(), baseurl); 41 | params.insert("start".to_string(), start); 42 | params.insert("count".to_string(), count); 43 | super::call(service, "search", "view", "urlsByUrlRegex", params) 44 | } 45 | 46 | /** 47 | * Returns the URLs of the HTTP messages that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages. 48 | */ 49 | pub fn urls_by_request_regex( 50 | service: &ZapService, 51 | regex: String, 52 | baseurl: String, 53 | start: String, 54 | count: String, 55 | ) -> Result { 56 | let mut params = HashMap::new(); 57 | params.insert("regex".to_string(), regex); 58 | params.insert("baseurl".to_string(), baseurl); 59 | params.insert("start".to_string(), start); 60 | params.insert("count".to_string(), count); 61 | super::call(service, "search", "view", "urlsByRequestRegex", params) 62 | } 63 | 64 | /** 65 | * Returns the URLs of the HTTP messages that match the given regular expression in the response optionally filtered by URL and paginated with 'start' position and 'count' of messages. 66 | */ 67 | pub fn urls_by_response_regex( 68 | service: &ZapService, 69 | regex: String, 70 | baseurl: String, 71 | start: String, 72 | count: String, 73 | ) -> Result { 74 | let mut params = HashMap::new(); 75 | params.insert("regex".to_string(), regex); 76 | params.insert("baseurl".to_string(), baseurl); 77 | params.insert("start".to_string(), start); 78 | params.insert("count".to_string(), count); 79 | super::call(service, "search", "view", "urlsByResponseRegex", params) 80 | } 81 | 82 | /** 83 | * Returns the URLs of the HTTP messages that match the given regular expression in the header(s) optionally filtered by URL and paginated with 'start' position and 'count' of messages. 84 | */ 85 | pub fn urls_by_header_regex( 86 | service: &ZapService, 87 | regex: String, 88 | baseurl: String, 89 | start: String, 90 | count: String, 91 | ) -> Result { 92 | let mut params = HashMap::new(); 93 | params.insert("regex".to_string(), regex); 94 | params.insert("baseurl".to_string(), baseurl); 95 | params.insert("start".to_string(), start); 96 | params.insert("count".to_string(), count); 97 | super::call(service, "search", "view", "urlsByHeaderRegex", params) 98 | } 99 | 100 | /** 101 | * Returns the HTTP messages that match the given regular expression in the URL optionally filtered by URL and paginated with 'start' position and 'count' of messages. 102 | */ 103 | pub fn messages_by_url_regex( 104 | service: &ZapService, 105 | regex: String, 106 | baseurl: String, 107 | start: String, 108 | count: String, 109 | ) -> Result { 110 | let mut params = HashMap::new(); 111 | params.insert("regex".to_string(), regex); 112 | params.insert("baseurl".to_string(), baseurl); 113 | params.insert("start".to_string(), start); 114 | params.insert("count".to_string(), count); 115 | super::call(service, "search", "view", "messagesByUrlRegex", params) 116 | } 117 | 118 | /** 119 | * Returns the HTTP messages that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages. 120 | */ 121 | pub fn messages_by_request_regex( 122 | service: &ZapService, 123 | regex: String, 124 | baseurl: String, 125 | start: String, 126 | count: String, 127 | ) -> Result { 128 | let mut params = HashMap::new(); 129 | params.insert("regex".to_string(), regex); 130 | params.insert("baseurl".to_string(), baseurl); 131 | params.insert("start".to_string(), start); 132 | params.insert("count".to_string(), count); 133 | super::call(service, "search", "view", "messagesByRequestRegex", params) 134 | } 135 | 136 | /** 137 | * Returns the HTTP messages that match the given regular expression in the response optionally filtered by URL and paginated with 'start' position and 'count' of messages. 138 | */ 139 | pub fn messages_by_response_regex( 140 | service: &ZapService, 141 | regex: String, 142 | baseurl: String, 143 | start: String, 144 | count: String, 145 | ) -> Result { 146 | let mut params = HashMap::new(); 147 | params.insert("regex".to_string(), regex); 148 | params.insert("baseurl".to_string(), baseurl); 149 | params.insert("start".to_string(), start); 150 | params.insert("count".to_string(), count); 151 | super::call(service, "search", "view", "messagesByResponseRegex", params) 152 | } 153 | 154 | /** 155 | * Returns the HTTP messages that match the given regular expression in the header(s) optionally filtered by URL and paginated with 'start' position and 'count' of messages. 156 | */ 157 | pub fn messages_by_header_regex( 158 | service: &ZapService, 159 | regex: String, 160 | baseurl: String, 161 | start: String, 162 | count: String, 163 | ) -> Result { 164 | let mut params = HashMap::new(); 165 | params.insert("regex".to_string(), regex); 166 | params.insert("baseurl".to_string(), baseurl); 167 | params.insert("start".to_string(), start); 168 | params.insert("count".to_string(), count); 169 | super::call(service, "search", "view", "messagesByHeaderRegex", params) 170 | } 171 | 172 | /** 173 | * Returns the HTTP messages, in HAR format, that match the given regular expression in the URL optionally filtered by URL and paginated with 'start' position and 'count' of messages. 174 | */ 175 | pub fn har_by_url_regex( 176 | service: &ZapService, 177 | regex: String, 178 | baseurl: String, 179 | start: String, 180 | count: String, 181 | ) -> Result { 182 | let mut params = HashMap::new(); 183 | params.insert("regex".to_string(), regex); 184 | params.insert("baseurl".to_string(), baseurl); 185 | params.insert("start".to_string(), start); 186 | params.insert("count".to_string(), count); 187 | super::call(service, "search", "other", "harByUrlRegex", params) 188 | } 189 | 190 | /** 191 | * Returns the HTTP messages, in HAR format, that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages. 192 | */ 193 | pub fn har_by_request_regex( 194 | service: &ZapService, 195 | regex: String, 196 | baseurl: String, 197 | start: String, 198 | count: String, 199 | ) -> Result { 200 | let mut params = HashMap::new(); 201 | params.insert("regex".to_string(), regex); 202 | params.insert("baseurl".to_string(), baseurl); 203 | params.insert("start".to_string(), start); 204 | params.insert("count".to_string(), count); 205 | super::call(service, "search", "other", "harByRequestRegex", params) 206 | } 207 | 208 | /** 209 | * Returns the HTTP messages, in HAR format, that match the given regular expression in the response optionally filtered by URL and paginated with 'start' position and 'count' of messages. 210 | */ 211 | pub fn har_by_response_regex( 212 | service: &ZapService, 213 | regex: String, 214 | baseurl: String, 215 | start: String, 216 | count: String, 217 | ) -> Result { 218 | let mut params = HashMap::new(); 219 | params.insert("regex".to_string(), regex); 220 | params.insert("baseurl".to_string(), baseurl); 221 | params.insert("start".to_string(), start); 222 | params.insert("count".to_string(), count); 223 | super::call(service, "search", "other", "harByResponseRegex", params) 224 | } 225 | 226 | /** 227 | * Returns the HTTP messages, in HAR format, that match the given regular expression in the header(s) optionally filtered by URL and paginated with 'start' position and 'count' of messages. 228 | */ 229 | pub fn har_by_header_regex( 230 | service: &ZapService, 231 | regex: String, 232 | baseurl: String, 233 | start: String, 234 | count: String, 235 | ) -> Result { 236 | let mut params = HashMap::new(); 237 | params.insert("regex".to_string(), regex); 238 | params.insert("baseurl".to_string(), baseurl); 239 | params.insert("start".to_string(), start); 240 | params.insert("count".to_string(), count); 241 | super::call(service, "search", "other", "harByHeaderRegex", params) 242 | } 243 | -------------------------------------------------------------------------------- /src/selenium.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Returns the current path to ChromeDriver 30 | *

31 | * This component is optional and therefore the API will only work if it is installed 32 | */ 33 | pub fn option_chrome_driver_path(service: &ZapService) -> Result { 34 | let params = HashMap::new(); 35 | super::call( 36 | service, 37 | "selenium", 38 | "view", 39 | "optionChromeDriverPath", 40 | params, 41 | ) 42 | } 43 | 44 | /** 45 | * Returns the current path to Firefox binary 46 | *

47 | * This component is optional and therefore the API will only work if it is installed 48 | */ 49 | pub fn option_firefox_binary_path(service: &ZapService) -> Result { 50 | let params = HashMap::new(); 51 | super::call( 52 | service, 53 | "selenium", 54 | "view", 55 | "optionFirefoxBinaryPath", 56 | params, 57 | ) 58 | } 59 | 60 | /** 61 | * Returns the current path to Firefox driver (geckodriver) 62 | *

63 | * This component is optional and therefore the API will only work if it is installed 64 | */ 65 | pub fn option_firefox_driver_path(service: &ZapService) -> Result { 66 | let params = HashMap::new(); 67 | super::call( 68 | service, 69 | "selenium", 70 | "view", 71 | "optionFirefoxDriverPath", 72 | params, 73 | ) 74 | } 75 | 76 | /** 77 | * This component is optional and therefore the API will only work if it is installed 78 | */ 79 | pub fn option_ie_driver_path(service: &ZapService) -> Result { 80 | let params = HashMap::new(); 81 | super::call(service, "selenium", "view", "optionIeDriverPath", params) 82 | } 83 | 84 | /** 85 | * Returns the current path to PhantomJS binary 86 | *

87 | * This component is optional and therefore the API will only work if it is installed 88 | */ 89 | pub fn option_phantom_js_binary_path(service: &ZapService) -> Result { 90 | let params = HashMap::new(); 91 | super::call( 92 | service, 93 | "selenium", 94 | "view", 95 | "optionPhantomJsBinaryPath", 96 | params, 97 | ) 98 | } 99 | 100 | /** 101 | * Sets the current path to ChromeDriver 102 | *

103 | * This component is optional and therefore the API will only work if it is installed 104 | */ 105 | pub fn set_option_chrome_driver_path( 106 | service: &ZapService, 107 | string: String, 108 | ) -> Result { 109 | let mut params = HashMap::new(); 110 | params.insert("String".to_string(), string); 111 | super::call( 112 | service, 113 | "selenium", 114 | "action", 115 | "setOptionChromeDriverPath", 116 | params, 117 | ) 118 | } 119 | 120 | /** 121 | * Sets the current path to Firefox binary 122 | *

123 | * This component is optional and therefore the API will only work if it is installed 124 | */ 125 | pub fn set_option_firefox_binary_path( 126 | service: &ZapService, 127 | string: String, 128 | ) -> Result { 129 | let mut params = HashMap::new(); 130 | params.insert("String".to_string(), string); 131 | super::call( 132 | service, 133 | "selenium", 134 | "action", 135 | "setOptionFirefoxBinaryPath", 136 | params, 137 | ) 138 | } 139 | 140 | /** 141 | * Sets the current path to Firefox driver (geckodriver) 142 | *

143 | * This component is optional and therefore the API will only work if it is installed 144 | */ 145 | pub fn set_option_firefox_driver_path( 146 | service: &ZapService, 147 | string: String, 148 | ) -> Result { 149 | let mut params = HashMap::new(); 150 | params.insert("String".to_string(), string); 151 | super::call( 152 | service, 153 | "selenium", 154 | "action", 155 | "setOptionFirefoxDriverPath", 156 | params, 157 | ) 158 | } 159 | 160 | /** 161 | * This component is optional and therefore the API will only work if it is installed 162 | */ 163 | pub fn set_option_ie_driver_path( 164 | service: &ZapService, 165 | string: String, 166 | ) -> Result { 167 | let mut params = HashMap::new(); 168 | params.insert("String".to_string(), string); 169 | super::call( 170 | service, 171 | "selenium", 172 | "action", 173 | "setOptionIeDriverPath", 174 | params, 175 | ) 176 | } 177 | 178 | /** 179 | * Sets the current path to PhantomJS binary 180 | *

181 | * This component is optional and therefore the API will only work if it is installed 182 | */ 183 | pub fn set_option_phantom_js_binary_path( 184 | service: &ZapService, 185 | string: String, 186 | ) -> Result { 187 | let mut params = HashMap::new(); 188 | params.insert("String".to_string(), string); 189 | super::call( 190 | service, 191 | "selenium", 192 | "action", 193 | "setOptionPhantomJsBinaryPath", 194 | params, 195 | ) 196 | } 197 | -------------------------------------------------------------------------------- /src/session_management.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Gets the name of the session management methods. 30 | */ 31 | pub fn get_supported_session_management_methods( 32 | service: &ZapService, 33 | ) -> Result { 34 | let params = HashMap::new(); 35 | super::call( 36 | service, 37 | "sessionManagement", 38 | "view", 39 | "getSupportedSessionManagementMethods", 40 | params, 41 | ) 42 | } 43 | 44 | /** 45 | * Gets the configuration parameters for the session management method with the given name. 46 | */ 47 | pub fn get_session_management_method_config_params( 48 | service: &ZapService, 49 | methodname: String, 50 | ) -> Result { 51 | let mut params = HashMap::new(); 52 | params.insert("methodName".to_string(), methodname); 53 | super::call( 54 | service, 55 | "sessionManagement", 56 | "view", 57 | "getSessionManagementMethodConfigParams", 58 | params, 59 | ) 60 | } 61 | 62 | /** 63 | * Gets the name of the session management method for the context with the given ID. 64 | */ 65 | pub fn get_session_management_method( 66 | service: &ZapService, 67 | contextid: String, 68 | ) -> Result { 69 | let mut params = HashMap::new(); 70 | params.insert("contextId".to_string(), contextid); 71 | super::call( 72 | service, 73 | "sessionManagement", 74 | "view", 75 | "getSessionManagementMethod", 76 | params, 77 | ) 78 | } 79 | 80 | /** 81 | * Sets the session management method for the context with the given ID. 82 | */ 83 | pub fn set_session_management_method( 84 | service: &ZapService, 85 | contextid: String, 86 | methodname: String, 87 | methodconfigparams: String, 88 | ) -> Result { 89 | let mut params = HashMap::new(); 90 | params.insert("contextId".to_string(), contextid); 91 | params.insert("methodName".to_string(), methodname); 92 | params.insert("methodConfigParams".to_string(), methodconfigparams); 93 | super::call( 94 | service, 95 | "sessionManagement", 96 | "action", 97 | "setSessionManagementMethod", 98 | params, 99 | ) 100 | } 101 | -------------------------------------------------------------------------------- /src/soap.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Import a WSDL definition from local file. 30 | *

31 | * This component is optional and therefore the API will only work if it is installed 32 | */ 33 | pub fn import_file(service: &ZapService, file: String) -> Result { 34 | let mut params = HashMap::new(); 35 | params.insert("file".to_string(), file); 36 | super::call(service, "soap", "action", "importFile", params) 37 | } 38 | 39 | /** 40 | * Import a WSDL definition from a URL. 41 | *

42 | * This component is optional and therefore the API will only work if it is installed 43 | */ 44 | pub fn import_url(service: &ZapService, url: String) -> Result { 45 | let mut params = HashMap::new(); 46 | params.insert("url".to_string(), url); 47 | super::call(service, "soap", "action", "importUrl", params) 48 | } 49 | -------------------------------------------------------------------------------- /src/spider.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | pub fn status(service: &ZapService, scanid: String) -> Result { 29 | let mut params = HashMap::new(); 30 | params.insert("scanId".to_string(), scanid); 31 | super::call(service, "spider", "view", "status", params) 32 | } 33 | 34 | pub fn results(service: &ZapService, scanid: String) -> Result { 35 | let mut params = HashMap::new(); 36 | params.insert("scanId".to_string(), scanid); 37 | super::call(service, "spider", "view", "results", params) 38 | } 39 | 40 | pub fn full_results(service: &ZapService, scanid: String) -> Result { 41 | let mut params = HashMap::new(); 42 | params.insert("scanId".to_string(), scanid); 43 | super::call(service, "spider", "view", "fullResults", params) 44 | } 45 | 46 | pub fn scans(service: &ZapService) -> Result { 47 | let params = HashMap::new(); 48 | super::call(service, "spider", "view", "scans", params) 49 | } 50 | 51 | /** 52 | * Gets the regexes of URLs excluded from the spider scans. 53 | */ 54 | pub fn excluded_from_scan(service: &ZapService) -> Result { 55 | let params = HashMap::new(); 56 | super::call(service, "spider", "view", "excludedFromScan", params) 57 | } 58 | 59 | /** 60 | * Returns a list of unique URLs from the history table based on HTTP messages added by the Spider. 61 | */ 62 | pub fn all_urls(service: &ZapService) -> Result { 63 | let params = HashMap::new(); 64 | super::call(service, "spider", "view", "allUrls", params) 65 | } 66 | 67 | /** 68 | * Returns a list of the names of the nodes added to the Sites tree by the specified scan. 69 | */ 70 | pub fn added_nodes(service: &ZapService, scanid: String) -> Result { 71 | let mut params = HashMap::new(); 72 | params.insert("scanId".to_string(), scanid); 73 | super::call(service, "spider", "view", "addedNodes", params) 74 | } 75 | 76 | /** 77 | * Gets all the domains that are always in scope. For each domain the following are shown: the index, the value (domain), if enabled, and if specified as a regex. 78 | */ 79 | pub fn domains_always_in_scope(service: &ZapService) -> Result { 80 | let params = HashMap::new(); 81 | super::call(service, "spider", "view", "domainsAlwaysInScope", params) 82 | } 83 | 84 | /** 85 | * Use view domainsAlwaysInScope instead. 86 | * Deprecated 87 | */ 88 | pub fn option_domains_always_in_scope(service: &ZapService) -> Result { 89 | let params = HashMap::new(); 90 | super::call( 91 | service, 92 | "spider", 93 | "view", 94 | "optionDomainsAlwaysInScope", 95 | params, 96 | ) 97 | } 98 | 99 | /** 100 | * Use view domainsAlwaysInScope instead. 101 | * Deprecated 102 | */ 103 | pub fn option_domains_always_in_scope_enabled(service: &ZapService) -> Result { 104 | let params = HashMap::new(); 105 | super::call( 106 | service, 107 | "spider", 108 | "view", 109 | "optionDomainsAlwaysInScopeEnabled", 110 | params, 111 | ) 112 | } 113 | 114 | pub fn option_handle_parameters(service: &ZapService) -> Result { 115 | let params = HashMap::new(); 116 | super::call(service, "spider", "view", "optionHandleParameters", params) 117 | } 118 | 119 | /** 120 | * Gets the maximum number of child nodes (per node) that can be crawled, 0 means no limit. 121 | */ 122 | pub fn option_max_children(service: &ZapService) -> Result { 123 | let params = HashMap::new(); 124 | super::call(service, "spider", "view", "optionMaxChildren", params) 125 | } 126 | 127 | /** 128 | * Gets the maximum depth the spider can crawl, 0 if unlimited. 129 | */ 130 | pub fn option_max_depth(service: &ZapService) -> Result { 131 | let params = HashMap::new(); 132 | super::call(service, "spider", "view", "optionMaxDepth", params) 133 | } 134 | 135 | pub fn option_max_duration(service: &ZapService) -> Result { 136 | let params = HashMap::new(); 137 | super::call(service, "spider", "view", "optionMaxDuration", params) 138 | } 139 | 140 | /** 141 | * Gets the maximum size, in bytes, that a response might have to be parsed. 142 | */ 143 | pub fn option_max_parse_size_bytes(service: &ZapService) -> Result { 144 | let params = HashMap::new(); 145 | super::call(service, "spider", "view", "optionMaxParseSizeBytes", params) 146 | } 147 | 148 | pub fn option_max_scans_in_ui(service: &ZapService) -> Result { 149 | let params = HashMap::new(); 150 | super::call(service, "spider", "view", "optionMaxScansInUI", params) 151 | } 152 | 153 | pub fn option_request_wait_time(service: &ZapService) -> Result { 154 | let params = HashMap::new(); 155 | super::call(service, "spider", "view", "optionRequestWaitTime", params) 156 | } 157 | 158 | pub fn option_scope(service: &ZapService) -> Result { 159 | let params = HashMap::new(); 160 | super::call(service, "spider", "view", "optionScope", params) 161 | } 162 | 163 | pub fn option_scope_text(service: &ZapService) -> Result { 164 | let params = HashMap::new(); 165 | super::call(service, "spider", "view", "optionScopeText", params) 166 | } 167 | 168 | pub fn option_skip_url_string(service: &ZapService) -> Result { 169 | let params = HashMap::new(); 170 | super::call(service, "spider", "view", "optionSkipURLString", params) 171 | } 172 | 173 | pub fn option_thread_count(service: &ZapService) -> Result { 174 | let params = HashMap::new(); 175 | super::call(service, "spider", "view", "optionThreadCount", params) 176 | } 177 | 178 | pub fn option_user_agent(service: &ZapService) -> Result { 179 | let params = HashMap::new(); 180 | super::call(service, "spider", "view", "optionUserAgent", params) 181 | } 182 | 183 | /** 184 | * Gets whether or not a spider process should accept cookies while spidering. 185 | */ 186 | pub fn option_accept_cookies(service: &ZapService) -> Result { 187 | let params = HashMap::new(); 188 | super::call(service, "spider", "view", "optionAcceptCookies", params) 189 | } 190 | 191 | pub fn option_handle_o_data_parameters_visited(service: &ZapService) -> Result { 192 | let params = HashMap::new(); 193 | super::call( 194 | service, 195 | "spider", 196 | "view", 197 | "optionHandleODataParametersVisited", 198 | params, 199 | ) 200 | } 201 | 202 | pub fn option_parse_comments(service: &ZapService) -> Result { 203 | let params = HashMap::new(); 204 | super::call(service, "spider", "view", "optionParseComments", params) 205 | } 206 | 207 | pub fn option_parse_git(service: &ZapService) -> Result { 208 | let params = HashMap::new(); 209 | super::call(service, "spider", "view", "optionParseGit", params) 210 | } 211 | 212 | pub fn option_parse_robots_txt(service: &ZapService) -> Result { 213 | let params = HashMap::new(); 214 | super::call(service, "spider", "view", "optionParseRobotsTxt", params) 215 | } 216 | 217 | pub fn option_parse_svn_entries(service: &ZapService) -> Result { 218 | let params = HashMap::new(); 219 | super::call(service, "spider", "view", "optionParseSVNEntries", params) 220 | } 221 | 222 | pub fn option_parse_sitemap_xml(service: &ZapService) -> Result { 223 | let params = HashMap::new(); 224 | super::call(service, "spider", "view", "optionParseSitemapXml", params) 225 | } 226 | 227 | pub fn option_post_form(service: &ZapService) -> Result { 228 | let params = HashMap::new(); 229 | super::call(service, "spider", "view", "optionPostForm", params) 230 | } 231 | 232 | pub fn option_process_form(service: &ZapService) -> Result { 233 | let params = HashMap::new(); 234 | super::call(service, "spider", "view", "optionProcessForm", params) 235 | } 236 | 237 | /** 238 | * Gets whether or not the 'Referer' header should be sent while spidering. 239 | */ 240 | pub fn option_send_referer_header(service: &ZapService) -> Result { 241 | let params = HashMap::new(); 242 | super::call(service, "spider", "view", "optionSendRefererHeader", params) 243 | } 244 | 245 | pub fn option_show_advanced_dialog(service: &ZapService) -> Result { 246 | let params = HashMap::new(); 247 | super::call( 248 | service, 249 | "spider", 250 | "view", 251 | "optionShowAdvancedDialog", 252 | params, 253 | ) 254 | } 255 | 256 | /** 257 | * Runs the spider against the given URL (or context). Optionally, the 'maxChildren' parameter can be set to limit the number of children scanned, the 'recurse' parameter can be used to prevent the spider from seeding recursively, the parameter 'contextName' can be used to constrain the scan to a Context and the parameter 'subtreeOnly' allows to restrict the spider under a site's subtree (using the specified 'url'). 258 | */ 259 | pub fn scan( 260 | service: &ZapService, 261 | url: String, 262 | maxchildren: String, 263 | recurse: String, 264 | contextname: String, 265 | subtreeonly: String, 266 | ) -> Result { 267 | let mut params = HashMap::new(); 268 | params.insert("url".to_string(), url); 269 | params.insert("maxChildren".to_string(), maxchildren); 270 | params.insert("recurse".to_string(), recurse); 271 | params.insert("contextName".to_string(), contextname); 272 | params.insert("subtreeOnly".to_string(), subtreeonly); 273 | super::call(service, "spider", "action", "scan", params) 274 | } 275 | 276 | /** 277 | * Runs the spider from the perspective of a User, obtained using the given Context ID and User ID. See 'scan' action for more details. 278 | */ 279 | pub fn scan_as_user( 280 | service: &ZapService, 281 | contextid: String, 282 | userid: String, 283 | url: String, 284 | maxchildren: String, 285 | recurse: String, 286 | subtreeonly: String, 287 | ) -> Result { 288 | let mut params = HashMap::new(); 289 | params.insert("contextId".to_string(), contextid); 290 | params.insert("userId".to_string(), userid); 291 | params.insert("url".to_string(), url); 292 | params.insert("maxChildren".to_string(), maxchildren); 293 | params.insert("recurse".to_string(), recurse); 294 | params.insert("subtreeOnly".to_string(), subtreeonly); 295 | super::call(service, "spider", "action", "scanAsUser", params) 296 | } 297 | 298 | pub fn pause(service: &ZapService, scanid: String) -> Result { 299 | let mut params = HashMap::new(); 300 | params.insert("scanId".to_string(), scanid); 301 | super::call(service, "spider", "action", "pause", params) 302 | } 303 | 304 | pub fn resume(service: &ZapService, scanid: String) -> Result { 305 | let mut params = HashMap::new(); 306 | params.insert("scanId".to_string(), scanid); 307 | super::call(service, "spider", "action", "resume", params) 308 | } 309 | 310 | pub fn stop(service: &ZapService, scanid: String) -> Result { 311 | let mut params = HashMap::new(); 312 | params.insert("scanId".to_string(), scanid); 313 | super::call(service, "spider", "action", "stop", params) 314 | } 315 | 316 | pub fn remove_scan(service: &ZapService, scanid: String) -> Result { 317 | let mut params = HashMap::new(); 318 | params.insert("scanId".to_string(), scanid); 319 | super::call(service, "spider", "action", "removeScan", params) 320 | } 321 | 322 | pub fn pause_all_scans(service: &ZapService) -> Result { 323 | let params = HashMap::new(); 324 | super::call(service, "spider", "action", "pauseAllScans", params) 325 | } 326 | 327 | pub fn resume_all_scans(service: &ZapService) -> Result { 328 | let params = HashMap::new(); 329 | super::call(service, "spider", "action", "resumeAllScans", params) 330 | } 331 | 332 | pub fn stop_all_scans(service: &ZapService) -> Result { 333 | let params = HashMap::new(); 334 | super::call(service, "spider", "action", "stopAllScans", params) 335 | } 336 | 337 | pub fn remove_all_scans(service: &ZapService) -> Result { 338 | let params = HashMap::new(); 339 | super::call(service, "spider", "action", "removeAllScans", params) 340 | } 341 | 342 | /** 343 | * Clears the regexes of URLs excluded from the spider scans. 344 | */ 345 | pub fn clear_excluded_from_scan(service: &ZapService) -> Result { 346 | let params = HashMap::new(); 347 | super::call(service, "spider", "action", "clearExcludedFromScan", params) 348 | } 349 | 350 | /** 351 | * Adds a regex of URLs that should be excluded from the spider scans. 352 | */ 353 | pub fn exclude_from_scan(service: &ZapService, regex: String) -> Result { 354 | let mut params = HashMap::new(); 355 | params.insert("regex".to_string(), regex); 356 | super::call(service, "spider", "action", "excludeFromScan", params) 357 | } 358 | 359 | /** 360 | * Adds a new domain that's always in scope, using the specified value. Optionally sets if the new entry is enabled (default, true) and whether or not the new value is specified as a regex (default, false). 361 | */ 362 | pub fn add_domain_always_in_scope( 363 | service: &ZapService, 364 | value: String, 365 | isregex: String, 366 | isenabled: String, 367 | ) -> Result { 368 | let mut params = HashMap::new(); 369 | params.insert("value".to_string(), value); 370 | params.insert("isRegex".to_string(), isregex); 371 | params.insert("isEnabled".to_string(), isenabled); 372 | super::call( 373 | service, 374 | "spider", 375 | "action", 376 | "addDomainAlwaysInScope", 377 | params, 378 | ) 379 | } 380 | 381 | /** 382 | * Modifies a domain that's always in scope. Allows to modify the value, if enabled or if a regex. The domain is selected with its index, which can be obtained with the view domainsAlwaysInScope. 383 | */ 384 | pub fn modify_domain_always_in_scope( 385 | service: &ZapService, 386 | idx: String, 387 | value: String, 388 | isregex: String, 389 | isenabled: String, 390 | ) -> Result { 391 | let mut params = HashMap::new(); 392 | params.insert("idx".to_string(), idx); 393 | params.insert("value".to_string(), value); 394 | params.insert("isRegex".to_string(), isregex); 395 | params.insert("isEnabled".to_string(), isenabled); 396 | super::call( 397 | service, 398 | "spider", 399 | "action", 400 | "modifyDomainAlwaysInScope", 401 | params, 402 | ) 403 | } 404 | 405 | /** 406 | * Removes a domain that's always in scope, with the given index. The index can be obtained with the view domainsAlwaysInScope. 407 | */ 408 | pub fn remove_domain_always_in_scope( 409 | service: &ZapService, 410 | idx: String, 411 | ) -> Result { 412 | let mut params = HashMap::new(); 413 | params.insert("idx".to_string(), idx); 414 | super::call( 415 | service, 416 | "spider", 417 | "action", 418 | "removeDomainAlwaysInScope", 419 | params, 420 | ) 421 | } 422 | 423 | /** 424 | * Enables all domains that are always in scope. 425 | */ 426 | pub fn enable_all_domains_always_in_scope(service: &ZapService) -> Result { 427 | let params = HashMap::new(); 428 | super::call( 429 | service, 430 | "spider", 431 | "action", 432 | "enableAllDomainsAlwaysInScope", 433 | params, 434 | ) 435 | } 436 | 437 | /** 438 | * Disables all domains that are always in scope. 439 | */ 440 | pub fn disable_all_domains_always_in_scope(service: &ZapService) -> Result { 441 | let params = HashMap::new(); 442 | super::call( 443 | service, 444 | "spider", 445 | "action", 446 | "disableAllDomainsAlwaysInScope", 447 | params, 448 | ) 449 | } 450 | 451 | pub fn set_option_handle_parameters( 452 | service: &ZapService, 453 | string: String, 454 | ) -> Result { 455 | let mut params = HashMap::new(); 456 | params.insert("String".to_string(), string); 457 | super::call( 458 | service, 459 | "spider", 460 | "action", 461 | "setOptionHandleParameters", 462 | params, 463 | ) 464 | } 465 | 466 | /** 467 | * Use actions [add|modify|remove]DomainAlwaysInScope instead. 468 | * Deprecated Option no longer in effective use. 469 | */ 470 | pub fn set_option_scope_string(service: &ZapService, string: String) -> Result { 471 | let mut params = HashMap::new(); 472 | params.insert("String".to_string(), string); 473 | super::call(service, "spider", "action", "setOptionScopeString", params) 474 | } 475 | 476 | pub fn set_option_skip_url_string( 477 | service: &ZapService, 478 | string: String, 479 | ) -> Result { 480 | let mut params = HashMap::new(); 481 | params.insert("String".to_string(), string); 482 | super::call( 483 | service, 484 | "spider", 485 | "action", 486 | "setOptionSkipURLString", 487 | params, 488 | ) 489 | } 490 | 491 | pub fn set_option_user_agent(service: &ZapService, string: String) -> Result { 492 | let mut params = HashMap::new(); 493 | params.insert("String".to_string(), string); 494 | super::call(service, "spider", "action", "setOptionUserAgent", params) 495 | } 496 | 497 | /** 498 | * Sets whether or not a spider process should accept cookies while spidering. 499 | */ 500 | pub fn set_option_accept_cookies( 501 | service: &ZapService, 502 | boolean: String, 503 | ) -> Result { 504 | let mut params = HashMap::new(); 505 | params.insert("Boolean".to_string(), boolean); 506 | super::call( 507 | service, 508 | "spider", 509 | "action", 510 | "setOptionAcceptCookies", 511 | params, 512 | ) 513 | } 514 | 515 | pub fn set_option_handle_o_data_parameters_visited( 516 | service: &ZapService, 517 | boolean: String, 518 | ) -> Result { 519 | let mut params = HashMap::new(); 520 | params.insert("Boolean".to_string(), boolean); 521 | super::call( 522 | service, 523 | "spider", 524 | "action", 525 | "setOptionHandleODataParametersVisited", 526 | params, 527 | ) 528 | } 529 | 530 | /** 531 | * Sets the maximum number of child nodes (per node) that can be crawled, 0 means no limit. 532 | */ 533 | pub fn set_option_max_children( 534 | service: &ZapService, 535 | integer: String, 536 | ) -> Result { 537 | let mut params = HashMap::new(); 538 | params.insert("Integer".to_string(), integer); 539 | super::call(service, "spider", "action", "setOptionMaxChildren", params) 540 | } 541 | 542 | /** 543 | * Sets the maximum depth the spider can crawl, 0 for unlimited depth. 544 | */ 545 | pub fn set_option_max_depth(service: &ZapService, integer: String) -> Result { 546 | let mut params = HashMap::new(); 547 | params.insert("Integer".to_string(), integer); 548 | super::call(service, "spider", "action", "setOptionMaxDepth", params) 549 | } 550 | 551 | pub fn set_option_max_duration( 552 | service: &ZapService, 553 | integer: String, 554 | ) -> Result { 555 | let mut params = HashMap::new(); 556 | params.insert("Integer".to_string(), integer); 557 | super::call(service, "spider", "action", "setOptionMaxDuration", params) 558 | } 559 | 560 | /** 561 | * Sets the maximum size, in bytes, that a response might have to be parsed. This allows the spider to skip big responses/files. 562 | */ 563 | pub fn set_option_max_parse_size_bytes( 564 | service: &ZapService, 565 | integer: String, 566 | ) -> Result { 567 | let mut params = HashMap::new(); 568 | params.insert("Integer".to_string(), integer); 569 | super::call( 570 | service, 571 | "spider", 572 | "action", 573 | "setOptionMaxParseSizeBytes", 574 | params, 575 | ) 576 | } 577 | 578 | pub fn set_option_max_scans_in_ui( 579 | service: &ZapService, 580 | integer: String, 581 | ) -> Result { 582 | let mut params = HashMap::new(); 583 | params.insert("Integer".to_string(), integer); 584 | super::call(service, "spider", "action", "setOptionMaxScansInUI", params) 585 | } 586 | 587 | pub fn set_option_parse_comments( 588 | service: &ZapService, 589 | boolean: String, 590 | ) -> Result { 591 | let mut params = HashMap::new(); 592 | params.insert("Boolean".to_string(), boolean); 593 | super::call( 594 | service, 595 | "spider", 596 | "action", 597 | "setOptionParseComments", 598 | params, 599 | ) 600 | } 601 | 602 | pub fn set_option_parse_git(service: &ZapService, boolean: String) -> Result { 603 | let mut params = HashMap::new(); 604 | params.insert("Boolean".to_string(), boolean); 605 | super::call(service, "spider", "action", "setOptionParseGit", params) 606 | } 607 | 608 | pub fn set_option_parse_robots_txt( 609 | service: &ZapService, 610 | boolean: String, 611 | ) -> Result { 612 | let mut params = HashMap::new(); 613 | params.insert("Boolean".to_string(), boolean); 614 | super::call( 615 | service, 616 | "spider", 617 | "action", 618 | "setOptionParseRobotsTxt", 619 | params, 620 | ) 621 | } 622 | 623 | pub fn set_option_parse_svn_entries( 624 | service: &ZapService, 625 | boolean: String, 626 | ) -> Result { 627 | let mut params = HashMap::new(); 628 | params.insert("Boolean".to_string(), boolean); 629 | super::call( 630 | service, 631 | "spider", 632 | "action", 633 | "setOptionParseSVNEntries", 634 | params, 635 | ) 636 | } 637 | 638 | pub fn set_option_parse_sitemap_xml( 639 | service: &ZapService, 640 | boolean: String, 641 | ) -> Result { 642 | let mut params = HashMap::new(); 643 | params.insert("Boolean".to_string(), boolean); 644 | super::call( 645 | service, 646 | "spider", 647 | "action", 648 | "setOptionParseSitemapXml", 649 | params, 650 | ) 651 | } 652 | 653 | pub fn set_option_post_form(service: &ZapService, boolean: String) -> Result { 654 | let mut params = HashMap::new(); 655 | params.insert("Boolean".to_string(), boolean); 656 | super::call(service, "spider", "action", "setOptionPostForm", params) 657 | } 658 | 659 | pub fn set_option_process_form( 660 | service: &ZapService, 661 | boolean: String, 662 | ) -> Result { 663 | let mut params = HashMap::new(); 664 | params.insert("Boolean".to_string(), boolean); 665 | super::call(service, "spider", "action", "setOptionProcessForm", params) 666 | } 667 | 668 | pub fn set_option_request_wait_time( 669 | service: &ZapService, 670 | integer: String, 671 | ) -> Result { 672 | let mut params = HashMap::new(); 673 | params.insert("Integer".to_string(), integer); 674 | super::call( 675 | service, 676 | "spider", 677 | "action", 678 | "setOptionRequestWaitTime", 679 | params, 680 | ) 681 | } 682 | 683 | /** 684 | * Sets whether or not the 'Referer' header should be sent while spidering. 685 | */ 686 | pub fn set_option_send_referer_header( 687 | service: &ZapService, 688 | boolean: String, 689 | ) -> Result { 690 | let mut params = HashMap::new(); 691 | params.insert("Boolean".to_string(), boolean); 692 | super::call( 693 | service, 694 | "spider", 695 | "action", 696 | "setOptionSendRefererHeader", 697 | params, 698 | ) 699 | } 700 | 701 | pub fn set_option_show_advanced_dialog( 702 | service: &ZapService, 703 | boolean: String, 704 | ) -> Result { 705 | let mut params = HashMap::new(); 706 | params.insert("Boolean".to_string(), boolean); 707 | super::call( 708 | service, 709 | "spider", 710 | "action", 711 | "setOptionShowAdvancedDialog", 712 | params, 713 | ) 714 | } 715 | 716 | pub fn set_option_thread_count( 717 | service: &ZapService, 718 | integer: String, 719 | ) -> Result { 720 | let mut params = HashMap::new(); 721 | params.insert("Integer".to_string(), integer); 722 | super::call(service, "spider", "action", "setOptionThreadCount", params) 723 | } 724 | -------------------------------------------------------------------------------- /src/stats.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Statistics 30 | */ 31 | pub fn stats(service: &ZapService, keyprefix: String) -> Result { 32 | let mut params = HashMap::new(); 33 | params.insert("keyPrefix".to_string(), keyprefix); 34 | super::call(service, "stats", "view", "stats", params) 35 | } 36 | 37 | /** 38 | * Gets all of the site based statistics, optionally filtered by a key prefix 39 | */ 40 | pub fn all_sites_stats(service: &ZapService, keyprefix: String) -> Result { 41 | let mut params = HashMap::new(); 42 | params.insert("keyPrefix".to_string(), keyprefix); 43 | super::call(service, "stats", "view", "allSitesStats", params) 44 | } 45 | 46 | /** 47 | * Gets all of the global statistics, optionally filtered by a key prefix 48 | */ 49 | pub fn site_stats( 50 | service: &ZapService, 51 | site: String, 52 | keyprefix: String, 53 | ) -> Result { 54 | let mut params = HashMap::new(); 55 | params.insert("site".to_string(), site); 56 | params.insert("keyPrefix".to_string(), keyprefix); 57 | super::call(service, "stats", "view", "siteStats", params) 58 | } 59 | 60 | /** 61 | * Gets the Statsd service hostname 62 | */ 63 | pub fn option_statsd_host(service: &ZapService) -> Result { 64 | let params = HashMap::new(); 65 | super::call(service, "stats", "view", "optionStatsdHost", params) 66 | } 67 | 68 | /** 69 | * Gets the Statsd service port 70 | */ 71 | pub fn option_statsd_port(service: &ZapService) -> Result { 72 | let params = HashMap::new(); 73 | super::call(service, "stats", "view", "optionStatsdPort", params) 74 | } 75 | 76 | /** 77 | * Gets the prefix to be applied to all stats sent to the configured Statsd service 78 | */ 79 | pub fn option_statsd_prefix(service: &ZapService) -> Result { 80 | let params = HashMap::new(); 81 | super::call(service, "stats", "view", "optionStatsdPrefix", params) 82 | } 83 | 84 | /** 85 | * Returns 'true' if in memory statistics are enabled, otherwise returns 'false' 86 | */ 87 | pub fn option_in_memory_enabled(service: &ZapService) -> Result { 88 | let params = HashMap::new(); 89 | super::call(service, "stats", "view", "optionInMemoryEnabled", params) 90 | } 91 | 92 | /** 93 | * Returns 'true' if a Statsd server has been correctly configured, otherwise returns 'false' 94 | */ 95 | pub fn option_statsd_enabled(service: &ZapService) -> Result { 96 | let params = HashMap::new(); 97 | super::call(service, "stats", "view", "optionStatsdEnabled", params) 98 | } 99 | 100 | /** 101 | * Clears all of the statistics 102 | */ 103 | pub fn clear_stats(service: &ZapService, keyprefix: String) -> Result { 104 | let mut params = HashMap::new(); 105 | params.insert("keyPrefix".to_string(), keyprefix); 106 | super::call(service, "stats", "action", "clearStats", params) 107 | } 108 | 109 | /** 110 | * Sets the Statsd service hostname, supply an empty string to stop using a Statsd service 111 | */ 112 | pub fn set_option_statsd_host(service: &ZapService, string: String) -> Result { 113 | let mut params = HashMap::new(); 114 | params.insert("String".to_string(), string); 115 | super::call(service, "stats", "action", "setOptionStatsdHost", params) 116 | } 117 | 118 | /** 119 | * Sets the prefix to be applied to all stats sent to the configured Statsd service 120 | */ 121 | pub fn set_option_statsd_prefix( 122 | service: &ZapService, 123 | string: String, 124 | ) -> Result { 125 | let mut params = HashMap::new(); 126 | params.insert("String".to_string(), string); 127 | super::call(service, "stats", "action", "setOptionStatsdPrefix", params) 128 | } 129 | 130 | /** 131 | * Sets whether in memory statistics are enabled 132 | */ 133 | pub fn set_option_in_memory_enabled( 134 | service: &ZapService, 135 | boolean: String, 136 | ) -> Result { 137 | let mut params = HashMap::new(); 138 | params.insert("Boolean".to_string(), boolean); 139 | super::call( 140 | service, 141 | "stats", 142 | "action", 143 | "setOptionInMemoryEnabled", 144 | params, 145 | ) 146 | } 147 | 148 | /** 149 | * Sets the Statsd service port 150 | */ 151 | pub fn set_option_statsd_port(service: &ZapService, integer: String) -> Result { 152 | let mut params = HashMap::new(); 153 | params.insert("Integer".to_string(), integer); 154 | super::call(service, "stats", "action", "setOptionStatsdPort", params) 155 | } 156 | -------------------------------------------------------------------------------- /src/users.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Gets a list of users that belong to the context with the given ID, or all users if none provided. 30 | */ 31 | pub fn users_list(service: &ZapService, contextid: String) -> Result { 32 | let mut params = HashMap::new(); 33 | params.insert("contextId".to_string(), contextid); 34 | super::call(service, "users", "view", "usersList", params) 35 | } 36 | 37 | /** 38 | * Gets the data of the user with the given ID that belongs to the context with the given ID. 39 | */ 40 | pub fn get_user_by_id( 41 | service: &ZapService, 42 | contextid: String, 43 | userid: String, 44 | ) -> Result { 45 | let mut params = HashMap::new(); 46 | params.insert("contextId".to_string(), contextid); 47 | params.insert("userId".to_string(), userid); 48 | super::call(service, "users", "view", "getUserById", params) 49 | } 50 | 51 | /** 52 | * Gets the configuration parameters for the credentials of the context with the given ID. 53 | */ 54 | pub fn get_authentication_credentials_config_params( 55 | service: &ZapService, 56 | contextid: String, 57 | ) -> Result { 58 | let mut params = HashMap::new(); 59 | params.insert("contextId".to_string(), contextid); 60 | super::call( 61 | service, 62 | "users", 63 | "view", 64 | "getAuthenticationCredentialsConfigParams", 65 | params, 66 | ) 67 | } 68 | 69 | /** 70 | * Gets the authentication credentials of the user with given ID that belongs to the context with the given ID. 71 | */ 72 | pub fn get_authentication_credentials( 73 | service: &ZapService, 74 | contextid: String, 75 | userid: String, 76 | ) -> Result { 77 | let mut params = HashMap::new(); 78 | params.insert("contextId".to_string(), contextid); 79 | params.insert("userId".to_string(), userid); 80 | super::call( 81 | service, 82 | "users", 83 | "view", 84 | "getAuthenticationCredentials", 85 | params, 86 | ) 87 | } 88 | 89 | /** 90 | * Creates a new user with the given name for the context with the given ID. 91 | */ 92 | pub fn new_user( 93 | service: &ZapService, 94 | contextid: String, 95 | name: String, 96 | ) -> Result { 97 | let mut params = HashMap::new(); 98 | params.insert("contextId".to_string(), contextid); 99 | params.insert("name".to_string(), name); 100 | super::call(service, "users", "action", "newUser", params) 101 | } 102 | 103 | /** 104 | * Removes the user with the given ID that belongs to the context with the given ID. 105 | */ 106 | pub fn remove_user( 107 | service: &ZapService, 108 | contextid: String, 109 | userid: String, 110 | ) -> Result { 111 | let mut params = HashMap::new(); 112 | params.insert("contextId".to_string(), contextid); 113 | params.insert("userId".to_string(), userid); 114 | super::call(service, "users", "action", "removeUser", params) 115 | } 116 | 117 | /** 118 | * Sets whether or not the user, with the given ID that belongs to the context with the given ID, should be enabled. 119 | */ 120 | pub fn set_user_enabled( 121 | service: &ZapService, 122 | contextid: String, 123 | userid: String, 124 | enabled: String, 125 | ) -> Result { 126 | let mut params = HashMap::new(); 127 | params.insert("contextId".to_string(), contextid); 128 | params.insert("userId".to_string(), userid); 129 | params.insert("enabled".to_string(), enabled); 130 | super::call(service, "users", "action", "setUserEnabled", params) 131 | } 132 | 133 | /** 134 | * Renames the user with the given ID that belongs to the context with the given ID. 135 | */ 136 | pub fn set_user_name( 137 | service: &ZapService, 138 | contextid: String, 139 | userid: String, 140 | name: String, 141 | ) -> Result { 142 | let mut params = HashMap::new(); 143 | params.insert("contextId".to_string(), contextid); 144 | params.insert("userId".to_string(), userid); 145 | params.insert("name".to_string(), name); 146 | super::call(service, "users", "action", "setUserName", params) 147 | } 148 | 149 | /** 150 | * Sets the authentication credentials for the user with the given ID that belongs to the context with the given ID. 151 | */ 152 | pub fn set_authentication_credentials( 153 | service: &ZapService, 154 | contextid: String, 155 | userid: String, 156 | authcredentialsconfigparams: String, 157 | ) -> Result { 158 | let mut params = HashMap::new(); 159 | params.insert("contextId".to_string(), contextid); 160 | params.insert("userId".to_string(), userid); 161 | params.insert( 162 | "authCredentialsConfigParams".to_string(), 163 | authcredentialsconfigparams, 164 | ); 165 | super::call( 166 | service, 167 | "users", 168 | "action", 169 | "setAuthenticationCredentials", 170 | params, 171 | ) 172 | } 173 | -------------------------------------------------------------------------------- /src/websocket.rs: -------------------------------------------------------------------------------- 1 | /* Zed Attack Proxy (ZAP) and its related class files. 2 | * 3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. 4 | * 5 | * Copyright 2019 the ZAP development team 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | use super::ZapApiError; 21 | use super::ZapService; 22 | use serde_json::Value; 23 | use std::collections::HashMap; 24 | 25 | /** 26 | * This file was automatically generated. 27 | */ 28 | /** 29 | * Returns all of the registered web socket channels 30 | *

31 | * This component is optional and therefore the API will only work if it is installed 32 | */ 33 | pub fn channels(service: &ZapService) -> Result { 34 | let params = HashMap::new(); 35 | super::call(service, "websocket", "view", "channels", params) 36 | } 37 | 38 | /** 39 | * Returns full details of the message specified by the channelId and messageId 40 | *

41 | * This component is optional and therefore the API will only work if it is installed 42 | */ 43 | pub fn message( 44 | service: &ZapService, 45 | channelid: String, 46 | messageid: String, 47 | ) -> Result { 48 | let mut params = HashMap::new(); 49 | params.insert("channelId".to_string(), channelid); 50 | params.insert("messageId".to_string(), messageid); 51 | super::call(service, "websocket", "view", "message", params) 52 | } 53 | 54 | /** 55 | * Returns a list of all of the messages that meet the given criteria (all optional), where channelId is a channel identifier, start is the offset to start returning messages from (starting from 0), count is the number of messages to return (default no limit) and payloadPreviewLength is the maximum number bytes to return for the payload contents 56 | *

57 | * This component is optional and therefore the API will only work if it is installed 58 | */ 59 | pub fn messages( 60 | service: &ZapService, 61 | channelid: String, 62 | start: String, 63 | count: String, 64 | payloadpreviewlength: String, 65 | ) -> Result { 66 | let mut params = HashMap::new(); 67 | params.insert("channelId".to_string(), channelid); 68 | params.insert("start".to_string(), start); 69 | params.insert("count".to_string(), count); 70 | params.insert("payloadPreviewLength".to_string(), payloadpreviewlength); 71 | super::call(service, "websocket", "view", "messages", params) 72 | } 73 | 74 | /** 75 | * Returns a text representation of an intercepted websockets message 76 | *

77 | * This component is optional and therefore the API will only work if it is installed 78 | */ 79 | pub fn break_text_message(service: &ZapService) -> Result { 80 | let params = HashMap::new(); 81 | super::call(service, "websocket", "view", "breakTextMessage", params) 82 | } 83 | 84 | /** 85 | * Sends the specified message on the channel specified by channelId, if outgoing is 'True' then the message will be sent to the server and if it is 'False' then it will be sent to the client 86 | *

87 | * This component is optional and therefore the API will only work if it is installed 88 | */ 89 | pub fn send_text_message( 90 | service: &ZapService, 91 | channelid: String, 92 | outgoing: String, 93 | message: String, 94 | ) -> Result { 95 | let mut params = HashMap::new(); 96 | params.insert("channelId".to_string(), channelid); 97 | params.insert("outgoing".to_string(), outgoing); 98 | params.insert("message".to_string(), message); 99 | super::call(service, "websocket", "action", "sendTextMessage", params) 100 | } 101 | 102 | /** 103 | * Sets the text message for an intercepted websockets message 104 | *

105 | * This component is optional and therefore the API will only work if it is installed 106 | */ 107 | pub fn set_break_text_message( 108 | service: &ZapService, 109 | message: String, 110 | outgoing: String, 111 | ) -> Result { 112 | let mut params = HashMap::new(); 113 | params.insert("message".to_string(), message); 114 | params.insert("outgoing".to_string(), outgoing); 115 | super::call( 116 | service, 117 | "websocket", 118 | "action", 119 | "setBreakTextMessage", 120 | params, 121 | ) 122 | } 123 | --------------------------------------------------------------------------------