diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..57cb43d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,13 @@ +* text=auto eol=lf + +*.java text +*.properties text +*.md text +*.xml text +*.gradle text + +*.bat eol=crlf +*.sh text +gradlew text + +*.jar binary \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1b52049 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + groups: + gha: + applies-to: version-updates + patterns: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8901a2c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: Java CI + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + java: [17, 21, 22] + + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: ${{ matrix.java }} + - uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2 + - run: ./gradlew assemble + - run: ./gradlew check diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9699ac8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: java -sudo: false - -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f6bcb1b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,256 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.17.0] - 2025-12-15 +### Added +- Add the APIs of the following add-ons: + - Client Side Integration version 0.20.0; + - Postman Support version 0.7.0. + +### Changed +- Update core APIs for 2.17. +- Update the APIs of the following add-ons: + - Automation Framework version 0.58.0; + - Passive Scanner version 0.6.0; + - Selenium version 15.43.0; + - Spider version 0.18.0. + +## [1.16.0] - 2025-02-03 +### Added +- Add support for JSON API calls with new method `callApiJson`. + +## [1.15.0] - 2025-01-20 +### Added +- Add the API of the following add-on: + - OAST Support + +### Changed +- Update core APIs for 2.16. +- Update the APIs of the following add-ons: + - AJAX Spider + - Import/Export + - OpenAPI Support + - Passive Scanner + - Replacer + - Script Console + - Selenium + - Spider + +## [1.14.0] - 2024-05-13 +### Changed +- Update core APIs for 2.15. + +## [1.13.0] - 2023-11-21 +### Added +- Add the APIs of the following add-on: + - Custom Payloads version 0.13.0. + +### Changed +- Update core APIs for 2.14. +- Update the APIs of the following add-on: + - Selenium version 15.16.0. +- Stop sending the API key as query parameter, not needed since ZAP 2.6.0. +- Allow to call the ZAP API with custom HTTP method (e.g. file upload). + +### Deprecated +- The following APIs were deprecated: + - `Exportreport` + +### Removed +- The Ant tasks are no longer provided. + +## [1.12.0] - 2023-07-13 +### Changed +- Minimum Java version is now 11. +- Update core APIs for 2.13. +- Update the APIs of the following add-ons: + - AJAX Spider version 23.15.0; + - Alert Filters version 17; + - GraphQL Support version 0.18.0; + - Network version 0.10.0; + - Selenium version 15.13.0; + - Spider version 0.5.0. + +## [1.11.0] - 2022-11-01 +### Added +- Add the APIs of the following add-ons: + - Import/Export version 0.3.0; + - Network version 0.3.0; + - Spider version 0.1.0. + +### Changed +- Update core APIs for 2.12. +- Update the APIs of the following add-ons: + - Automation Framework version 0.15.0; + - Selenium version 15.8.0; + - Replacer version 11. + +### Deprecated +- The following APIs were deprecated: + - `ImportLogFiles`; + - `Importurls`; + - `LocalProxies`. + +### Fixed +- Add a graphql object to ClientApi. + +## [1.10.0] - 2021-10-11 +### Added +- Add the APIs of the following add-ons: + - Automation Framework version 0.7.0; + - Report Generation add-on, version 0.8.0; + - Retest version 0.2.0. + +### Changed +- Update core APIs for 2.11. +- Update the APIs of the following add-ons: + - Ajax Spider version 23.6.0; + - Alert Filters version 13; + - GraphQL Support version 0.6.0; + - OpenAPI Support version 23; + - Replacer version 9. + +## [1.9.0] - 2020-12-18 +### Added +- Add API from GraphQL add-on. + +### Changed +- Core APIs updated for ZAP version 2.10.0. +- Update API from AJAX Spider add.on. + +## [1.8.0] - 2020-01-23 +### Added +- Core APIs. +- APIs from add-ons: + - Access Control Testing; + - Export Report; + - Revisit; + - Wappalyzer - Technology Detection. + +### Changed +- Core APIs updated for ZAP version 2.9.0. +- Update APIs from add-ons: + - Alert Filters; + - OpenAPI Support; + - Replacer. + +## [1.7.0] - 2019-06-13 +### Added +- Add API for SOAP Scanner add-on, version 3. + +### Changed +- Core APIs updated for ZAP version 2.8.0. +- Update Replacer API, per release of version 7. +- Update Websocket API, per release of version 19. +- Update Selenium API, per release of version 15.0.0. +- Add description to Importurls and AlertFilter API endpoints. + +### Fixed +- Disable XXE processing when parsing ZAP API responses. +- Ensure alerts file is always closed. + +## [1.6.0] - 2018-04-10 +### Added +- WebSockets ("websocket"). + +### Fixed +- Explicitly disable HTTP caching, to always obtain a fresh response from ZAP. + +## [1.5.0] - 2017-11-30 +### Changed +- Core APIs updated for ZAP version 2.7.0. + +## [1.4.0] - 2017-07-13 +### Added +- New Ant task to create ZAP reports: + ```XML + + + + + + ``` + +## [1.3.0] - 2017-06-23 +### Added +- Import files containing URLs ("importurls"). +- OpenAPI Support ("openapi"). +- Replacer ("replacer"). + +### Changed +- Update scan Ant tasks to wait for the corresponding scan to finish. + +## [1.2.0] - 2017-03-29 +### Changed +- Core APIs updated for ZAP version 2.6.0. +- Update AJAX Spider API + - Allows to obtain the full results of a scan, messages in/out of scope + and message with I/O errors. + +## [1.1.1] - 2017-03-09 +### Fixed +- Fixed a bug that prevented the new API methods (that don't require +the API key) from being used with ZAP versions <= 2.5.0. + +## [1.1.0] - 2017-03-09 +### Added +- Context Alert Filters API, for more information refer to the help page: +https://www.zaproxy.org/docs/desktop/addons/alert-filters/ +- The `Alert` now exposes the alert ID, message ID, and scanner ID. +- Added confidence "False Positive" (enum `Alert.Confidence`). + +### Changed +- The `ClientApi` now allows to set the API key through the constructor, +which ensures that the API key is sent whenever required. +- It's now possible to obtain the keys of the values of an `ApiResponseSet` +(also, deprecated unused/unnecessary constructor and method). +- It's now possible to specify the API key in all Ant tasks. +- Update AJAX Spider API + - Allows to scan a context, as a user and just a subtree. +- Update Selenium API + - Allows to choose which Firefox binary is used and set the path to geckodriver. + +### Deprecated + - The API methods that allowed to pass the API key were deprecated in +favour of using the new `ClientApi` constructor. +- `Alert` and `AlertTask` now use `name` instead of `alert` for the name +of the alert (zaproxy/zaproxy#1341), older methods were deprecated. + +### Fixed +- `ApiResponseSet` now has as values `ApiResponse` (zaproxy/zaproxy#3228). + +## [1.0.0] - 2016-06-03 +### Added + - First version as "stand alone library", it was migrated from the [zaproxy repository](https://github.com/zaproxy/zaproxy) + and released to Maven Central. + +[Unreleased]: https://github.com/zaproxy/zap-api-java/compare/v1.17.0...HEAD +[1.17.0]: https://github.com/zaproxy/zap-api-java/compare/v1.16.0...v1.17.0 +[1.16.0]: https://github.com/zaproxy/zap-api-java/compare/v1.15.0...v1.16.0 +[1.15.0]: https://github.com/zaproxy/zap-api-java/compare/v1.14.0...v1.15.0 +[1.14.0]: https://github.com/zaproxy/zap-api-java/compare/v1.13.0...v1.14.0 +[1.13.0]: https://github.com/zaproxy/zap-api-java/compare/v1.12.0...v1.13.0 +[1.12.0]: https://github.com/zaproxy/zap-api-java/compare/v1.11.0...v1.12.0 +[1.11.0]: https://github.com/zaproxy/zap-api-java/compare/v1.10.0...v1.11.0 +[1.10.0]: https://github.com/zaproxy/zap-api-java/compare/v1.9.0...v1.10.0 +[1.9.0]: https://github.com/zaproxy/zap-api-java/compare/v1.8.0...v1.9.0 +[1.8.0]: https://github.com/zaproxy/zap-api-java/compare/v1.7.0...v1.8.0 +[1.7.0]: https://github.com/zaproxy/zap-api-java/compare/v1.6.0...v1.7.0 +[1.6.0]: https://github.com/zaproxy/zap-api-java/compare/v1.5.0...v1.6.0 +[1.5.0]: https://github.com/zaproxy/zap-api-java/compare/v1.4.0...v1.5.0 +[1.4.0]: https://github.com/zaproxy/zap-api-java/compare/v1.3.0...v1.4.0 +[1.3.0]: https://github.com/zaproxy/zap-api-java/compare/v1.2.0...v1.3.0 +[1.2.0]: https://github.com/zaproxy/zap-api-java/compare/v1.1.1...v1.2.0 +[1.1.1]: https://github.com/zaproxy/zap-api-java/compare/v1.1.0...v1.1.1 +[1.1.0]: https://github.com/zaproxy/zap-api-java/compare/v1.0.0...v1.1.0 +[1.0.0]: https://github.com/zaproxy/zap-api-java/compare/6c778f77a817e1ff71e9279e4759535d482e8393...v1.0.0 diff --git a/README.md b/README.md index e5c1a3e..aaa2c7a 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,50 @@ -# OWASP ZAP Java API +# ZAP Java API -The Java implementation to access the [OWASP ZAP API](https://github.com/zaproxy/zaproxy/wiki/ApiDetails). For more information -about OWASP ZAP consult the (main) [OWASP ZAP project](https://github.com/zaproxy/zaproxy/). +[![Version](https://maven-badges.herokuapp.com/maven-central/org.zaproxy/zap-clientapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.zaproxy/zap-clientapi/) +[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) -This project produces two libraries: - * `zap-clientapi`, the library that contains the Java implementation to access the OWASP ZAP API; - * `zap-clientapi-ant`, the library that contains [Ant](https://ant.apache.org/) tasks that wrap functionality - provided by `zap-clientapi`. This library depends on `zap-clientapi` and Ant, both should be available at runtime. +The Java implementation to access the [ZAP API](https://www.zaproxy.org/docs/api/). For more information +about ZAP consult the (main) [ZAP project](https://github.com/zaproxy/zaproxy/). + +This project produces the library `zap-clientapi`, which contains the Java implementation to access the ZAP API. ## How to Obtain The latest released versions can be downloaded from the [Releases page](https://github.com/zaproxy/zap-api-java/releases). -Or, if using a dependency management tool, for example [Maven](https://maven.apache.org/), the `zap-clientapi` library -can be obtained from [Maven Central](http://search.maven.org/) with following coordinates: +Or, if using a dependency management tool, for example [Maven](https://maven.apache.org/) or [Gradle](https://gradle.org/), the `zap-clientapi` library +can be obtained from [Maven Central](https://search.maven.org/) with following coordinates: * GroupId: `org.zaproxy` * ArtifactId: `zap-clientapi` - * Version: `1.0.0` + * Version: `1.17.0` -Previous releases are also available, more details can be found in [Maven Central](http://search.maven.org/#search|ga|1|org.zaproxy). +Previous releases are also available, more details can be found in [Maven Central](https://search.maven.org/search?q=g:org.zaproxy%20AND%20a:zap-clientapi&core=gav). ## Getting Help -For help using OWASP ZAP API refer to: +For help using ZAP API refer to: * [Examples](subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples) - collection of examples using the library; - * [OWASP ZAP User Group](https://groups.google.com/group/zaproxy-users) - for asking questions; - * IRC: irc.mozilla.org #websectools (eg [using Mibbit](http://chat.mibbit.com/?server=irc.mozilla.org%3A%2B6697&channel=%23websectools)) - chat with core ZAP developers (European office hours usually best) + * [API Documentation](https://www.zaproxy.org/docs/api/) + * [ZAP User Group](https://groups.google.com/group/zaproxy-users) - for asking questions ## Issues -To report issues related to OWASP ZAP API, bugs and enhancements requests, use the [issue tracker of the main OWASP ZAP project](https://github.com/zaproxy/zaproxy/issues). +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). + +## Building + +This project uses Gradle to build its libraries, for example, running: + + ./gradlew build + +in the main directory of the project will build all the libraries. The libraries will be located in the `build/libs` directory +of each subproject. + +### Installing + +To install the artifacts to the local Maven repository you can run the following: + + ./gradlew install + +The installed artifacts (`zap-clientapi`) are then available for other (local) projects to use. diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..42a13fe --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,82 @@ +## Releasing + +In the following sections it will be explained the steps necessary to release a new version of the libraries. In all steps the +version to be released is referred to as ``, which should be replaced with appropriate version number +(e.g. 2.1.0). + +### Release Branching + +The project follows the [git-flow branching model](http://nvie.com/posts/a-successful-git-branching-model/). To release a new version it needs to be created a new release branch, update the version, and tag: + 1. Create a release branch: + `git checkout -b release- develop`; + 2. Update version in: + 1. `build.gradle` file (e.g. remove `-SNAPSHOT`); + 2. source code (e.g. `@since` and `@deprecated` JavaDoc tags); + 3. `README.md` file (in `How to Obtain` section); + 3. Review that everything is correct and commit the changes: + `git commit -S -m "Bump version number to "` + 4. Checkout `master` and merge the release branch: + 1. `git checkout master` + 2. `git merge -S --no-ff release- -m "Merge branch 'release-' into master"` + 5. Tag the new version: + `git tag -s v -m "Version "` + +Reintegrate the changes into `develop` branch: + 1. Checkout develop branch: + `git checkout develop` + 2. Merge the `release-` branch: + `git merge -S --no-ff release- -m "Merge branch 'release-' into develop"` + 1. Resolve possible conflicts; + 1. The version can be bumped to the next developing version (e.g. increase the minor version and add `-SNAPSHOT`); + 2. Continue with the merge (if the version was bumped mention it in the commit message); + 3. Bump to the next developing version now (e.g. increase the minor version and add `-SNAPSHOT`), if not done during the merge: + `git commit -S -m "Bump version number to -SNAPSHOT"` + +Delete the release branch: + + git branch -d release- + +Push the branches (`develop` and `master`) and tag: + + git push upstream develop master v + +(Assuming `upstream` is the zaproxy repo.) + +### Build for Release + +Checkout the tagged version: + + git checkout v + +Create the artifacts/libraries necessary for the release: + + ./gradlew clean build + +### Release to Maven Central + +To upload the built artifacts to OSSRH you can run the following: + + ./gradlew publish + +Once uploaded continue with the release process in OSSRH: +http://central.sonatype.org/pages/releasing-the-deployment.html + +NOTE: The following properties must be defined (e.g. in file `GRADLE_HOME/gradle.properties` ) to successfully sign and +upload the artifacts: + - `signing.keyId` - the ID of the GPG key, used to sign the artifacts; + - `ossrhUsername` - the OSSRH username; + - `ossrhPassword` - the OSSRH password for above username. + +Also, the user must have permissions to upload to GroupId `org.zaproxy`. + +### GitHub Release + +Release in GitHub: + 1. Draft a [new release](https://github.com/zaproxy/zap-api-java/releases/new): + - Tag: `v` + - Title: `Version ` + - Description: (Add a summary of the changes done in the new version and mention the artifacts/libraries available.) + 2. Upload the libraries: + - `zap-api-.jar` + - `zap-clientapi-.jar` + 3. Publish release. diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 453321d..0000000 --- a/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -task wrapper(type: Wrapper) { - gradleVersion = '2.13' -} - -apply from: "gradle/compile.gradle" -apply from: "gradle/idea.gradle" -apply from: "gradle/eclipse.gradle" - -allprojects { - apply plugin: 'java' - group = 'org.zaproxy' - - repositories { - mavenLocal() - mavenCentral() - } - - sourceCompatibility = 1.7 - targetCompatibility = 1.7 -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..e36d43f --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,54 @@ +import net.ltgt.gradle.errorprone.errorprone + +plugins { + id("com.diffplug.spotless") + id("net.ltgt.errorprone") version "4.0.0" + id("org.zaproxy.common") +} + +subprojects { + apply(plugin = "java-library") + apply(plugin = "com.diffplug.spotless") + apply(plugin = "net.ltgt.errorprone") + apply(plugin = "org.zaproxy.common") + + group = "org.zaproxy" + + version = "1.18.0-SNAPSHOT" + extra["versionBC"] = "1.17.0" + + java { + if (System.getenv("RELEASE") != null) { + toolchain { + languageVersion.set(JavaLanguageVersion.of(11)) + } + } else { + val javaVersion = JavaVersion.VERSION_11 + sourceCompatibility = javaVersion + targetCompatibility = javaVersion + } + } + + spotless { + kotlin { + ktlint() + } + + kotlinGradle { + ktlint() + } + } + + dependencies { + "errorprone"("com.google.errorprone:error_prone_core:2.28.0") + } + + tasks.withType { + options.errorprone { + disable("EmptyBlockTag", "InlineMeSuggester") + } + } +} + +fun Project.java(configure: JavaPluginExtension.() -> Unit): Unit = + (this as ExtensionAware).extensions.configure("java", configure) diff --git a/gradle/compile.gradle b/gradle/compile.gradle deleted file mode 100644 index 8114f95..0000000 --- a/gradle/compile.gradle +++ /dev/null @@ -1,10 +0,0 @@ -allprojects { - tasks.withType(JavaCompile) { - options.encoding = 'utf-8' - options.compilerArgs = [ - '-Xlint:all', - '-Xlint:-options', - '-Werror' - ] - } -} \ No newline at end of file diff --git a/gradle/eclipse.gradle b/gradle/eclipse.gradle deleted file mode 100644 index bbe861d..0000000 --- a/gradle/eclipse.gradle +++ /dev/null @@ -1,4 +0,0 @@ -allprojects { - apply plugin: 'eclipse' - -} \ No newline at end of file diff --git a/gradle/idea.gradle b/gradle/idea.gradle deleted file mode 100644 index 18c6ba7..0000000 --- a/gradle/idea.gradle +++ /dev/null @@ -1,4 +0,0 @@ -allprojects { - apply plugin: "idea" - -} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index ca78035..9bbc975 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 58a993b..2a6e21b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,8 @@ -#Wed Jun 01 09:44:38 WEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionSha256Sum=fba8464465835e74f7270bbf43d6d8a8d7709ab0a43ce1aa3323f73e9aa0c612 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip -distributionSha256Sum=0f665ec6a5a67865faf7ba0d825afb19c26705ea0597cec80dd191b0f2cbb664 \ No newline at end of file diff --git a/gradlew b/gradlew index 27309d9..faf9300 100755 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env bash +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,84 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f6d5974..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,90 +1,94 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 3530632..0000000 --- a/settings.gradle +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2016 The ZAP Development Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -include 'zap-clientapi' -include 'zap-clientapi-ant' - -rootProject.name = 'zap-api-java' -rootProject.children.each {project -> - String fileBaseName = project.name.replaceAll("\\p{Upper}") { "-${it.toLowerCase()}" } - String projectDirName = "subprojects/$fileBaseName" - project.projectDir = new File(settingsDir, projectDirName) - project.buildFileName = "${fileBaseName}.gradle" - assert project.projectDir.isDirectory() - assert project.buildFile.isFile() -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..c99cc74 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,21 @@ +plugins { + id("org.zaproxy.common.settings") version "0.5.0" + + id("com.diffplug.spotless") version "6.25.0" apply false +} + +include("zap-clientapi") + +rootProject.name = "zap-api-java" + +rootProject.children.forEach { project -> + project.projectDir = File("$settingsDir/subprojects/", project.name) + project.buildFileName = "${project.name}.gradle" + + if (!project.projectDir.isDirectory) { + throw AssertionError("Project ${project.name} has no directory: ${project.projectDir}") + } + if (!project.buildFile.isFile) { + throw AssertionError("Project ${project.name} has no build file: ${project.buildFile}") + } +} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AccessUrlTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AccessUrlTask.java deleted file mode 100644 index d545875..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AccessUrlTask.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.BuildException; - -public class AccessUrlTask extends ZapTask { - - private String url; - - @Override - public void execute() throws BuildException { - try { - this.getClientApi().accessUrl(url); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ActiveScanSubtreeTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ActiveScanSubtreeTask.java deleted file mode 100644 index 3b481a1..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ActiveScanSubtreeTask.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.BuildException; - -public class ActiveScanSubtreeTask extends ZapTask { - - private String url; - private String apikey; - - @Override - public void execute() throws BuildException { - try { - this.getClientApi().ascan.scan(apikey, url, "true", "false", "", "", ""); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getApikey() { - return apikey; - } - - public void setApikey(String apikey) { - this.apikey = apikey; - } -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ActiveScanUrlTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ActiveScanUrlTask.java deleted file mode 100644 index d8a883c..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ActiveScanUrlTask.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.BuildException; - -public class ActiveScanUrlTask extends ZapTask { - - private String url; - private String apikey; - - @Override - public void execute() throws BuildException { - try { - this.getClientApi().ascan.scan(apikey, url, "false", "false", "", "", ""); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getApikey() { - return apikey; - } - - public void setApikey(String apikey) { - this.apikey = apikey; - } -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AlertCheckTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AlertCheckTask.java deleted file mode 100644 index 4434348..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AlertCheckTask.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tools.ant.BuildException; -import org.zaproxy.clientapi.core.Alert; - -public class AlertCheckTask extends ZapTask { - - private List ignoreAlertTasks = new ArrayList<>(); - private List requireAlertTasks = new ArrayList<>(); - - @Override - public void execute() throws BuildException { - try { - List ignoreAlerts = new ArrayList<>(ignoreAlertTasks.size()); - List requireAlerts = new ArrayList<>(requireAlertTasks.size()); - for (AlertTask alert: ignoreAlertTasks) { - ignoreAlerts.add(new Alert(alert.getAlert(), alert.getUrl(), alert.getRisk(), alert.getConfidence(), alert.getParam(), alert.getOther())); - } - for (AlertTask alert: requireAlertTasks) { - requireAlerts.add(new Alert(alert.getAlert(), alert.getUrl(), alert.getRisk(), alert.getConfidence(), alert.getParam(), alert.getOther())); - } - - this.getClientApi().checkAlerts(ignoreAlerts, requireAlerts); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - public void addIgnoreAlert(AlertTask alert) { - this.ignoreAlertTasks.add(alert); - } - - public void addRequireAlert(AlertTask alert) { - this.requireAlertTasks.add(alert); - } - - public List getIgnoreAlerts() { - return ignoreAlertTasks; - } - - public List getRequireAlerts() { - return requireAlertTasks; - } -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AlertTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AlertTask.java deleted file mode 100644 index b94fb63..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/AlertTask.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.Task; - -public class AlertTask extends Task { - private String alert; - private String risk; - /** - * @deprecated - * Use of reliability has been deprecated in favour of using confidence - */ - @Deprecated - private String reliability; - private String confidence; - private String url; - private String other; - private String param; - - public String getAlert() { - return alert; - } - public void setAlert(String alert) { - this.alert = alert; - } - public String getRisk() { - return risk; - } - public void setRisk(String risk) { - this.risk = risk; - } - /** - * @deprecated (2.4.0) {@link #getConfidence()}. - * Use of reliability has been deprecated in favour of using confidence. - */ - @Deprecated - public String getReliability() { - return reliability; - } - /** - * @deprecated (2.4.0) Replaced by {@link #setConfidence(String)} - * Use of reliability has been deprecated in favour of using confidence - */ - @Deprecated - public void setReliability(String reliability) { - this.reliability = reliability; - } - public String getConfidence() { - return confidence; - } - public void setConfidence(String confidence) { - this.confidence = confidence; - } - public String getUrl() { - return url; - } - public void setUrl(String url) { - this.url = url; - } - public String getOther() { - return other; - } - public void setOther(String other) { - this.other = other; - } - public String getParam() { - return param; - } - public void setParam(String param) { - this.param = param; - } - -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/LoadSessionTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/LoadSessionTask.java deleted file mode 100644 index aa8be39..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/LoadSessionTask.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.BuildException; - -public class LoadSessionTask extends ZapTask { - - private String name; - private String apikey; - - @Override - public void execute() throws BuildException { - try { - this.getClientApi().core.loadSession(apikey, name); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getApikey() { - return apikey; - } - - public void setApikey(String apikey) { - this.apikey = apikey; - } -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/NewSessionTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/NewSessionTask.java deleted file mode 100644 index fa1ceec..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/NewSessionTask.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.BuildException; - -public class NewSessionTask extends ZapTask { - - private String name; - private String apikey; - - @Override - public void execute() throws BuildException { - try { - this.getClientApi().core.newSession(apikey, name, "true"); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getApikey() { - return apikey; - } - - public void setApikey(String apikey) { - this.apikey = apikey; - } -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/SaveSessionTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/SaveSessionTask.java deleted file mode 100644 index 4649e58..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/SaveSessionTask.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.BuildException; - -public class SaveSessionTask extends ZapTask { - - private String name; - private String apikey; - - @Override - public void execute() throws BuildException { - try { - this.getClientApi().core.saveSession(apikey, name, "true"); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getApikey() { - return apikey; - } - - public void setApikey(String apikey) { - this.apikey = apikey; - } -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/SpiderUrlTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/SpiderUrlTask.java deleted file mode 100644 index 7ee5f01..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/SpiderUrlTask.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.BuildException; - -public class SpiderUrlTask extends ZapTask { - - private String url; - private String apikey; - - @Override - public void execute() throws BuildException { - try { - this.getClientApi().spider.scan(apikey, url, "", "", null, null); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getApikey() { - return apikey; - } - - public void setApikey(String apikey) { - this.apikey = apikey; - } - -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/StopZapTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/StopZapTask.java deleted file mode 100644 index 7978e30..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/StopZapTask.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.BuildException; - -public class StopZapTask extends ZapTask { - - private String apikey; - - @Override - public void execute() throws BuildException { - try { - this.getClientApi().core.shutdown(apikey); - } catch (Exception e) { - e.printStackTrace(); - throw new BuildException(e); - } - } - - public String getApikey() { - return apikey; - } - - public void setApikey(String apikey) { - this.apikey = apikey; - } - -} diff --git a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ZapTask.java b/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ZapTask.java deleted file mode 100644 index af83eda..0000000 --- a/subprojects/zap-clientapi-ant/src/main/java/org/zaproxy/clientapi/ant/ZapTask.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.ant; - -import org.apache.tools.ant.Task; -import org.zaproxy.clientapi.core.ClientApi; - -public abstract class ZapTask extends Task { - private String zapAddress; - private int zapPort; - private boolean debug = false; - - protected ClientApi getClientApi() { - return new ClientApi(zapAddress, zapPort, debug); - } - - public String getZapAddress() { - return zapAddress; - } - public void setZapAddress(String zapAddress) { - this.zapAddress = zapAddress; - } - public int getZapPort() { - return zapPort; - } - public void setZapPort(int zapPort) { - this.zapPort = zapPort; - } - - public boolean isDebug() { - return debug; - } - - public void setDebug(boolean debug) { - this.debug = debug; - } -} diff --git a/subprojects/zap-clientapi-ant/zap-clientapi-ant.gradle b/subprojects/zap-clientapi-ant/zap-clientapi-ant.gradle deleted file mode 100644 index d1b73e2..0000000 --- a/subprojects/zap-clientapi-ant/zap-clientapi-ant.gradle +++ /dev/null @@ -1,17 +0,0 @@ - -version '1.0.1-SNAPSHOT' - -dependencies { - compile project(':zap-clientapi') - compileOnly 'org.apache.ant:ant:1.9.7' -} - -sourceSets { examples } - -jar { - manifest { - attributes 'Implementation-Title': 'OWASP ZAP Ant API Client', - 'Implementation-Version': version, - 'Create-Date': new Date().format("yyyy-MM-dd") - } -} diff --git a/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/SimpleExample.java b/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/SimpleExample.java index 7142ab8..cb3715a 100644 --- a/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/SimpleExample.java +++ b/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/SimpleExample.java @@ -1,92 +1,111 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2016 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.examples; - -import org.zaproxy.clientapi.core.ApiResponse; -import org.zaproxy.clientapi.core.ApiResponseElement; -import org.zaproxy.clientapi.core.ClientApi; - -/** - * A simple example showing how to use the API to spider and active scan a site and then retrieve and print out the alerts. - *

- * ZAP must be running on the specified host and port for this script to work - */ -public class SimpleExample { - - private static final String ZAP_ADDRESS = "localhost"; - private static final int ZAP_PORT = 8090; - private static final String ZAP_API_KEY = null; // Change this if you have set the apikey in ZAP via Options / API - - private static final String TARGET = "http://localhost:8080/bodgeit/"; - - public static void main(String[] args) { - ClientApi api = new ClientApi(ZAP_ADDRESS, ZAP_PORT); - - try { - // Start spidering the target - System.out.println("Spider : " + TARGET); - ApiResponse resp = api.spider.scan(ZAP_API_KEY, TARGET, null, null, null, null); - String scanid; - int progress; - - // The scan now returns a scan id to support concurrent scanning - scanid = ((ApiResponseElement) resp).getValue(); - - // Poll the status until it completes - while (true) { - Thread.sleep(1000); - progress = Integer.parseInt(((ApiResponseElement) api.spider.status(scanid)).getValue()); - System.out.println("Spider progress : " + progress + "%"); - if (progress >= 100) { - break; - } - } - System.out.println("Spider complete"); - - // Give the passive scanner a chance to complete - Thread.sleep(2000); - - System.out.println("Active scan : " + TARGET); - resp = api.ascan.scan(ZAP_API_KEY, TARGET, "True", "False", null, null, null); - - // The scan now returns a scan id to support concurrent scanning - scanid = ((ApiResponseElement) resp).getValue(); - - // Poll the status until it completes - while (true) { - Thread.sleep(5000); - progress = Integer.parseInt(((ApiResponseElement) api.ascan.status(scanid)).getValue()); - System.out.println("Active Scan progress : " + progress + "%"); - if (progress >= 100) { - break; - } - } - System.out.println("Active Scan complete"); - - System.out.println("Alerts:"); - System.out.println(new String(api.core.xmlreport(ZAP_API_KEY))); - - } catch (Exception e) { - System.out.println("Exception : " + e.getMessage()); - e.printStackTrace(); - } - } - -} +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2016 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.examples; + +import java.nio.charset.StandardCharsets; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ApiResponseElement; +import org.zaproxy.clientapi.core.ClientApi; + +/** + * A simple example showing how to use the API to spider and active scan a site and then retrieve + * and print out the alerts. + * + *

ZAP must be running on the specified host and port for this script to work + */ +public class SimpleExample { + + private static final String ZAP_ADDRESS = "localhost"; + private static final int ZAP_PORT = 8090; + private static final String ZAP_API_KEY = + null; // Change this if you have set the apikey in ZAP via Options / API + + private static final String TARGET = "http://localhost:8080/bodgeit/"; + + @SuppressWarnings("deprecation") + public static void main(String[] args) { + ClientApi api = new ClientApi(ZAP_ADDRESS, ZAP_PORT, ZAP_API_KEY); + + try { + // Start spidering the target + System.out.println("Spider : " + TARGET); + // It's not necessary to pass the ZAP API key again, already set when creating the + // ClientApi. + ApiResponse resp = api.spider.scan(TARGET, null, null, null, null); + String scanid; + int progress; + + // The scan now returns a scan id to support concurrent scanning + scanid = ((ApiResponseElement) resp).getValue(); + + // Poll the status until it completes + while (true) { + Thread.sleep(1000); + progress = + Integer.parseInt( + ((ApiResponseElement) api.spider.status(scanid)).getValue()); + System.out.println("Spider progress : " + progress + "%"); + if (progress >= 100) { + break; + } + } + System.out.println("Spider complete"); + + // Poll the number of records the passive scanner still has to scan until it completes + while (true) { + Thread.sleep(1000); + progress = + Integer.parseInt( + ((ApiResponseElement) api.pscan.recordsToScan()).getValue()); + System.out.println("Passive Scan progress : " + progress + " records left"); + if (progress < 1) { + break; + } + } + System.out.println("Passive Scan complete"); + + System.out.println("Active scan : " + TARGET); + resp = api.ascan.scan(TARGET, "True", "False", null, null, null); + + // The scan now returns a scan id to support concurrent scanning + scanid = ((ApiResponseElement) resp).getValue(); + + // Poll the status until it completes + while (true) { + Thread.sleep(5000); + progress = + Integer.parseInt( + ((ApiResponseElement) api.ascan.status(scanid)).getValue()); + System.out.println("Active Scan progress : " + progress + "%"); + if (progress >= 100) { + break; + } + } + System.out.println("Active Scan complete"); + + System.out.println("Alerts:"); + System.out.println(new String(api.core.xmlreport(), StandardCharsets.UTF_8)); + + } catch (Exception e) { + System.out.println("Exception : " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/Test.java b/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/Test.java deleted file mode 100644 index 2b085ae..0000000 --- a/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/Test.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.zaproxy.clientapi.examples; - -import java.util.ArrayList; -import java.util.List; - -import org.zaproxy.clientapi.core.Alert; -import org.zaproxy.clientapi.core.ClientApi; -import org.zaproxy.clientapi.core.Alert.Confidence; -import org.zaproxy.clientapi.core.Alert.Risk; - -public class Test { - - /** - * @param args - */ - public static void main(String[] args) { - // TODO List - // High priority - // * Start ZAP in background - task still waits! } Need docs? - // * Get checkAlerts to work with inner elements } - // Medium - tidy up - // * Create min zapapi.jar - // * Correct way of installing in Eclipse - // Docs etc - // * Full wave reg test - // * Full wavsep reg test - // * Documentation - // Publicise - // * Blog, tweet etc etc - // * Work out priorities for extending api - // * Complete tasks - more for internal use than anything else - - List ignoreAlerts = new ArrayList<>(2); - ignoreAlerts.add(new Alert("Cookie set without HttpOnly flag", null, Risk.Low, Confidence.Medium, null, null)); - ignoreAlerts.add(new Alert(null, null, Risk.Low, Confidence.Medium, null, null)); - - try { - (new ClientApi("localhost", 8090)).checkAlerts(ignoreAlerts, null ); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - List requireAlerts = new ArrayList<>(1); - //ignoreAlerts.add(new Alert(null, null, null, null, null, null)); - requireAlerts.add(new Alert("Not present", null, Risk.Low, Confidence.Medium, null, null)); - try { - (new ClientApi("localhost", 8090)).checkAlerts(ignoreAlerts, requireAlerts); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } -} - -} diff --git a/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/authentication/FormBasedAuthentication.java b/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/authentication/FormBasedAuthentication.java index 0ed3f11..af208d6 100644 --- a/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/authentication/FormBasedAuthentication.java +++ b/subprojects/zap-clientapi/src/examples/java/org/zaproxy/clientapi/examples/authentication/FormBasedAuthentication.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright the ZAP development team + * Copyright 2014 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -20,9 +21,8 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; - import org.zaproxy.clientapi.core.ApiResponse; import org.zaproxy.clientapi.core.ApiResponseElement; import org.zaproxy.clientapi.core.ApiResponseList; @@ -33,155 +33,181 @@ /** * An example of how to set up authentication via the API and get information about existing * configuration. - * - * Some important aspects regarding the Authentication API: + * + *

Some important aspects regarding the Authentication API: + * *

    - *
  • - * since the AuthenticationMethods are loaded dynamically, there's no way to generate a 'static' API - * for each auth method. That's why, when setting up the authentication method, depending on the - * method, different values are passed to the setAuthenticationMethod . This is where the - * getSupportedAuthenticationMethods and getAuthenticationMethodConfigParams methods come into play. - * Basically the first one gives a list of available/loaded authentication methods while the second - * one gives info about the parameters required to configure each authentication method type.
  • - *
  • when setting up the authentication method for a context, the setAuthenticationMethod method - * is used. It takes the context id on which we're working, the name of the authentication method - * and a 'authMethodConfigParams' parameter which contains all the configuration for the method. The - * format of the value passed for 'authMethodConfigParams' matches the www-form-urlencoded style: - * parameterName = urlEncodedValue. Check out the referenced example to see how the configuration is - * build for the BodgeIt store login. The pseudocode for generating the config would be:
    - * paramA + "=" + urlEncode(paramAValue) + "&" + paramB + "=" + urlEncode(paramBValue) + ... - *
  • - *
  • - * for formBasedAuthentication, the places filled in with the credentials are marked via {%username%} - * and {%password%}, in either the requestUrl or the requestBody
  • + *
  • since the AuthenticationMethods are loaded dynamically, there's no way to generate a + * 'static' API for each auth method. That's why, when setting up the authentication method, + * depending on the method, different values are passed to the setAuthenticationMethod . This + * is where the getSupportedAuthenticationMethods and getAuthenticationMethodConfigParams + * methods come into play. Basically the first one gives a list of available/loaded + * authentication methods while the second one gives info about the parameters required to + * configure each authentication method type. + *
  • when setting up the authentication method for a context, the setAuthenticationMethod method + * is used. It takes the context id on which we're working, the name of the authentication + * method and a 'authMethodConfigParams' parameter which contains all the configuration for + * the method. The format of the value passed for 'authMethodConfigParams' matches the + * www-form-urlencoded style: parameterName = urlEncodedValue. Check out the referenced + * example to see how the configuration is build for the BodgeIt store login. The pseudocode + * for generating the config would be:
    + * + * paramA + "=" + urlEncode(paramAValue) + "&" + paramB + "=" + urlEncode(paramBValue) + ... + * + *
  • for formBasedAuthentication, the places filled in with the credentials are marked via + * {%username%} and {%password%}, in either the requestUrl or the requestBody *
*/ public class FormBasedAuthentication { - private static final String ZAP_ADDRESS = "localhost"; - private static final int ZAP_PORT = 8090; - private static final String ZAP_API_KEY = null; - - private static void listAuthInformation(ClientApi clientApi) throws ClientApiException { - // Check out which authentication methods are supported by the API - List supportedMethodNames = new LinkedList<>(); - ApiResponseList authMethodsList = (ApiResponseList) clientApi.authentication.getSupportedAuthenticationMethods(); - for (ApiResponse authMethod : authMethodsList.getItems()) { - supportedMethodNames.add(((ApiResponseElement) authMethod).getValue()); - } - System.out.println("Supported authentication methods: " + supportedMethodNames); - - // Check out which are the config parameters of the authentication methods - for (String methodName : supportedMethodNames) { - - ApiResponseList configParamsList = (ApiResponseList) clientApi.authentication - .getAuthenticationMethodConfigParams(methodName); - - for (ApiResponse r : configParamsList.getItems()) { - ApiResponseSet set = (ApiResponseSet) r; - System.out.println("'" + methodName + "' config param: " + set.getValue("name") + " (" - + (set.getValue("mandatory").equals("true") ? "mandatory" : "optional") + ")"); - } - } - } - - private static void listUserConfigInformation(ClientApi clientApi) throws ClientApiException { - // Check out which are the config parameters required to set up an user with the currently - // set authentication methods - String contextId = "1"; - ApiResponseList configParamsList = (ApiResponseList) clientApi.users - .getAuthenticationCredentialsConfigParams(contextId); - - StringBuilder sb = new StringBuilder("Users' config params: "); - for (ApiResponse r : configParamsList.getItems()) { - ApiResponseSet set = (ApiResponseSet) r; - sb.append(set.getValue("name")).append(" ("); - sb.append((set.getValue("mandatory").equals("true") ? "mandatory" : "optional")); - sb.append("), "); - } - System.out.println(sb.deleteCharAt(sb.length() - 2).toString()); - } - - private static void setLoggedInIndicator(ClientApi clientApi) throws ClientApiException { - // Prepare values to set, with the logged in indicator as a regex matching the logout link - String loggedInIndicator = ""; - String contextId = "1"; - - // Actually set the logged in indicator - clientApi.authentication.setLoggedInIndicator(ZAP_API_KEY, contextId, java.util.regex.Pattern.quote(loggedInIndicator)); - - // Check out the logged in indicator that is set - System.out.println("Configured logged in indicator regex: " - + ((ApiResponseElement) clientApi.authentication.getLoggedInIndicator(contextId)).getValue()); - } - - private static void setFormBasedAuthenticationForBodgeit(ClientApi clientApi) throws ClientApiException, - UnsupportedEncodingException { - // Setup the authentication method - String contextId = "1"; - String loginUrl = "http://localhost:8080/bodgeit/login.jsp"; - String loginRequestData = "username={%username%}&password={%password%}"; - - // Prepare the configuration in a format similar to how URL parameters are formed. This - // means that any value we add for the configuration values has to be URL encoded. - StringBuilder formBasedConfig = new StringBuilder(); - formBasedConfig.append("loginUrl=").append(URLEncoder.encode(loginUrl, "UTF-8")); - formBasedConfig.append("&loginRequestData=").append(URLEncoder.encode(loginRequestData, "UTF-8")); - - System.out.println("Setting form based authentication configuration as: " - + formBasedConfig.toString()); - clientApi.authentication.setAuthenticationMethod(ZAP_API_KEY, contextId, "formBasedAuthentication", - formBasedConfig.toString()); - - // Check if everything is set up ok - System.out - .println("Authentication config: " + clientApi.authentication.getAuthenticationMethod(contextId).toString(0)); - } - - private static void setUserAuthConfigForBodgeit(ClientApi clientApi) throws ClientApiException, UnsupportedEncodingException { - // Prepare info - String contextId = "1"; - String user = "Test User"; - String username = "test@example.com"; - String password = "weakPassword"; - - // Make sure we have at least one user - String userId = extractUserId(clientApi.users.newUser(ZAP_API_KEY, contextId, user)); - - // Prepare the configuration in a format similar to how URL parameters are formed. This - // means that any value we add for the configuration values has to be URL encoded. - StringBuilder userAuthConfig = new StringBuilder(); - userAuthConfig.append("username=").append(URLEncoder.encode(username, "UTF-8")); - userAuthConfig.append("&password=").append(URLEncoder.encode(password, "UTF-8")); - - System.out.println("Setting user authentication configuration as: " + userAuthConfig.toString()); - clientApi.users.setAuthenticationCredentials(ZAP_API_KEY, contextId, userId, userAuthConfig.toString()); - - // Check if everything is set up ok - System.out.println("Authentication config: " + clientApi.users.getUserById(contextId, userId).toString(0)); - } - - private static String extractUserId(ApiResponse response) { - return ((ApiResponseElement) response).getValue(); - } - - /** - * The main method. - * - * @param args the arguments - * @throws Exception if an error occurred while accessing the API - */ - public static void main(String[] args) throws Exception { - ClientApi clientApi = new ClientApi(ZAP_ADDRESS, ZAP_PORT); - - listAuthInformation(clientApi); - System.out.println("-------------"); - setFormBasedAuthenticationForBodgeit(clientApi); - System.out.println("-------------"); - setLoggedInIndicator(clientApi); - System.out.println("-------------"); - listUserConfigInformation(clientApi); - System.out.println("-------------"); - setUserAuthConfigForBodgeit(clientApi); - } + private static final String ZAP_ADDRESS = "localhost"; + private static final int ZAP_PORT = 8090; + private static final String ZAP_API_KEY = null; + + private static void listAuthInformation(ClientApi clientApi) throws ClientApiException { + // Check out which authentication methods are supported by the API + List supportedMethodNames = new ArrayList<>(); + ApiResponseList authMethodsList = + (ApiResponseList) clientApi.authentication.getSupportedAuthenticationMethods(); + for (ApiResponse authMethod : authMethodsList.getItems()) { + supportedMethodNames.add(((ApiResponseElement) authMethod).getValue()); + } + System.out.println("Supported authentication methods: " + supportedMethodNames); + + // Check out which are the config parameters of the authentication methods + for (String methodName : supportedMethodNames) { + + ApiResponseList configParamsList = + (ApiResponseList) + clientApi.authentication.getAuthenticationMethodConfigParams( + methodName); + + for (ApiResponse r : configParamsList.getItems()) { + ApiResponseSet set = (ApiResponseSet) r; + System.out.println( + "'" + + methodName + + "' config param: " + + set.getValue("name") + + " (" + + (set.getStringValue("mandatory").equals("true") + ? "mandatory" + : "optional") + + ")"); + } + } + } + + private static void listUserConfigInformation(ClientApi clientApi) throws ClientApiException { + // Check out which are the config parameters required to set up an user with the currently + // set authentication methods + String contextId = "1"; + ApiResponseList configParamsList = + (ApiResponseList) + clientApi.users.getAuthenticationCredentialsConfigParams(contextId); + + StringBuilder sb = new StringBuilder("Users' config params: "); + for (ApiResponse r : configParamsList.getItems()) { + ApiResponseSet set = (ApiResponseSet) r; + sb.append(set.getValue("name")).append(" ("); + sb.append((set.getStringValue("mandatory").equals("true") ? "mandatory" : "optional")); + sb.append("), "); + } + System.out.println(sb.deleteCharAt(sb.length() - 2).toString()); + } + + private static void setLoggedInIndicator(ClientApi clientApi) throws ClientApiException { + // Prepare values to set, with the logged in indicator as a regex matching the logout link + String loggedInIndicator = ""; + String contextId = "1"; + + // Actually set the logged in indicator + clientApi.authentication.setLoggedInIndicator( + contextId, java.util.regex.Pattern.quote(loggedInIndicator)); + + // Check out the logged in indicator that is set + System.out.println( + "Configured logged in indicator regex: " + + ((ApiResponseElement) + clientApi.authentication.getLoggedInIndicator(contextId)) + .getValue()); + } + + private static void setFormBasedAuthenticationForBodgeit(ClientApi clientApi) + throws ClientApiException, UnsupportedEncodingException { + // Setup the authentication method + String contextId = "1"; + String loginUrl = "http://localhost:8080/bodgeit/login.jsp"; + String loginRequestData = "username={%username%}&password={%password%}"; + + // Prepare the configuration in a format similar to how URL parameters are formed. This + // means that any value we add for the configuration values has to be URL encoded. + StringBuilder formBasedConfig = new StringBuilder(); + formBasedConfig.append("loginUrl=").append(URLEncoder.encode(loginUrl, "UTF-8")); + formBasedConfig + .append("&loginRequestData=") + .append(URLEncoder.encode(loginRequestData, "UTF-8")); + + System.out.println( + "Setting form based authentication configuration as: " + + formBasedConfig.toString()); + clientApi.authentication.setAuthenticationMethod( + contextId, "formBasedAuthentication", formBasedConfig.toString()); + + // Check if everything is set up ok + System.out.println( + "Authentication config: " + + clientApi.authentication.getAuthenticationMethod(contextId).toString(0)); + } + + private static void setUserAuthConfigForBodgeit(ClientApi clientApi) + throws ClientApiException, UnsupportedEncodingException { + // Prepare info + String contextId = "1"; + String user = "Test User"; + String username = "test@example.com"; + String password = "weakPassword"; + + // Make sure we have at least one user + String userId = extractUserId(clientApi.users.newUser(contextId, user)); + + // Prepare the configuration in a format similar to how URL parameters are formed. This + // means that any value we add for the configuration values has to be URL encoded. + StringBuilder userAuthConfig = new StringBuilder(); + userAuthConfig.append("username=").append(URLEncoder.encode(username, "UTF-8")); + userAuthConfig.append("&password=").append(URLEncoder.encode(password, "UTF-8")); + + System.out.println( + "Setting user authentication configuration as: " + userAuthConfig.toString()); + clientApi.users.setAuthenticationCredentials(contextId, userId, userAuthConfig.toString()); + + // Check if everything is set up ok + System.out.println( + "Authentication config: " + + clientApi.users.getUserById(contextId, userId).toString(0)); + } + + private static String extractUserId(ApiResponse response) { + return ((ApiResponseElement) response).getValue(); + } + + /** + * The main method. + * + * @param args the arguments + * @throws Exception if an error occurred while accessing the API + */ + public static void main(String[] args) throws Exception { + ClientApi clientApi = new ClientApi(ZAP_ADDRESS, ZAP_PORT, ZAP_API_KEY); + + listAuthInformation(clientApi); + System.out.println("-------------"); + setFormBasedAuthenticationForBodgeit(clientApi); + System.out.println("-------------"); + setLoggedInIndicator(clientApi); + System.out.println("-------------"); + listUserConfigInformation(clientApi); + System.out.println("-------------"); + setUserAuthConfigForBodgeit(clientApi); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/Alert.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/Alert.java index a4dfd1b..f9a585b 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/Alert.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/Alert.java @@ -1,360 +1,551 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.core; - - -public class Alert { - - public enum Risk {Informational, Low, Medium, High}; - /** - * @deprecated (2.4.0) Replaced by {@link Confidence}. - * Use of reliability has been deprecated in favour of using confidence. - */ - @Deprecated - public enum Reliability {Suspicious, Warning}; - public enum Confidence {Low, Medium, High, Confirmed}; - - private String alert; - private Risk risk; - /** - * @deprecated (2.4.0) Replaced by {@link Confidence}. - * Use of reliability has been deprecated in favour of using confidence - */ - @Deprecated - private Reliability reliability; - private Confidence confidence; - private String url; - private String other; - private String param; - private String attack; - private String evidence; - private String description; - private String reference; - private String solution; - private int cweId; - private int wascId; - - public Alert(String alert, String url, String riskStr, String confidenceStr, - String param, String other) { - super(); - this.alert = alert; - this.url = url; - this.other = other; - this.param = param; - if (riskStr != null) { - this.risk = Risk.valueOf(riskStr); - } - if (confidenceStr != null) { - this.confidence = Confidence.valueOf(confidenceStr); - } - } - - public Alert(String alert, String url, Risk risk, Confidence confidence, - String param, String other, String attack, String description, String reference, String solution, - String evidence, int cweId, int wascId) { - super(); - this.alert = alert; - this.risk = risk; - this.confidence = confidence; - this.url = url; - this.other = other; - this.param = param; - this.attack = attack; - this.description = description; - this.reference = reference; - this.solution = solution; - this.evidence = evidence; - this.cweId = cweId; - this.wascId = wascId; - } - - public Alert(String alert, String url, Risk risk, Confidence confidence, - String param, String other) { - super(); - this.alert = alert; - this.risk = risk; - this.confidence = confidence; - this.url = url; - this.other = other; - this.param = param; - } - - public Alert(String alert, String url, Risk risk, Confidence confidence) { - super(); - this.alert = alert; - this.risk = risk; - this.confidence = confidence; - this.url = url; - } - - public Alert(String alert, String url) { - super(); - this.alert = alert; - this.url = url; - } - - public String getAlert() { - return alert; - } - public void setAlert(String alert) { - this.alert = alert; - } - public Risk getRisk() { - return risk; - } - public void setRisk(Risk risk) { - this.risk = risk; - } - public void setRisk(String risk) { - this.risk = Risk.valueOf(risk); - } - /** - * @deprecated - * {@link #getConfidence()} - * Use of reliability has been deprecated in favour of using confidence - */ - @Deprecated - public Reliability getReliability() { - return reliability; - } - /** - * @deprecated - * {@link #setConfidence(Confidence)} - * Use of reliability has been deprecated in favour of using confidence - */ - @Deprecated - public void setReliability(Reliability reliability) { - this.reliability = reliability; - } - /** - * @deprecated - * {@link #setConfidence(String)} - * Use of reliability has been deprecated in favour of using confidence - */ - @Deprecated - public void setReliability(String reliability) { - this.reliability = Reliability.valueOf(reliability); - } - public Confidence getConfidence() { - return confidence; - } - public void setConfidence(Confidence confidence) { - this.confidence = confidence; - } - public void setConfidence(String confidence) { - this.confidence = Confidence.valueOf(confidence); - } - public String getUrl() { - return url; - } - public void setUrl(String url) { - this.url = url; - } - public String getOther() { - return other; - } - public void setOther(String other) { - this.other = other; - } - public String getParam() { - return param; - } - public void setParam(String param) { - this.param = param; - } - - public String getAttack() { - return attack; - } - - public String getDescription() { - return description; - } - - public String getReference() { - return reference; - } - - public String getSolution() { - return solution; - } - - public String getEvidence() { - return evidence; - } - - public int getCweId() { - return cweId; - } - - public int getWascId() { - return wascId; - } - - public boolean matches (Alert alertFilter) { - boolean matches = true; - if (alertFilter.getAlert() != null && ! alertFilter.getAlert().equals(alert) ) { - matches = false; - } - if (alertFilter.getRisk() != null && ! alertFilter.getRisk().equals(risk) ) { - matches = false; - } - if (alertFilter.getConfidence() != null && ! alertFilter.getConfidence().equals(confidence) ) { - matches = false; - } - - return matches; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((alert == null) ? 0 : alert.hashCode()); - result = prime * result + ((attack == null) ? 0 : attack.hashCode()); - result = prime * result + cweId; - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((evidence == null) ? 0 : evidence.hashCode()); - result = prime * result + ((other == null) ? 0 : other.hashCode()); - result = prime * result + ((param == null) ? 0 : param.hashCode()); - result = prime * result + ((reference == null) ? 0 : reference.hashCode()); - result = prime * result + ((confidence == null) ? 0 : confidence.hashCode()); - result = prime * result + ((risk == null) ? 0 : risk.hashCode()); - result = prime * result + ((solution == null) ? 0 : solution.hashCode()); - result = prime * result + ((url == null) ? 0 : url.hashCode()); - result = prime * result + wascId; - return result; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object == null) { - return false; - } - if (getClass() != object.getClass()) { - return false; - } - Alert otherAlert = (Alert) object; - if (alert == null) { - if (otherAlert.alert != null) { - return false; - } - } else if (!alert.equals(otherAlert.alert)) { - return false; - } - if (attack == null) { - if (otherAlert.attack != null) { - return false; - } - } else if (!attack.equals(otherAlert.attack)) { - return false; - } - if (cweId != otherAlert.cweId) { - return false; - } - if (description == null) { - if (otherAlert.description != null) { - return false; - } - } else if (!description.equals(otherAlert.description)) { - return false; - } - if (evidence == null) { - if (otherAlert.evidence != null) { - return false; - } - } else if (!evidence.equals(otherAlert.evidence)) { - return false; - } - if (this.other == null) { - if (otherAlert.other != null) { - return false; - } - } else if (!this.other.equals(otherAlert.other)) { - return false; - } - if (param == null) { - if (otherAlert.param != null) { - return false; - } - } else if (!param.equals(otherAlert.param)) { - return false; - } - if (reference == null) { - if (otherAlert.reference != null) { - return false; - } - } else if (!reference.equals(otherAlert.reference)) { - return false; - } - if (confidence != otherAlert.confidence) { - return false; - } - if (risk != otherAlert.risk) { - return false; - } - if (solution == null) { - if (otherAlert.solution != null) { - return false; - } - } else if (!solution.equals(otherAlert.solution)) { - return false; - } - if (url == null) { - if (otherAlert.url != null) { - return false; - } - } else if (!url.equals(otherAlert.url)) { - return false; - } - if (wascId != otherAlert.wascId) { - return false; - } - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("\tAlert: ").append(getAlert()).append(", "); - sb.append("Risk: "); - if (getRisk() != null) { - sb.append(getRisk().name()); - } else { - sb.append("null"); - } - sb.append(", "); - sb.append("Confidence: "); - if (getConfidence() != null) { - sb.append(getConfidence().name()); - } else { - sb.append("null"); - } - sb.append(", "); - sb.append("Url: ").append(getUrl()).append(", "); - sb.append("Param: ").append(getParam()).append(", "); - sb.append("Other: ").append(getOther()); - return sb.toString(); - } - -} +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2011 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.core; + +public class Alert { + + public enum Risk { + Informational, + Low, + Medium, + High + } + + /** + * @deprecated (2.4.0) Replaced by {@link Confidence}. Use of reliability has been deprecated in + * favour of using confidence. + */ + @Deprecated + public enum Reliability { + Suspicious, + Warning + } + + public enum Confidence { + FalsePositive, + Low, + Medium, + High, + Confirmed + } + + private String id; + private String name; + private Risk risk; + + /** + * @deprecated (2.4.0) Replaced by {@link Confidence}. Use of reliability has been deprecated in + * favour of using confidence + */ + @Deprecated private Reliability reliability; + + private Confidence confidence; + private String url; + private String other; + private String param; + private String attack; + private String evidence; + private String description; + private String reference; + private String solution; + private int cweId; + private int wascId; + private String messageId; + private String pluginId; + + /** + * Constructs an {@code Alert} from the given {@code ApiResponseSet}. + * + * @param apiResponseSet the {@code ApiResponseSet} returned from an alert related ZAP API call. + * @since 1.1.0 + */ + public Alert(ApiResponseSet apiResponseSet) { + super(); + this.id = apiResponseSet.getStringValue("id"); + this.pluginId = apiResponseSet.getStringValue("pluginId"); + String name = apiResponseSet.getStringValue("name"); + if (name == null) { + // TODO Remove once alert attribute is no longer supported. + name = apiResponseSet.getStringValue("alert"); + } + this.name = name; + this.description = apiResponseSet.getStringValue("description"); + this.risk = stringToRisk(apiResponseSet.getStringValue("risk")); + this.confidence = stringToConfidence(apiResponseSet.getStringValue("confidence")); + this.url = apiResponseSet.getStringValue("url"); + this.other = apiResponseSet.getStringValue("other"); + this.param = apiResponseSet.getStringValue("param"); + this.attack = apiResponseSet.getStringValue("attack"); + this.evidence = apiResponseSet.getStringValue("evidence"); + this.reference = apiResponseSet.getStringValue("reference"); + this.cweId = stringToInt(apiResponseSet.getStringValue("cweid"), 0); + this.wascId = stringToInt(apiResponseSet.getStringValue("wascid"), 0); + this.solution = apiResponseSet.getStringValue("solution"); + this.messageId = apiResponseSet.getStringValue("messageId"); + } + + public Alert( + String name, + String url, + String riskStr, + String confidenceStr, + String param, + String other) { + super(); + this.name = name; + this.url = url; + this.other = other; + this.param = param; + this.risk = stringToRisk(riskStr); + this.confidence = stringToConfidence(confidenceStr); + } + + public Alert( + String name, + String url, + Risk risk, + Confidence confidence, + String param, + String other, + String attack, + String description, + String reference, + String solution, + String evidence, + int cweId, + int wascId) { + super(); + this.name = name; + this.risk = risk; + this.confidence = confidence; + this.url = url; + this.other = other; + this.param = param; + this.attack = attack; + this.description = description; + this.reference = reference; + this.solution = solution; + this.evidence = evidence; + this.cweId = cweId; + this.wascId = wascId; + } + + public Alert( + String name, String url, Risk risk, Confidence confidence, String param, String other) { + super(); + this.name = name; + this.risk = risk; + this.confidence = confidence; + this.url = url; + this.other = other; + this.param = param; + } + + public Alert(String name, String url, Risk risk, Confidence confidence) { + super(); + this.name = name; + this.risk = risk; + this.confidence = confidence; + this.url = url; + } + + public Alert(String name, String url) { + super(); + this.name = name; + this.url = url; + } + + /** + * Converts the given {@code string} to an {@code int}. + * + *

If the given {@code string} is {@code null} or not a valid {@code int}, the default value + * is returned. + * + * @param string the string to be converted to {@code int}. + * @param defaultValue the value to return in case the {@code string} is {@code null} or not an + * {@code int}. + * @return the {@code int} converted from the {@code string}, or the default value if {@code + * string} is {@code null} or not an {@code int}. + */ + private static int stringToInt(String string, int defaultValue) { + if (string == null) { + return defaultValue; + } + try { + return Integer.parseInt(string); + } catch (NumberFormatException e) { + // Ignore. + } + return defaultValue; + } + + /** + * Converts the given {@code string} to a {@link Risk} value. + * + * @param string the string to be converted to a {@link Risk} value. + * @return the {@code Risk} value converted from the {@code string}, or null if {@code string} + * is {@code null}. + */ + private static Risk stringToRisk(String string) { + if (string == null) { + return null; + } + return Risk.valueOf(string); + } + + /** + * Converts the given {@code string} to a {@link Confidence} value. + * + * @param string the string to be converted to a {@link Confidence} value. + * @return the {@code Confidence} value converted from the {@code string}, or null if {@code + * string} is {@code null}. + */ + private static Confidence stringToConfidence(String string) { + if (string == null) { + return null; + } + if ("False Positive".equalsIgnoreCase(string)) { + return Confidence.FalsePositive; + } + return Confidence.valueOf(string); + } + + /** + * Gets the ID of the alert. + * + * @return the ID of the alert. + * @since 1.1.0 + */ + public String getId() { + return id; + } + + /** + * Gets the ID of the plugin/scanner that raised the alert. + * + * @return the ID of the plugin/scanner that raised the alert. + * @since 1.1.0 + */ + public String getPluginId() { + return pluginId; + } + + /** + * Gets the ID of the HTTP message of the alert. + * + * @return the ID of the HTTP message. + * @since 1.1.0 + */ + public String getMessageId() { + return messageId; + } + + /** + * Gets the name of the alert. + * + * @return the name of the alert + * @since 1.1.0 + */ + public String getName() { + return name; + } + + /** + * Sets the name of the alert. + * + * @param name the name of the alert + * @since 1.1.0 + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets the name of the alert. + * + * @return the name of the alert + * @deprecated (1.1.0) Use {@link #getName()} instead. + */ + @Deprecated + public String getAlert() { + return name; + } + + /** + * Sets the name of the alert. + * + * @param name the name of the alert + * @deprecated (1.1.0) Use {@link #setName(String)} instead. + */ + @Deprecated + public void setAlert(String name) { + this.name = name; + } + + public Risk getRisk() { + return risk; + } + + public void setRisk(Risk risk) { + this.risk = risk; + } + + public void setRisk(String risk) { + this.risk = Risk.valueOf(risk); + } + + /** + * @deprecated {@link #getConfidence()} Use of reliability has been deprecated in favour of + * using confidence + */ + @Deprecated + public Reliability getReliability() { + return reliability; + } + + /** + * @deprecated {@link #setConfidence(Confidence)} Use of reliability has been deprecated in + * favour of using confidence + */ + @Deprecated + public void setReliability(Reliability reliability) { + this.reliability = reliability; + } + + /** + * @deprecated {@link #setConfidence(String)} Use of reliability has been deprecated in favour + * of using confidence + */ + @Deprecated + public void setReliability(String reliability) { + this.reliability = Reliability.valueOf(reliability); + } + + public Confidence getConfidence() { + return confidence; + } + + public void setConfidence(Confidence confidence) { + this.confidence = confidence; + } + + public void setConfidence(String confidence) { + this.confidence = Confidence.valueOf(confidence); + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getOther() { + return other; + } + + public void setOther(String other) { + this.other = other; + } + + public String getParam() { + return param; + } + + public void setParam(String param) { + this.param = param; + } + + public String getAttack() { + return attack; + } + + public String getDescription() { + return description; + } + + public String getReference() { + return reference; + } + + public String getSolution() { + return solution; + } + + public String getEvidence() { + return evidence; + } + + public int getCweId() { + return cweId; + } + + public int getWascId() { + return wascId; + } + + public boolean matches(Alert alertFilter) { + boolean matches = true; + if (alertFilter.getName() != null && !alertFilter.getName().equals(name)) { + matches = false; + } + if (alertFilter.getRisk() != null && !alertFilter.getRisk().equals(risk)) { + matches = false; + } + if (alertFilter.getConfidence() != null + && !alertFilter.getConfidence().equals(confidence)) { + matches = false; + } + + return matches; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((attack == null) ? 0 : attack.hashCode()); + result = prime * result + cweId; + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((evidence == null) ? 0 : evidence.hashCode()); + result = prime * result + ((other == null) ? 0 : other.hashCode()); + result = prime * result + ((param == null) ? 0 : param.hashCode()); + result = prime * result + ((reference == null) ? 0 : reference.hashCode()); + result = prime * result + ((confidence == null) ? 0 : confidence.hashCode()); + result = prime * result + ((risk == null) ? 0 : risk.hashCode()); + result = prime * result + ((solution == null) ? 0 : solution.hashCode()); + result = prime * result + ((url == null) ? 0 : url.hashCode()); + result = prime * result + wascId; + return result; + } + + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (!(object instanceof Alert)) { + return false; + } + Alert otherAlert = (Alert) object; + if (name == null) { + if (otherAlert.name != null) { + return false; + } + } else if (!name.equals(otherAlert.name)) { + return false; + } + if (attack == null) { + if (otherAlert.attack != null) { + return false; + } + } else if (!attack.equals(otherAlert.attack)) { + return false; + } + if (cweId != otherAlert.cweId) { + return false; + } + if (description == null) { + if (otherAlert.description != null) { + return false; + } + } else if (!description.equals(otherAlert.description)) { + return false; + } + if (evidence == null) { + if (otherAlert.evidence != null) { + return false; + } + } else if (!evidence.equals(otherAlert.evidence)) { + return false; + } + if (this.other == null) { + if (otherAlert.other != null) { + return false; + } + } else if (!this.other.equals(otherAlert.other)) { + return false; + } + if (param == null) { + if (otherAlert.param != null) { + return false; + } + } else if (!param.equals(otherAlert.param)) { + return false; + } + if (reference == null) { + if (otherAlert.reference != null) { + return false; + } + } else if (!reference.equals(otherAlert.reference)) { + return false; + } + if (confidence != otherAlert.confidence) { + return false; + } + if (risk != otherAlert.risk) { + return false; + } + if (solution == null) { + if (otherAlert.solution != null) { + return false; + } + } else if (!solution.equals(otherAlert.solution)) { + return false; + } + if (url == null) { + if (otherAlert.url != null) { + return false; + } + } else if (!url.equals(otherAlert.url)) { + return false; + } + if (wascId != otherAlert.wascId) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("\tAlert: ").append(getAlert()).append(", "); + sb.append("Risk: "); + if (getRisk() != null) { + sb.append(getRisk().name()); + } else { + sb.append("null"); + } + sb.append(", "); + sb.append("Confidence: "); + if (getConfidence() != null) { + sb.append(getConfidence().name()); + } else { + sb.append("null"); + } + sb.append(", "); + sb.append("Url: ").append(getUrl()).append(", "); + sb.append("Param: ").append(getParam()).append(", "); + sb.append("Other: ").append(getOther()); + return sb.toString(); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/AlertsFile.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/AlertsFile.java index f463db9..f2a8f2a 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/AlertsFile.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/AlertsFile.java @@ -1,107 +1,134 @@ -package org.zaproxy.clientapi.core; - -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; -import org.jdom.output.Format; -import org.jdom.output.XMLOutputter; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class AlertsFile { - public static void saveAlertsToFile(List requireAlerts, List reportAlerts, List ignoredAlerts, File outputFile) throws JDOMException, IOException { - Element alerts = new Element("alerts"); - Document alertsDocument = new Document(alerts); - alertsDocument.setRootElement(alerts); - if (reportAlerts.size() > 0){ - Element alertsFound = new Element("alertsFound"); - alertsFound.setAttribute("alertsFound", Integer.toString(reportAlerts.size())); - for (Alert alert : reportAlerts){ - createAlertXMLElements(alertsFound, alert); - } - alertsDocument.getRootElement().addContent(alertsFound); - } - - if (requireAlerts.size() > 0){ - Element alertsNotFound = new Element("alertsNotFound"); - alertsNotFound.setAttribute("alertsNotFound", Integer.toString(requireAlerts.size())); - for (Alert alert : requireAlerts){ - createAlertXMLElements(alertsNotFound, alert); - } - alertsDocument.getRootElement().addContent(alertsNotFound); - } - - if (ignoredAlerts.size() > 0){ - Element ignoredAlertsFound = new Element("ignoredAlertsFound"); - ignoredAlertsFound.setAttribute("ignoredAlertsFound", Integer.toString(ignoredAlerts.size())); - for (Alert alert : ignoredAlerts){ - createAlertXMLElements(ignoredAlertsFound, alert); - } - alertsDocument.getRootElement().addContent(ignoredAlertsFound); - } - - writeAlertsToFile(outputFile, alertsDocument); - } - - private static void writeAlertsToFile(File outputFile, Document doc) { - - XMLOutputter xmlOutput = new XMLOutputter(); - - xmlOutput.setFormat(Format.getPrettyFormat()); - try { - xmlOutput.output(doc, new FileWriter(outputFile)); - System.out.println("alert xml report saved to: "+outputFile.getAbsolutePath()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void createAlertXMLElements(Element alertsFound, Alert alert) { - Element alertElement = new Element("alert"); - if (alert.getAlert() != null) - alertElement.setAttribute("alert", alert.getAlert()); - if (alert.getRisk() != null) - alertElement.setAttribute("risk", alert.getRisk().name()); - if (alert.getUrl() != null) - alertElement.setAttribute("confidence", alert.getConfidence().name()); - if (alert.getUrl() != null) - alertElement.setAttribute("url", alert.getUrl()); - if (alert.getParam() != null) - alertElement.setAttribute("param", alert.getParam()); - if (alert.getOther() != null) - alertElement.setAttribute("other", alert.getOther()); - if (alert.getAttack() != null) - alertElement.setAttribute("attack", alert.getAttack()); - if (alert.getDescription() != null) - alertElement.setAttribute("description", alert.getDescription()); - if (alert.getSolution() != null) - alertElement.setAttribute("solution", alert.getSolution()); - if (alert.getReference() != null) - alertElement.setAttribute("reference", alert.getReference()); - alertsFound.addContent(alertElement); - } - - public static List getAlertsFromFile(File file, String alertType) throws JDOMException, IOException { - List alerts = new ArrayList<>(); - SAXBuilder parser = new SAXBuilder(); - Document alertsDoc = parser.build(file); - @SuppressWarnings("unchecked") - List alertElements = alertsDoc.getRootElement().getChildren(alertType); - for (Element element: alertElements){ - Alert alert = new Alert( - element.getAttributeValue("alert"), - element.getAttributeValue("url"), - element.getAttributeValue("risk"), - element.getAttributeValue("confidence"), - element.getAttributeValue("param"), - element.getAttributeValue("other")); - alerts.add(alert); - } - return alerts; - } -} +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2012 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.core; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; + +public class AlertsFile { + public static void saveAlertsToFile( + List requireAlerts, + List reportAlerts, + List ignoredAlerts, + File outputFile) + throws JDOMException, IOException { + Element alerts = new Element("alerts"); + Document alertsDocument = new Document(alerts); + alertsDocument.setRootElement(alerts); + if (reportAlerts.size() > 0) { + Element alertsFound = new Element("alertsFound"); + alertsFound.setAttribute("alertsFound", Integer.toString(reportAlerts.size())); + for (Alert alert : reportAlerts) { + createAlertXMLElements(alertsFound, alert); + } + alertsDocument.getRootElement().addContent(alertsFound); + } + + if (requireAlerts.size() > 0) { + Element alertsNotFound = new Element("alertsNotFound"); + alertsNotFound.setAttribute("alertsNotFound", Integer.toString(requireAlerts.size())); + for (Alert alert : requireAlerts) { + createAlertXMLElements(alertsNotFound, alert); + } + alertsDocument.getRootElement().addContent(alertsNotFound); + } + + if (ignoredAlerts.size() > 0) { + Element ignoredAlertsFound = new Element("ignoredAlertsFound"); + ignoredAlertsFound.setAttribute( + "ignoredAlertsFound", Integer.toString(ignoredAlerts.size())); + for (Alert alert : ignoredAlerts) { + createAlertXMLElements(ignoredAlertsFound, alert); + } + alertsDocument.getRootElement().addContent(ignoredAlertsFound); + } + + writeAlertsToFile(outputFile, alertsDocument); + } + + private static void writeAlertsToFile(File outputFile, Document doc) throws IOException { + + XMLOutputter xmlOutput = new XMLOutputter(); + + xmlOutput.setFormat(Format.getPrettyFormat()); + try (OutputStream os = Files.newOutputStream(outputFile.toPath())) { + xmlOutput.output(doc, os); + System.out.println("alert xml report saved to: " + outputFile.getAbsolutePath()); + } + } + + private static void createAlertXMLElements(Element alertsFound, Alert alert) { + Element alertElement = new Element("alert"); + if (alert.getName() != null) { + alertElement.setAttribute("name", alert.getName()); + // TODO Remove once alert attribute is no longer supported. + alertElement.setAttribute("alert", alert.getName()); + } + if (alert.getRisk() != null) alertElement.setAttribute("risk", alert.getRisk().name()); + if (alert.getUrl() != null) + alertElement.setAttribute("confidence", alert.getConfidence().name()); + if (alert.getUrl() != null) alertElement.setAttribute("url", alert.getUrl()); + if (alert.getParam() != null) alertElement.setAttribute("param", alert.getParam()); + if (alert.getOther() != null) alertElement.setAttribute("other", alert.getOther()); + if (alert.getAttack() != null) alertElement.setAttribute("attack", alert.getAttack()); + if (alert.getDescription() != null) + alertElement.setAttribute("description", alert.getDescription()); + if (alert.getSolution() != null) alertElement.setAttribute("solution", alert.getSolution()); + if (alert.getReference() != null) + alertElement.setAttribute("reference", alert.getReference()); + alertsFound.addContent(alertElement); + } + + public static List getAlertsFromFile(File file, String alertType) + throws JDOMException, IOException { + List alerts = new ArrayList<>(); + SAXBuilder parser = new SAXBuilder(); + Document alertsDoc = parser.build(file); + @SuppressWarnings("unchecked") + List alertElements = alertsDoc.getRootElement().getChildren(alertType); + for (Element element : alertElements) { + String name = element.getAttributeValue("name"); + if (name == null) { + // TODO Remove once alert attribute is no longer supported. + name = element.getAttributeValue("alert"); + } + Alert alert = + new Alert( + name, + element.getAttributeValue("url"), + element.getAttributeValue("risk"), + element.getAttributeValue("confidence"), + element.getAttributeValue("param"), + element.getAttributeValue("other")); + alerts.add(alert); + } + return alerts; + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponse.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponse.java index 71add5d..9db5608 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponse.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponse.java @@ -1,40 +1,40 @@ /* * Zed Attack Proxy (ZAP) and its related class files. - * + * * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Copyright 2012 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.zaproxy.clientapi.core; - public abstract class ApiResponse { - private String name = null; - - public ApiResponse(String name) { - super(); - this.name = name; - } + private String name = null; - public String getName() { - return name; - } + public ApiResponse(String name) { + super(); + this.name = name; + } - public void setName(String name) { - this.name = name; - } + public String getName() { + return name; + } - public abstract String toString(int indent); + public void setName(String name) { + this.name = name; + } + public abstract String toString(int indent); } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseElement.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseElement.java index 5ccdd8b..44a8eca 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseElement.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseElement.java @@ -1,67 +1,72 @@ /* * Zed Attack Proxy (ZAP) and its related class files. - * + * * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Copyright 2012 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.zaproxy.clientapi.core; import org.w3c.dom.Node; public class ApiResponseElement extends ApiResponse { - - public static ApiResponseElement OK = new ApiResponseElement("Result", "OK"); - public static ApiResponseElement FAIL = new ApiResponseElement("Result", "FAIL"); - - private String value = null; - public ApiResponseElement(String name) { - super(name); - } + public static ApiResponseElement OK = new ApiResponseElement("Result", "OK"); + public static ApiResponseElement FAIL = new ApiResponseElement("Result", "FAIL"); - public ApiResponseElement(String name, String value) { - super(name); - this.value = value; - } + private String value = null; - public ApiResponseElement(Node node, ApiResponse template) { - super(node.getNodeName()); - this.value = node.getTextContent(); + public ApiResponseElement(String name) { + super(name); + } - } + public ApiResponseElement(String name, String value) { + super(name); + this.value = value; + } - public ApiResponseElement(Node node) { - super(node.getNodeName()); - this.value = node.getTextContent(); - } + public ApiResponseElement(Node node, ApiResponse template) { + super(node.getNodeName()); + this.value = node.getTextContent(); + } - public String getValue() { - return value; - } + public ApiResponseElement(Node node) { + super(node.getNodeName()); + this.value = node.getTextContent(); + } - @Override - public String toString(int indent) { - StringBuilder sb = new StringBuilder(); - for (int i=0 ; i < indent; i++) { - sb.append("\t"); - } - sb.append("ApiResponseElement "); - sb.append(this.getName()); - sb.append(" = " ); - sb.append(this.getValue()); - sb.append("\n"); - return sb.toString(); - } + public String getValue() { + return value; + } + @Override + public String toString(int indent) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < indent; i++) { + sb.append("\t"); + } + sb.append("ApiResponseElement "); + sb.append(this.getName()); + sb.append(" = "); + sb.append(this.getValue()); + sb.append("\n"); + return sb.toString(); + } + + @Override + public String toString() { + return getValue(); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseFactory.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseFactory.java index 20df241..03fd374 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseFactory.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseFactory.java @@ -1,38 +1,55 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2012 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.zaproxy.clientapi.core; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public final class ApiResponseFactory { - - private ApiResponseFactory() { - } - - public static ApiResponse getResponse(Node node) throws ClientApiException { - if (node == null) { - throw new ClientApiException("Null node"); - } - Node typeNode = node.getAttributes().getNamedItem("type"); - if (typeNode != null) { - String type = typeNode.getNodeValue(); - if ("list".equals(type)) { - return new ApiResponseList(node); - } - if ("set".equals(type)) { - return new ApiResponseSet(node); - } - if ("exception".equals(type)) { - NamedNodeMap atts = node.getAttributes(); - String code = atts.getNamedItem("code").getNodeValue(); - String detail = null; - if (atts.getNamedItem("detail") != null) { - detail = atts.getNamedItem("detail").getNodeValue(); - } - throw new ClientApiException(node.getTextContent(), code, detail); - } - } - return new ApiResponseElement(node); - } + private ApiResponseFactory() {} + public static ApiResponse getResponse(Node node) throws ClientApiException { + if (node == null) { + throw new ClientApiException("Null node"); + } + Node typeNode = node.getAttributes().getNamedItem("type"); + if (typeNode != null) { + String type = typeNode.getNodeValue(); + if ("list".equals(type)) { + return new ApiResponseList(node); + } + if ("set".equals(type)) { + return new ApiResponseSet(node); + } + if ("exception".equals(type)) { + NamedNodeMap atts = node.getAttributes(); + + String code = atts.getNamedItem("code").getNodeValue(); + String detail = null; + if (atts.getNamedItem("detail") != null) { + detail = atts.getNamedItem("detail").getNodeValue(); + } + throw new ClientApiException(node.getTextContent(), code, detail); + } + } + return new ApiResponseElement(node); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseList.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseList.java index 6bbbf38..d69cb5e 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseList.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseList.java @@ -1,113 +1,115 @@ /* * Zed Attack Proxy (ZAP) and its related class files. - * + * * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Copyright 2012 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.zaproxy.clientapi.core; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; - import org.w3c.dom.Node; public class ApiResponseList extends ApiResponse { - - private List list = null; - public ApiResponseList(String name) { - super(name); - this.list = new ArrayList(); - } + private List list = null; + + public ApiResponseList(String name) { + super(name); + this.list = new ArrayList<>(); + } + + public ApiResponseList(Node node) throws ClientApiException { + this(node.getNodeName()); + Node child = node.getFirstChild(); + while (child != null) { + addItemImpl(ApiResponseFactory.getResponse(child)); + child = child.getNextSibling(); + } + } + + public ApiResponseList(Node node, ApiResponseList template) throws ClientApiException { + super(node.getNodeName()); + try { + this.list = new ArrayList<>(); + Class clazz = template.getItemsClass(); + if (clazz != null) { + + Node child = node.getFirstChild(); + while (child != null) { + Constructor cons = + clazz.getConstructor(Node.class, ApiResponse.class); + addItemImpl(cons.newInstance(child, template.list.get(0))); + child = child.getNextSibling(); + } + } + } catch (Exception e) { + throw new ClientApiException(e); + } + } - public ApiResponseList(Node node) - throws ClientApiException { - this(node.getNodeName()); - Node child = node.getFirstChild(); - while (child != null) { - this.addItem(ApiResponseFactory.getResponse(child)); - child = child.getNextSibling(); - } - } + public ApiResponseList(String name, ApiResponse[] array) { + super(name); + this.list = new ArrayList<>(); + for (ApiResponse resp : array) { + list.add(resp); + } + } - public ApiResponseList(Node node, ApiResponseList template) - throws ClientApiException { - super(node.getNodeName()); - try { - this.list = new ArrayList(); - Class clazz = template.getItemsClass(); - if (clazz != null) { + public ApiResponseList(String name, List list) { + super(name); + this.list = list; + } - Node child = node.getFirstChild(); - while (child != null) { - Constructor cons = clazz.getConstructor(Node.class, ApiResponse.class); - this.addItem(cons.newInstance(child, template.list.get(0))); - child = child.getNextSibling(); - } - } - } catch (Exception e) { - throw new ClientApiException(e); - } - } + public void addItem(ApiResponse item) { + addItemImpl(item); + } - public ApiResponseList(String name, ApiResponse[] array) { - super(name); - this.list = new ArrayList(); - for (ApiResponse resp: array) { - list.add(resp); - } - } + private void addItemImpl(ApiResponse item) { + list.add(item); + } - public ApiResponseList(String name, List list) { - super(name); - this.list = list; - } - - public void addItem(ApiResponse item) { - this.list.add(item); - } - - public List getItems() { - return this.list; - } - - public Class getItemsClass() { - if (this.list == null || this.list.size() == 0) { - return null; - } - return this.list.get(0).getClass(); - } + public List getItems() { + return this.list; + } - @Override - public String toString(int indent) { - StringBuilder sb = new StringBuilder(); - for (int i=0 ; i < indent; i++) { - sb.append("\t"); - } - sb.append("ApiResponseList "); - sb.append(this.getName()); - sb.append(" : [\n"); - for (ApiResponse resp: this.list) { - sb.append(resp.toString(indent+1)); - } - for (int i=0 ; i < indent; i++) { - sb.append("\t"); - } - sb.append("]\n"); - return sb.toString(); - } + public Class getItemsClass() { + if (this.list == null || this.list.size() == 0) { + return null; + } + return this.list.get(0).getClass(); + } - + @Override + public String toString(int indent) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < indent; i++) { + sb.append("\t"); + } + sb.append("ApiResponseList "); + sb.append(this.getName()); + sb.append(" : [\n"); + for (ApiResponse resp : this.list) { + sb.append(resp.toString(indent + 1)); + } + for (int i = 0; i < indent; i++) { + sb.append("\t"); + } + sb.append("]\n"); + return sb.toString(); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseSet.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseSet.java index 1e2ebdb..c3dd2c8 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseSet.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ApiResponseSet.java @@ -1,19 +1,21 @@ /* * Zed Attack Proxy (ZAP) and its related class files. - * + * * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * + * Copyright 2012 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.zaproxy.clientapi.core; @@ -23,148 +25,173 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; - import org.w3c.dom.Node; public class ApiResponseSet extends ApiResponse { - - private String[] attributes = null; - private final Map valuesMap; - /** - * Constructs an {@code ApiResponseSet} with the given name and attributes. - * - * @param name the name of the API response - * @param attributes the attributes - * @deprecated (TODO add version) Unused, there's no replacement. - */ - @Deprecated - public ApiResponseSet(String name, String[] attributes) { - super(name); - this.attributes = attributes; - this.valuesMap = Collections.emptyMap(); - } + private String[] attributes = null; + private final Map valuesMap; + + /** + * Constructs an {@code ApiResponseSet} with the given name and attributes. + * + * @param name the name of the API response + * @param attributes the attributes + * @deprecated (1.1.0) Unused, there's no replacement. + */ + @Deprecated + public ApiResponseSet(String name, String[] attributes) { + super(name); + this.attributes = attributes; + this.valuesMap = Collections.emptyMap(); + } + + public ApiResponseSet(String name, Map values) { + super(name); + this.valuesMap = Collections.unmodifiableMap(new HashMap<>(values)); + } - public ApiResponseSet(String name, Map values) { - super(name); - this.valuesMap = Collections.unmodifiableMap(new HashMap<>(values)); - } + public ApiResponseSet(Node node) throws ClientApiException { + super(node.getNodeName()); + Node child = node.getFirstChild(); + Map values = new HashMap<>(); + while (child != null) { + ApiResponse elem = ApiResponseFactory.getResponse(child); + values.put(elem.getName(), elem); + child = child.getNextSibling(); + } + this.valuesMap = Collections.unmodifiableMap(values); + } - public ApiResponseSet(Node node) throws ClientApiException { - super(node.getNodeName()); - Node child = node.getFirstChild(); - Map values = new HashMap<>(); - while (child != null) { - ApiResponseElement elem = (ApiResponseElement) ApiResponseFactory.getResponse(child); - values.put(elem.getName(), elem.getValue()); - child = child.getNextSibling(); - } - this.valuesMap = Collections.unmodifiableMap(values); - } + /** + * Gets the attributes. + * + * @return the attributes, might be {@code null}. + * @deprecated (1.1.0) Unused, there's no replacement. + * @see #getValues() + */ + @Deprecated + public String[] getAttributes() { + return attributes; + } - /** - * Gets the attributes. - * - * @return the attributes, might be {@code null}. - * @deprecated (TODO add version) Unused, there's no replacement. - * @see #getValues() - */ - @Deprecated - public String[] getAttributes() { - return attributes; - } - - /** - * Gets the value for the given {@code key}. - * - * @param key the key of the value - * @return the value, or {@code null} if no value exists for the given {@code key}. - * @deprecated (TODO add version) Use {@link #getValue(String)} instead. - */ - @Deprecated - public String getAttribute(String key) { - return getValue(key); - } + /** + * Gets the value for the given {@code key}. + * + * @param key the key of the value + * @return the value, or {@code null} if no value exists for the given {@code key}. + * @deprecated (1.1.0) Use {@link #getStringValue(String)} or {@link #getValue(String)} instead. + */ + @Deprecated + public String getAttribute(String key) { + return getStringValue(key); + } - /** - * Gets the value for the given {@code key}. - * - * @param key the key of the value - * @return the value, or {@code null} if no value exists for the given {@code key}. - * @since TODO add version - * @see #getKeys() - */ - public String getValue(String key) { - return valuesMap.get(key); - } + /** + * Gets the value for the given {@code key}. + * + * @param key the key of the value + * @return the value, or {@code null} if no value exists for the given {@code key}. + * @since 1.1.0 + * @see #getKeys() + * @see #getStringValue(String) + */ + public ApiResponse getValue(String key) { + return valuesMap.get(key); + } - /** - * Gets a {@code Map} with the keys and values. - *

- * The returned {@code Map} is unmodifiable, any attempt to modify it will result in an - * {@code UnsupportedOperationException}. - * - * @return the map with the keys/values, never {@code null}. - * @since TODO add version - */ - public Map getValuesMap() { - return valuesMap; - } + /** + * Gets the value for the given {@code key} as {@code String}. + * + *

For {@link ApiResponseElement}s it returns {@link ApiResponseElement#getValue() its + * value}, for other {@link ApiResponse} types it returns the conversion to {@code String}. + * + * @param key the key of the value + * @return the value, or {@code null} if no value exists for the given {@code key}. + * @since 1.1.0 + * @see #getKeys() + * @see #getValue(String) + */ + public String getStringValue(String key) { + ApiResponse value = valuesMap.get(key); + if (value instanceof ApiResponseElement) { + return ((ApiResponseElement) value).getValue(); + } + return value != null ? value.toString() : null; + } - /** - * Gets the keys of the values. - *

- * The returned {@code Set} is unmodifiable, any attempt to modify it will result in an - * {@code UnsupportedOperationException}. - * - * @return the keys, never {@code null}. - * @since TODO add version - * @see #getValue(String) - * @see #getValues() - * @see #getValuesMap() - */ - public Set getKeys() { - return valuesMap.keySet(); - } + /** + * Gets a {@code Map} with the keys and values. + * + *

The returned {@code Map} is unmodifiable, any attempt to modify it will result in an + * {@code UnsupportedOperationException}. + * + * @return the map with the keys/values, never {@code null}. + * @since 1.1.0 + */ + public Map getValuesMap() { + return valuesMap; + } - /** - * Gets the values. - *

- * The returned {@code Collection} is unmodifiable, any attempt to modify it will result in an - * {@code UnsupportedOperationException}. - * - * @return the values, never {@code null}. - * @since TODO add version - * @see #getValue(String) - */ - public Collection getValues() { - return valuesMap.values(); - } + /** + * Gets the keys of the values. + * + *

The returned {@code Set} is unmodifiable, any attempt to modify it will result in an + * {@code UnsupportedOperationException}. + * + * @return the keys, never {@code null}. + * @since 1.1.0 + * @see #getValue(String) + * @see #getStringValue(String) + * @see #getValues() + * @see #getValuesMap() + */ + public Set getKeys() { + return valuesMap.keySet(); + } - @Override - public String toString(int indent) { - StringBuilder sb = new StringBuilder(); - for (int i=0 ; i < indent; i++) { - sb.append("\t"); - } - sb.append("ApiResponseSet "); - sb.append(this.getName()); - sb.append(" : [\n"); - for (Entry val : valuesMap.entrySet()) { - for (int i=0 ; i < indent+1; i++) { - sb.append("\t"); - } - sb.append(val.getKey()); - sb.append(" = "); - sb.append(val.getValue()); - sb.append("\n"); - } - for (int i=0 ; i < indent; i++) { - sb.append("\t"); - } - sb.append("]\n"); - return sb.toString(); - } + /** + * Gets the values. + * + *

The returned {@code Collection} is unmodifiable, any attempt to modify it will result in + * an {@code UnsupportedOperationException}. + * + * @return the values, never {@code null}. + * @since 1.1.0 + * @see #getValue(String) + * @see #getStringValue(String) + */ + public Collection getValues() { + return valuesMap.values(); + } - + @Override + public String toString(int indent) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < indent; i++) { + sb.append("\t"); + } + sb.append("ApiResponseSet "); + sb.append(this.getName()); + sb.append(" : [\n"); + for (Entry val : valuesMap.entrySet()) { + for (int i = 0; i < indent + 1; i++) { + sb.append("\t"); + } + sb.append(val.getKey()); + sb.append(" = "); + if (val.getValue() instanceof ApiResponseElement) { + sb.append(val.getValue()); + } else { + sb.append('\n'); + sb.append(val.getValue().toString(indent + 2)); + } + sb.append("\n"); + } + for (int i = 0; i < indent; i++) { + sb.append("\t"); + } + sb.append("]\n"); + return sb.toString(); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApi.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApi.java index 494b3f1..e57e7a7 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApi.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApi.java @@ -1,507 +1,889 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2011 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.core; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.InetSocketAddress; -import java.net.MalformedURLException; -import java.net.Proxy; -import java.net.Socket; -import java.net.SocketTimeoutException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; -import org.zaproxy.clientapi.core.Alert.Confidence; -import org.zaproxy.clientapi.core.Alert.Risk; -import org.zaproxy.clientapi.gen.Acsrf; -import org.zaproxy.clientapi.gen.AjaxSpider; -import org.zaproxy.clientapi.gen.Ascan; -import org.zaproxy.clientapi.gen.Authentication; -import org.zaproxy.clientapi.gen.Authorization; -import org.zaproxy.clientapi.gen.Autoupdate; -import org.zaproxy.clientapi.gen.Break; -import org.zaproxy.clientapi.gen.Context; -import org.zaproxy.clientapi.gen.Core; -import org.zaproxy.clientapi.gen.ForcedUser; -import org.zaproxy.clientapi.gen.HttpSessions; -import org.zaproxy.clientapi.gen.ImportLogFiles; -import org.zaproxy.clientapi.gen.Params; -import org.zaproxy.clientapi.gen.Pnh; -import org.zaproxy.clientapi.gen.Pscan; -import org.zaproxy.clientapi.gen.Reveal; -import org.zaproxy.clientapi.gen.Script; -import org.zaproxy.clientapi.gen.Search; -import org.zaproxy.clientapi.gen.Selenium; -import org.zaproxy.clientapi.gen.SessionManagement; -import org.zaproxy.clientapi.gen.Spider; -import org.zaproxy.clientapi.gen.Stats; -import org.zaproxy.clientapi.gen.Users; - -public class ClientApi { - - private static final int DEFAULT_CONNECTION_POOLING_IN_MS = 1000; - - private Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8090)); - private boolean debug = false; - private PrintStream debugStream = System.out; - - private final String zapAddress; - private final int zapPort; - - // Note that any new API implementations added have to be added here manually - public Acsrf acsrf = new Acsrf(this); - public AjaxSpider ajaxSpider = new AjaxSpider(this); - public Ascan ascan = new Ascan(this); - public Authentication authentication = new Authentication(this); - public Authorization authorization = new Authorization(this); - public Autoupdate autoupdate = new Autoupdate(this); - public Break brk = new Break(this); - public Context context = new Context(this); - public Core core = new Core(this); - public ForcedUser forcedUser = new ForcedUser(this); - public HttpSessions httpSessions = new HttpSessions(this); - public ImportLogFiles logImportFiles = new ImportLogFiles(this); - public Params params = new Params(this); - public Pnh pnh = new Pnh(this); - public Pscan pscan = new Pscan(this); - public Reveal reveal = new Reveal(this); - public Search search = new Search(this); - public Script script = new Script(this); - public Selenium selenium = new Selenium(this); - public SessionManagement sessionManagement = new SessionManagement(this); - public Spider spider = new Spider(this); - public Stats stats = new Stats(this); - public Users users = new Users(this); - - public ClientApi (String zapAddress, int zapPort) { - this(zapAddress, zapPort, false); - } - - public ClientApi (String zapAddress, int zapPort, boolean debug) { - proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(zapAddress, zapPort)); - this.debug = debug; - this.zapAddress = zapAddress; - this.zapPort = zapPort; - } - - public void setDebugStream(PrintStream debugStream) { - this.debugStream = debugStream; - } - - public void accessUrl (String url) throws ClientApiException { - accessUrlViaProxy(proxy, url); - } - - private int statusToInt(ApiResponse response) { - return Integer.parseInt(((ApiResponseElement)response).getValue()); - } - - public void checkAlerts (List ignoreAlerts, List requireAlerts) throws ClientApiException { - HashMap> results = checkForAlerts(ignoreAlerts, requireAlerts); - verifyAlerts(results.get("requireAlerts"), results.get("reportAlerts")); - } - - private void verifyAlerts(List requireAlerts, List reportAlerts) throws ClientApiException { - StringBuilder sb = new StringBuilder(); - if (reportAlerts.size() > 0) { - sb.append("Found ").append(reportAlerts.size()).append(" alerts\n"); - for (Alert alert: reportAlerts) { - sb.append('\t'); - sb.append(alert.toString()); - sb.append('\n'); - } - } - if (requireAlerts != null && requireAlerts.size() > 0) { - if (sb.length() > 0) { - sb.append('\n'); - } - sb.append("Not found ").append(requireAlerts.size()).append(" alerts\n"); - for (Alert alert: requireAlerts) { - sb.append('\t'); - sb.append(alert.toString()); - sb.append('\n'); - } - } - if (sb.length() > 0) { - if (debug) { - debugStream.println("Failed: " + sb.toString()); - } - throw new ClientApiException (sb.toString()); - } - } - - public void checkAlerts(List ignoreAlerts, List requireAlerts, File outputFile) throws ClientApiException { - HashMap> results = checkForAlerts(ignoreAlerts, requireAlerts); - int alertsFound = results.get("reportAlerts").size(); - int alertsNotFound = results.get("requireAlerts").size(); - int alertsIgnored = results.get("ignoredAlerts").size(); - String resultsString = String.format("Alerts Found: %d, Alerts required but not found: %d, Alerts ignored: %d", alertsFound, alertsNotFound, alertsIgnored); - try { - AlertsFile.saveAlertsToFile(results.get("requireAlerts"), results.get("reportAlerts"), results.get("ignoredAlerts"), outputFile); - } catch (Exception e) { - throw new ClientApiException (e); - } - if (alertsFound>0 || alertsNotFound>0){ - throw new ClientApiException("Check Alerts Failed!\n"+resultsString); - }else{ - if (debug) { - debugStream.println("Check Alerts Passed!\n" + resultsString); - } - } - } - - public List getAlerts(String baseUrl, int start, int count) throws ClientApiException { - List alerts = new ArrayList(); - ApiResponse response = core.alerts(baseUrl, String.valueOf(start), String.valueOf(count)); - if (response != null && response instanceof ApiResponseList) { - ApiResponseList alertList = (ApiResponseList)response; - for (ApiResponse resp : alertList.getItems()) { - ApiResponseSet alertSet = (ApiResponseSet)resp; - alerts.add(new Alert( - alertSet.getValue("alert"), - alertSet.getValue("url"), - Risk.valueOf(alertSet.getValue("risk")), - Confidence.valueOf(alertSet.getValue("confidence")), - alertSet.getValue("param"), - alertSet.getValue("other"), - alertSet.getValue("attack"), - alertSet.getValue("description"), - alertSet.getValue("reference"), - alertSet.getValue("solution"), - alertSet.getValue("evidence"), - Integer.parseInt(alertSet.getValue("cweid")), - Integer.parseInt(alertSet.getValue("wascid")))); - } - } - return alerts; - } - - private HashMap> checkForAlerts(List ignoreAlerts, List requireAlerts) throws ClientApiException { - List reportAlerts = new ArrayList<>(); - List ignoredAlerts = new ArrayList<>(); - List alerts = getAlerts(null, -1, -1); - for (Alert alert : alerts) { - boolean ignore = false; - if (ignoreAlerts != null) { - for (Alert ignoreAlert : ignoreAlerts) { - if (alert.matches(ignoreAlert)) { - if (debug) { - debugStream.println("Ignoring alert " + ignoreAlert); - } - ignoredAlerts.add(alert); - ignore = true; - break; - } - } - } - if (! ignore) { - reportAlerts.add(alert); - } - if (requireAlerts != null) { - for (Alert requireAlert : requireAlerts) { - if (alert.matches(requireAlert)) { - if (debug) { - debugStream.println("Found alert " + alert); - } - requireAlerts.remove(requireAlert); - // Remove it from the not-ignored list as well - reportAlerts.remove(alert); - break; - } - } - } - } - HashMap> results = new HashMap<>(); - results.put("reportAlerts", reportAlerts); - results.put("requireAlerts", requireAlerts); - results.put("ignoredAlerts", ignoredAlerts); - return results; - } - - private void accessUrlViaProxy (Proxy proxy, String apiurl) throws ClientApiException { - try { - URL url = new URL(apiurl); - if (debug) { - debugStream.println("Open URL: " + apiurl); - } - HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy); - uc.connect(); - - BufferedReader in; - try { - in = new BufferedReader(new InputStreamReader(uc.getInputStream())); - String inputLine; - - while ((inputLine = in.readLine()) != null) { - if (debug) { - debugStream.println(inputLine); - } - } - in.close(); - - } catch (IOException e) { - // Ignore - if (debug) { - debugStream.println("Ignoring exception " + e); - } - } - } catch (Exception e) { - throw new ClientApiException (e); - } - } - - public ApiResponse callApi (String component, String type, String method, - Map params) throws ClientApiException { - Document dom = this.callApiDom(component, type, method, params); - return ApiResponseFactory.getResponse(dom.getFirstChild()); - } - - private Document callApiDom (String component, String type, String method, - Map params) throws ClientApiException { - try { - URL url = buildZapRequestUrl("xml", component, type, method, params); - if (debug) { - debugStream.println("Open URL: " + url); - } - //get the factory - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - //Using factory get an instance of document builder - DocumentBuilder db = dbf.newDocumentBuilder(); - //parse using builder to get DOM representation of the XML file - return db.parse(getConnectionInputStream(url)); - } catch (Exception e) { - throw new ClientApiException(e); - } - } - - private InputStream getConnectionInputStream(URL url) throws IOException { - HttpURLConnection uc = (HttpURLConnection) url.openConnection(proxy); - uc.connect(); - if (uc.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { - return uc.getErrorStream(); - } - return uc.getInputStream(); - } - - public byte[] callApiOther (String component, String type, String method, - Map params) throws ClientApiException { - try { - URL url = buildZapRequestUrl("other", component, type, method, params); - if (debug) { - debugStream.println("Open URL: " + url); - } - InputStream in = getConnectionInputStream(url); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buffer = new byte[8 * 1024]; - try { - int bytesRead; - while ((bytesRead = in.read(buffer)) != -1) { - out.write(buffer, 0, bytesRead); - } - } finally { - out.close(); - in.close(); - } - return out.toByteArray(); - - } catch (Exception e) { - throw new ClientApiException(e); - } - } - - private static URL buildZapRequestUrl( - String format, - String component, - String type, - String method, - Map params) throws MalformedURLException { - StringBuilder sb = new StringBuilder(); - sb.append("http://zap/"); - sb.append(format); - sb.append('/'); - sb.append(component); - sb.append('/'); - sb.append(type); - sb.append('/'); - sb.append(method); - sb.append('/'); - if (params != null) { - sb.append('?'); - for (Map.Entry p : params.entrySet()) { - sb.append(encodeQueryParam(p.getKey())); - sb.append('='); - if (p.getValue() != null) { - sb.append(encodeQueryParam(p.getValue())); - } - sb.append('&'); - } - } - - return new URL(sb.toString()); - } - - private static String encodeQueryParam(String param) { - try { - return URLEncoder.encode(param, "UTF-8"); - } catch (UnsupportedEncodingException ignore) { - // UTF-8 is a standard charset. - } - return param; - } - - public void addExcludeFromContext(String apikey, String contextName, String regex) throws Exception { - context.excludeFromContext(apikey, contextName, regex); - } - - public void addIncludeInContext(String apikey, String contextName, String regex) throws Exception { - context.includeInContext(apikey, contextName, regex); - } - - public void includeOneMatchingNodeInContext(String apikey, String contextName, String regex) throws Exception { - List sessionUrls = getSessionUrls(); - boolean foundOneMatch = false; - for (String sessionUrl : sessionUrls){ - if (sessionUrl.matches(regex)){ - if (foundOneMatch){ - addExcludeFromContext(apikey, contextName, sessionUrl); - } else { - foundOneMatch = true; - } - } - } - if(!foundOneMatch){ - throw new Exception("Unexpected result: No url found in site tree matching regex " + regex); - } - - } - - private List getSessionUrls() throws Exception { - List sessionUrls = new ArrayList<>(); - ApiResponse response = core.urls(); - if (response != null && response instanceof ApiResponseList) { - ApiResponseElement urlList = (ApiResponseElement) ((ApiResponseList) response).getItems().get(0); - for (ApiResponse element: ((ApiResponseList) response).getItems()){ - URL url = new URL(((ApiResponseElement)element).getValue()); - sessionUrls.add(url.getProtocol()+"://"+url.getHost()+url.getPath()); - } - System.out.println(urlList); - } - return sessionUrls; - } - - public void activeScanSiteInScope(String apikey, String url) throws Exception { - ascan.scan(apikey, url, "true", "true", "", "", ""); - // Poll until spider finished - int status = 0; - while ( status < 100) { - status = statusToInt(ascan.status("")); - if(debug){ - String format = "Scanning %s Progress: %d%%"; - System.out.println(String.format(format, url, status)); - }try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // Ignore - } - } - } - - /** - * Convenience method to wait for ZAP to be ready to receive API calls, when started programmatically. - *

- * It attempts to establish a connection to ZAP's proxy, in the given time, throwing an exception if the connection is not - * successful. The connection attempts might be polled in one second interval. - * - * @param timeoutInSeconds the (maximum) number of seconds to wait for ZAP to start - * @throws ClientApiException if the timeout was reached or if the thread was interrupted while waiting - * @see #waitForSuccessfulConnectionToZap(int, int) - */ - public void waitForSuccessfulConnectionToZap(int timeoutInSeconds) throws ClientApiException { - waitForSuccessfulConnectionToZap(timeoutInSeconds, DEFAULT_CONNECTION_POOLING_IN_MS); - } - - /** - * Convenience method to wait for ZAP to be ready to receive API calls, when started programmatically. - *

- * It attempts to establish a connection to ZAP's proxy, in the given time, throwing an exception if the connection is not - * successful. The connection attempts are done with the given polling interval. - * - * @param timeoutInSeconds the (maximum) number of seconds to wait for ZAP to start - * @param pollingIntervalInMs the interval, in milliseconds, for connection polling - * @throws ClientApiException if the timeout was reached or if the thread was interrupted while waiting. - * @throws IllegalArgumentException if the interval for connection polling is negative. - * @see #waitForSuccessfulConnectionToZap(int) - */ - public void waitForSuccessfulConnectionToZap(int timeoutInSeconds, int pollingIntervalInMs) throws ClientApiException { - int timeoutInMs = (int) TimeUnit.SECONDS.toMillis(timeoutInSeconds); - int connectionTimeoutInMs = timeoutInMs; - boolean connectionSuccessful = false; - long startTime = System.currentTimeMillis(); - do { - try (Socket socket = new Socket()) { - try { - socket.connect(new InetSocketAddress(zapAddress, zapPort), connectionTimeoutInMs); - connectionSuccessful = true; - } catch (SocketTimeoutException ignore) { - throw newTimeoutConnectionToZap(timeoutInSeconds); - } catch (IOException ignore) { - // and keep trying but wait some time first... - try { - Thread.sleep(pollingIntervalInMs); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new ClientApiException( - "The ClientApi was interrupted while sleeping between connection polling.", - e); - } - - long ellapsedTime = System.currentTimeMillis() - startTime; - if (ellapsedTime >= timeoutInMs) { - throw newTimeoutConnectionToZap(timeoutInSeconds); - } - connectionTimeoutInMs = (int) (timeoutInMs - ellapsedTime); - } - } catch (IOException ignore) { - // the closing state doesn't matter. - } - } while (!connectionSuccessful); - } - - private static ClientApiException newTimeoutConnectionToZap(int timeoutInSeconds) { - return new ClientApiException("Unable to connect to ZAP's proxy after " + timeoutInSeconds + " seconds."); - } -} +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2011 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.core; + +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.InetSocketAddress; +import java.net.MalformedURLException; +import java.net.Proxy; +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.w3c.dom.Document; +import org.zaproxy.clientapi.gen.AccessControl; +import org.zaproxy.clientapi.gen.Acsrf; +import org.zaproxy.clientapi.gen.AjaxSpider; +import org.zaproxy.clientapi.gen.AlertFilter; +import org.zaproxy.clientapi.gen.Ascan; +import org.zaproxy.clientapi.gen.Authentication; +import org.zaproxy.clientapi.gen.Authorization; +import org.zaproxy.clientapi.gen.Automation; +import org.zaproxy.clientapi.gen.Autoupdate; +import org.zaproxy.clientapi.gen.Break; +import org.zaproxy.clientapi.gen.Client; +import org.zaproxy.clientapi.gen.ClientSpider; +import org.zaproxy.clientapi.gen.Context; +import org.zaproxy.clientapi.gen.Core; +import org.zaproxy.clientapi.gen.Exim; +import org.zaproxy.clientapi.gen.ForcedUser; +import org.zaproxy.clientapi.gen.Graphql; +import org.zaproxy.clientapi.gen.HttpSessions; +import org.zaproxy.clientapi.gen.Network; +import org.zaproxy.clientapi.gen.Oast; +import org.zaproxy.clientapi.gen.Openapi; +import org.zaproxy.clientapi.gen.Params; +import org.zaproxy.clientapi.gen.Pnh; +import org.zaproxy.clientapi.gen.Postman; +import org.zaproxy.clientapi.gen.Pscan; +import org.zaproxy.clientapi.gen.Replacer; +import org.zaproxy.clientapi.gen.Reports; +import org.zaproxy.clientapi.gen.Retest; +import org.zaproxy.clientapi.gen.Reveal; +import org.zaproxy.clientapi.gen.Revisit; +import org.zaproxy.clientapi.gen.RuleConfig; +import org.zaproxy.clientapi.gen.Script; +import org.zaproxy.clientapi.gen.Search; +import org.zaproxy.clientapi.gen.Selenium; +import org.zaproxy.clientapi.gen.SessionManagement; +import org.zaproxy.clientapi.gen.Soap; +import org.zaproxy.clientapi.gen.Spider; +import org.zaproxy.clientapi.gen.Stats; +import org.zaproxy.clientapi.gen.Users; +import org.zaproxy.clientapi.gen.Wappalyzer; +import org.zaproxy.clientapi.gen.Websocket; + +@SuppressWarnings("this-escape") +public class ClientApi { + + private static final int DEFAULT_CONNECTION_POOLING_IN_MS = 1000; + + private static final String ZAP_API_KEY_HEADER = "X-ZAP-API-Key"; + + private Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8090)); + private boolean debug = false; + private PrintStream debugStream = System.out; + + private final String zapAddress; + private final int zapPort; + + private final String apiKey; + + private DocumentBuilderFactory docBuilderFactory; + + // Note that any new API implementations added have to be added here manually + public AccessControl accessControl = new AccessControl(this); + public Acsrf acsrf = new Acsrf(this); + public AjaxSpider ajaxSpider = new AjaxSpider(this); + public AlertFilter alertFilter = new AlertFilter(this); + public org.zaproxy.clientapi.gen.Alert alert = new org.zaproxy.clientapi.gen.Alert(this); + public Ascan ascan = new Ascan(this); + public Authentication authentication = new Authentication(this); + public Authorization authorization = new Authorization(this); + public Automation automation = new Automation(this); + public Autoupdate autoupdate = new Autoupdate(this); + public Break brk = new Break(this); + public Client client = new Client(this); + public ClientSpider clientSpider = new ClientSpider(this); + public Context context = new Context(this); + public Core core = new Core(this); + public Exim exim = new Exim(this); + + @SuppressWarnings("removal") + public org.zaproxy.clientapi.gen.Exportreport exportreport = + new org.zaproxy.clientapi.gen.Exportreport(this); + + public ForcedUser forcedUser = new ForcedUser(this); + public Graphql graphql = new Graphql(this); + public HttpSessions httpSessions = new HttpSessions(this); + + @SuppressWarnings("removal") + public org.zaproxy.clientapi.gen.ImportLogFiles logImportFiles = + new org.zaproxy.clientapi.gen.ImportLogFiles(this); + + @SuppressWarnings("removal") + public org.zaproxy.clientapi.gen.Importurls importurls = + new org.zaproxy.clientapi.gen.Importurls(this); + + @SuppressWarnings("removal") + public org.zaproxy.clientapi.gen.LocalProxies localProxies = + new org.zaproxy.clientapi.gen.LocalProxies(this); + + public Network network = new Network(this); + public Oast oast = new Oast(this); + public Openapi openapi = new Openapi(this); + public Params params = new Params(this); + public Pnh pnh = new Pnh(this); + public Postman postman = new Postman(this); + public Pscan pscan = new Pscan(this); + public Replacer replacer = new Replacer(this); + public Reports reports = new Reports(this); + public Retest retest = new Retest(this); + public Reveal reveal = new Reveal(this); + public Revisit revisit = new Revisit(this); + public RuleConfig ruleConfig = new RuleConfig(this); + public Search search = new Search(this); + public Script script = new Script(this); + public Selenium selenium = new Selenium(this); + public SessionManagement sessionManagement = new SessionManagement(this); + public Soap soap = new Soap(this); + public Spider spider = new Spider(this); + public Stats stats = new Stats(this); + public Users users = new Users(this); + public Wappalyzer wappalyzer = new Wappalyzer(this); + public Websocket websocket = new Websocket(this); + + public ClientApi(String zapAddress, int zapPort) { + this(zapAddress, zapPort, false); + } + + /** + * Constructs a {@code ClientApi} with the given ZAP address/port and with the given API key, to + * be sent with all API requests. + * + * @param zapAddress ZAP's address + * @param zapPort ZAP's listening port + * @param apiKey the ZAP API key, might be {@code null} or empty in which case is not used/sent. + * @since 1.1.0 + */ + public ClientApi(String zapAddress, int zapPort, String apiKey) { + this(zapAddress, zapPort, apiKey, false); + } + + public ClientApi(String zapAddress, int zapPort, boolean debug) { + this(zapAddress, zapPort, null, debug); + } + + /** + * Constructs a {@code ClientApi} with the given ZAP address/port and with the given API key, to + * be sent with all API requests. Also, sets whether or not client API debug information should + * be written to the {@link #setDebugStream(PrintStream) debug stream} (by default the standard + * output stream). + * + * @param zapAddress ZAP's address + * @param zapPort ZAP's listening port + * @param apiKey the ZAP API key, might be {@code null} or empty in which case is not used/sent. + * @param debug {@code true} if debug information should be written to debug stream, {@code + * false} otherwise. + * @since 1.1.0 + */ + public ClientApi(String zapAddress, int zapPort, String apiKey, boolean debug) { + proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(zapAddress, zapPort)); + this.debug = debug; + this.zapAddress = zapAddress; + this.zapPort = zapPort; + this.apiKey = apiKey; + } + + public void setDebugStream(PrintStream debugStream) { + this.debugStream = debugStream; + } + + public void accessUrl(String url) throws ClientApiException { + accessUrlViaProxy(proxy, url); + } + + private int statusToInt(ApiResponse response) { + return Integer.parseInt(((ApiResponseElement) response).getValue()); + } + + public void checkAlerts(List ignoreAlerts, List requireAlerts) + throws ClientApiException { + Map> results = checkForAlerts(ignoreAlerts, requireAlerts); + verifyAlerts(results.get("requireAlerts"), results.get("reportAlerts")); + } + + private void verifyAlerts(List requireAlerts, List reportAlerts) + throws ClientApiException { + StringBuilder sb = new StringBuilder(); + if (reportAlerts.size() > 0) { + sb.append("Found ").append(reportAlerts.size()).append(" alerts\n"); + for (Alert alert : reportAlerts) { + sb.append('\t'); + sb.append(alert.toString()); + sb.append('\n'); + } + } + if (requireAlerts != null && requireAlerts.size() > 0) { + if (sb.length() > 0) { + sb.append('\n'); + } + sb.append("Not found ").append(requireAlerts.size()).append(" alerts\n"); + for (Alert alert : requireAlerts) { + sb.append('\t'); + sb.append(alert.toString()); + sb.append('\n'); + } + } + if (sb.length() > 0) { + if (debug) { + debugStream.println("Failed: " + sb.toString()); + } + throw new ClientApiException(sb.toString()); + } + } + + public void checkAlerts(List ignoreAlerts, List requireAlerts, File outputFile) + throws ClientApiException { + Map> results = checkForAlerts(ignoreAlerts, requireAlerts); + int alertsFound = results.get("reportAlerts").size(); + int alertsNotFound = results.get("requireAlerts").size(); + int alertsIgnored = results.get("ignoredAlerts").size(); + String resultsString = + String.format( + "Alerts Found: %d, Alerts required but not found: %d, Alerts ignored: %d", + alertsFound, alertsNotFound, alertsIgnored); + try { + AlertsFile.saveAlertsToFile( + results.get("requireAlerts"), + results.get("reportAlerts"), + results.get("ignoredAlerts"), + outputFile); + } catch (Exception e) { + throw new ClientApiException("Failed to save the alerts:", e); + } + if (alertsFound > 0 || alertsNotFound > 0) { + throw new ClientApiException("Check Alerts Failed!\n" + resultsString); + } else { + if (debug) { + debugStream.println("Check Alerts Passed!\n" + resultsString); + } + } + } + + public List getAlerts(String baseUrl, int start, int count) throws ClientApiException { + List alerts = new ArrayList<>(); + ApiResponse response = + alert.alerts(baseUrl, String.valueOf(start), String.valueOf(count), null); + if (response != null && response instanceof ApiResponseList) { + ApiResponseList alertList = (ApiResponseList) response; + for (ApiResponse resp : alertList.getItems()) { + alerts.add(new Alert((ApiResponseSet) resp)); + } + } + return alerts; + } + + private Map> checkForAlerts( + List ignoreAlerts, List requireAlerts) throws ClientApiException { + List reportAlerts = new ArrayList<>(); + List ignoredAlerts = new ArrayList<>(); + List alerts = getAlerts(null, -1, -1); + for (Alert alert : alerts) { + boolean ignore = false; + if (ignoreAlerts != null) { + for (Alert ignoreAlert : ignoreAlerts) { + if (alert.matches(ignoreAlert)) { + if (debug) { + debugStream.println("Ignoring alert " + ignoreAlert); + } + ignoredAlerts.add(alert); + ignore = true; + break; + } + } + } + if (!ignore) { + reportAlerts.add(alert); + } + if (requireAlerts != null) { + for (Alert requireAlert : requireAlerts) { + if (alert.matches(requireAlert)) { + if (debug) { + debugStream.println("Found alert " + alert); + } + requireAlerts.remove(requireAlert); + // Remove it from the not-ignored list as well + reportAlerts.remove(alert); + break; + } + } + } + } + HashMap> results = new HashMap<>(); + results.put("reportAlerts", reportAlerts); + results.put("requireAlerts", requireAlerts); + results.put("ignoredAlerts", ignoredAlerts); + return results; + } + + private void accessUrlViaProxy(Proxy proxy, String apiurl) throws ClientApiException { + try { + URL url = createUrl(apiurl); + if (debug) { + debugStream.println("Open URL: " + apiurl); + } + HttpURLConnection uc = (HttpURLConnection) url.openConnection(proxy); + uc.connect(); + + try (BufferedReader in = + new BufferedReader( + new InputStreamReader(uc.getInputStream(), StandardCharsets.UTF_8))) { + String inputLine; + + while ((inputLine = in.readLine()) != null) { + if (debug) { + debugStream.println(inputLine); + } + } + + } catch (IOException e) { + // Ignore + if (debug) { + debugStream.println("Ignoring exception " + e); + } + } + } catch (Exception e) { + throw new ClientApiException(e); + } + } + + private static URL createUrl(String value) throws MalformedURLException, URISyntaxException { + return new URI(value).toURL(); + } + + public ApiResponse callApi( + String component, String type, String method, Map params) + throws ClientApiException { + return callApi(HttpRequest.GET_METHOD, component, type, method, params); + } + + public ApiResponse callApi( + String requestMethod, + String component, + String type, + String method, + Map params) + throws ClientApiException { + Document dom = this.callApiDom(requestMethod, component, type, method, params); + return ApiResponseFactory.getResponse(dom.getFirstChild()); + } + + private Document callApiDom( + String requestMethod, + String component, + String type, + String method, + Map params) + throws ClientApiException { + try { + HttpRequest request = + buildZapRequest(requestMethod, "xml", component, type, method, params); + if (debug) { + debugStream.println("Open URL: " + request.getRequestUri()); + } + DocumentBuilder db = getDocumentBuilderFactory().newDocumentBuilder(); + // parse using builder to get DOM representation of the XML file + return db.parse(getConnectionInputStream(request)); + } catch (Exception e) { + throw new ClientApiException(e); + } + } + + /** + * Gets the {@code DocumentBuilderFactory} instance with XML External Entity (XXE) processing + * disabled. + * + * @return the {@code DocumentBuilderFactory} instance with XXE processing disabled. + * @throws ParserConfigurationException if an error occurred while disabling XXE processing. + * @see DocumentBuilderFactory + */ + private DocumentBuilderFactory getDocumentBuilderFactory() throws ParserConfigurationException { + if (docBuilderFactory == null) { + // Disable XXE processing, not required by default. + // https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); + factory.setFeature("http://xml.org/sax/features/external-general-entities", false); + factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); + factory.setExpandEntityReferences(false); + docBuilderFactory = factory; + } + return docBuilderFactory; + } + + private InputStream getConnectionInputStream(HttpRequest request) throws IOException { + HttpURLConnection uc = (HttpURLConnection) request.getRequestUri().openConnection(proxy); + uc.setUseCaches(false); + for (Entry header : request.getHeaders().entrySet()) { + uc.setRequestProperty(header.getKey(), header.getValue()); + } + if (!isGetRequest(request.getMethod())) { + uc.setRequestMethod(request.getMethod()); + String body = request.getBody(); + if (body != null && !body.isEmpty()) { + uc.setDoOutput(true); + try (var os = + new OutputStreamWriter(uc.getOutputStream(), StandardCharsets.UTF_8)) { + os.write(request.getBody()); + } + } + } + uc.connect(); + if (uc.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { + return uc.getErrorStream(); + } + return uc.getInputStream(); + } + + public byte[] callApiOther( + String component, String type, String method, Map params) + throws ClientApiException { + return callApiOther(HttpRequest.GET_METHOD, component, type, method, params); + } + + public byte[] callApiOther( + String requestMethod, + String component, + String type, + String method, + Map params) + throws ClientApiException { + return getBytes(requestMethod, "other", component, type, method, params); + } + + public String callApiJson( + String component, String type, String method, Map params) + throws ClientApiException { + byte[] json = getBytes(HttpRequest.GET_METHOD, "JSON", component, type, method, params); + return new String(json, StandardCharsets.UTF_8); + } + + private byte[] getBytes( + String requestMethod, + String format, + String component, + String type, + String method, + Map params) + throws ClientApiException { + try { + HttpRequest request = + buildZapRequest(requestMethod, format, component, type, method, params); + if (debug) { + debugStream.println("Open URL: " + request.getRequestUri()); + } + InputStream in = getConnectionInputStream(request); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buffer = new byte[8 * 1024]; + try { + int bytesRead; + while ((bytesRead = in.read(buffer)) != -1) { + out.write(buffer, 0, bytesRead); + } + } finally { + out.close(); + in.close(); + } + return out.toByteArray(); + + } catch (Exception e) { + throw new ClientApiException(e); + } + } + + /** + * Builds a request for the ZAP API with the given data. + * + *

As the API client proxies through ZAP the built API requests use a specific domain, {@code + * zap}, to ensure that they are always handled by ZAP (and not forward). + * + * @param requestMethod the HTTP request method. + * @param format the desired format of the API response (e.g. XML, JSON, other). + * @param component the API component (e.g. core, spider). + * @param type the type of the API endpoint (e.g. action, view). + * @param method the name of the endpoint. + * @param params the parameters for the endpoint. + * @return the API request. + * @throws MalformedURLException if an error occurred while building the URL. + * @throws URISyntaxException if an error occurred while building the URL. + */ + private HttpRequest buildZapRequest( + String requestMethod, + String format, + String component, + String type, + String method, + Map params) + throws MalformedURLException, URISyntaxException { + StringBuilder sb = new StringBuilder(); + sb.append("http://zap/"); + sb.append(format); + sb.append('/'); + sb.append(component); + sb.append('/'); + sb.append(type); + sb.append('/'); + sb.append(method); + sb.append('/'); + String body = null; + if (params != null) { + if (isGetRequest(requestMethod)) { + sb.append('?'); + appendParams(params, sb); + } else { + body = appendParams(params, new StringBuilder()).toString(); + } + } + + HttpRequest request = new HttpRequest(requestMethod, createUrl(sb.toString()), body); + if (apiKey != null && !apiKey.isEmpty()) { + request.addHeader(ZAP_API_KEY_HEADER, apiKey); + } + return request; + } + + private static boolean isGetRequest(String requestMethod) { + return HttpRequest.GET_METHOD.equals(requestMethod); + } + + private static StringBuilder appendParams(Map params, StringBuilder sb) { + for (Map.Entry p : params.entrySet()) { + sb.append(encodeQueryParam(p.getKey())); + sb.append('='); + if (p.getValue() != null) { + sb.append(encodeQueryParam(p.getValue())); + } + sb.append('&'); + } + return sb; + } + + private static String encodeQueryParam(String param) { + try { + return URLEncoder.encode(param, "UTF-8"); + } catch (UnsupportedEncodingException ignore) { + // UTF-8 is a standard charset. + } + return param; + } + + /** + * Adds the given regular expression to the exclusion list of the given context. + * + * @param apiKey the API key, might be {@code null}. + * @param contextName the name of the context. + * @param regex the regular expression to add. + * @throws Exception if an error occurred while calling the API. + * @deprecated (1.1.0) Use {@link Context#excludeFromContext(String, String)} instead. + * @see #context + */ + @Deprecated + public void addExcludeFromContext(String apiKey, String contextName, String regex) + throws Exception { + context.excludeFromContext(apiKey, contextName, regex); + } + + /** + * Adds the given regular expression to the inclusion list of the given context. + * + * @param apiKey the API key, might be {@code null}. + * @param contextName the name of the context. + * @param regex the regular expression to add. + * @throws Exception if an error occurred while calling the API. + * @deprecated (1.1.0) Use {@link Context#includeInContext(String, String)} instead. + * @see #context + */ + @Deprecated + public void addIncludeInContext(String apiKey, String contextName, String regex) + throws Exception { + context.includeInContext(apiKey, contextName, regex); + } + + /** + * Includes just one of the nodes that match the given regular expression in the context with + * the given name. + * + *

Nodes that do not match the regular expression are excluded. + * + * @param apiKey the API key, might be {@code null}. + * @param contextName the name of the context. + * @param regex the regular expression to match the node/URL. + * @throws Exception if an error occurred while calling the API. + * @deprecated (1.1.0) Use {@link #includeOneMatchingNodeInContext(String, String)} instead. + */ + @Deprecated + public void includeOneMatchingNodeInContext(String apiKey, String contextName, String regex) + throws Exception { + List sessionUrls = getSessionUrls(); + boolean foundOneMatch = false; + for (String sessionUrl : sessionUrls) { + if (sessionUrl.matches(regex)) { + if (foundOneMatch) { + addExcludeFromContext(apiKey, contextName, sessionUrl); + } else { + foundOneMatch = true; + } + } + } + if (!foundOneMatch) { + throw new Exception( + "Unexpected result: No url found in site tree matching regex " + regex); + } + } + + /** + * Includes just one of the nodes that match the given regular expression in the context with + * the given name. + * + *

Nodes that do not match the regular expression are excluded. + * + * @param contextName the name of the context. + * @param regex the regular expression to match the node/URL. + * @throws Exception if an error occurred while calling the API. + */ + public void includeOneMatchingNodeInContext(String contextName, String regex) throws Exception { + List sessionUrls = getSessionUrls(); + boolean foundOneMatch = false; + for (String sessionUrl : sessionUrls) { + if (sessionUrl.matches(regex)) { + if (foundOneMatch) { + context.excludeFromContext(contextName, regex); + } else { + foundOneMatch = true; + } + } + } + if (!foundOneMatch) { + throw new Exception( + "Unexpected result: No url found in site tree matching regex " + regex); + } + } + + private List getSessionUrls() throws Exception { + List sessionUrls = new ArrayList<>(); + ApiResponse response = core.urls(); + if (response != null && response instanceof ApiResponseList) { + ApiResponseElement urlList = + (ApiResponseElement) ((ApiResponseList) response).getItems().get(0); + for (ApiResponse element : ((ApiResponseList) response).getItems()) { + URL url = createUrl(((ApiResponseElement) element).getValue()); + sessionUrls.add(url.getProtocol() + "://" + url.getHost() + url.getPath()); + } + System.out.println(urlList); + } + return sessionUrls; + } + + /** + * Active scans the given site, that's in scope. + * + *

The method returns only after the scan has finished. + * + * @param apiKey the API key, might be {@code null}. + * @param url the site to scan + * @throws Exception if an error occurred while calling the API. + * @deprecated (1.1.0) Use {@link #activeScanSiteInScope(String)} instead, the API key should be + * set using one of the {@code ClientApi} constructors. + */ + @Deprecated + public void activeScanSiteInScope(String apiKey, String url) throws Exception { + ascan.scan(apiKey, url, "true", "true", "", "", ""); + waitForAScanToFinish(url); + } + + /** + * Active scans the given site, that's in scope. + * + *

The method returns only after the scan has finished. + * + * @param url the site to scan + * @throws Exception if an error occurred while calling the API. + * @since 1.1.0 + */ + public void activeScanSiteInScope(String url) throws Exception { + ascan.scan(url, "true", "true", "", "", ""); + waitForAScanToFinish(url); + } + + private void waitForAScanToFinish(String targetUrl) throws ClientApiException { + // Poll until spider finished + int status = 0; + while (status < 100) { + status = statusToInt(ascan.status("")); + if (debug) { + String format = "Scanning %s Progress: %d%%"; + System.out.println(String.format(format, targetUrl, status)); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // Ignore + } + } + } + + /** + * Convenience method to wait for ZAP to be ready to receive API calls, when started + * programmatically. + * + *

It attempts to establish a connection to ZAP's proxy, in the given time, throwing an + * exception if the connection is not successful. The connection attempts might be polled in one + * second interval. + * + * @param timeoutInSeconds the (maximum) number of seconds to wait for ZAP to start + * @throws ClientApiException if the timeout was reached or if the thread was interrupted while + * waiting + * @see #waitForSuccessfulConnectionToZap(int, int) + */ + public void waitForSuccessfulConnectionToZap(int timeoutInSeconds) throws ClientApiException { + waitForSuccessfulConnectionToZap(timeoutInSeconds, DEFAULT_CONNECTION_POOLING_IN_MS); + } + + /** + * Convenience method to wait for ZAP to be ready to receive API calls, when started + * programmatically. + * + *

It attempts to establish a connection to ZAP's proxy, in the given time, throwing an + * exception if the connection is not successful. The connection attempts are done with the + * given polling interval. + * + * @param timeoutInSeconds the (maximum) number of seconds to wait for ZAP to start + * @param pollingIntervalInMs the interval, in milliseconds, for connection polling + * @throws ClientApiException if the timeout was reached or if the thread was interrupted while + * waiting. + * @throws IllegalArgumentException if the interval for connection polling is negative. + * @see #waitForSuccessfulConnectionToZap(int) + */ + public void waitForSuccessfulConnectionToZap(int timeoutInSeconds, int pollingIntervalInMs) + throws ClientApiException { + int timeoutInMs = (int) TimeUnit.SECONDS.toMillis(timeoutInSeconds); + int connectionTimeoutInMs = timeoutInMs; + boolean connectionSuccessful = false; + long startTime = System.currentTimeMillis(); + do { + try (Socket socket = new Socket()) { + try { + socket.connect( + new InetSocketAddress(zapAddress, zapPort), connectionTimeoutInMs); + connectionSuccessful = true; + } catch (SocketTimeoutException ignore) { + throw newTimeoutConnectionToZap(timeoutInSeconds); + } catch (IOException ignore) { + // and keep trying but wait some time first... + try { + Thread.sleep(pollingIntervalInMs); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ClientApiException( + "The ClientApi was interrupted while sleeping between connection polling.", + e); + } + + long ellapsedTime = System.currentTimeMillis() - startTime; + if (ellapsedTime >= timeoutInMs) { + throw newTimeoutConnectionToZap(timeoutInSeconds); + } + connectionTimeoutInMs = (int) (timeoutInMs - ellapsedTime); + } + } catch (IOException ignore) { + // the closing state doesn't matter. + } + } while (!connectionSuccessful); + } + + private static ClientApiException newTimeoutConnectionToZap(int timeoutInSeconds) { + return new ClientApiException( + "Unable to connect to ZAP's proxy after " + timeoutInSeconds + " seconds."); + } + + /** + * A simple HTTP request. + * + *

Contains the request URI and headers. + */ + private static class HttpRequest { + + private static final String GET_METHOD = "GET"; + + private final String method; + private final URL requestUri; + private final Map headers; + private final String body; + + public HttpRequest(String method, URL url, String body) { + this.method = method; + this.requestUri = url; + this.headers = new HashMap<>(); + this.body = body; + } + + public String getMethod() { + return method; + } + + /** + * Gets the request URI of the request. + * + * @return the request URI. + */ + public URL getRequestUri() { + return requestUri; + } + + /** + * Adds a header with the given name and value. + * + *

If a header with the given name already exists it is replaced with the new value. + * + * @param name the name of the header. + * @param value the value of the header. + */ + public void addHeader(String name, String value) { + headers.put(name, value); + } + + /** + * Gets the headers of the HTTP request. An unmodifiable {@code Map} containing the headers + * (the keys correspond to the header names and the values for its contents). + * + * @return an unmodifiable {@code Map} containing the headers. + */ + public Map getHeaders() { + return Collections.unmodifiableMap(headers); + } + + public String getBody() { + return body; + } + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApiException.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApiException.java index acf0ce8..ab49c27 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApiException.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApiException.java @@ -3,13 +3,13 @@ * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2012 The Zed Attack Proxy Team + * Copyright 2012 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -19,44 +19,42 @@ */ package org.zaproxy.clientapi.core; - public class ClientApiException extends Exception { - private static final long serialVersionUID = 1L; - - private final String code; - private final String detail; - - public ClientApiException(Exception e) { - super(e); - this.code = null; - this.detail = null; - } - - public ClientApiException(String s) { - super(s); - this.code = null; - this.detail = null; - } - - public ClientApiException(String message, Exception cause) { - super(message, cause); - this.code = null; - this.detail = null; - } - - public ClientApiException(String message, String code, String detail) { - super(message); - this.code = code; - this.detail = detail; - } - - public String getCode() { - return code; - } - - public String getDetail() { - return detail; - } - + private static final long serialVersionUID = 1L; + + private final String code; + private final String detail; + + public ClientApiException(Exception e) { + super(e); + this.code = null; + this.detail = null; + } + + public ClientApiException(String s) { + super(s); + this.code = null; + this.detail = null; + } + + public ClientApiException(String message, Exception cause) { + super(message, cause); + this.code = null; + this.detail = null; + } + + public ClientApiException(String message, String code, String detail) { + super(message); + this.code = code; + this.detail = detail; + } + + public String getCode() { + return code; + } + + public String getDetail() { + return detail; + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApiMain.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApiMain.java index 37c2894..7de0717 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApiMain.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApiMain.java @@ -1,330 +1,361 @@ -/* - * Zed Attack Proxy (ZAP) and its related class files. - * - * ZAP is an HTTP/HTTPS proxy for assessing web application security. - * - * Copyright 2012 The Zed Attack Proxy Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.zaproxy.clientapi.core; - -import java.io.File; -import java.net.ConnectException; -import java.util.HashMap; -import java.util.List; - -public class ClientApiMain { - - private HashMap params = new HashMap<>(); - private String zapaddr = "localhost"; - private int zapport = 8090; - private Task task; - private ClientApi api; - private boolean debug = false; - - private enum Task{ - stop, showAlerts, checkAlerts, saveSession, newSession, activeScanUrl, activeScanSiteInScope, - addExcludeRegexToContext, addIncludeRegexToContext, addIncludeOneMatchingNodeToContext - } - - public static void main(String[] args){ - new ClientApiMain(args); - } - - public ClientApiMain(String[] args){ - initialize(args); - try { - executeTask(); - }catch (Exception e){ - e.printStackTrace(); - showHelp(); - } - } - - private void executeTask() throws Exception { - try { - switch(task){ - case stop: - api.core.shutdown((String)params.get("apikey")); - break; - case checkAlerts: - if (params.get("alertsFile") == null){ - System.out.println("No Alerts File Path Supplied\n"); - showHelp(); - System.exit(1); - } - File alertsFile = (File)params.get("alertsFile"); - if (!alertsFile.exists()){ - System.out.println("File not Found: "+alertsFile.getAbsolutePath()); - showHelp(); - System.exit(1); - } - if (params.get("outputFile") == null){ - api.checkAlerts( - AlertsFile.getAlertsFromFile(alertsFile, "ignoreAlert"), - AlertsFile.getAlertsFromFile(alertsFile, "requireAlert")); - }else{ - File outFile = (File)params.get("outputFile"); - try { - api.checkAlerts( - AlertsFile.getAlertsFromFile(alertsFile, "ignoreAlert"), - AlertsFile.getAlertsFromFile(alertsFile, "requireAlert"), - outFile); - } catch (AssertionError e){ - System.out.println(e.getMessage()); - System.exit(1); - } - } - break; - case showAlerts: - List alerts = api.getAlerts(null, -1, -1); - for (Alert alert : alerts) { - System.out.println(alert.toString()); - } - break; - case saveSession: - if (params.get("sessionName") == null){ - System.out.println("No session name supplied\n"); - showHelp(); - System.exit(1); - } - api.core.saveSession((String)params.get("apikey"), (String)params.get("sessionName"), "true"); - break; - case newSession: - if (params.get("sessionName") == null){ - api.core.newSession((String)params.get("apikey"), "", "true"); - }else{ - api.core.newSession((String)params.get("apikey"), (String)params.get("sessionName"), "true"); - } - break; - case activeScanUrl: - if (params.get("url") == null){ - System.out.println("No url supplied\n"); - showHelp(); - System.exit(1); - }else{ - api.ascan.scan((String)params.get("apikey"), (String)params.get("url"), "true", "false", "", "", ""); - } - break; - case activeScanSiteInScope: - checkForUrlParam(); - api.activeScanSiteInScope((String)params.get("apikey"), (String)params.get("url")); - break; - case addExcludeRegexToContext: - checkForContextNameParam(); - checkForRegexParam(); - api.addExcludeFromContext((String)params.get("apikey"), (String)params.get("contextName"), (String)params.get("regex")); - break; - case addIncludeRegexToContext: - checkForContextNameParam(); - checkForRegexParam(); - api.addIncludeInContext((String)params.get("apikey"), (String)params.get("contextName"), (String)params.get("regex")); - break; - case addIncludeOneMatchingNodeToContext: - checkForContextNameParam(); - checkForRegexParam(); - api.includeOneMatchingNodeInContext((String)params.get("apikey"), (String)params.get("contextName"), (String)params.get("regex")); - break; - } - } catch (ConnectException e){ - System.out.println(e.getMessage()+String.format(": zapaddr=%s, zapport=%d\n", zapaddr, zapport)); - showHelp(); - System.exit(1); - } - } - - private void checkForRegexParam() { - if(params.get("regex") == null){ - System.out.println("No regex supplied\n"); - showHelp(); - System.exit(1); - } - } - - private void checkForContextNameParam() { - if (params.get("contextName") == null){ - System.out.println("No context name supplied\n"); - showHelp(); - System.exit(1); - } - } - - private void checkForUrlParam() { - if (params.get("url") == null){ - System.out.println("No url supplied\n"); - showHelp(); - System.exit(1); - } - } - - private void initialize(String[] args) { - if (args.length > 0){ - if (args[0].equalsIgnoreCase("help")){ - try { - setTask(args[1]); - }catch (IndexOutOfBoundsException e){ - showHelp(); - System.exit(1); - } - showHelp(); - System.exit(0); - } - setTask(args[0]); - for (String arg: args){ - String[] pair = arg.split("="); - if (pair.length == 2){ - if (pair[0].equalsIgnoreCase("zapaddr")){ - zapaddr = pair[1]; - } else if(pair[0].equalsIgnoreCase("zapport")){ - try { - zapport = Integer.parseInt(pair[1]); - } catch (NumberFormatException e){ - System.out.println("Invalid value to zapport, must be in integer: "+pair[1]); - showHelp(); - System.exit(1); - } - }else if(pair[0].equalsIgnoreCase("debug") && pair[1].equalsIgnoreCase("true")){ - debug = true; - }else if(pair[0].contains("File")){ - params.put(pair[0], new File(pair[1])); - } - else{ - params.put(pair[0], pair[1]); - } - } - } - } else { - showHelp(); - System.exit(1); - } - api = new ClientApi(zapaddr, zapport, debug); - } - - private void setTask(String arg) { - try { - task = Task.valueOf(arg); - } catch (IllegalArgumentException e){ - System.out.println("Unknown Task: "+arg); - showHelp(); - System.exit(1); - } - } - - private void showHelp() { - String help = ""; - if (task == null){ - help = "usage: java -jar zap-api.jar [args]\n\n"+ - "Type 'java -jar zap-api.jar help ' for help on a specific subcommand.\n\n" + - "Available subcommands:\n"+ - "\tstop\n"+ - "\tcheckAlerts\n"+ - "\tshowAlerts\n"+ - "\tsaveSession\n"+ - "\tnewSession\n"; - } else{ - // TODO add case for activeScanSiteInScope - switch (task){ - case stop: - help = "usage: stop [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples:\n\t" + - "1. Type 'java -jar zap-api.jar stop' \n\t\t" + - "Stop zap listening on default settings (localhost:8090)\n\t" + - "2. Type 'java -jar zap-api.jar stop zapaddr=192.168.1.1 apikey=1234' \n\t\t" + - "Stop zap listening on 192.168.1.1:8090\n\t" + - "3. Type 'java -jar zap-api.jar stop zapport=7080 apikey=1234' \n\t\t" + - "Stop zap listening on localhost:7080\n\t" + - "4. Type 'java -jar zap-api.jar stop zapaddr=192.168.1.1 zapport=7080 apikey=1234' \n\t\t" + - "Stop zap listening on 192.168.1.1:7080\n\n"; - break; - case checkAlerts: - help = "usage: checkAlerts alertsFile={PATH} [outputFile={PATH}] [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples\n\t" + - "1. Type 'java -jar zap-api.jar checkAlerts alertsFile=\"C:\\Users\\me\\My Documents\\alerts.xml\"' \n\t\t" + - "Check alerts ignoring alerts from alertsFile, looking for required alerts from alertsFile, using zap listening on localhost:8090\n\t" + - "2. Type 'java -jar zap-api.jar checkAlerts alertsFile=\"C:\\Users\\me\\My Documents\\alerts.xml\" outputFile=\"C:\\Users\\me\\My Documents\\report.xml\"' \n\t\t" + - "Check alerts ignoring alerts from alertsFile, looking for required alerts from alertsFile. Outputting results to report.xml, using zap listening on localhost:8090\n\t" + - "3. Type 'java -jar zap-api.jar checkAlerts alertsFile=\"C:\\Users\\me\\My Documents\\alerts.xml\" outputFile=\"C:\\Users\\me\\My Documents\\report.xml\"' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "Check alerts ignoring alerts from alertsFile, looking for required alerts from alertsFile. Outputting results to report.xml, using zap listening on 192.168.1.1:7080\n" + - "Note: for paths containing spaces ensure path is enclosed in quotes\n\n"; - break; - case showAlerts: - help = "usage: showAlerts [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples:\n\t" + - "1. Type 'java -jar zap-api.jar showAlerts' \n\t\t" + - "Show alerts, using zap listening on default settings (localhost:8090)\n\t" + - "2. Type 'java -jar zap-api.jar showAlerts zapaddr=192.168.1.1' \n\t\t" + - "Show alerts, using zap listening on 192.168.1.1:8090\n\t" + - "3. Type 'java -jar zap-api.jar showAlerts zapport=7080' \n\t\t" + - "Show alerts, using zap listening on localhost:7080\n\t" + - "4. Type 'java -jar zap-api.jar showAlerts zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "Show alerts, using zap listening on 192.168.1.1:7080\n\n"; - break; - case saveSession: - help = "usage: saveSession sessionName={PATH} [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples:\n\t" + - "1. Type 'java -jar zap-api.jar saveSession sessionName=\"Users/me/My Documents/mysession/mysessionfile\"' \n\t\t" + - "Save zap session using zap listening on localhost:8090\n\t" + - "2. Type 'java -jar zap-api.jar saveSession sessionName=\"Users/me/My Documents/mysession/mysessionfile\" zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "Save zap session using zap listening on 192.168.1.1:7080\nNote: for paths containing spaces ensure path is enclosed in quotes\n\n"; - break; - case newSession: - help = "usage: newSession [sessionName={PATH}] [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples:\n\t" + - "1. Type 'java -jar zap-api.jar newSession' \n\t\t" + - "Start new session using zap listening on localhost:8090\n\t" + - "2. Type 'java -jar zap-api.jar newSession zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "Start new session using zap listening on 192.168.1.1:7080\n\t" + - "3. Type 'java -jar zap-api.jar newSession sessionName=\"Users/me/My Documents/mysession/newsession\"' \n\t\t" + - "Start new session using zap listening on localhost:8090, creating session files at /Users/me/My Documents/mysession/newsession\n\t" + - "4. Type 'java -jar zap-api.jar newSession sessionName=\"Users/me/My Documents/mysession/mysessionfile\" zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "Start new session using zap listening on 192.168.1.1:7080, creating session files at /Users/me/My Documents/mysession/newsession\n" + - "Note: for paths containing spaces ensure path is enclosed in quotes"; - break; - case activeScanUrl: - help = "usage: activeScanUrl url={url} [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples:\n\t" + - "1. Type 'java -jar zap-api.jar activeScanUrl url=http://myurl.com/' \n\t\t" + - "Execute and active scan on http://myurl.com/ using zap listening on localhost:8090\n\t" + - "2. Type 'java -jar zap-api.jar activeScanUrl url=http://myurl.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "Execute and active scan on http://myurl.com/ using zap listening on 192.168.1.1:7080\n\t"; - break; - case addExcludeRegexToContext: - help = "usage: addExcludeRegexToContext contextName={contextName} regex={regex} [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples:\n\t" + - "1. Type 'java -jar zap-api.jar addExcludeRegexToContext contextName=1 regex=\\Qhttp://example.com/area\\E.* \n\t\t" + - "Urls that match the regex will be excluded from scope using context '1' using zap listening on localhost:8090\n\t" + - "2. Type 'java -jar zap-api.jar addExcludeRegexToContext url=http://myurl.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "Urls that match the regex will be excluded from scope using context '1' using zap listening on 192.168.1.1:7080\n\t"; - break; - case addIncludeRegexToContext: - help = "usage: addIncludeRegexToContext contextName={contextName} regex={regex} [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples:\n\t" + - "1. Type 'java -jar zap-api.jar addIncludeRegexToContext contextName=1 regex=\\Qhttp://example.com/area\\E.* \n\t\t" + - "Urls that match the regex will be included in scope using context '1' using zap listening on localhost:8090\n\t" + - "2. Type 'java -jar zap-api.jar addIncludeRegexToContext url=http://myurl.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "Urls that match the regex will be included in scope using context '1' using zap listening on 192.168.1.1:7080\n\t"; - break; - case addIncludeOneMatchingNodeToContext: - help = "usage: addIncludeOneMatchingNodeToContext contextName={contextName} regex={regex} [zapaddr={ip}] [zapport={port}]\n\n" + - "Examples:\n\t" + - "1. Type 'java -jar zap-api.jar addIncludeOneMatchingNodeToContext contextName=1 regex=\\Qhttp://example.com/area\\E.* \n\t\t" + - "The first url from the current session that matches the regex will be included in scope using context '1'. Any other matching url will be excluded from scope using zap listening on localhost:8090\n\t" + - "2. Type 'java -jar zap-api.jar addIncludeOneMatchingNodeToContext url=http://myurl.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + - "The first url from the current session that matches the regex will be included in scope using context '1'. Any other matching url will be excluded from scope using context '1' using zap listening on 192.168.1.1:7080\n\t"; - break; - } - } - System.out.println(help); - } -} +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2012 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.core; + +import java.io.File; +import java.net.ConnectException; +import java.util.HashMap; +import java.util.List; + +public class ClientApiMain { + + private HashMap params = new HashMap<>(); + private String zapaddr = "localhost"; + private int zapport = 8090; + private Task task; + private ClientApi api; + private boolean debug = false; + + private enum Task { + stop, + showAlerts, + checkAlerts, + saveSession, + newSession, + activeScanUrl, + activeScanSiteInScope, + addExcludeRegexToContext, + addIncludeRegexToContext, + addIncludeOneMatchingNodeToContext + } + + public static void main(String[] args) { + new ClientApiMain(args); + } + + public ClientApiMain(String[] args) { + initialize(args); + try { + executeTask(); + } catch (Exception e) { + e.printStackTrace(); + showHelp(); + } + } + + private void executeTask() throws Exception { + try { + switch (task) { + case stop: + api.core.shutdown(); + break; + case checkAlerts: + if (params.get("alertsFile") == null) { + System.out.println("No Alerts File Path Supplied\n"); + showHelp(); + System.exit(1); + } + File alertsFile = (File) params.get("alertsFile"); + if (!alertsFile.exists()) { + System.out.println("File not Found: " + alertsFile.getAbsolutePath()); + showHelp(); + System.exit(1); + } + if (params.get("outputFile") == null) { + api.checkAlerts( + AlertsFile.getAlertsFromFile(alertsFile, "ignoreAlert"), + AlertsFile.getAlertsFromFile(alertsFile, "requireAlert")); + } else { + File outFile = (File) params.get("outputFile"); + try { + api.checkAlerts( + AlertsFile.getAlertsFromFile(alertsFile, "ignoreAlert"), + AlertsFile.getAlertsFromFile(alertsFile, "requireAlert"), + outFile); + } catch (AssertionError e) { + System.out.println(e.getMessage()); + System.exit(1); + } + } + break; + case showAlerts: + List alerts = api.getAlerts(null, -1, -1); + for (Alert alert : alerts) { + System.out.println(alert.toString()); + } + break; + case saveSession: + if (params.get("sessionName") == null) { + System.out.println("No session name supplied\n"); + showHelp(); + System.exit(1); + } + api.core.saveSession((String) params.get("sessionName"), "true"); + break; + case newSession: + if (params.get("sessionName") == null) { + api.core.newSession("", "true"); + } else { + api.core.newSession((String) params.get("sessionName"), "true"); + } + break; + case activeScanUrl: + if (params.get("url") == null) { + System.out.println("No url supplied\n"); + showHelp(); + System.exit(1); + } else { + api.ascan.scan((String) params.get("url"), "true", "false", "", "", ""); + } + break; + case activeScanSiteInScope: + checkForUrlParam(); + api.activeScanSiteInScope((String) params.get("url")); + break; + case addExcludeRegexToContext: + checkForContextNameParam(); + checkForRegexParam(); + api.context.excludeFromContext( + (String) params.get("contextName"), (String) params.get("regex")); + break; + case addIncludeRegexToContext: + checkForContextNameParam(); + checkForRegexParam(); + api.context.includeInContext( + (String) params.get("contextName"), (String) params.get("regex")); + break; + case addIncludeOneMatchingNodeToContext: + checkForContextNameParam(); + checkForRegexParam(); + api.includeOneMatchingNodeInContext( + (String) params.get("contextName"), (String) params.get("regex")); + break; + } + } catch (ConnectException e) { + System.out.println( + e.getMessage() + String.format(": zapaddr=%s, zapport=%d\n", zapaddr, zapport)); + showHelp(); + System.exit(1); + } + } + + private void checkForRegexParam() { + if (params.get("regex") == null) { + System.out.println("No regex supplied\n"); + showHelp(); + System.exit(1); + } + } + + private void checkForContextNameParam() { + if (params.get("contextName") == null) { + System.out.println("No context name supplied\n"); + showHelp(); + System.exit(1); + } + } + + private void checkForUrlParam() { + if (params.get("url") == null) { + System.out.println("No url supplied\n"); + showHelp(); + System.exit(1); + } + } + + private void initialize(String[] args) { + if (args.length > 0) { + if (args[0].equalsIgnoreCase("help")) { + try { + setTask(args[1]); + } catch (IndexOutOfBoundsException e) { + showHelp(); + System.exit(1); + } + showHelp(); + System.exit(0); + } + setTask(args[0]); + for (String arg : args) { + String[] pair = arg.split("=", 2); + if (pair.length == 2) { + if (pair[0].equalsIgnoreCase("zapaddr")) { + zapaddr = pair[1]; + } else if (pair[0].equalsIgnoreCase("zapport")) { + try { + zapport = Integer.parseInt(pair[1]); + } catch (NumberFormatException e) { + System.out.println( + "Invalid value to zapport, must be in integer: " + pair[1]); + showHelp(); + System.exit(1); + } + } else if (pair[0].equalsIgnoreCase("debug") + && pair[1].equalsIgnoreCase("true")) { + debug = true; + } else if (pair[0].contains("File")) { + params.put(pair[0], new File(pair[1])); + } else { + params.put(pair[0], pair[1]); + } + } + } + } else { + showHelp(); + System.exit(1); + } + api = new ClientApi(zapaddr, zapport, (String) params.get("apikey"), debug); + } + + private void setTask(String arg) { + try { + task = Task.valueOf(arg); + } catch (IllegalArgumentException e) { + System.out.println("Unknown Task: " + arg); + showHelp(); + System.exit(1); + } + } + + private void showHelp() { + String help = ""; + if (task == null) { + help = + "usage: java -jar zap-api.jar [args]\n\n" + + "Type 'java -jar zap-api.jar help ' for help on a specific subcommand.\n\n" + + "Available subcommands:\n" + + "\tstop\n" + + "\tcheckAlerts\n" + + "\tshowAlerts\n" + + "\tsaveSession\n" + + "\tnewSession\n"; + } else { + switch (task) { + case stop: + help = + "usage: stop [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar stop' \n\t\t" + + "Stop zap listening on default settings (localhost:8090)\n\t" + + "2. Type 'java -jar zap-api.jar stop zapaddr=192.168.1.1 apikey=1234' \n\t\t" + + "Stop zap listening on 192.168.1.1:8090\n\t" + + "3. Type 'java -jar zap-api.jar stop zapport=7080 apikey=1234' \n\t\t" + + "Stop zap listening on localhost:7080\n\t" + + "4. Type 'java -jar zap-api.jar stop zapaddr=192.168.1.1 zapport=7080 apikey=1234' \n\t\t" + + "Stop zap listening on 192.168.1.1:7080\n\n"; + break; + case checkAlerts: + help = + "usage: checkAlerts alertsFile={PATH} [outputFile={PATH}] [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples\n\t" + + "1. Type 'java -jar zap-api.jar checkAlerts alertsFile=\"C:\\Users\\me\\My Documents\\alerts.xml\"' \n\t\t" + + "Check alerts ignoring alerts from alertsFile, looking for required alerts from alertsFile, using zap listening on localhost:8090\n\t" + + "2. Type 'java -jar zap-api.jar checkAlerts alertsFile=\"C:\\Users\\me\\My Documents\\alerts.xml\" outputFile=\"C:\\Users\\me\\My Documents\\report.xml\"' \n\t\t" + + "Check alerts ignoring alerts from alertsFile, looking for required alerts from alertsFile. Outputting results to report.xml, using zap listening on localhost:8090\n\t" + + "3. Type 'java -jar zap-api.jar checkAlerts alertsFile=\"C:\\Users\\me\\My Documents\\alerts.xml\" outputFile=\"C:\\Users\\me\\My Documents\\report.xml\"' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Check alerts ignoring alerts from alertsFile, looking for required alerts from alertsFile. Outputting results to report.xml, using zap listening on 192.168.1.1:7080\n" + + "Note: for paths containing spaces ensure path is enclosed in quotes\n\n"; + break; + case showAlerts: + help = + "usage: showAlerts [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar showAlerts' \n\t\t" + + "Show alerts, using zap listening on default settings (localhost:8090)\n\t" + + "2. Type 'java -jar zap-api.jar showAlerts zapaddr=192.168.1.1' \n\t\t" + + "Show alerts, using zap listening on 192.168.1.1:8090\n\t" + + "3. Type 'java -jar zap-api.jar showAlerts zapport=7080' \n\t\t" + + "Show alerts, using zap listening on localhost:7080\n\t" + + "4. Type 'java -jar zap-api.jar showAlerts zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Show alerts, using zap listening on 192.168.1.1:7080\n\n"; + break; + case saveSession: + help = + "usage: saveSession sessionName={PATH} [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar saveSession sessionName=\"Users/me/My Documents/mysession/mysessionfile\"' \n\t\t" + + "Save zap session using zap listening on localhost:8090\n\t" + + "2. Type 'java -jar zap-api.jar saveSession sessionName=\"Users/me/My Documents/mysession/mysessionfile\" zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Save zap session using zap listening on 192.168.1.1:7080\nNote: for paths containing spaces ensure path is enclosed in quotes\n\n"; + break; + case newSession: + help = + "usage: newSession [sessionName={PATH}] [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar newSession' \n\t\t" + + "Start new session using zap listening on localhost:8090\n\t" + + "2. Type 'java -jar zap-api.jar newSession zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Start new session using zap listening on 192.168.1.1:7080\n\t" + + "3. Type 'java -jar zap-api.jar newSession sessionName=\"Users/me/My Documents/mysession/newsession\"' \n\t\t" + + "Start new session using zap listening on localhost:8090, creating session files at /Users/me/My Documents/mysession/newsession\n\t" + + "4. Type 'java -jar zap-api.jar newSession sessionName=\"Users/me/My Documents/mysession/mysessionfile\" zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Start new session using zap listening on 192.168.1.1:7080, creating session files at /Users/me/My Documents/mysession/newsession\n" + + "Note: for paths containing spaces ensure path is enclosed in quotes"; + break; + case activeScanUrl: + help = + "usage: activeScanUrl url={url} [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar activeScanUrl url=http://myurl.com/' \n\t\t" + + "Execute an active scan on http://myurl.com/ using zap listening on localhost:8090\n\t" + + "2. Type 'java -jar zap-api.jar activeScanUrl url=http://myurl.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Execute an active scan on http://myurl.com/ using zap listening on 192.168.1.1:7080\n\t"; + break; + case activeScanSiteInScope: + help = + "usage: activeScanSiteInScope url={url} [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar activeScanSiteInScope url=http://example.com/' \n\t\t" + + "Execute an active scan for URLs in scope under http://example.com/ using zap listening on localhost:8090\n\t" + + "2. Type 'java -jar zap-api.jar activeScanSiteInScope url=http://example.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Execute an active scan for URLs in scope under http://example.com/ using zap listening on 192.168.1.1:7080\n\t"; + break; + case addExcludeRegexToContext: + help = + "usage: addExcludeRegexToContext contextName={contextName} regex={regex} [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar addExcludeRegexToContext contextName=1 regex=\\Qhttp://example.com/area\\E.* \n\t\t" + + "Urls that match the regex will be excluded from scope using context '1' using zap listening on localhost:8090\n\t" + + "2. Type 'java -jar zap-api.jar addExcludeRegexToContext url=http://myurl.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Urls that match the regex will be excluded from scope using context '1' using zap listening on 192.168.1.1:7080\n\t"; + break; + case addIncludeRegexToContext: + help = + "usage: addIncludeRegexToContext contextName={contextName} regex={regex} [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar addIncludeRegexToContext contextName=1 regex=\\Qhttp://example.com/area\\E.* \n\t\t" + + "Urls that match the regex will be included in scope using context '1' using zap listening on localhost:8090\n\t" + + "2. Type 'java -jar zap-api.jar addIncludeRegexToContext url=http://myurl.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "Urls that match the regex will be included in scope using context '1' using zap listening on 192.168.1.1:7080\n\t"; + break; + case addIncludeOneMatchingNodeToContext: + help = + "usage: addIncludeOneMatchingNodeToContext contextName={contextName} regex={regex} [zapaddr={ip}] [zapport={port}]\n\n" + + "Examples:\n\t" + + "1. Type 'java -jar zap-api.jar addIncludeOneMatchingNodeToContext contextName=1 regex=\\Qhttp://example.com/area\\E.* \n\t\t" + + "The first url from the current session that matches the regex will be included in scope using context '1'. Any other matching url will be excluded from scope using zap listening on localhost:8090\n\t" + + "2. Type 'java -jar zap-api.jar addIncludeOneMatchingNodeToContext url=http://myurl.com/' zapaddr=192.168.1.1 zapport=7080' \n\t\t" + + "The first url from the current session that matches the regex will be included in scope using context '1'. Any other matching url will be excluded from scope using context '1' using zap listening on 192.168.1.1:7080\n\t"; + break; + } + } + System.out.println(help); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AccessControl.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AccessControl.java new file mode 100644 index 0000000..5ddd26e --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AccessControl.java @@ -0,0 +1,103 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2020 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class AccessControl { + + private final ClientApi api; + + public AccessControl(ClientApi api) { + this.api = api; + } + + /** + * Gets the Access Control scan progress (percentage integer) for the given context ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getScanProgress(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("accessControl", "view", "getScanProgress", map); + } + + /** + * Gets the Access Control scan status (description string) for the given context ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getScanStatus(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("accessControl", "view", "getScanStatus", map); + } + + /** + * Starts an Access Control scan with the given context ID and user ID. (Optional parameters: + * user ID for Unauthenticated user, boolean identifying whether or not Alerts are raised, and + * the Risk level for the Alerts.) [This assumes the Access Control rules were previously + * established via ZAP gui and the necessary Context exported/imported.] + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scan( + String contextid, + String userid, + String scanasunauthuser, + String raisealert, + String alertrisklevel) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + if (scanasunauthuser != null) { + map.put("scanAsUnAuthUser", scanasunauthuser); + } + if (raisealert != null) { + map.put("raiseAlert", raisealert); + } + if (alertrisklevel != null) { + map.put("alertRiskLevel", alertrisklevel); + } + return api.callApi("accessControl", "action", "scan", map); + } + + /** + * Generates an Access Control report for the given context ID and saves it based on the + * provided filename (path). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse writeHTMLreport(String contextid, String filename) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("fileName", filename); + return api.callApi("accessControl", "action", "writeHTMLreport", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Acsrf.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Acsrf.java index 07412c7..68a9b14 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Acsrf.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Acsrf.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,63 +25,60 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Acsrf extends org.zaproxy.clientapi.gen.deprecated.AcsrfDeprecated { -/** - * This file was automatically generated. - */ -public class Acsrf { + private final ClientApi api; + + public Acsrf(ClientApi api) { + super(api); + this.api = api; + } - private ClientApi api = null; + /** Lists the names of all anti-CSRF tokens */ + public ApiResponse optionTokensNames() throws ClientApiException { + return api.callApi("acsrf", "view", "optionTokensNames", null); + } - public Acsrf(ClientApi api) { - this.api = api; - } + /** Define if ZAP should detect CSRF tokens by searching for partial matches */ + public ApiResponse optionPartialMatchingEnabled() throws ClientApiException { + return api.callApi("acsrf", "view", "optionPartialMatchingEnabled", null); + } - /** - * Lists the names of all anti CSRF tokens - */ - public ApiResponse optionTokensNames() throws ClientApiException { - Map map = null; - return api.callApi("acsrf", "view", "optionTokensNames", map); - } + /** Adds an anti-CSRF token with the given name, enabled by default */ + public ApiResponse addOptionToken(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("acsrf", "action", "addOptionToken", map); + } - /** - * Adds an anti CSRF token with the given name, enabled by default - */ - public ApiResponse addOptionToken(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("acsrf", "action", "addOptionToken", map); - } + /** Removes the anti-CSRF token with the given name */ + public ApiResponse removeOptionToken(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("acsrf", "action", "removeOptionToken", map); + } - /** - * Removes the anti CSRF token with the given name - */ - public ApiResponse removeOptionToken(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("acsrf", "action", "removeOptionToken", map); - } + /** Define if ZAP should detect CSRF tokens by searching for partial matches. */ + public ApiResponse setOptionPartialMatchingEnabled(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("acsrf", "action", "setOptionPartialMatchingEnabled", map); + } - /** - * Generate a form for testing lack of anti CSRF tokens - typically invoked via ZAP - */ - public byte[] genForm(String apikey, String hrefid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("hrefId", hrefid); - return api.callApiOther("acsrf", "other", "genForm", map); - } + /** Generate a form for testing lack of anti-CSRF tokens - typically invoked via ZAP */ + public byte[] genForm(String hrefid) throws ClientApiException { + return genFormActionUrl(hrefid, null); + } + /** Generate a form for testing lack of anti-CSRF tokens - typically invoked via ZAP */ + public byte[] genFormActionUrl(String hrefid, String actionurl) throws ClientApiException { + Map map = new HashMap<>(); + map.put("hrefId", hrefid); + if (actionurl != null) { + map.put("actionUrl", actionurl); + } + return api.callApiOther("acsrf", "other", "genForm", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AjaxSpider.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AjaxSpider.java index 4455b80..3b09886 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AjaxSpider.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AjaxSpider.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2016 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,298 +25,479 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class AjaxSpider { - - private final ClientApi api; - - public AjaxSpider(ClientApi api) { - this.api = api; - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse status() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "status", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse results(String start, String count) throws ClientApiException { - Map map = new HashMap<>(); - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("ajaxSpider", "view", "results", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse numberOfResults() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "numberOfResults", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionBrowserId() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionBrowserId", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionEventWait() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionEventWait", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionMaxCrawlDepth() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionMaxCrawlDepth", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionMaxCrawlStates() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionMaxCrawlStates", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionMaxDuration() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionMaxDuration", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionNumberOfBrowsers() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionNumberOfBrowsers", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionReloadWait() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionReloadWait", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionClickDefaultElems() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionClickDefaultElems", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionClickElemsOnce() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionClickElemsOnce", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionRandomInputs() throws ClientApiException { - return api.callApi("ajaxSpider", "view", "optionRandomInputs", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed. - */ - public ApiResponse scan(String apikey, String url, String inscope) throws ClientApiException { - return scan(apikey, url, inscope, null, null); - } - - /** - * 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'). - *

- * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse scan(String apikey, String url, String inscope, String contextname, String subtreeonly) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (url != null) { - map.put("url", url); - } - if (inscope != null) { - map.put("inScope", inscope); - } - if (contextname != null) { - map.put("contextName", contextname); - } - if (subtreeonly != null) { - map.put("subtreeOnly", subtreeonly); - } - return api.callApi("ajaxSpider", "action", "scan", map); - } - - /** - * 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'). - *

- * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse scanAsUser(String apikey, String contextname, String username, String url, String subtreeonly) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - map.put("userName", username); - if (url != null) { - map.put("url", url); - } - if (subtreeonly != null) { - map.put("subtreeOnly", subtreeonly); - } - return api.callApi("ajaxSpider", "action", "scanAsUser", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse stop(String apikey) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("ajaxSpider", "action", "stop", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionBrowserId(String apikey, String string) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("ajaxSpider", "action", "setOptionBrowserId", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionClickDefaultElems(String apikey, boolean bool) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ajaxSpider", "action", "setOptionClickDefaultElems", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionClickElemsOnce(String apikey, boolean bool) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ajaxSpider", "action", "setOptionClickElemsOnce", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionEventWait(String apikey, int i) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ajaxSpider", "action", "setOptionEventWait", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionMaxCrawlDepth(String apikey, int i) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ajaxSpider", "action", "setOptionMaxCrawlDepth", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionMaxCrawlStates(String apikey, int i) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ajaxSpider", "action", "setOptionMaxCrawlStates", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionMaxDuration(String apikey, int i) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ajaxSpider", "action", "setOptionMaxDuration", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionNumberOfBrowsers(String apikey, int i) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ajaxSpider", "action", "setOptionNumberOfBrowsers", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionRandomInputs(String apikey, boolean bool) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ajaxSpider", "action", "setOptionRandomInputs", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionReloadWait(String apikey, int i) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ajaxSpider", "action", "setOptionReloadWait", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class AjaxSpider extends org.zaproxy.clientapi.gen.deprecated.AjaxSpiderDeprecated { + + private final ClientApi api; + + public AjaxSpider(ClientApi api) { + super(api); + this.api = api; + } + + /** + * Gets the allowed resources. The allowed resources are always fetched even if out of scope, + * allowing to include necessary resources (e.g. scripts) from 3rd-parties. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse allowedResources() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "allowedResources", null); + } + + /** + * Gets the excluded elements. The excluded elements are not clicked during crawling, for + * example, to prevent logging out. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse excludedElements(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("ajaxSpider", "view", "excludedElements", map); + } + + /** + * Gets the current status of the crawler. Actual values are Stopped and Running. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse status() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "status", null); + } + + /** + * Gets the current results of the crawler. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse results(String start, String count) throws ClientApiException { + Map map = new HashMap<>(); + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("ajaxSpider", "view", "results", map); + } + + /** + * Gets the number of resources found. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse numberOfResults() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "numberOfResults", null); + } + + /** + * Gets the full crawled content detected by the AJAX Spider. Returns a set of values based on + * 'inScope' URLs, 'outOfScope' URLs, and 'errors' encountered during the last/current run of + * the AJAX Spider. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse fullResults() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "fullResults", null); + } + + /** + * Gets the configured browser to use for crawling. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionBrowserId() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionBrowserId", null); + } + + /** + * Gets the time to wait after an event (in milliseconds). For example: the wait delay after the + * cursor hovers over an element, in order for a menu to display, etc. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionEventWait() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionEventWait", null); + } + + /** + * Gets the configured value for the max crawl depth. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxCrawlDepth() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionMaxCrawlDepth", null); + } + + /** + * Gets the configured value for the maximum crawl states allowed. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxCrawlStates() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionMaxCrawlStates", null); + } + + /** + * Gets the configured max duration of the crawl, the value is in minutes. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxDuration() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionMaxDuration", null); + } + + /** + * Gets the configured number of browsers to be used. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionNumberOfBrowsers() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionNumberOfBrowsers", null); + } + + /** + * Gets the configured time to wait after reloading the page, this value is in milliseconds. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionReloadWait() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionReloadWait", null); + } + + /** + * Gets the configured value for 'Click Default Elements Only', HTML elements such as 'a', + * 'button', 'input', all associated with some action or links on the page. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionClickDefaultElems() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionClickDefaultElems", null); + } + + /** + * Gets the value configured for the AJAX Spider to know if it should click on the elements only + * once. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionClickElemsOnce() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionClickElemsOnce", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionEnableExtensions() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionEnableExtensions", null); + } + + /** + * Gets if the AJAX Spider will use random values in form fields when crawling, if set to true. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionRandomInputs() throws ClientApiException { + return api.callApi("ajaxSpider", "view", "optionRandomInputs", null); + } + + /** + * Runs the AJAX Spider against a given target. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scan(String url, String inscope, String contextname, String subtreeonly) + throws ClientApiException { + Map map = new HashMap<>(); + if (url != null) { + map.put("url", url); + } + if (inscope != null) { + map.put("inScope", inscope); + } + if (contextname != null) { + map.put("contextName", contextname); + } + if (subtreeonly != null) { + map.put("subtreeOnly", subtreeonly); + } + return api.callApi("ajaxSpider", "action", "scan", map); + } + + /** + * Runs the AJAX Spider from the perspective of a User of the web application. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scanAsUser( + String contextname, String username, String url, String subtreeonly) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("userName", username); + if (url != null) { + map.put("url", url); + } + if (subtreeonly != null) { + map.put("subtreeOnly", subtreeonly); + } + return api.callApi("ajaxSpider", "action", "scanAsUser", map); + } + + /** + * Stops the AJAX Spider. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse stop() throws ClientApiException { + return api.callApi("ajaxSpider", "action", "stop", null); + } + + /** + * Adds an allowed resource. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addAllowedResource(String regex, String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (enabled != null) { + map.put("enabled", enabled); + } + return api.callApi("ajaxSpider", "action", "addAllowedResource", map); + } + + /** + * Adds an excluded element to a context. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addExcludedElement( + String contextname, + String description, + String element, + String xpath, + String text, + String attributename, + String attributevalue, + String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("description", description); + map.put("element", element); + if (xpath != null) { + map.put("xpath", xpath); + } + if (text != null) { + map.put("text", text); + } + if (attributename != null) { + map.put("attributeName", attributename); + } + if (attributevalue != null) { + map.put("attributeValue", attributevalue); + } + if (enabled != null) { + map.put("enabled", enabled); + } + return api.callApi("ajaxSpider", "action", "addExcludedElement", map); + } + + /** + * Modifies an excluded element of a context. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse modifyExcludedElement( + String contextname, + String description, + String element, + String descriptionnew, + String xpath, + String text, + String attributename, + String attributevalue, + String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("description", description); + map.put("element", element); + if (descriptionnew != null) { + map.put("descriptionNew", descriptionnew); + } + if (xpath != null) { + map.put("xpath", xpath); + } + if (text != null) { + map.put("text", text); + } + if (attributename != null) { + map.put("attributeName", attributename); + } + if (attributevalue != null) { + map.put("attributeValue", attributevalue); + } + if (enabled != null) { + map.put("enabled", enabled); + } + return api.callApi("ajaxSpider", "action", "modifyExcludedElement", map); + } + + /** + * Removes an excluded element from a context. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeExcludedElement(String contextname, String description) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("description", description); + return api.callApi("ajaxSpider", "action", "removeExcludedElement", map); + } + + /** + * Removes an allowed resource. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeAllowedResource(String regex) throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + return api.callApi("ajaxSpider", "action", "removeAllowedResource", map); + } + + /** + * Sets whether or not an allowed resource is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setEnabledAllowedResource(String regex, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + map.put("enabled", enabled); + return api.callApi("ajaxSpider", "action", "setEnabledAllowedResource", map); + } + + /** + * Sets the configuration of the AJAX Spider to use one of the supported browsers. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionBrowserId(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("ajaxSpider", "action", "setOptionBrowserId", map); + } + + /** + * Sets whether or not the AJAX Spider will only click on the default HTML elements. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionClickDefaultElems(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ajaxSpider", "action", "setOptionClickDefaultElems", map); + } + + /** + * When enabled, the crawler attempts to interact with each element (e.g., by clicking) only + * once. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionClickElemsOnce(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ajaxSpider", "action", "setOptionClickElemsOnce", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionEnableExtensions(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ajaxSpider", "action", "setOptionEnableExtensions", map); + } + + /** + * Sets the time to wait after an event (in milliseconds). For example: the wait delay after the + * cursor hovers over an element, in order for a menu to display, etc. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionEventWait(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionEventWait", map); + } + + /** + * Sets the maximum depth that the crawler can reach. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxCrawlDepth(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionMaxCrawlDepth", map); + } + + /** + * Sets the maximum number of states that the crawler should crawl. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxCrawlStates(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionMaxCrawlStates", map); + } + + /** + * The maximum time that the crawler is allowed to run. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxDuration(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionMaxDuration", map); + } + + /** + * Sets the number of windows to be used by AJAX Spider. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionNumberOfBrowsers(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionNumberOfBrowsers", map); + } + + /** + * When enabled, inserts random values into form fields. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionRandomInputs(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ajaxSpider", "action", "setOptionRandomInputs", map); + } + + /** + * Sets the time to wait after the page is loaded before interacting with it. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionReloadWait(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionReloadWait", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Alert.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Alert.java new file mode 100644 index 0000000..5bd6940 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Alert.java @@ -0,0 +1,298 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2019 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Alert { + + private final ClientApi api; + + public Alert(ClientApi api) { + this.api = api; + } + + /** + * Gets the alert with the given ID, the corresponding HTTP message can be obtained with the + * 'messageId' field and 'message' API method + */ + public ApiResponse alert(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("alert", "view", "alert", map); + } + + /** + * Gets the alerts raised by ZAP, optionally filtering by URL or riskId, and paginating with + * 'start' position and 'count' of alerts + */ + public ApiResponse alerts(String baseurl, String start, String count, String riskid) + throws ClientApiException { + return alerts(baseurl, start, count, riskid, null); + } + + /** + * Gets the alerts raised by ZAP, optionally filtering by URL or riskId, and paginating with + * 'start' position and 'count' of alerts + */ + public ApiResponse alerts( + String baseurl, String start, String count, String riskid, String contextname) + throws ClientApiException { + return alerts(baseurl, start, count, riskid, null, null); + } + + /** + * Gets the alerts raised by ZAP, optionally filtering by URL or riskId, and paginating with + * 'start' position and 'count' of alerts + */ + public ApiResponse alerts( + String baseurl, + String start, + String count, + String riskid, + String contextname, + String falsepositive) + throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + if (riskid != null) { + map.put("riskId", riskid); + } + if (contextname != null) { + map.put("contextName", contextname); + } + if (falsepositive != null) { + map.put("falsePositive", falsepositive); + } + return api.callApi("alert", "view", "alerts", map); + } + + /** Gets number of alerts grouped by each risk level, optionally filtering by URL */ + public ApiResponse alertsSummary(String baseurl) throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + return api.callApi("alert", "view", "alertsSummary", map); + } + + /** Gets the number of alerts, optionally filtering by URL or riskId */ + public ApiResponse numberOfAlerts(String baseurl, String riskid) throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (riskid != null) { + map.put("riskId", riskid); + } + return api.callApi("alert", "view", "numberOfAlerts", map); + } + + /** + * 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) + */ + public ApiResponse alertsByRisk(String url, String recurse) throws ClientApiException { + Map map = new HashMap<>(); + if (url != null) { + map.put("url", url); + } + if (recurse != null) { + map.put("recurse", recurse); + } + return api.callApi("alert", "view", "alertsByRisk", map); + } + + /** Gets a count of the alerts, optionally filtered as per alertsPerRisk */ + public ApiResponse alertCountsByRisk(String url, String recurse) throws ClientApiException { + Map map = new HashMap<>(); + if (url != null) { + map.put("url", url); + } + if (recurse != null) { + map.put("recurse", recurse); + } + return api.callApi("alert", "view", "alertCountsByRisk", map); + } + + /** Deletes all alerts of the current session. */ + public ApiResponse deleteAllAlerts() throws ClientApiException { + return api.callApi("alert", "action", "deleteAllAlerts", null); + } + + /** + * Deletes all the alerts optionally filtered by URL which fall within the Context with the + * provided name, risk, or base URL. + */ + public ApiResponse deleteAlerts(String contextname, String baseurl, String riskid) + throws ClientApiException { + Map map = new HashMap<>(); + if (contextname != null) { + map.put("contextName", contextname); + } + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (riskid != null) { + map.put("riskId", riskid); + } + return api.callApi("alert", "action", "deleteAlerts", map); + } + + /** Deletes the alert with the given ID. */ + public ApiResponse deleteAlert(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("alert", "action", "deleteAlert", map); + } + + /** Update the confidence of the alerts. */ + public ApiResponse updateAlertsConfidence(String ids, String confidenceid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + map.put("confidenceId", confidenceid); + return api.callApi("alert", "action", "updateAlertsConfidence", map); + } + + /** Update the risk of the alerts. */ + public ApiResponse updateAlertsRisk(String ids, String riskid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + map.put("riskId", riskid); + return api.callApi("alert", "action", "updateAlertsRisk", map); + } + + /** Update the alert with the given ID, with the provided details. */ + public ApiResponse updateAlert( + String id, + String name, + String riskid, + String confidenceid, + String description, + String param, + String attack, + String otherinfo, + String solution, + String references, + String evidence, + String cweid, + String wascid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + map.put("name", name); + map.put("riskId", riskid); + map.put("confidenceId", confidenceid); + map.put("description", description); + if (param != null) { + map.put("param", param); + } + if (attack != null) { + map.put("attack", attack); + } + if (otherinfo != null) { + map.put("otherInfo", otherinfo); + } + if (solution != null) { + map.put("solution", solution); + } + if (references != null) { + map.put("references", references); + } + if (evidence != null) { + map.put("evidence", evidence); + } + if (cweid != null) { + map.put("cweId", cweid); + } + if (wascid != null) { + map.put("wascId", wascid); + } + return api.callApi("alert", "action", "updateAlert", map); + } + + /** + * Add an alert associated with the given message ID, with the provided details. (The ID of the + * created alert is returned.) + */ + public ApiResponse addAlert( + String messageid, + String name, + String riskid, + String confidenceid, + String description, + String param, + String attack, + String otherinfo, + String solution, + String references, + String evidence, + String cweid, + String wascid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("messageId", messageid); + map.put("name", name); + map.put("riskId", riskid); + map.put("confidenceId", confidenceid); + map.put("description", description); + if (param != null) { + map.put("param", param); + } + if (attack != null) { + map.put("attack", attack); + } + if (otherinfo != null) { + map.put("otherInfo", otherinfo); + } + if (solution != null) { + map.put("solution", solution); + } + if (references != null) { + map.put("references", references); + } + if (evidence != null) { + map.put("evidence", evidence); + } + if (cweid != null) { + map.put("cweId", cweid); + } + if (wascid != null) { + map.put("wascId", wascid); + } + return api.callApi("alert", "action", "addAlert", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AlertFilter.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AlertFilter.java new file mode 100644 index 0000000..fd2e405 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/AlertFilter.java @@ -0,0 +1,339 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2016 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class AlertFilter extends org.zaproxy.clientapi.gen.deprecated.AlertFilterDeprecated { + + private final ClientApi api; + + public AlertFilter(ClientApi api) { + this.api = api; + } + + /** + * Lists the alert filters of the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse alertFilterList(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("alertFilter", "view", "alertFilterList", map); + } + + /** + * Lists the global alert filters. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse globalAlertFilterList() throws ClientApiException { + return api.callApi("alertFilter", "view", "globalAlertFilterList", null); + } + + /** + * Adds a new alert filter for the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + @Override + public ApiResponse addAlertFilter( + String contextid, + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex, + String methods) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("ruleId", ruleid); + map.put("newLevel", newlevel); + if (url != null) { + map.put("url", url); + } + if (urlisregex != null) { + map.put("urlIsRegex", urlisregex); + } + if (parameter != null) { + map.put("parameter", parameter); + } + if (enabled != null) { + map.put("enabled", enabled); + } + if (parameterisregex != null) { + map.put("parameterIsRegex", parameterisregex); + } + if (attack != null) { + map.put("attack", attack); + } + if (attackisregex != null) { + map.put("attackIsRegex", attackisregex); + } + if (evidence != null) { + map.put("evidence", evidence); + } + if (evidenceisregex != null) { + map.put("evidenceIsRegex", evidenceisregex); + } + if (methods != null) { + map.put("methods", methods); + } + return api.callApi("alertFilter", "action", "addAlertFilter", map); + } + + /** + * Removes an alert filter from the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + @Override + public ApiResponse removeAlertFilter( + String contextid, + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex, + String methods) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("ruleId", ruleid); + map.put("newLevel", newlevel); + if (url != null) { + map.put("url", url); + } + if (urlisregex != null) { + map.put("urlIsRegex", urlisregex); + } + if (parameter != null) { + map.put("parameter", parameter); + } + if (enabled != null) { + map.put("enabled", enabled); + } + if (parameterisregex != null) { + map.put("parameterIsRegex", parameterisregex); + } + if (attack != null) { + map.put("attack", attack); + } + if (attackisregex != null) { + map.put("attackIsRegex", attackisregex); + } + if (evidence != null) { + map.put("evidence", evidence); + } + if (evidenceisregex != null) { + map.put("evidenceIsRegex", evidenceisregex); + } + if (methods != null) { + map.put("methods", methods); + } + return api.callApi("alertFilter", "action", "removeAlertFilter", map); + } + + /** + * Adds a new global alert filter. + * + *

This component is optional and therefore the API will only work if it is installed + */ + @Override + public ApiResponse addGlobalAlertFilter( + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex, + String methods) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("ruleId", ruleid); + map.put("newLevel", newlevel); + if (url != null) { + map.put("url", url); + } + if (urlisregex != null) { + map.put("urlIsRegex", urlisregex); + } + if (parameter != null) { + map.put("parameter", parameter); + } + if (enabled != null) { + map.put("enabled", enabled); + } + if (parameterisregex != null) { + map.put("parameterIsRegex", parameterisregex); + } + if (attack != null) { + map.put("attack", attack); + } + if (attackisregex != null) { + map.put("attackIsRegex", attackisregex); + } + if (evidence != null) { + map.put("evidence", evidence); + } + if (evidenceisregex != null) { + map.put("evidenceIsRegex", evidenceisregex); + } + if (methods != null) { + map.put("methods", methods); + } + return api.callApi("alertFilter", "action", "addGlobalAlertFilter", map); + } + + /** + * Removes a global alert filter. + * + *

This component is optional and therefore the API will only work if it is installed + */ + @Override + public ApiResponse removeGlobalAlertFilter( + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex, + String methods) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("ruleId", ruleid); + map.put("newLevel", newlevel); + if (url != null) { + map.put("url", url); + } + if (urlisregex != null) { + map.put("urlIsRegex", urlisregex); + } + if (parameter != null) { + map.put("parameter", parameter); + } + if (enabled != null) { + map.put("enabled", enabled); + } + if (parameterisregex != null) { + map.put("parameterIsRegex", parameterisregex); + } + if (attack != null) { + map.put("attack", attack); + } + if (attackisregex != null) { + map.put("attackIsRegex", attackisregex); + } + if (evidence != null) { + map.put("evidence", evidence); + } + if (evidenceisregex != null) { + map.put("evidenceIsRegex", evidenceisregex); + } + if (methods != null) { + map.put("methods", methods); + } + return api.callApi("alertFilter", "action", "removeGlobalAlertFilter", map); + } + + /** + * Applies all currently enabled Global and Context alert filters. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse applyAll() throws ClientApiException { + return api.callApi("alertFilter", "action", "applyAll", null); + } + + /** + * Applies all currently enabled Context alert filters. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse applyContext() throws ClientApiException { + return api.callApi("alertFilter", "action", "applyContext", null); + } + + /** + * Applies all currently enabled Global alert filters. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse applyGlobal() throws ClientApiException { + return api.callApi("alertFilter", "action", "applyGlobal", null); + } + + /** + * Tests all currently enabled Global and Context alert filters. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse testAll() throws ClientApiException { + return api.callApi("alertFilter", "action", "testAll", null); + } + + /** + * Tests all currently enabled Context alert filters. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse testContext() throws ClientApiException { + return api.callApi("alertFilter", "action", "testContext", null); + } + + /** + * Tests all currently enabled Global alert filters. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse testGlobal() throws ClientApiException { + return api.callApi("alertFilter", "action", "testGlobal", null); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Ascan.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Ascan.java index 29ef0b5..ad4929b 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Ascan.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Ascan.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,659 +25,769 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Ascan { - - private ClientApi api = null; - - public Ascan(ClientApi api) { - this.api = api; - } - - public ApiResponse status(String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (scanid != null) { - map.put("scanId", scanid); - } - return api.callApi("ascan", "view", "status", map); - } - - public ApiResponse scanProgress(String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (scanid != null) { - map.put("scanId", scanid); - } - return api.callApi("ascan", "view", "scanProgress", map); - } - - public ApiResponse messagesIds(String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("scanId", scanid); - return api.callApi("ascan", "view", "messagesIds", map); - } - - public ApiResponse alertsIds(String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("scanId", scanid); - return api.callApi("ascan", "view", "alertsIds", map); - } - - public ApiResponse scans() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "scans", map); - } - - public ApiResponse scanPolicyNames() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "scanPolicyNames", map); - } - - public ApiResponse excludedFromScan() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "excludedFromScan", map); - } - - public ApiResponse scanners(String scanpolicyname, String policyid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - if (policyid != null) { - map.put("policyId", policyid); - } - return api.callApi("ascan", "view", "scanners", map); - } - - public ApiResponse policies(String scanpolicyname, String policyid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - if (policyid != null) { - map.put("policyId", policyid); - } - return api.callApi("ascan", "view", "policies", map); - } - - public ApiResponse attackModeQueue() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "attackModeQueue", map); - } - - public ApiResponse optionAttackPolicy() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionAttackPolicy", map); - } - - public ApiResponse optionDefaultPolicy() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionDefaultPolicy", map); - } - - public ApiResponse optionDelayInMs() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionDelayInMs", map); - } - - public ApiResponse optionExcludedParamList() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionExcludedParamList", map); - } - - public ApiResponse optionHandleAntiCSRFTokens() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionHandleAntiCSRFTokens", map); - } - - public ApiResponse optionHostPerScan() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionHostPerScan", map); - } - - public ApiResponse optionMaxChartTimeInMins() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionMaxChartTimeInMins", map); - } - - public ApiResponse optionMaxResultsToList() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionMaxResultsToList", map); - } - - public ApiResponse optionMaxScansInUI() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionMaxScansInUI", map); - } - - public ApiResponse optionTargetParamsEnabledRPC() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionTargetParamsEnabledRPC", map); - } - - public ApiResponse optionTargetParamsInjectable() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionTargetParamsInjectable", map); - } - - public ApiResponse optionThreadPerHost() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionThreadPerHost", map); - } - - public ApiResponse optionAllowAttackOnStart() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionAllowAttackOnStart", map); - } - - public ApiResponse optionInjectPluginIdInHeader() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionInjectPluginIdInHeader", map); - } - - public ApiResponse optionPromptInAttackMode() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionPromptInAttackMode", map); - } - - public ApiResponse optionPromptToClearFinishedScans() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionPromptToClearFinishedScans", map); - } - - public ApiResponse optionRescanInAttackMode() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionRescanInAttackMode", map); - } - - /** - * 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. - */ - public ApiResponse optionScanHeadersAllRequests() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionScanHeadersAllRequests", map); - } - - public ApiResponse optionShowAdvancedDialog() throws ClientApiException { - Map map = null; - return api.callApi("ascan", "view", "optionShowAdvancedDialog", map); - } - - public ApiResponse scan(String apikey, String url, String recurse, String inscopeonly, String scanpolicyname, String method, String postdata) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("url", url); - if (recurse != null) { - map.put("recurse", recurse); - } - if (inscopeonly != null) { - map.put("inScopeOnly", inscopeonly); - } - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - if (method != null) { - map.put("method", method); - } - if (postdata != null) { - map.put("postData", postdata); - } - return api.callApi("ascan", "action", "scan", map); - } - - /** - * Active Scans from the perspective of a User, obtained using the given Context ID and User ID. See 'scan' action for more details. - */ - public ApiResponse scanAsUser(String apikey, String url, String contextid, String userid, String recurse, String scanpolicyname, String method, String postdata) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("url", url); - map.put("contextId", contextid); - map.put("userId", userid); - if (recurse != null) { - map.put("recurse", recurse); - } - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - if (method != null) { - map.put("method", method); - } - if (postdata != null) { - map.put("postData", postdata); - } - return api.callApi("ascan", "action", "scanAsUser", map); - } - - public ApiResponse pause(String apikey, String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanId", scanid); - return api.callApi("ascan", "action", "pause", map); - } - - public ApiResponse resume(String apikey, String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanId", scanid); - return api.callApi("ascan", "action", "resume", map); - } - - public ApiResponse stop(String apikey, String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanId", scanid); - return api.callApi("ascan", "action", "stop", map); - } - - public ApiResponse removeScan(String apikey, String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanId", scanid); - return api.callApi("ascan", "action", "removeScan", map); - } - - public ApiResponse pauseAllScans(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("ascan", "action", "pauseAllScans", map); - } - - public ApiResponse resumeAllScans(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("ascan", "action", "resumeAllScans", map); - } - - public ApiResponse stopAllScans(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("ascan", "action", "stopAllScans", map); - } - - public ApiResponse removeAllScans(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("ascan", "action", "removeAllScans", map); - } - - public ApiResponse clearExcludedFromScan(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("ascan", "action", "clearExcludedFromScan", map); - } - - public ApiResponse excludeFromScan(String apikey, String regex) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("regex", regex); - return api.callApi("ascan", "action", "excludeFromScan", map); - } - - public ApiResponse enableAllScanners(String apikey, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "enableAllScanners", map); - } - - public ApiResponse disableAllScanners(String apikey, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "disableAllScanners", map); - } - - public ApiResponse enableScanners(String apikey, String ids, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("ids", ids); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "enableScanners", map); - } - - public ApiResponse disableScanners(String apikey, String ids, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("ids", ids); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "disableScanners", map); - } - - public ApiResponse setEnabledPolicies(String apikey, String ids, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("ids", ids); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "setEnabledPolicies", map); - } - - public ApiResponse setPolicyAttackStrength(String apikey, String id, String attackstrength, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - map.put("attackStrength", attackstrength); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "setPolicyAttackStrength", map); - } - - public ApiResponse setPolicyAlertThreshold(String apikey, String id, String alertthreshold, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - map.put("alertThreshold", alertthreshold); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "setPolicyAlertThreshold", map); - } - - public ApiResponse setScannerAttackStrength(String apikey, String id, String attackstrength, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - map.put("attackStrength", attackstrength); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "setScannerAttackStrength", map); - } - - public ApiResponse setScannerAlertThreshold(String apikey, String id, String alertthreshold, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - map.put("alertThreshold", alertthreshold); - if (scanpolicyname != null) { - map.put("scanPolicyName", scanpolicyname); - } - return api.callApi("ascan", "action", "setScannerAlertThreshold", map); - } - - public ApiResponse addScanPolicy(String apikey, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanPolicyName", scanpolicyname); - return api.callApi("ascan", "action", "addScanPolicy", map); - } - - public ApiResponse removeScanPolicy(String apikey, String scanpolicyname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanPolicyName", scanpolicyname); - return api.callApi("ascan", "action", "removeScanPolicy", map); - } - - public ApiResponse setOptionAttackPolicy(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("ascan", "action", "setOptionAttackPolicy", map); - } - - public ApiResponse setOptionDefaultPolicy(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("ascan", "action", "setOptionDefaultPolicy", map); - } - - public ApiResponse setOptionAllowAttackOnStart(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ascan", "action", "setOptionAllowAttackOnStart", map); - } - - public ApiResponse setOptionDelayInMs(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ascan", "action", "setOptionDelayInMs", map); - } - - public ApiResponse setOptionHandleAntiCSRFTokens(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ascan", "action", "setOptionHandleAntiCSRFTokens", map); - } - - public ApiResponse setOptionHostPerScan(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ascan", "action", "setOptionHostPerScan", map); - } - - public ApiResponse setOptionInjectPluginIdInHeader(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ascan", "action", "setOptionInjectPluginIdInHeader", map); - } - - public ApiResponse setOptionMaxChartTimeInMins(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ascan", "action", "setOptionMaxChartTimeInMins", map); - } - - public ApiResponse setOptionMaxResultsToList(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ascan", "action", "setOptionMaxResultsToList", map); - } - - public ApiResponse setOptionMaxScansInUI(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ascan", "action", "setOptionMaxScansInUI", map); - } - - public ApiResponse setOptionPromptInAttackMode(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ascan", "action", "setOptionPromptInAttackMode", map); - } - - public ApiResponse setOptionPromptToClearFinishedScans(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ascan", "action", "setOptionPromptToClearFinishedScans", map); - } - - public ApiResponse setOptionRescanInAttackMode(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ascan", "action", "setOptionRescanInAttackMode", map); - } - - /** - * 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. - */ - public ApiResponse setOptionScanHeadersAllRequests(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ascan", "action", "setOptionScanHeadersAllRequests", map); - } - - public ApiResponse setOptionShowAdvancedDialog(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("ascan", "action", "setOptionShowAdvancedDialog", map); - } - - public ApiResponse setOptionTargetParamsEnabledRPC(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ascan", "action", "setOptionTargetParamsEnabledRPC", map); - } - - public ApiResponse setOptionTargetParamsInjectable(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ascan", "action", "setOptionTargetParamsInjectable", map); - } - - public ApiResponse setOptionThreadPerHost(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("ascan", "action", "setOptionThreadPerHost", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Ascan extends org.zaproxy.clientapi.gen.deprecated.AscanDeprecated { + + private final ClientApi api; + + public Ascan(ClientApi api) { + super(api); + this.api = api; + } + + public ApiResponse status(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (scanid != null) { + map.put("scanId", scanid); + } + return api.callApi("ascan", "view", "status", map); + } + + public ApiResponse scanProgress(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (scanid != null) { + map.put("scanId", scanid); + } + return api.callApi("ascan", "view", "scanProgress", map); + } + + /** + * Gets the IDs of the messages sent during the scan with the given ID. A message can be + * obtained with 'message' core view. + */ + public ApiResponse messagesIds(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("ascan", "view", "messagesIds", map); + } + + /** + * Gets the IDs of the alerts raised during the scan with the given ID. An alert can be obtained + * with 'alert' core view. + */ + public ApiResponse alertsIds(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("ascan", "view", "alertsIds", map); + } + + public ApiResponse scans() throws ClientApiException { + return api.callApi("ascan", "view", "scans", null); + } + + public ApiResponse scanPolicyNames() throws ClientApiException { + return api.callApi("ascan", "view", "scanPolicyNames", null); + } + + /** Gets the regexes of URLs excluded from the active scans. */ + public ApiResponse excludedFromScan() throws ClientApiException { + return api.callApi("ascan", "view", "excludedFromScan", null); + } + + /** Gets the scan rules, optionally, of the given scan policy or scanner policy/category ID. */ + public ApiResponse scanners(String scanpolicyname, String policyid) throws ClientApiException { + Map map = new HashMap<>(); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + if (policyid != null) { + map.put("policyId", policyid); + } + return api.callApi("ascan", "view", "scanners", map); + } + + public ApiResponse policies(String scanpolicyname, String policyid) throws ClientApiException { + Map map = new HashMap<>(); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + if (policyid != null) { + map.put("policyId", policyid); + } + return api.callApi("ascan", "view", "policies", map); + } + + public ApiResponse attackModeQueue() throws ClientApiException { + return api.callApi("ascan", "view", "attackModeQueue", null); + } + + /** + * Gets all the parameters that are excluded. For each parameter the following are shown: the + * name, the URL, and the parameter type. + */ + public ApiResponse excludedParams() throws ClientApiException { + return api.callApi("ascan", "view", "excludedParams", null); + } + + /** + * Use view excludedParams instead. + * + * @deprecated + */ + @Deprecated + public ApiResponse optionExcludedParamList() throws ClientApiException { + return api.callApi("ascan", "view", "optionExcludedParamList", null); + } + + /** + * Gets all the types of excluded parameters. For each type the following are shown: the ID and + * the name. + */ + public ApiResponse excludedParamTypes() throws ClientApiException { + return api.callApi("ascan", "view", "excludedParamTypes", null); + } + + public ApiResponse optionAttackPolicy() throws ClientApiException { + return api.callApi("ascan", "view", "optionAttackPolicy", null); + } + + public ApiResponse optionDefaultPolicy() throws ClientApiException { + return api.callApi("ascan", "view", "optionDefaultPolicy", null); + } + + /** + * @deprecated Option no longer in effective use. + */ + @Deprecated + public ApiResponse optionDelayInMs() throws ClientApiException { + return api.callApi("ascan", "view", "optionDelayInMs", null); + } + + public ApiResponse optionHandleAntiCSRFTokens() throws ClientApiException { + return api.callApi("ascan", "view", "optionHandleAntiCSRFTokens", null); + } + + public ApiResponse optionHostPerScan() throws ClientApiException { + return api.callApi("ascan", "view", "optionHostPerScan", null); + } + + /** Gets the maximum number of alerts that a rule can raise before being skipped. */ + public ApiResponse optionMaxAlertsPerRule() throws ClientApiException { + return api.callApi("ascan", "view", "optionMaxAlertsPerRule", null); + } + + public ApiResponse optionMaxChartTimeInMins() throws ClientApiException { + return api.callApi("ascan", "view", "optionMaxChartTimeInMins", null); + } + + public ApiResponse optionMaxResultsToList() throws ClientApiException { + return api.callApi("ascan", "view", "optionMaxResultsToList", null); + } + + public ApiResponse optionMaxRuleDurationInMins() throws ClientApiException { + return api.callApi("ascan", "view", "optionMaxRuleDurationInMins", null); + } + + public ApiResponse optionMaxScanDurationInMins() throws ClientApiException { + return api.callApi("ascan", "view", "optionMaxScanDurationInMins", null); + } + + public ApiResponse optionMaxScansInUI() throws ClientApiException { + return api.callApi("ascan", "view", "optionMaxScansInUI", null); + } + + public ApiResponse optionTargetParamsEnabledRPC() throws ClientApiException { + return api.callApi("ascan", "view", "optionTargetParamsEnabledRPC", null); + } + + public ApiResponse optionTargetParamsInjectable() throws ClientApiException { + return api.callApi("ascan", "view", "optionTargetParamsInjectable", null); + } + + public ApiResponse optionThreadPerHost() throws ClientApiException { + return api.callApi("ascan", "view", "optionThreadPerHost", null); + } + + /** + * Tells whether or not the active scanner should add a query parameter to GET request that + * don't have parameters to start with. + */ + public ApiResponse optionAddQueryParam() throws ClientApiException { + return api.callApi("ascan", "view", "optionAddQueryParam", null); + } + + public ApiResponse optionAllowAttackOnStart() throws ClientApiException { + return api.callApi("ascan", "view", "optionAllowAttackOnStart", null); + } + + /** Tells whether or not the active scanner should encode cookie values. */ + public ApiResponse optionEncodeCookieValues() throws ClientApiException { + return api.callApi("ascan", "view", "optionEncodeCookieValues", null); + } + + /** Tells whether or not the active scanner should exclude anti-csrf tokens from the scan. */ + public ApiResponse optionExcludeAntiCsrfTokens() throws ClientApiException { + return api.callApi("ascan", "view", "optionExcludeAntiCsrfTokens", null); + } + + /** + * Tells whether or not the active scanner should inject the HTTP request header X-ZAP-Scan-ID, + * with the ID of the scan rule that's sending the requests. + */ + public ApiResponse optionInjectPluginIdInHeader() throws ClientApiException { + return api.callApi("ascan", "view", "optionInjectPluginIdInHeader", null); + } + + /** + * Tells whether or not the temporary HTTP messages sent while active scanning should be + * persisted. + */ + public ApiResponse optionPersistTemporaryMessages() throws ClientApiException { + return api.callApi("ascan", "view", "optionPersistTemporaryMessages", null); + } + + public ApiResponse optionPromptInAttackMode() throws ClientApiException { + return api.callApi("ascan", "view", "optionPromptInAttackMode", null); + } + + public ApiResponse optionPromptToClearFinishedScans() throws ClientApiException { + return api.callApi("ascan", "view", "optionPromptToClearFinishedScans", null); + } + + public ApiResponse optionRescanInAttackMode() throws ClientApiException { + return api.callApi("ascan", "view", "optionRescanInAttackMode", null); + } + + /** + * 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. + */ + public ApiResponse optionScanHeadersAllRequests() throws ClientApiException { + return api.callApi("ascan", "view", "optionScanHeadersAllRequests", null); + } + + /** Tells whether or not the active scanner should scan null JSON values. */ + public ApiResponse optionScanNullJsonValues() throws ClientApiException { + return api.callApi("ascan", "view", "optionScanNullJsonValues", null); + } + + public ApiResponse optionShowAdvancedDialog() throws ClientApiException { + return api.callApi("ascan", "view", "optionShowAdvancedDialog", null); + } + + public ApiResponse scan( + String url, + String recurse, + String inscopeonly, + String scanpolicyname, + String method, + String postdata) + throws ClientApiException { + return scan(url, recurse, inscopeonly, scanpolicyname, method, postdata, (Integer) null); + } + + /** + * Runs the active scanner against the given URL 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. + */ + public ApiResponse scan( + String url, + String recurse, + String inscopeonly, + String scanpolicyname, + String method, + String postdata, + Integer contextid) + throws ClientApiException { + Map map = new HashMap<>(); + if (url != null) { + map.put("url", url); + } + if (recurse != null) { + map.put("recurse", recurse); + } + if (inscopeonly != null) { + map.put("inScopeOnly", inscopeonly); + } + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + if (method != null) { + map.put("method", method); + } + if (postdata != null) { + map.put("postData", postdata); + } + if (contextid != null) { + map.put("contextId", contextid.toString()); + } + return api.callApi("ascan", "action", "scan", map); + } + + /** + * Active Scans from the perspective of a User, obtained using the given Context ID and User ID. + * See 'scan' action for more details. + */ + public ApiResponse scanAsUser( + String url, + String contextid, + String userid, + String recurse, + String scanpolicyname, + String method, + String postdata) + throws ClientApiException { + Map map = new HashMap<>(); + if (url != null) { + map.put("url", url); + } + if (contextid != null) { + map.put("contextId", contextid); + } + if (userid != null) { + map.put("userId", userid); + } + if (recurse != null) { + map.put("recurse", recurse); + } + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + if (method != null) { + map.put("method", method); + } + if (postdata != null) { + map.put("postData", postdata); + } + return api.callApi("ascan", "action", "scanAsUser", map); + } + + public ApiResponse pause(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("ascan", "action", "pause", map); + } + + public ApiResponse resume(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("ascan", "action", "resume", map); + } + + public ApiResponse stop(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("ascan", "action", "stop", map); + } + + public ApiResponse removeScan(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("ascan", "action", "removeScan", map); + } + + public ApiResponse pauseAllScans() throws ClientApiException { + return api.callApi("ascan", "action", "pauseAllScans", null); + } + + public ApiResponse resumeAllScans() throws ClientApiException { + return api.callApi("ascan", "action", "resumeAllScans", null); + } + + public ApiResponse stopAllScans() throws ClientApiException { + return api.callApi("ascan", "action", "stopAllScans", null); + } + + public ApiResponse removeAllScans() throws ClientApiException { + return api.callApi("ascan", "action", "removeAllScans", null); + } + + /** Clears the regexes of URLs excluded from the active scans. */ + public ApiResponse clearExcludedFromScan() throws ClientApiException { + return api.callApi("ascan", "action", "clearExcludedFromScan", null); + } + + /** Adds a regex of URLs that should be excluded from the active scans. */ + public ApiResponse excludeFromScan(String regex) throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + return api.callApi("ascan", "action", "excludeFromScan", map); + } + + /** + * Enables all scan rules of the scan policy with the given name, or the default if none given. + */ + public ApiResponse enableAllScanners(String scanpolicyname) throws ClientApiException { + Map map = new HashMap<>(); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "enableAllScanners", map); + } + + /** + * Disables all scan rules of the scan policy with the given name, or the default if none given. + */ + public ApiResponse disableAllScanners(String scanpolicyname) throws ClientApiException { + Map map = new HashMap<>(); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "disableAllScanners", map); + } + + /** + * Enables the scan rules with the given IDs (comma separated list of IDs) of the scan policy + * with the given name, or the default if none given. + */ + public ApiResponse enableScanners(String ids, String scanpolicyname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "enableScanners", map); + } + + /** + * Disables the scan rules with the given IDs (comma separated list of IDs) of the scan policy + * with the given name, or the default if none given. + */ + public ApiResponse disableScanners(String ids, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "disableScanners", map); + } + + public ApiResponse setEnabledPolicies(String ids, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setEnabledPolicies", map); + } + + public ApiResponse setPolicyAttackStrength( + String id, String attackstrength, String scanpolicyname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + map.put("attackStrength", attackstrength); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setPolicyAttackStrength", map); + } + + public ApiResponse setPolicyAlertThreshold( + String id, String alertthreshold, String scanpolicyname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + map.put("alertThreshold", alertthreshold); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setPolicyAlertThreshold", map); + } + + public ApiResponse setScannerAttackStrength( + String id, String attackstrength, String scanpolicyname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + map.put("attackStrength", attackstrength); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setScannerAttackStrength", map); + } + + public ApiResponse setScannerAlertThreshold( + String id, String alertthreshold, String scanpolicyname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + map.put("alertThreshold", alertthreshold); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setScannerAlertThreshold", map); + } + + public ApiResponse addScanPolicy( + String scanpolicyname, String alertthreshold, String attackstrength) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanPolicyName", scanpolicyname); + if (alertthreshold != null) { + map.put("alertThreshold", alertthreshold); + } + if (attackstrength != null) { + map.put("attackStrength", attackstrength); + } + return api.callApi("ascan", "action", "addScanPolicy", map); + } + + public ApiResponse removeScanPolicy(String scanpolicyname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanPolicyName", scanpolicyname); + return api.callApi("ascan", "action", "removeScanPolicy", map); + } + + public ApiResponse updateScanPolicy( + String scanpolicyname, String alertthreshold, String attackstrength) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanPolicyName", scanpolicyname); + if (alertthreshold != null) { + map.put("alertThreshold", alertthreshold); + } + if (attackstrength != null) { + map.put("attackStrength", attackstrength); + } + return api.callApi("ascan", "action", "updateScanPolicy", map); + } + + /** Imports a Scan Policy using the given file system path. */ + public ApiResponse importScanPolicy(String path) throws ClientApiException { + Map map = new HashMap<>(); + map.put("path", path); + return api.callApi("ascan", "action", "importScanPolicy", map); + } + + /** + * 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. + */ + public ApiResponse addExcludedParam(String name, String type, String url) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("name", name); + if (type != null) { + map.put("type", type); + } + if (url != null) { + map.put("url", url); + } + return api.callApi("ascan", "action", "addExcludedParam", map); + } + + /** + * 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. + */ + public ApiResponse modifyExcludedParam(String idx, String name, String type, String url) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("idx", idx); + if (name != null) { + map.put("name", name); + } + if (type != null) { + map.put("type", type); + } + if (url != null) { + map.put("url", url); + } + return api.callApi("ascan", "action", "modifyExcludedParam", map); + } + + /** + * Removes a parameter excluded from the scan, with the given index. The index can be obtained + * with the view excludedParams. + */ + public ApiResponse removeExcludedParam(String idx) throws ClientApiException { + Map map = new HashMap<>(); + map.put("idx", idx); + return api.callApi("ascan", "action", "removeExcludedParam", map); + } + + /** Skips the scan rule using the given IDs of the scan and the scan rule. */ + public ApiResponse skipScanner(String scanid, String scannerid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + map.put("scannerId", scannerid); + return api.callApi("ascan", "action", "skipScanner", map); + } + + public ApiResponse setOptionAttackPolicy(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("ascan", "action", "setOptionAttackPolicy", map); + } + + public ApiResponse setOptionDefaultPolicy(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("ascan", "action", "setOptionDefaultPolicy", map); + } + + /** + * Sets whether or not the active scanner should add a query param to GET requests which do not + * have parameters to start with. + */ + public ApiResponse setOptionAddQueryParam(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionAddQueryParam", map); + } + + public ApiResponse setOptionAllowAttackOnStart(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionAllowAttackOnStart", map); + } + + /** + * @deprecated Option no longer in effective use. + */ + @Deprecated + public ApiResponse setOptionDelayInMs(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionDelayInMs", map); + } + + /** Sets whether or not the active scanner should encode cookie values. */ + public ApiResponse setOptionEncodeCookieValues(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionEncodeCookieValues", map); + } + + /** Sets whether or not the active scanner should exclude anti-csrf tokens from the scan. */ + public ApiResponse setOptionExcludeAntiCsrfTokens(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionExcludeAntiCsrfTokens", map); + } + + public ApiResponse setOptionHandleAntiCSRFTokens(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionHandleAntiCSRFTokens", map); + } + + public ApiResponse setOptionHostPerScan(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionHostPerScan", map); + } + + /** + * Sets whether or not the active scanner should inject the HTTP request header X-ZAP-Scan-ID, + * with the ID of the scan rule that's sending the requests. + */ + public ApiResponse setOptionInjectPluginIdInHeader(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionInjectPluginIdInHeader", map); + } + + /** Sets the maximum number of alerts that a rule can raise before being skipped. */ + public ApiResponse setOptionMaxAlertsPerRule(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxAlertsPerRule", map); + } + + public ApiResponse setOptionMaxChartTimeInMins(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxChartTimeInMins", map); + } + + public ApiResponse setOptionMaxResultsToList(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxResultsToList", map); + } + + public ApiResponse setOptionMaxRuleDurationInMins(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxRuleDurationInMins", map); + } + + public ApiResponse setOptionMaxScanDurationInMins(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxScanDurationInMins", map); + } + + public ApiResponse setOptionMaxScansInUI(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxScansInUI", map); + } + + /** + * Sets whether or not the temporary HTTP messages sent while active scanning should be + * persisted. + */ + public ApiResponse setOptionPersistTemporaryMessages(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionPersistTemporaryMessages", map); + } + + public ApiResponse setOptionPromptInAttackMode(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionPromptInAttackMode", map); + } + + public ApiResponse setOptionPromptToClearFinishedScans(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionPromptToClearFinishedScans", map); + } + + public ApiResponse setOptionRescanInAttackMode(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionRescanInAttackMode", map); + } + + /** + * 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. + */ + public ApiResponse setOptionScanHeadersAllRequests(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionScanHeadersAllRequests", map); + } + + /** Sets whether or not the active scanner should scan null JSON values. */ + public ApiResponse setOptionScanNullJsonValues(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionScanNullJsonValues", map); + } + + public ApiResponse setOptionShowAdvancedDialog(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionShowAdvancedDialog", map); + } + + public ApiResponse setOptionTargetParamsEnabledRPC(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionTargetParamsEnabledRPC", map); + } + + public ApiResponse setOptionTargetParamsInjectable(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionTargetParamsInjectable", map); + } + + public ApiResponse setOptionThreadPerHost(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionThreadPerHost", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authentication.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authentication.java index f22fca2..f7d0f94 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authentication.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authentication.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,85 +25,79 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Authentication { - - private ClientApi api = null; - - public Authentication(ClientApi api) { - this.api = api; - } - - public ApiResponse getSupportedAuthenticationMethods() throws ClientApiException { - Map map = null; - return api.callApi("authentication", "view", "getSupportedAuthenticationMethods", map); - } - - public ApiResponse getAuthenticationMethodConfigParams(String authmethodname) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("authMethodName", authmethodname); - return api.callApi("authentication", "view", "getAuthenticationMethodConfigParams", map); - } - - public ApiResponse getAuthenticationMethod(String contextid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextId", contextid); - return api.callApi("authentication", "view", "getAuthenticationMethod", map); - } - - public ApiResponse getLoggedInIndicator(String contextid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextId", contextid); - return api.callApi("authentication", "view", "getLoggedInIndicator", map); - } - - public ApiResponse getLoggedOutIndicator(String contextid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextId", contextid); - return api.callApi("authentication", "view", "getLoggedOutIndicator", map); - } - - public ApiResponse setAuthenticationMethod(String apikey, String contextid, String authmethodname, String authmethodconfigparams) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("authMethodName", authmethodname); - if (authmethodconfigparams != null) { - map.put("authMethodConfigParams", authmethodconfigparams); - } - return api.callApi("authentication", "action", "setAuthenticationMethod", map); - } - - public ApiResponse setLoggedInIndicator(String apikey, String contextid, String loggedinindicatorregex) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("loggedInIndicatorRegex", loggedinindicatorregex); - return api.callApi("authentication", "action", "setLoggedInIndicator", map); - } - - public ApiResponse setLoggedOutIndicator(String apikey, String contextid, String loggedoutindicatorregex) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("loggedOutIndicatorRegex", loggedoutindicatorregex); - return api.callApi("authentication", "action", "setLoggedOutIndicator", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Authentication extends org.zaproxy.clientapi.gen.deprecated.AuthenticationDeprecated { + + private final ClientApi api; + + public Authentication(ClientApi api) { + super(api); + this.api = api; + } + + /** Gets the name of the authentication methods. */ + public ApiResponse getSupportedAuthenticationMethods() throws ClientApiException { + return api.callApi("authentication", "view", "getSupportedAuthenticationMethods", null); + } + + /** Gets the configuration parameters for the authentication method with the given name. */ + public ApiResponse getAuthenticationMethodConfigParams(String authmethodname) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("authMethodName", authmethodname); + return api.callApi("authentication", "view", "getAuthenticationMethodConfigParams", map); + } + + /** Gets the name of the authentication method for the context with the given ID. */ + public ApiResponse getAuthenticationMethod(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("authentication", "view", "getAuthenticationMethod", map); + } + + /** Gets the logged in indicator for the context with the given ID. */ + public ApiResponse getLoggedInIndicator(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("authentication", "view", "getLoggedInIndicator", map); + } + + /** Gets the logged out indicator for the context with the given ID. */ + public ApiResponse getLoggedOutIndicator(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("authentication", "view", "getLoggedOutIndicator", map); + } + + /** Sets the authentication method for the context with the given ID. */ + public ApiResponse setAuthenticationMethod( + String contextid, String authmethodname, String authmethodconfigparams) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("authMethodName", authmethodname); + if (authmethodconfigparams != null) { + map.put("authMethodConfigParams", authmethodconfigparams); + } + return api.callApi("authentication", "action", "setAuthenticationMethod", map); + } + + /** Sets the logged in indicator for the context with the given ID. */ + public ApiResponse setLoggedInIndicator(String contextid, String loggedinindicatorregex) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("loggedInIndicatorRegex", loggedinindicatorregex); + return api.callApi("authentication", "action", "setLoggedInIndicator", map); + } + + /** Sets the logged out indicator for the context with the given ID. */ + public ApiResponse setLoggedOutIndicator(String contextid, String loggedoutindicatorregex) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("loggedOutIndicatorRegex", loggedoutindicatorregex); + return api.callApi("authentication", "action", "setLoggedOutIndicator", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authorization.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authorization.java index ad5f698..87fee7b 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authorization.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Authorization.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,51 +25,54 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Authorization extends org.zaproxy.clientapi.gen.deprecated.AuthorizationDeprecated { -/** - * This file was automatically generated. - */ -public class Authorization { - - private ClientApi api = null; - - public Authorization(ClientApi api) { - this.api = api; - } + private final ClientApi api; - /** - * Obtains all the configuration of the authorization detection method that is currently set for a context. - */ - public ApiResponse getAuthorizationDetectionMethod(String contextid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextId", contextid); - return api.callApi("authorization", "view", "getAuthorizationDetectionMethod", map); - } + public Authorization(ClientApi api) { + super(api); + this.api = api; + } - /** - * 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". - */ - public ApiResponse setBasicAuthorizationDetectionMethod(String apikey, String contextid, String headerregex, String bodyregex, String statuscode, String logicaloperator) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - if (headerregex != null) { - map.put("headerRegex", headerregex); - } - if (bodyregex != null) { - map.put("bodyRegex", bodyregex); - } - if (statuscode != null) { - map.put("statusCode", statuscode); - } - if (logicaloperator != null) { - map.put("logicalOperator", logicaloperator); - } - return api.callApi("authorization", "action", "setBasicAuthorizationDetectionMethod", map); - } + /** + * Obtains all the configuration of the authorization detection method that is currently set for + * a context. + */ + public ApiResponse getAuthorizationDetectionMethod(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("authorization", "view", "getAuthorizationDetectionMethod", map); + } + /** + * 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". + */ + public ApiResponse setBasicAuthorizationDetectionMethod( + String contextid, + String headerregex, + String bodyregex, + String statuscode, + String logicaloperator) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + if (headerregex != null) { + map.put("headerRegex", headerregex); + } + if (bodyregex != null) { + map.put("bodyRegex", bodyregex); + } + if (statuscode != null) { + map.put("statusCode", statuscode); + } + if (logicaloperator != null) { + map.put("logicalOperator", logicaloperator); + } + return api.callApi("authorization", "action", "setBasicAuthorizationDetectionMethod", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Automation.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Automation.java new file mode 100644 index 0000000..8b3f141 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Automation.java @@ -0,0 +1,79 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2021 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Automation { + + private final ClientApi api; + + public Automation(ClientApi api) { + this.api = api; + } + + /** + * Returns the progress details for the specified planId + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse planProgress(String planid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("planId", planid); + return api.callApi("automation", "view", "planProgress", map); + } + + /** + * Loads and asynchronously runs the plan in the specified file, returning a planId + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse runPlan(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("automation", "action", "runPlan", map); + } + + /** + * Stops the running plan identified by the planId + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse stopPlan(String planid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("planId", planid); + return api.callApi("automation", "action", "stopPlan", map); + } + + /** + * Ends the currently running delay job, if any + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse endDelayJob() throws ClientApiException { + return api.callApi("automation", "action", "endDelayJob", null); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Autoupdate.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Autoupdate.java index 3f341ff..991b154 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Autoupdate.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Autoupdate.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,189 +25,185 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Autoupdate { - - private ClientApi api = null; - - public Autoupdate(ClientApi api) { - this.api = api; - } - - /** - * Returns the latest version number - */ - public ApiResponse latestVersionNumber() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "latestVersionNumber", map); - } - - /** - * Returns 'true' if ZAP is on the latest version - */ - public ApiResponse isLatestVersion() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "isLatestVersion", map); - } - - public ApiResponse optionAddonDirectories() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionAddonDirectories", map); - } - - public ApiResponse optionDayLastChecked() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionDayLastChecked", map); - } - - public ApiResponse optionDayLastInstallWarned() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionDayLastInstallWarned", map); - } - - public ApiResponse optionDayLastUpdateWarned() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionDayLastUpdateWarned", map); - } - - public ApiResponse optionDownloadDirectory() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionDownloadDirectory", map); - } - - public ApiResponse optionCheckAddonUpdates() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionCheckAddonUpdates", map); - } - - public ApiResponse optionCheckOnStart() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionCheckOnStart", map); - } - - public ApiResponse optionDownloadNewRelease() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionDownloadNewRelease", map); - } - - public ApiResponse optionInstallAddonUpdates() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionInstallAddonUpdates", map); - } - - public ApiResponse optionInstallScannerRules() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionInstallScannerRules", map); - } - - public ApiResponse optionReportAlphaAddons() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionReportAlphaAddons", map); - } - - public ApiResponse optionReportBetaAddons() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionReportBetaAddons", map); - } - - public ApiResponse optionReportReleaseAddons() throws ClientApiException { - Map map = null; - return api.callApi("autoupdate", "view", "optionReportReleaseAddons", map); - } - - /** - * Downloads the latest release, if any - */ - public ApiResponse downloadLatestRelease(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("autoupdate", "action", "downloadLatestRelease", map); - } - - public ApiResponse setOptionCheckAddonUpdates(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("autoupdate", "action", "setOptionCheckAddonUpdates", map); - } - - public ApiResponse setOptionCheckOnStart(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("autoupdate", "action", "setOptionCheckOnStart", map); - } - - public ApiResponse setOptionDownloadNewRelease(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("autoupdate", "action", "setOptionDownloadNewRelease", map); - } - - public ApiResponse setOptionInstallAddonUpdates(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("autoupdate", "action", "setOptionInstallAddonUpdates", map); - } - - public ApiResponse setOptionInstallScannerRules(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("autoupdate", "action", "setOptionInstallScannerRules", map); - } - - public ApiResponse setOptionReportAlphaAddons(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("autoupdate", "action", "setOptionReportAlphaAddons", map); - } - - public ApiResponse setOptionReportBetaAddons(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("autoupdate", "action", "setOptionReportBetaAddons", map); - } - - public ApiResponse setOptionReportReleaseAddons(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("autoupdate", "action", "setOptionReportReleaseAddons", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Autoupdate extends org.zaproxy.clientapi.gen.deprecated.AutoupdateDeprecated { + + private final ClientApi api; + + public Autoupdate(ClientApi api) { + super(api); + this.api = api; + } + + /** Returns the latest version number */ + public ApiResponse latestVersionNumber() throws ClientApiException { + return api.callApi("autoupdate", "view", "latestVersionNumber", null); + } + + /** Returns 'true' if ZAP is on the latest version */ + public ApiResponse isLatestVersion() throws ClientApiException { + return api.callApi("autoupdate", "view", "isLatestVersion", null); + } + + /** Return a list of all of the installed add-ons */ + public ApiResponse installedAddons() throws ClientApiException { + return api.callApi("autoupdate", "view", "installedAddons", null); + } + + /** Returns a list with all local add-ons, installed or not. */ + public ApiResponse localAddons() throws ClientApiException { + return api.callApi("autoupdate", "view", "localAddons", null); + } + + /** + * Return a list of any add-ons that have been added to the Marketplace since the last check for + * updates + */ + public ApiResponse newAddons() throws ClientApiException { + return api.callApi("autoupdate", "view", "newAddons", null); + } + + /** + * Return a list of any add-ons that have been changed in the Marketplace since the last check + * for updates + */ + public ApiResponse updatedAddons() throws ClientApiException { + return api.callApi("autoupdate", "view", "updatedAddons", null); + } + + /** + * Return a list of all of the add-ons on the ZAP Marketplace (this information is read once and + * then cached) + */ + public ApiResponse marketplaceAddons() throws ClientApiException { + return api.callApi("autoupdate", "view", "marketplaceAddons", null); + } + + public ApiResponse optionAddonDirectories() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionAddonDirectories", null); + } + + public ApiResponse optionDayLastChecked() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionDayLastChecked", null); + } + + public ApiResponse optionDayLastInstallWarned() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionDayLastInstallWarned", null); + } + + public ApiResponse optionDayLastUpdateWarned() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionDayLastUpdateWarned", null); + } + + public ApiResponse optionDownloadDirectory() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionDownloadDirectory", null); + } + + public ApiResponse optionCheckAddonUpdates() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionCheckAddonUpdates", null); + } + + public ApiResponse optionCheckOnStart() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionCheckOnStart", null); + } + + public ApiResponse optionDownloadNewRelease() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionDownloadNewRelease", null); + } + + public ApiResponse optionInstallAddonUpdates() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionInstallAddonUpdates", null); + } + + public ApiResponse optionInstallScannerRules() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionInstallScannerRules", null); + } + + public ApiResponse optionReportAlphaAddons() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionReportAlphaAddons", null); + } + + public ApiResponse optionReportBetaAddons() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionReportBetaAddons", null); + } + + public ApiResponse optionReportReleaseAddons() throws ClientApiException { + return api.callApi("autoupdate", "view", "optionReportReleaseAddons", null); + } + + /** Downloads the latest release, if any */ + public ApiResponse downloadLatestRelease() throws ClientApiException { + return api.callApi("autoupdate", "action", "downloadLatestRelease", null); + } + + /** + * Installs or updates the specified add-on, returning when complete (i.e. not asynchronously) + */ + public ApiResponse installAddon(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("autoupdate", "action", "installAddon", map); + } + + public ApiResponse installLocalAddon(String file) throws ClientApiException { + Map map = new HashMap<>(); + map.put("file", file); + return api.callApi("autoupdate", "action", "installLocalAddon", map); + } + + /** Uninstalls the specified add-on */ + public ApiResponse uninstallAddon(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("autoupdate", "action", "uninstallAddon", map); + } + + public ApiResponse setOptionCheckAddonUpdates(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionCheckAddonUpdates", map); + } + + public ApiResponse setOptionCheckOnStart(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionCheckOnStart", map); + } + + public ApiResponse setOptionDownloadNewRelease(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionDownloadNewRelease", map); + } + + public ApiResponse setOptionInstallAddonUpdates(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionInstallAddonUpdates", map); + } + + public ApiResponse setOptionInstallScannerRules(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionInstallScannerRules", map); + } + + public ApiResponse setOptionReportAlphaAddons(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionReportAlphaAddons", map); + } + + public ApiResponse setOptionReportBetaAddons(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionReportBetaAddons", map); + } + + public ApiResponse setOptionReportReleaseAddons(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionReportReleaseAddons", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Break.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Break.java index 213234c..d47af9e 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Break.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Break.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,56 +25,111 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Break extends org.zaproxy.clientapi.gen.deprecated.BreakDeprecated { -/** - * This file was automatically generated. - */ -public class Break { + private final ClientApi api; + + public Break(ClientApi api) { + super(api); + this.api = api; + } + + /** Returns True if ZAP will break on both requests and responses */ + public ApiResponse isBreakAll() throws ClientApiException { + return api.callApi("break", "view", "isBreakAll", null); + } + + /** Returns True if ZAP will break on requests */ + public ApiResponse isBreakRequest() throws ClientApiException { + return api.callApi("break", "view", "isBreakRequest", null); + } + + /** Returns True if ZAP will break on responses */ + public ApiResponse isBreakResponse() throws ClientApiException { + return api.callApi("break", "view", "isBreakResponse", null); + } + + /** Returns the HTTP message currently intercepted (if any) */ + public ApiResponse httpMessage() throws ClientApiException { + return api.callApi("break", "view", "httpMessage", null); + } + + /** + * 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. + */ + public ApiResponse brk(String type, String state, String scope) throws ClientApiException { + Map map = new HashMap<>(); + map.put("type", type); + map.put("state", state); + if (scope != null) { + map.put("scope", scope); + } + return api.callApi("break", "action", "break", map); + } - private ClientApi api = null; + /** Overwrites the currently intercepted message with the data provided */ + public ApiResponse setHttpMessage(String httpheader, String httpbody) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("httpHeader", httpheader); + if (httpbody != null) { + map.put("httpBody", httpbody); + } + return api.callApi("break", "action", "setHttpMessage", map); + } - public Break(ClientApi api) { - this.api = api; - } + /** + * Submits the currently intercepted message and unsets the global request/response breakpoints + */ + public ApiResponse cont() throws ClientApiException { + return api.callApi("break", "action", "continue", null); + } - public ApiResponse brk(String apikey, String type, String scope, String state) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("type", type); - map.put("scope", scope); - map.put("state", state); - return api.callApi("break", "action", "break", map); - } + /** + * Submits the currently intercepted message, the next request or response will automatically be + * intercepted + */ + public ApiResponse step() throws ClientApiException { + return api.callApi("break", "action", "step", null); + } - public ApiResponse addHttpBreakpoint(String apikey, String string, String location, String match, String inverse, String ignorecase) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("string", string); - map.put("location", location); - map.put("match", match); - map.put("inverse", inverse); - map.put("ignorecase", ignorecase); - return api.callApi("break", "action", "addHttpBreakpoint", map); - } + /** Drops the currently intercepted message */ + public ApiResponse drop() throws ClientApiException { + return api.callApi("break", "action", "drop", null); + } - public ApiResponse removeHttpBreakpoint(String apikey, String string, String location, String match, String inverse, String ignorecase) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("string", string); - map.put("location", location); - map.put("match", match); - map.put("inverse", inverse); - map.put("ignorecase", ignorecase); - return api.callApi("break", "action", "removeHttpBreakpoint", map); - } + /** + * Adds a custom HTTP breakpoint. 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. + */ + public ApiResponse addHttpBreakpoint( + String string, String location, String match, String inverse, String ignorecase) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("string", string); + map.put("location", location); + map.put("match", match); + map.put("inverse", inverse); + map.put("ignorecase", ignorecase); + return api.callApi("break", "action", "addHttpBreakpoint", map); + } + /** Removes the specified breakpoint */ + public ApiResponse removeHttpBreakpoint( + String string, String location, String match, String inverse, String ignorecase) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("string", string); + map.put("location", location); + map.put("match", match); + map.put("inverse", inverse); + map.put("ignorecase", ignorecase); + return api.callApi("break", "action", "removeHttpBreakpoint", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Client.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Client.java new file mode 100644 index 0000000..1d843de --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Client.java @@ -0,0 +1,76 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2025 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Client { + + private final ClientApi api; + + public Client(ClientApi api) { + this.api = api; + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse reportObject(String objectjson) throws ClientApiException { + Map map = new HashMap<>(); + map.put("objectJson", objectjson); + return api.callApi("client", "action", "reportObject", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse reportEvent(String eventjson) throws ClientApiException { + Map map = new HashMap<>(); + map.put("eventJson", eventjson); + return api.callApi("client", "action", "reportEvent", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse reportZestStatement(String statementjson) throws ClientApiException { + Map map = new HashMap<>(); + map.put("statementJson", statementjson); + return api.callApi("client", "action", "reportZestStatement", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse reportZestScript(String scriptjson) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptJson", scriptjson); + return api.callApi("client", "action", "reportZestScript", map); + } + + /** + * Exports the Client Map to a file. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse exportClientMap(String pathyaml) throws ClientApiException { + Map map = new HashMap<>(); + map.put("pathYaml", pathyaml); + return api.callApi("client", "action", "exportClientMap", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ClientSpider.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ClientSpider.java new file mode 100644 index 0000000..a1176fe --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ClientSpider.java @@ -0,0 +1,106 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2025 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class ClientSpider { + + private final ClientApi api; + + public ClientSpider(ClientApi api) { + this.api = api; + } + + /** + * Gets the status of a client spider scan. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse status(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("clientSpider", "view", "status", map); + } + + /** + * Starts a client spider scan. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scan( + String browser, + String url, + String contextname, + String username, + String subtreeonly, + String maxcrawldepth, + String pageloadtime, + String numberofbrowsers, + String scopecheck) + throws ClientApiException { + Map map = new HashMap<>(); + if (browser != null) { + map.put("browser", browser); + } + if (url != null) { + map.put("url", url); + } + if (contextname != null) { + map.put("contextName", contextname); + } + if (username != null) { + map.put("userName", username); + } + if (subtreeonly != null) { + map.put("subtreeOnly", subtreeonly); + } + if (maxcrawldepth != null) { + map.put("maxCrawlDepth", maxcrawldepth); + } + if (pageloadtime != null) { + map.put("pageLoadTime", pageloadtime); + } + if (numberofbrowsers != null) { + map.put("numberOfBrowsers", numberofbrowsers); + } + if (scopecheck != null) { + map.put("scopeCheck", scopecheck); + } + return api.callApi("clientSpider", "action", "scan", map); + } + + /** + * Stops a client spider scan. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse stop(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("clientSpider", "action", "stop", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Context.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Context.java index 2d087a1..c9d325d 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Context.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Context.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,231 +25,205 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Context { - - private ClientApi api = null; - - public Context(ClientApi api) { - this.api = api; - } - - /** - * List context names of current session - */ - public ApiResponse contextList() throws ClientApiException { - Map map = null; - return api.callApi("context", "view", "contextList", map); - } - - /** - * List excluded regexs for context - */ - public ApiResponse excludeRegexs(String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextName", contextname); - return api.callApi("context", "view", "excludeRegexs", map); - } - - /** - * List included regexs for context - */ - public ApiResponse includeRegexs(String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextName", contextname); - return api.callApi("context", "view", "includeRegexs", map); - } - - /** - * List the information about the named context - */ - public ApiResponse context(String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextName", contextname); - return api.callApi("context", "view", "context", map); - } - - /** - * Lists the names of all built in technologies - */ - public ApiResponse technologyList() throws ClientApiException { - Map map = null; - return api.callApi("context", "view", "technologyList", map); - } - - /** - * Lists the names of all technologies included in a context - */ - public ApiResponse includedTechnologyList(String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextName", contextname); - return api.callApi("context", "view", "includedTechnologyList", map); - } - - /** - * Lists the names of all technologies excluded from a context - */ - public ApiResponse excludedTechnologyList(String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextName", contextname); - return api.callApi("context", "view", "excludedTechnologyList", map); - } - - /** - * Add exclude regex to context - */ - public ApiResponse excludeFromContext(String apikey, String contextname, String regex) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - map.put("regex", regex); - return api.callApi("context", "action", "excludeFromContext", map); - } - - /** - * Add include regex to context - */ - public ApiResponse includeInContext(String apikey, String contextname, String regex) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - map.put("regex", regex); - return api.callApi("context", "action", "includeInContext", map); - } - - /** - * Creates a new context with the given name in the current session - */ - public ApiResponse newContext(String apikey, String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - return api.callApi("context", "action", "newContext", map); - } - - /** - * Removes a context in the current session - */ - public ApiResponse removeContext(String apikey, String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - return api.callApi("context", "action", "removeContext", map); - } - - /** - * 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. - */ - public ApiResponse exportContext(String apikey, String contextname, String contextfile) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - map.put("contextFile", contextfile); - return api.callApi("context", "action", "exportContext", map); - } - - /** - * 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. - */ - public ApiResponse importContext(String apikey, String contextfile) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextFile", contextfile); - return api.callApi("context", "action", "importContext", map); - } - - /** - * Includes technologies with the given names, separated by a comma, to a context - */ - public ApiResponse includeContextTechnologies(String apikey, String contextname, String technologynames) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - map.put("technologyNames", technologynames); - return api.callApi("context", "action", "includeContextTechnologies", map); - } - - /** - * Includes all built in technologies in to a context - */ - public ApiResponse includeAllContextTechnologies(String apikey, String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - return api.callApi("context", "action", "includeAllContextTechnologies", map); - } - - /** - * Excludes technologies with the given names, separated by a comma, from a context - */ - public ApiResponse excludeContextTechnologies(String apikey, String contextname, String technologynames) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - map.put("technologyNames", technologynames); - return api.callApi("context", "action", "excludeContextTechnologies", map); - } - - /** - * Excludes all built in technologies from a context - */ - public ApiResponse excludeAllContextTechnologies(String apikey, String contextname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - return api.callApi("context", "action", "excludeAllContextTechnologies", map); - } - - /** - * Sets a context to in scope (contexts are in scope by default) - */ - public ApiResponse setContextInScope(String apikey, String contextname, String booleaninscope) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextName", contextname); - map.put("booleanInScope", booleaninscope); - return api.callApi("context", "action", "setContextInScope", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Context extends org.zaproxy.clientapi.gen.deprecated.ContextDeprecated { + + private final ClientApi api; + + public Context(ClientApi api) { + super(api); + this.api = api; + } + + /** List context names of current session */ + public ApiResponse contextList() throws ClientApiException { + return api.callApi("context", "view", "contextList", null); + } + + /** List excluded regexs for context */ + public ApiResponse excludeRegexs(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "view", "excludeRegexs", map); + } + + /** List included regexs for context */ + public ApiResponse includeRegexs(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "view", "includeRegexs", map); + } + + /** List the information about the named context */ + public ApiResponse context(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "view", "context", map); + } + + /** Lists the names of all built in technologies */ + public ApiResponse technologyList() throws ClientApiException { + return api.callApi("context", "view", "technologyList", null); + } + + /** Lists the names of all technologies included in a context */ + public ApiResponse includedTechnologyList(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "view", "includedTechnologyList", map); + } + + /** Lists the names of all technologies excluded from a context */ + public ApiResponse excludedTechnologyList(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "view", "excludedTechnologyList", map); + } + + /** Lists the URLs accessed through/by ZAP, that belong to the context with the given name. */ + public ApiResponse urls(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "view", "urls", map); + } + + /** Add exclude regex to context */ + public ApiResponse excludeFromContext(String contextname, String regex) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("regex", regex); + return api.callApi("context", "action", "excludeFromContext", map); + } + + /** Add include regex to context */ + public ApiResponse includeInContext(String contextname, String regex) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("regex", regex); + return api.callApi("context", "action", "includeInContext", map); + } + + /** Set the regexs to include and exclude for a context, both supplied as JSON string arrays */ + public ApiResponse setContextRegexs(String contextname, String incregexs, String excregexs) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("incRegexs", incregexs); + map.put("excRegexs", excregexs); + return api.callApi("context", "action", "setContextRegexs", map); + } + + /** + * Set the checking strategy for a context - this defines how ZAP checks that a request is + * authenticated + */ + public ApiResponse setContextCheckingStrategy( + String contextname, + String checkingstrategy, + String pollurl, + String polldata, + String pollheaders, + String pollfrequency, + String pollfrequencyunits) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("checkingStrategy", checkingstrategy); + if (pollurl != null) { + map.put("pollUrl", pollurl); + } + if (polldata != null) { + map.put("pollData", polldata); + } + if (pollheaders != null) { + map.put("pollHeaders", pollheaders); + } + if (pollfrequency != null) { + map.put("pollFrequency", pollfrequency); + } + if (pollfrequencyunits != null) { + map.put("pollFrequencyUnits", pollfrequencyunits); + } + return api.callApi("context", "action", "setContextCheckingStrategy", map); + } + + /** Creates a new context with the given name in the current session */ + public ApiResponse newContext(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "action", "newContext", map); + } + + /** Removes a context in the current session */ + public ApiResponse removeContext(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "action", "removeContext", map); + } + + /** + * 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. + */ + public ApiResponse exportContext(String contextname, String contextfile) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("contextFile", contextfile); + return api.callApi("context", "action", "exportContext", map); + } + + /** + * 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. + */ + public ApiResponse importContext(String contextfile) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextFile", contextfile); + return api.callApi("context", "action", "importContext", map); + } + + /** Includes technologies with the given names, separated by a comma, to a context */ + public ApiResponse includeContextTechnologies(String contextname, String technologynames) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("technologyNames", technologynames); + return api.callApi("context", "action", "includeContextTechnologies", map); + } + + /** Includes all built in technologies in to a context */ + public ApiResponse includeAllContextTechnologies(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "action", "includeAllContextTechnologies", map); + } + + /** Excludes technologies with the given names, separated by a comma, from a context */ + public ApiResponse excludeContextTechnologies(String contextname, String technologynames) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("technologyNames", technologynames); + return api.callApi("context", "action", "excludeContextTechnologies", map); + } + + /** Excludes all built in technologies from a context */ + public ApiResponse excludeAllContextTechnologies(String contextname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + return api.callApi("context", "action", "excludeAllContextTechnologies", map); + } + + /** Sets a context to in scope (contexts are in scope by default) */ + public ApiResponse setContextInScope(String contextname, String booleaninscope) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextName", contextname); + map.put("booleanInScope", booleaninscope); + return api.callApi("context", "action", "setContextInScope", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Core.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Core.java index 22186a4..179958a 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Core.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Core.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,649 +25,1010 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Core { - - private ClientApi api = null; - - public Core(ClientApi api) { - this.api = api; - } - - /** - * Gets the alert with the given ID, the corresponding HTTP message can be obtained with the 'messageId' field and 'message' API method - */ - public ApiResponse alert(String id) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("id", id); - return api.callApi("core", "view", "alert", map); - } - - /** - * Gets the alerts raised by ZAP, optionally filtering by URL and paginating with 'start' position and 'count' of alerts - */ - public ApiResponse alerts(String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("core", "view", "alerts", map); - } - - /** - * Gets the number of alerts, optionally filtering by URL - */ - public ApiResponse numberOfAlerts(String baseurl) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - return api.callApi("core", "view", "numberOfAlerts", map); - } - - /** - * Gets the name of the hosts accessed through/by ZAP - */ - public ApiResponse hosts() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "hosts", map); - } - - /** - * Gets the sites accessed through/by ZAP (scheme and domain) - */ - public ApiResponse sites() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "sites", map); - } - - /** - * Gets the URLs accessed through/by ZAP - */ - public ApiResponse urls() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "urls", map); - } - - /** - * Gets the HTTP message with the given ID. Returns the ID, request/response headers and bodies, cookies and note. - */ - public ApiResponse message(String id) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("id", id); - return api.callApi("core", "view", "message", map); - } - - /** - * Gets the HTTP messages sent by ZAP, request and response, optionally filtered by URL and paginated with 'start' position and 'count' of messages - */ - public ApiResponse messages(String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("core", "view", "messages", map); - } - - /** - * Gets the number of messages, optionally filtering by URL - */ - public ApiResponse numberOfMessages(String baseurl) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - return api.callApi("core", "view", "numberOfMessages", map); - } - - /** - * Gets the mode - */ - public ApiResponse mode() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "mode", map); - } - - /** - * Gets ZAP version - */ - public ApiResponse version() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "version", map); - } - - /** - * Gets the regular expressions, applied to URLs, to exclude from the Proxy - */ - public ApiResponse excludedFromProxy() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "excludedFromProxy", map); - } - - public ApiResponse homeDirectory() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "homeDirectory", map); - } - - public ApiResponse optionDefaultUserAgent() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionDefaultUserAgent", map); - } - - public ApiResponse optionHttpState() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionHttpState", map); - } - - public ApiResponse optionProxyChainName() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyChainName", map); - } - - public ApiResponse optionProxyChainPassword() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyChainPassword", map); - } - - public ApiResponse optionProxyChainPort() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyChainPort", map); - } - - public ApiResponse optionProxyChainRealm() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyChainRealm", map); - } - - public ApiResponse optionProxyChainSkipName() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyChainSkipName", map); - } - - public ApiResponse optionProxyChainUserName() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyChainUserName", map); - } - - public ApiResponse optionProxyExcludedDomains() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyExcludedDomains", map); - } - - public ApiResponse optionProxyExcludedDomainsEnabled() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyExcludedDomainsEnabled", map); - } - - public ApiResponse optionTimeoutInSecs() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionTimeoutInSecs", map); - } - - public ApiResponse optionHttpStateEnabled() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionHttpStateEnabled", map); - } - - public ApiResponse optionProxyChainPrompt() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionProxyChainPrompt", map); - } - - public ApiResponse optionSingleCookieRequestHeader() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionSingleCookieRequestHeader", map); - } - - public ApiResponse optionUseProxyChain() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionUseProxyChain", map); - } - - public ApiResponse optionUseProxyChainAuth() throws ClientApiException { - Map map = null; - return api.callApi("core", "view", "optionUseProxyChainAuth", map); - } - - /** - * Convenient and simple action to access a URL, optionally following redirections. Returns the request sent and response received and followed redirections, if any. Other actions are available which offer more control on what is sent, like, 'sendRequest' or 'sendHarRequest'. - */ - public ApiResponse accessUrl(String apikey, String url, String followredirects) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("url", url); - if (followredirects != null) { - map.put("followRedirects", followredirects); - } - return api.callApi("core", "action", "accessUrl", map); - } - - /** - * Shuts down ZAP - */ - public ApiResponse shutdown(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("core", "action", "shutdown", map); - } - - /** - * Creates a new session, optionally overwriting existing files. If a relative path is specified it will be resolved against the "session" directory in ZAP "home" dir. - */ - public ApiResponse newSession(String apikey, String name, String overwrite) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (name != null) { - map.put("name", name); - } - if (overwrite != null) { - map.put("overwrite", overwrite); - } - return api.callApi("core", "action", "newSession", map); - } - - /** - * Loads the session with the given name. If a relative path is specified it will be resolved against the "session" directory in ZAP "home" dir. - */ - public ApiResponse loadSession(String apikey, String name) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("name", name); - return api.callApi("core", "action", "loadSession", map); - } - - /** - * Saves the session with the name supplied, optionally overwriting existing files. If a relative path is specified it will be resolved against the "session" directory in ZAP "home" dir. - */ - public ApiResponse saveSession(String apikey, String name, String overwrite) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("name", name); - if (overwrite != null) { - map.put("overwrite", overwrite); - } - return api.callApi("core", "action", "saveSession", map); - } - - public ApiResponse snapshotSession(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("core", "action", "snapshotSession", map); - } - - public ApiResponse clearExcludedFromProxy(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("core", "action", "clearExcludedFromProxy", map); - } - - public ApiResponse excludeFromProxy(String apikey, String regex) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("regex", regex); - return api.callApi("core", "action", "excludeFromProxy", map); - } - - public ApiResponse setHomeDirectory(String apikey, String dir) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("dir", dir); - return api.callApi("core", "action", "setHomeDirectory", map); - } - - /** - * Sets the mode, which may be one of [safe, protect, standard, attack] - */ - public ApiResponse setMode(String apikey, String mode) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("mode", mode); - return api.callApi("core", "action", "setMode", map); - } - - public ApiResponse generateRootCA(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("core", "action", "generateRootCA", map); - } - - /** - * Sends the HTTP request, optionally following redirections. Returns the request sent and response received and followed redirections, if any. - */ - public ApiResponse sendRequest(String apikey, String request, String followredirects) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("request", request); - if (followredirects != null) { - map.put("followRedirects", followredirects); - } - return api.callApi("core", "action", "sendRequest", map); - } - - public ApiResponse deleteAllAlerts(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("core", "action", "deleteAllAlerts", map); - } - - public ApiResponse runGarbageCollection(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("core", "action", "runGarbageCollection", map); - } - - /** - * Deletes the site node found in the Sites Tree on the basis of the URL, HTTP method, and post data (if applicable and specified). - */ - public ApiResponse deleteSiteNode(String apikey, String url, String method, String postdata) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("url", url); - if (method != null) { - map.put("method", method); - } - if (postdata != null) { - map.put("postData", postdata); - } - return api.callApi("core", "action", "deleteSiteNode", map); - } - - public ApiResponse setOptionDefaultUserAgent(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("core", "action", "setOptionDefaultUserAgent", map); - } - - public ApiResponse setOptionProxyChainName(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("core", "action", "setOptionProxyChainName", map); - } - - public ApiResponse setOptionProxyChainPassword(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("core", "action", "setOptionProxyChainPassword", map); - } - - public ApiResponse setOptionProxyChainRealm(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("core", "action", "setOptionProxyChainRealm", map); - } - - public ApiResponse setOptionProxyChainSkipName(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("core", "action", "setOptionProxyChainSkipName", map); - } - - public ApiResponse setOptionProxyChainUserName(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("core", "action", "setOptionProxyChainUserName", map); - } - - public ApiResponse setOptionHttpStateEnabled(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("core", "action", "setOptionHttpStateEnabled", map); - } - - public ApiResponse setOptionProxyChainPort(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("core", "action", "setOptionProxyChainPort", map); - } - - public ApiResponse setOptionProxyChainPrompt(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("core", "action", "setOptionProxyChainPrompt", map); - } - - public ApiResponse setOptionSingleCookieRequestHeader(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("core", "action", "setOptionSingleCookieRequestHeader", map); - } - - public ApiResponse setOptionTimeoutInSecs(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("core", "action", "setOptionTimeoutInSecs", map); - } - - public ApiResponse setOptionUseProxyChain(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("core", "action", "setOptionUseProxyChain", map); - } - - public ApiResponse setOptionUseProxyChainAuth(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("core", "action", "setOptionUseProxyChainAuth", map); - } - - public byte[] proxypac(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApiOther("core", "other", "proxy.pac", map); - } - - public byte[] rootcert(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApiOther("core", "other", "rootcert", map); - } - - public byte[] setproxy(String apikey, String proxy) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("proxy", proxy); - return api.callApiOther("core", "other", "setproxy", map); - } - - /** - * Generates a report in XML format - */ - public byte[] xmlreport(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApiOther("core", "other", "xmlreport", map); - } - - /** - * Generates a report in HTML format - */ - public byte[] htmlreport(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApiOther("core", "other", "htmlreport", map); - } - - /** - * Gets the message with the given ID in HAR format - */ - public byte[] messageHar(String apikey, String id) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - return api.callApiOther("core", "other", "messageHar", map); - } - - /** - * Gets the HTTP messages sent through/by ZAP, in HAR format, optionally filtered by URL and paginated with 'start' position and 'count' of messages - */ - public byte[] messagesHar(String apikey, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApiOther("core", "other", "messagesHar", map); - } - - /** - * Sends the first HAR request entry, optionally following redirections. Returns, in HAR format, the request sent and response received and followed redirections, if any. - */ - public byte[] sendHarRequest(String apikey, String request, String followredirects) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("request", request); - if (followredirects != null) { - map.put("followRedirects", followredirects); - } - return api.callApiOther("core", "other", "sendHarRequest", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Core extends org.zaproxy.clientapi.gen.deprecated.CoreDeprecated { + + private final ClientApi api; + + public Core(ClientApi api) { + super(api); + this.api = api; + } + + /** Gets the name of the hosts accessed through/by ZAP */ + public ApiResponse hosts() throws ClientApiException { + return api.callApi("core", "view", "hosts", null); + } + + /** Gets the sites accessed through/by ZAP (scheme and domain) */ + public ApiResponse sites() throws ClientApiException { + return api.callApi("core", "view", "sites", null); + } + + /** Gets the URLs accessed through/by ZAP, optionally filtering by (base) URL. */ + public ApiResponse urls(String baseurl) throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + return api.callApi("core", "view", "urls", map); + } + + /** Gets the child nodes underneath the specified URL in the Sites tree */ + public ApiResponse childNodes(String url) throws ClientApiException { + Map map = new HashMap<>(); + if (url != null) { + map.put("url", url); + } + return api.callApi("core", "view", "childNodes", map); + } + + /** + * Gets the HTTP message with the given ID. Returns the ID, request/response headers and bodies, + * cookies, note, type, RTT, and timestamp. + */ + public ApiResponse message(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("core", "view", "message", map); + } + + /** + * Gets the HTTP messages sent by ZAP, request and response, optionally filtered by URL and + * paginated with 'start' position and 'count' of messages + */ + public ApiResponse messages(String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("core", "view", "messages", map); + } + + /** Gets the HTTP messages with the given IDs. */ + public ApiResponse messagesById(String ids) throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + return api.callApi("core", "view", "messagesById", map); + } + + /** Gets the number of messages, optionally filtering by URL */ + public ApiResponse numberOfMessages(String baseurl) throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + return api.callApi("core", "view", "numberOfMessages", map); + } + + /** Gets the mode */ + public ApiResponse mode() throws ClientApiException { + return api.callApi("core", "view", "mode", null); + } + + /** Gets ZAP version */ + public ApiResponse version() throws ClientApiException { + return api.callApi("core", "view", "version", null); + } + + /** Gets the regular expressions, applied to URLs, to exclude from the local proxies. */ + public ApiResponse excludedFromProxy() throws ClientApiException { + return api.callApi("core", "view", "excludedFromProxy", null); + } + + /** Gets the location of the current session file */ + public ApiResponse sessionLocation() throws ClientApiException { + return api.callApi("core", "view", "sessionLocation", null); + } + + /** + * Gets all the domains that are excluded from the outgoing proxy. For each domain the following + * are shown: the index, the value (domain), if enabled, and if specified as a regex. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse proxyChainExcludedDomains() throws ClientApiException { + return api.callApi("core", "view", "proxyChainExcludedDomains", null); + } + + /** Gets the path to ZAP's home directory. */ + public ApiResponse zapHomePath() throws ClientApiException { + return api.callApi("core", "view", "zapHomePath", null); + } + + /** Gets the maximum number of alert instances to include in a report. */ + public ApiResponse optionMaximumAlertInstances() throws ClientApiException { + return api.callApi("core", "view", "optionMaximumAlertInstances", null); + } + + /** Gets whether or not related alerts will be merged in any reports generated. */ + public ApiResponse optionMergeRelatedAlerts() throws ClientApiException { + return api.callApi("core", "view", "optionMergeRelatedAlerts", null); + } + + /** Gets the path to the file with alert overrides. */ + public ApiResponse optionAlertOverridesFilePath() throws ClientApiException { + return api.callApi("core", "view", "optionAlertOverridesFilePath", null); + } + + /** + * @deprecated + */ + @Deprecated + public ApiResponse homeDirectory() throws ClientApiException { + return api.callApi("core", "view", "homeDirectory", null); + } + + /** + * Use view proxyChainExcludedDomains instead. + * + * @deprecated + */ + @Deprecated + public ApiResponse optionProxyChainSkipName() throws ClientApiException { + return api.callApi("core", "view", "optionProxyChainSkipName", null); + } + + /** + * Use view proxyChainExcludedDomains instead. + * + * @deprecated + */ + @Deprecated + public ApiResponse optionProxyExcludedDomains() throws ClientApiException { + return api.callApi("core", "view", "optionProxyExcludedDomains", null); + } + + /** + * Use view proxyChainExcludedDomains instead. + * + * @deprecated + */ + @Deprecated + public ApiResponse optionProxyExcludedDomainsEnabled() throws ClientApiException { + return api.callApi("core", "view", "optionProxyExcludedDomainsEnabled", null); + } + + /** + * Gets the alert with the given ID, the corresponding HTTP message can be obtained with the + * 'messageId' field and 'message' API method + * + * @deprecated Use the API endpoint with the same name in the 'alert' component instead. + */ + @Deprecated + public ApiResponse alert(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("core", "view", "alert", map); + } + + /** + * Gets the alerts raised by ZAP, optionally filtering by URL or riskId, and paginating with + * 'start' position and 'count' of alerts + * + * @deprecated Use the API endpoint with the same name in the 'alert' component instead. + */ + @Deprecated + public ApiResponse alerts(String baseurl, String start, String count, String riskid) + throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + if (riskid != null) { + map.put("riskId", riskid); + } + return api.callApi("core", "view", "alerts", map); + } + + /** + * Gets number of alerts grouped by each risk level, optionally filtering by URL + * + * @deprecated Use the API endpoint with the same name in the 'alert' component instead. + */ + @Deprecated + public ApiResponse alertsSummary(String baseurl) throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + return api.callApi("core", "view", "alertsSummary", map); + } + + /** + * Gets the number of alerts, optionally filtering by URL or riskId + * + * @deprecated Use the API endpoint with the same name in the 'alert' component instead. + */ + @Deprecated + public ApiResponse numberOfAlerts(String baseurl, String riskid) throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (riskid != null) { + map.put("riskId", riskid); + } + return api.callApi("core", "view", "numberOfAlerts", map); + } + + /** The detailed logging config, optionally filtered based on a name (ex: starts with). */ + public ApiResponse getLogLevel(String name) throws ClientApiException { + Map map = new HashMap<>(); + if (name != null) { + map.put("name", name); + } + return api.callApi("core", "view", "getLogLevel", map); + } + + /** + * Gets the user agent that ZAP should use when creating HTTP messages (for example, spider + * messages or CONNECT requests to outgoing proxy). + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionDefaultUserAgent() throws ClientApiException { + return api.callApi("core", "view", "optionDefaultUserAgent", null); + } + + /** + * Gets the TTL (in seconds) of successful DNS queries. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionDnsTtlSuccessfulQueries() throws ClientApiException { + return api.callApi("core", "view", "optionDnsTtlSuccessfulQueries", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionHttpState() throws ClientApiException { + return api.callApi("core", "view", "optionHttpState", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionHttpStateEnabled() throws ClientApiException { + return api.callApi("core", "view", "optionHttpStateEnabled", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionProxyChainName() throws ClientApiException { + return api.callApi("core", "view", "optionProxyChainName", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionProxyChainPassword() throws ClientApiException { + return api.callApi("core", "view", "optionProxyChainPassword", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionProxyChainPort() throws ClientApiException { + return api.callApi("core", "view", "optionProxyChainPort", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionProxyChainPrompt() throws ClientApiException { + return api.callApi("core", "view", "optionProxyChainPrompt", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionProxyChainRealm() throws ClientApiException { + return api.callApi("core", "view", "optionProxyChainRealm", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionProxyChainUserName() throws ClientApiException { + return api.callApi("core", "view", "optionProxyChainUserName", null); + } + + /** + * @deprecated Option no longer in effective use. + */ + @Deprecated + public ApiResponse optionSingleCookieRequestHeader() throws ClientApiException { + return api.callApi("core", "view", "optionSingleCookieRequestHeader", null); + } + + /** + * Gets the connection time out (in seconds). + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionTimeoutInSecs() throws ClientApiException { + return api.callApi("core", "view", "optionTimeoutInSecs", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionUseProxyChain() throws ClientApiException { + return api.callApi("core", "view", "optionUseProxyChain", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionUseProxyChainAuth() throws ClientApiException { + return api.callApi("core", "view", "optionUseProxyChainAuth", null); + } + + /** + * Gets whether or not the SOCKS proxy should be used. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse optionUseSocksProxy() throws ClientApiException { + return api.callApi("core", "view", "optionUseSocksProxy", null); + } + + /** + * Convenient and simple action to access a URL, optionally following redirections. Returns the + * request sent and response received and followed redirections, if any. Other actions are + * available which offer more control on what is sent, like, 'sendRequest' or 'sendHarRequest'. + */ + public ApiResponse accessUrl(String url, String followredirects) throws ClientApiException { + Map map = new HashMap<>(); + map.put("url", url); + if (followredirects != null) { + map.put("followRedirects", followredirects); + } + return api.callApi("core", "action", "accessUrl", map); + } + + /** Shuts down ZAP */ + public ApiResponse shutdown() throws ClientApiException { + return api.callApi("core", "action", "shutdown", null); + } + + /** + * Creates a new session, optionally overwriting existing files. If a relative path is specified + * it will be resolved against the "session" directory in ZAP "home" dir. + */ + public ApiResponse newSession(String name, String overwrite) throws ClientApiException { + Map map = new HashMap<>(); + if (name != null) { + map.put("name", name); + } + if (overwrite != null) { + map.put("overwrite", overwrite); + } + return api.callApi("core", "action", "newSession", map); + } + + /** + * Loads the session with the given name. If a relative path is specified it will be resolved + * against the "session" directory in ZAP "home" dir. + */ + public ApiResponse loadSession(String name) throws ClientApiException { + Map map = new HashMap<>(); + map.put("name", name); + return api.callApi("core", "action", "loadSession", map); + } + + /** Saves the session. */ + public ApiResponse saveSession(String name, String overwrite) throws ClientApiException { + Map map = new HashMap<>(); + map.put("name", name); + if (overwrite != null) { + map.put("overwrite", overwrite); + } + return api.callApi("core", "action", "saveSession", map); + } + + /** + * Snapshots the session, optionally with the given name, and overwriting existing files. If no + * name is specified the name of the current session with a timestamp appended is used. If a + * relative path is specified it will be resolved against the "session" directory in ZAP "home" + * dir. + */ + public ApiResponse snapshotSession(String name, String overwrite) throws ClientApiException { + Map map = new HashMap<>(); + if (name != null) { + map.put("name", name); + } + if (overwrite != null) { + map.put("overwrite", overwrite); + } + return api.callApi("core", "action", "snapshotSession", map); + } + + /** Clears the regexes of URLs excluded from the local proxies. */ + public ApiResponse clearExcludedFromProxy() throws ClientApiException { + return api.callApi("core", "action", "clearExcludedFromProxy", null); + } + + /** Adds a regex of URLs that should be excluded from the local proxies. */ + public ApiResponse excludeFromProxy(String regex) throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + return api.callApi("core", "action", "excludeFromProxy", map); + } + + public ApiResponse setHomeDirectory(String dir) throws ClientApiException { + Map map = new HashMap<>(); + map.put("dir", dir); + return api.callApi("core", "action", "setHomeDirectory", map); + } + + /** Sets the mode, which may be one of [safe, protect, standard, attack] */ + public ApiResponse setMode(String mode) throws ClientApiException { + Map map = new HashMap<>(); + map.put("mode", mode); + return api.callApi("core", "action", "setMode", map); + } + + /** + * Generates a new Root CA certificate for the local proxies. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse generateRootCA() throws ClientApiException { + return api.callApi("core", "action", "generateRootCA", null); + } + + /** + * Sends the HTTP request, optionally following redirections. Returns the request sent and + * response received and followed redirections, if any. The Mode is enforced when sending the + * request (and following redirections), custom manual requests are not allowed in 'Safe' mode + * nor in 'Protected' mode if out of scope. + */ + public ApiResponse sendRequest(String request, String followredirects) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("request", request); + if (followredirects != null) { + map.put("followRedirects", followredirects); + } + return api.callApi("core", "action", "sendRequest", map); + } + + public ApiResponse runGarbageCollection() throws ClientApiException { + return api.callApi("core", "action", "runGarbageCollection", null); + } + + /** + * Deletes the site node found in the Sites Tree on the basis of the URL, HTTP method, and post + * data (if applicable and specified). + */ + public ApiResponse deleteSiteNode(String url, String method, String postdata) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("url", url); + if (method != null) { + map.put("method", method); + } + if (postdata != null) { + map.put("postData", postdata); + } + return api.callApi("core", "action", "deleteSiteNode", map); + } + + /** + * Adds a domain to be excluded from the outgoing proxy, 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). + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse addProxyChainExcludedDomain(String value, String isregex, String isenabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("value", value); + if (isregex != null) { + map.put("isRegex", isregex); + } + if (isenabled != null) { + map.put("isEnabled", isenabled); + } + return api.callApi("core", "action", "addProxyChainExcludedDomain", map); + } + + /** + * Modifies a domain excluded from the outgoing proxy. 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 + * proxyChainExcludedDomains. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse modifyProxyChainExcludedDomain( + String idx, String value, String isregex, String isenabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("idx", idx); + if (value != null) { + map.put("value", value); + } + if (isregex != null) { + map.put("isRegex", isregex); + } + if (isenabled != null) { + map.put("isEnabled", isenabled); + } + return api.callApi("core", "action", "modifyProxyChainExcludedDomain", map); + } + + /** + * Removes a domain excluded from the outgoing proxy, with the given index. The index can be + * obtained with the view proxyChainExcludedDomains. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse removeProxyChainExcludedDomain(String idx) throws ClientApiException { + Map map = new HashMap<>(); + map.put("idx", idx); + return api.callApi("core", "action", "removeProxyChainExcludedDomain", map); + } + + /** + * Enables all domains excluded from the outgoing proxy. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse enableAllProxyChainExcludedDomains() throws ClientApiException { + return api.callApi("core", "action", "enableAllProxyChainExcludedDomains", null); + } + + /** + * Disables all domains excluded from the outgoing proxy. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse disableAllProxyChainExcludedDomains() throws ClientApiException { + return api.callApi("core", "action", "disableAllProxyChainExcludedDomains", null); + } + + /** + * Sets the maximum number of alert instances to include in a report. A value of zero is treated + * as unlimited. + */ + public ApiResponse setOptionMaximumAlertInstances(String numberofinstances) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("numberOfInstances", numberofinstances); + return api.callApi("core", "action", "setOptionMaximumAlertInstances", map); + } + + /** Sets whether or not related alerts will be merged in any reports generated. */ + public ApiResponse setOptionMergeRelatedAlerts(String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("enabled", enabled); + return api.callApi("core", "action", "setOptionMergeRelatedAlerts", map); + } + + /** Sets (or clears, if empty) the path to the file with alert overrides. */ + public ApiResponse setOptionAlertOverridesFilePath(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + if (filepath != null) { + map.put("filePath", filepath); + } + return api.callApi("core", "action", "setOptionAlertOverridesFilePath", map); + } + + /** + * Enables use of a PKCS12 client certificate for the certificate with the given file system + * path, password, and optional index. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse enablePKCS12ClientCertificate(String filepath, String password, String index) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + map.put("password", password); + if (index != null) { + map.put("index", index); + } + return api.callApi("core", "action", "enablePKCS12ClientCertificate", map); + } + + /** + * Disables the option for use of client certificates. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse disableClientCertificate() throws ClientApiException { + return api.callApi("core", "action", "disableClientCertificate", null); + } + + /** Create a zip file of the ZAP core and add-on SBOMs */ + public ApiResponse createSbomZip(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("core", "action", "createSbomZip", map); + } + + /** + * Deletes all alerts of the current session. + * + * @deprecated Use the API endpoint with the same name in the 'alert' component instead. + */ + @Deprecated + public ApiResponse deleteAllAlerts() throws ClientApiException { + return api.callApi("core", "action", "deleteAllAlerts", null); + } + + /** + * Deletes the alert with the given ID. + * + * @deprecated Use the API endpoint with the same name in the 'alert' component instead. + */ + @Deprecated + public ApiResponse deleteAlert(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("core", "action", "deleteAlert", map); + } + + /** Sets the logging level for a given logger name. */ + public ApiResponse setLogLevel(String name, String loglevel) throws ClientApiException { + Map map = new HashMap<>(); + map.put("name", name); + map.put("logLevel", loglevel); + return api.callApi("core", "action", "setLogLevel", map); + } + + /** + * Sets the user agent that ZAP should use when creating HTTP messages (for example, spider + * messages or CONNECT requests to outgoing proxy). + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionDefaultUserAgent(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("core", "action", "setOptionDefaultUserAgent", map); + } + + /** + * Sets the TTL (in seconds) of successful DNS queries (applies after ZAP restart). + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionDnsTtlSuccessfulQueries(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("core", "action", "setOptionDnsTtlSuccessfulQueries", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionHttpStateEnabled(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionHttpStateEnabled", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionProxyChainName(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainName", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionProxyChainPassword(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainPassword", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionProxyChainPort(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("core", "action", "setOptionProxyChainPort", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionProxyChainPrompt(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionProxyChainPrompt", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionProxyChainRealm(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainRealm", map); + } + + /** + * Use actions [add|modify|remove]ProxyChainExcludedDomain instead. + * + * @deprecated Option no longer in effective use. + */ + @Deprecated + public ApiResponse setOptionProxyChainSkipName(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainSkipName", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionProxyChainUserName(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainUserName", map); + } + + /** + * @deprecated Option no longer in effective use. + */ + @Deprecated + public ApiResponse setOptionSingleCookieRequestHeader(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionSingleCookieRequestHeader", map); + } + + /** + * Sets the connection time out (in seconds). + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionTimeoutInSecs(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("core", "action", "setOptionTimeoutInSecs", map); + } + + /** + * Sets whether or not the outgoing proxy should be used. The address/hostname of the outgoing + * proxy must be set to enable this option. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionUseProxyChain(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionUseProxyChain", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionUseProxyChainAuth(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionUseProxyChainAuth", map); + } + + /** + * Sets whether or not the SOCKS proxy should be used. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public ApiResponse setOptionUseSocksProxy(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionUseSocksProxy", map); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public byte[] proxypac() throws ClientApiException { + return api.callApiOther("core", "other", "proxy.pac", null); + } + + /** + * Gets the Root CA certificate used by the local proxies. + * + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public byte[] rootcert() throws ClientApiException { + return api.callApiOther("core", "other", "rootcert", null); + } + + /** + * @deprecated Use the API endpoints in the 'network' component instead. + */ + @Deprecated + public byte[] setproxy(String proxy) throws ClientApiException { + Map map = new HashMap<>(); + map.put("proxy", proxy); + return api.callApiOther("core", "other", "setproxy", map); + } + + /** + * Generates a report in XML format + * + * @deprecated Use the 'generate' API endpoint the 'reports' component instead. + */ + @Deprecated + public byte[] xmlreport() throws ClientApiException { + return api.callApiOther("core", "other", "xmlreport", null); + } + + /** + * Generates a report in HTML format + * + * @deprecated Use the 'generate' API endpoint the 'reports' component instead. + */ + @Deprecated + public byte[] htmlreport() throws ClientApiException { + return api.callApiOther("core", "other", "htmlreport", null); + } + + /** + * Generates a report in JSON format + * + * @deprecated Use the 'generate' API endpoint the 'reports' component instead. + */ + @Deprecated + public byte[] jsonreport() throws ClientApiException { + return api.callApiOther("core", "other", "jsonreport", null); + } + + /** + * Generates a report in Markdown format + * + * @deprecated Use the 'generate' API endpoint the 'reports' component instead. + */ + @Deprecated + public byte[] mdreport() throws ClientApiException { + return api.callApiOther("core", "other", "mdreport", null); + } + + /** + * Gets the message with the given ID in HAR format + * + * @deprecated Use the API endpoints in the 'exim' add-on instead. + */ + @Deprecated + public byte[] messageHar(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApiOther("core", "other", "messageHar", map); + } + + /** + * Gets the HTTP messages sent through/by ZAP, in HAR format, optionally filtered by URL and + * paginated with 'start' position and 'count' of messages + * + * @deprecated Use the API endpoints in the 'exim' add-on instead. + */ + @Deprecated + public byte[] messagesHar(String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("core", "other", "messagesHar", map); + } + + /** + * Gets the HTTP messages with the given IDs, in HAR format. + * + * @deprecated Use the API endpoints in the 'exim' add-on instead. + */ + @Deprecated + public byte[] messagesHarById(String ids) throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + return api.callApiOther("core", "other", "messagesHarById", map); + } + + /** + * Sends the first HAR request entry, optionally following redirections. Returns, in HAR format, + * the request sent and response received and followed redirections, if any. The Mode is + * enforced when sending the request (and following redirections), custom manual requests are + * not allowed in 'Safe' mode nor in 'Protected' mode if out of scope. + * + * @deprecated Use the API endpoints in the 'exim' add-on instead. + */ + @Deprecated + public byte[] sendHarRequest(String request, String followredirects) throws ClientApiException { + Map map = new HashMap<>(); + map.put("request", request); + if (followredirects != null) { + map.put("followRedirects", followredirects); + } + return api.callApiOther("core", "other", "sendHarRequest", map); + } + + /** Download a file from the transfer directory */ + public byte[] fileDownload(String filename) throws ClientApiException { + Map map = new HashMap<>(); + map.put("fileName", filename); + return api.callApiOther("core", "other", "fileDownload", map); + } + + /** + * Upload a file to the transfer directory. Only POST requests accepted with encodings of + * "multipart/form-data" or "application/x-www-form-urlencoded". + */ + public byte[] fileUpload(String filename, String filecontents) throws ClientApiException { + Map map = new HashMap<>(); + map.put("fileName", filename); + map.put("fileContents", filecontents); + return api.callApiOther("POST", "core", "other", "fileUpload", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Custompayloads.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Custompayloads.java new file mode 100644 index 0000000..b57e5b5 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Custompayloads.java @@ -0,0 +1,145 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2023 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Custompayloads { + + private final ClientApi api; + + public Custompayloads(ClientApi api) { + this.api = api; + } + + /** + * Lists all available categories. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse customPayloadsCategories() throws ClientApiException { + return api.callApi("custompayloads", "view", "customPayloadsCategories", null); + } + + /** + * Lists all the payloads currently loaded (category, payload, enabled state). Optionally + * filtered by category. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse customPayloads(String category) throws ClientApiException { + Map map = new HashMap<>(); + if (category != null) { + map.put("category", category); + } + return api.callApi("custompayloads", "view", "customPayloads", map); + } + + /** + * Disables payloads for a given category. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse disableCustomPayloads(String category) throws ClientApiException { + Map map = new HashMap<>(); + if (category != null) { + map.put("category", category); + } + return api.callApi("custompayloads", "action", "disableCustomPayloads", map); + } + + /** + * Enables payloads for a given category. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse enableCustomPayloads(String category) throws ClientApiException { + Map map = new HashMap<>(); + if (category != null) { + map.put("category", category); + } + return api.callApi("custompayloads", "action", "enableCustomPayloads", map); + } + + /** + * Removes a payload. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeCustomPayload(String category, String payload) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("category", category); + if (payload != null) { + map.put("payload", payload); + } + return api.callApi("custompayloads", "action", "removeCustomPayload", map); + } + + /** + * Adds a new payload. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addCustomPayload(String category, String payload) throws ClientApiException { + Map map = new HashMap<>(); + map.put("category", category); + if (payload != null) { + map.put("payload", payload); + } + return api.callApi("custompayloads", "action", "addCustomPayload", map); + } + + /** + * Enables a given payload. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse enableCustomPayload(String category, String payload) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("category", category); + if (payload != null) { + map.put("payload", payload); + } + return api.callApi("custompayloads", "action", "enableCustomPayload", map); + } + + /** + * Disables a given payload. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse disableCustomPayload(String category, String payload) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("category", category); + if (payload != null) { + map.put("payload", payload); + } + return api.callApi("custompayloads", "action", "disableCustomPayload", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Exim.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Exim.java new file mode 100644 index 0000000..0e7e965 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Exim.java @@ -0,0 +1,151 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2022 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Exim { + + private final ClientApi api; + + public Exim(ClientApi api) { + this.api = api; + } + + /** + * Imports a HAR file. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importHar(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("exim", "action", "importHar", map); + } + + /** + * Imports URLs (one per line) from the file with the given file system path. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importUrls(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("exim", "action", "importUrls", map); + } + + /** + * Imports previously exported ZAP messages from the file with the given file system path. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importZapLogs(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("exim", "action", "importZapLogs", map); + } + + /** + * Imports ModSecurity2 logs from the file with the given file system path. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importModsec2Logs(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("exim", "action", "importModsec2Logs", map); + } + + /** + * Exports the Sites Tree in the Sites Tree YAML format. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse exportSitesTree(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("exim", "action", "exportSitesTree", map); + } + + /** + * Prunes the Sites Tree based on a file in the Sites Tree YAML format. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse pruneSitesTree(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("exim", "action", "pruneSitesTree", map); + } + + /** + * Gets the HTTP messages sent through/by ZAP, in HAR format, optionally filtered by URL and + * paginated with 'start' position and 'count' of messages + * + *

This component is optional and therefore the API will only work if it is installed + */ + public byte[] exportHar(String baseurl, String start, String count) throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("exim", "other", "exportHar", map); + } + + /** + * Gets the HTTP messages with the given IDs, in HAR format. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public byte[] exportHarById(String ids) throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + return api.callApiOther("exim", "other", "exportHarById", map); + } + + /** + * Sends the first HAR request entry, optionally following redirections. Returns, in HAR format, + * the request sent and response received and followed redirections, if any. The Mode is + * enforced when sending the request (and following redirections), custom manual requests are + * not allowed in 'Safe' mode nor in 'Protected' mode if out of scope. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public byte[] sendHarRequest(String request, String followredirects) throws ClientApiException { + Map map = new HashMap<>(); + map.put("request", request); + if (followredirects != null) { + map.put("followRedirects", followredirects); + } + return api.callApiOther("exim", "other", "sendHarRequest", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Exportreport.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Exportreport.java new file mode 100644 index 0000000..21058f4 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Exportreport.java @@ -0,0 +1,68 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2020 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +@Deprecated(since = "1.13.0", forRemoval = true) +public class Exportreport { + + private final ClientApi api; + + public Exportreport(ClientApi api) { + this.api = api; + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse formats() throws ClientApiException { + return api.callApi("exportreport", "view", "formats", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse generate( + String absolutepath, + String fileextension, + String sourcedetails, + String alertseverity, + String alertdetails, + String scanid, + String includepassivealerts) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("absolutePath", absolutepath); + map.put("fileExtension", fileextension); + map.put("sourceDetails", sourcedetails); + map.put("alertSeverity", alertseverity); + map.put("alertDetails", alertdetails); + if (scanid != null) { + map.put("scanId", scanid); + } + if (includepassivealerts != null) { + map.put("includePassiveAlerts", includepassivealerts); + } + return api.callApi("exportreport", "action", "generate", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ForcedUser.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ForcedUser.java index 7e404fd..e91f5ca 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ForcedUser.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ForcedUser.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,61 +25,41 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class ForcedUser extends org.zaproxy.clientapi.gen.deprecated.ForcedUserDeprecated { -/** - * This file was automatically generated. - */ -public class ForcedUser { - - private ClientApi api = null; - - public ForcedUser(ClientApi api) { - this.api = api; - } + private final ClientApi api; - /** - * Returns 'true' if 'forced user' mode is enabled, 'false' otherwise - */ - public ApiResponse isForcedUserModeEnabled() throws ClientApiException { - Map map = null; - return api.callApi("forcedUser", "view", "isForcedUserModeEnabled", map); - } + public ForcedUser(ClientApi api) { + super(api); + this.api = api; + } - /** - * Gets the user (ID) set as 'forced user' for the given context (ID) - */ - public ApiResponse getForcedUser(String contextid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextId", contextid); - return api.callApi("forcedUser", "view", "getForcedUser", map); - } + /** Returns 'true' if 'forced user' mode is enabled, 'false' otherwise */ + public ApiResponse isForcedUserModeEnabled() throws ClientApiException { + return api.callApi("forcedUser", "view", "isForcedUserModeEnabled", null); + } - /** - * Sets the user (ID) that should be used in 'forced user' mode for the given context (ID) - */ - public ApiResponse setForcedUser(String apikey, String contextid, String userid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("userId", userid); - return api.callApi("forcedUser", "action", "setForcedUser", map); - } + /** Gets the user (ID) set as 'forced user' for the given context (ID) */ + public ApiResponse getForcedUser(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("forcedUser", "view", "getForcedUser", map); + } - /** - * Sets if 'forced user' mode should be enabled or not - */ - public ApiResponse setForcedUserModeEnabled(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("boolean", Boolean.toString(bool)); - return api.callApi("forcedUser", "action", "setForcedUserModeEnabled", map); - } + /** Sets the user (ID) that should be used in 'forced user' mode for the given context (ID) */ + public ApiResponse setForcedUser(String contextid, String userid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("forcedUser", "action", "setForcedUser", map); + } + /** Sets if 'forced user' mode should be enabled or not */ + public ApiResponse setForcedUserModeEnabled(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("boolean", Boolean.toString(bool)); + return api.callApi("forcedUser", "action", "setForcedUserModeEnabled", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Graphql.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Graphql.java new file mode 100644 index 0000000..ed0a5d6 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Graphql.java @@ -0,0 +1,244 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2020 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Graphql { + + private final ClientApi api; + + public Graphql(ClientApi api) { + this.api = api; + } + + /** + * Returns how arguments are currently specified. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionArgsType() throws ClientApiException { + return api.callApi("graphql", "view", "optionArgsType", null); + } + + /** + * Returns whether or not lenient maximum query generation depth is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionLenientMaxQueryDepthEnabled() throws ClientApiException { + return api.callApi("graphql", "view", "optionLenientMaxQueryDepthEnabled", null); + } + + /** + * Returns the current maximum additional query generation depth. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxAdditionalQueryDepth() throws ClientApiException { + return api.callApi("graphql", "view", "optionMaxAdditionalQueryDepth", null); + } + + /** + * Returns the current maximum arguments generation depth. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxArgsDepth() throws ClientApiException { + return api.callApi("graphql", "view", "optionMaxArgsDepth", null); + } + + /** + * Returns the current maximum query generation depth. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxQueryDepth() throws ClientApiException { + return api.callApi("graphql", "view", "optionMaxQueryDepth", null); + } + + /** + * Returns whether or not optional arguments are currently specified. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionOptionalArgsEnabled() throws ClientApiException { + return api.callApi("graphql", "view", "optionOptionalArgsEnabled", null); + } + + /** + * Returns whether the query generator is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionQueryGenEnabled() throws ClientApiException { + return api.callApi("graphql", "view", "optionQueryGenEnabled", null); + } + + /** + * Returns the current level for which a single query is generated. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionQuerySplitType() throws ClientApiException { + return api.callApi("graphql", "view", "optionQuerySplitType", null); + } + + /** + * Returns the current request method. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionRequestMethod() throws ClientApiException { + return api.callApi("graphql", "view", "optionRequestMethod", null); + } + + /** + * Imports a GraphQL Schema from a File. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importFile(String endurl, String file) throws ClientApiException { + Map map = new HashMap<>(); + map.put("endurl", endurl); + map.put("file", file); + return api.callApi("graphql", "action", "importFile", map); + } + + /** + * Imports a GraphQL Schema from a URL. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importUrl(String endurl, String url) throws ClientApiException { + Map map = new HashMap<>(); + map.put("endurl", endurl); + if (url != null) { + map.put("url", url); + } + return api.callApi("graphql", "action", "importUrl", map); + } + + /** + * Sets how arguments are specified. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionArgsType(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("graphql", "action", "setOptionArgsType", map); + } + + /** + * Sets the level for which a single query is generated. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionQuerySplitType(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("graphql", "action", "setOptionQuerySplitType", map); + } + + /** + * Sets the request method. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionRequestMethod(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("graphql", "action", "setOptionRequestMethod", map); + } + + /** + * Sets whether or not Maximum Query Depth is enforced leniently. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionLenientMaxQueryDepthEnabled(boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("graphql", "action", "setOptionLenientMaxQueryDepthEnabled", map); + } + + /** + * Sets the maximum additional query generation depth (used if enforced leniently). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxAdditionalQueryDepth(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("graphql", "action", "setOptionMaxAdditionalQueryDepth", map); + } + + /** + * Sets the maximum arguments generation depth. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxArgsDepth(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("graphql", "action", "setOptionMaxArgsDepth", map); + } + + /** + * Sets the maximum query generation depth. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxQueryDepth(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("graphql", "action", "setOptionMaxQueryDepth", map); + } + + /** + * Sets whether or not Optional Arguments should be specified. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionOptionalArgsEnabled(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("graphql", "action", "setOptionOptionalArgsEnabled", map); + } + + /** + * Sets whether the query generator is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionQueryGenEnabled(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("graphql", "action", "setOptionQueryGenEnabled", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/HttpSessions.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/HttpSessions.java index fb67288..afa6d79 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/HttpSessions.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/HttpSessions.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,165 +25,150 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class HttpSessions { - - private ClientApi api = null; - - public HttpSessions(ClientApi api) { - this.api = api; - } - - /** - * Gets the sessions of the given site. Optionally returning just the session with the given name. - */ - public ApiResponse sessions(String site, String session) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("site", site); - if (session != null) { - map.put("session", session); - } - return api.callApi("httpSessions", "view", "sessions", map); - } - - /** - * Gets the name of the active session for the given site. - */ - public ApiResponse activeSession(String site) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("site", site); - return api.callApi("httpSessions", "view", "activeSession", map); - } - - /** - * Gets the names of the session tokens for the given site. - */ - public ApiResponse sessionTokens(String site) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("site", site); - return api.callApi("httpSessions", "view", "sessionTokens", map); - } - - /** - * Creates an empty session for the given site. Optionally with the given name. - */ - public ApiResponse createEmptySession(String apikey, String site, String session) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("site", site); - if (session != null) { - map.put("session", session); - } - return api.callApi("httpSessions", "action", "createEmptySession", map); - } - - /** - * Removes the session from the given site. - */ - public ApiResponse removeSession(String apikey, String site, String session) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("site", site); - map.put("session", session); - return api.callApi("httpSessions", "action", "removeSession", map); - } - - /** - * Sets the given session as active for the given site. - */ - public ApiResponse setActiveSession(String apikey, String site, String session) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("site", site); - map.put("session", session); - return api.callApi("httpSessions", "action", "setActiveSession", map); - } - - /** - * Unsets the active session of the given site. - */ - public ApiResponse unsetActiveSession(String apikey, String site) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("site", site); - return api.callApi("httpSessions", "action", "unsetActiveSession", map); - } - - /** - * Adds the session token to the given site. - */ - public ApiResponse addSessionToken(String apikey, String site, String sessiontoken) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("site", site); - map.put("sessionToken", sessiontoken); - return api.callApi("httpSessions", "action", "addSessionToken", map); - } - - /** - * Removes the session token from the given site. - */ - public ApiResponse removeSessionToken(String apikey, String site, String sessiontoken) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("site", site); - map.put("sessionToken", sessiontoken); - return api.callApi("httpSessions", "action", "removeSessionToken", map); - } - - /** - * Sets the value of the session token of the given session for the given site. - */ - public ApiResponse setSessionTokenValue(String apikey, String site, String session, String sessiontoken, String tokenvalue) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("site", site); - map.put("session", session); - map.put("sessionToken", sessiontoken); - map.put("tokenValue", tokenvalue); - return api.callApi("httpSessions", "action", "setSessionTokenValue", map); - } - - /** - * Renames the session of the given site. - */ - public ApiResponse renameSession(String apikey, String site, String oldsessionname, String newsessionname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("site", site); - map.put("oldSessionName", oldsessionname); - map.put("newSessionName", newsessionname); - return api.callApi("httpSessions", "action", "renameSession", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class HttpSessions extends org.zaproxy.clientapi.gen.deprecated.HttpSessionsDeprecated { + + private final ClientApi api; + + public HttpSessions(ClientApi api) { + super(api); + this.api = api; + } + + /** Gets all of the sites that have sessions. */ + public ApiResponse sites() throws ClientApiException { + return api.callApi("httpSessions", "view", "sites", null); + } + + /** + * Gets the sessions for the given site. Optionally returning just the session with the given + * name. + */ + public ApiResponse sessions(String site, String session) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + if (session != null) { + map.put("session", session); + } + return api.callApi("httpSessions", "view", "sessions", map); + } + + /** Gets the name of the active session for the given site. */ + public ApiResponse activeSession(String site) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + return api.callApi("httpSessions", "view", "activeSession", map); + } + + /** Gets the names of the session tokens for the given site. */ + public ApiResponse sessionTokens(String site) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + return api.callApi("httpSessions", "view", "sessionTokens", map); + } + + /** Gets the default session tokens. */ + public ApiResponse defaultSessionTokens() throws ClientApiException { + return api.callApi("httpSessions", "view", "defaultSessionTokens", null); + } + + /** Creates an empty session for the given site. Optionally with the given name. */ + public ApiResponse createEmptySession(String site, String session) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + if (session != null) { + map.put("session", session); + } + return api.callApi("httpSessions", "action", "createEmptySession", map); + } + + /** Removes the session from the given site. */ + public ApiResponse removeSession(String site, String session) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + map.put("session", session); + return api.callApi("httpSessions", "action", "removeSession", map); + } + + /** Sets the given session as active for the given site. */ + public ApiResponse setActiveSession(String site, String session) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + map.put("session", session); + return api.callApi("httpSessions", "action", "setActiveSession", map); + } + + /** Unsets the active session of the given site. */ + public ApiResponse unsetActiveSession(String site) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + return api.callApi("httpSessions", "action", "unsetActiveSession", map); + } + + /** Adds the session token to the given site. */ + public ApiResponse addSessionToken(String site, String sessiontoken) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + map.put("sessionToken", sessiontoken); + return api.callApi("httpSessions", "action", "addSessionToken", map); + } + + /** Removes the session token from the given site. */ + public ApiResponse removeSessionToken(String site, String sessiontoken) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + map.put("sessionToken", sessiontoken); + return api.callApi("httpSessions", "action", "removeSessionToken", map); + } + + /** Sets the value of the session token of the given session for the given site. */ + public ApiResponse setSessionTokenValue( + String site, String session, String sessiontoken, String tokenvalue) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + map.put("session", session); + map.put("sessionToken", sessiontoken); + map.put("tokenValue", tokenvalue); + return api.callApi("httpSessions", "action", "setSessionTokenValue", map); + } + + /** Renames the session of the given site. */ + public ApiResponse renameSession(String site, String oldsessionname, String newsessionname) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + map.put("oldSessionName", oldsessionname); + map.put("newSessionName", newsessionname); + return api.callApi("httpSessions", "action", "renameSession", map); + } + + /** Adds a default session token with the given name and enabled state. */ + public ApiResponse addDefaultSessionToken(String sessiontoken, String tokenenabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("sessionToken", sessiontoken); + if (tokenenabled != null) { + map.put("tokenEnabled", tokenenabled); + } + return api.callApi("httpSessions", "action", "addDefaultSessionToken", map); + } + + /** Sets whether or not the default session token with the given name is enabled. */ + public ApiResponse setDefaultSessionTokenEnabled(String sessiontoken, String tokenenabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("sessionToken", sessiontoken); + map.put("tokenEnabled", tokenenabled); + return api.callApi("httpSessions", "action", "setDefaultSessionTokenEnabled", map); + } + + /** Removes the default session token with the given name. */ + public ApiResponse removeDefaultSessionToken(String sessiontoken) throws ClientApiException { + Map map = new HashMap<>(); + map.put("sessionToken", sessiontoken); + return api.callApi("httpSessions", "action", "removeDefaultSessionToken", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ImportLogFiles.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ImportLogFiles.java index ee60571..c7081e9 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ImportLogFiles.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/ImportLogFiles.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2016 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,75 +25,60 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - /** * This file was automatically generated. + * + * @deprecated Use {@link Exim} instead. */ -public class ImportLogFiles { - - private ClientApi api = null; +@SuppressWarnings("javadoc") +@Deprecated(since = "1.11.0", forRemoval = true) +public class ImportLogFiles extends org.zaproxy.clientapi.gen.deprecated.ImportLogFilesDeprecated { - public ImportLogFiles(ClientApi api) { - this.api = api; - } + private final ClientApi api; - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse ImportZAPLogFromFile(String filepath) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("FilePath", filepath); - return api.callApi("importLogFiles", "view", "ImportZAPLogFromFile", map); - } + public ImportLogFiles(ClientApi api) { + super(api); + this.api = api; + } - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse ImportModSecurityLogFromFile(String filepath) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("FilePath", filepath); - return api.callApi("importLogFiles", "view", "ImportModSecurityLogFromFile", map); - } + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse ImportZAPLogFromFile(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("FilePath", filepath); + return api.callApi("importLogFiles", "action", "ImportZAPLogFromFile", map); + } - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse ImportZAPHttpRequestResponsePair(String httprequest, String httpresponse) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("HTTPRequest", httprequest); - map.put("HTTPResponse", httpresponse); - return api.callApi("importLogFiles", "view", "ImportZAPHttpRequestResponsePair", map); - } + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse ImportModSecurityLogFromFile(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("FilePath", filepath); + return api.callApi("importLogFiles", "action", "ImportModSecurityLogFromFile", map); + } - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse PostModSecurityAuditEvent(String apikey, String auditeventstring) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (auditeventstring != null) { - map.put("AuditEventString", auditeventstring); - } - return api.callApi("importLogFiles", "action", "PostModSecurityAuditEvent", map); - } + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse ImportZAPHttpRequestResponsePair(String httprequest, String httpresponse) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("HTTPRequest", httprequest); + map.put("HTTPResponse", httpresponse); + return api.callApi("importLogFiles", "action", "ImportZAPHttpRequestResponsePair", map); + } - /** - * This component is optional and therefore the API will only work if it is installed - */ - public byte[] OtherPostModSecurityAuditEvent(String apikey, String auditeventstring) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("AuditEventString", auditeventstring); - return api.callApiOther("importLogFiles", "other", "OtherPostModSecurityAuditEvent", map); - } + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse PostModSecurityAuditEvent(String auditeventstring) + throws ClientApiException { + Map map = new HashMap<>(); + if (auditeventstring != null) { + map.put("AuditEventString", auditeventstring); + } + return api.callApi("importLogFiles", "action", "PostModSecurityAuditEvent", map); + } + /** This component is optional and therefore the API will only work if it is installed */ + public byte[] OtherPostModSecurityAuditEvent(String auditeventstring) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("AuditEventString", auditeventstring); + return api.callApiOther("importLogFiles", "other", "OtherPostModSecurityAuditEvent", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Importurls.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Importurls.java new file mode 100644 index 0000000..f534a81 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Importurls.java @@ -0,0 +1,53 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2016 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** + * This file was automatically generated. + * + * @deprecated Use {@link Exim} instead. + */ +@SuppressWarnings("javadoc") +@Deprecated(since = "1.11.0", forRemoval = true) +public class Importurls { + + private final ClientApi api; + + public Importurls(ClientApi api) { + this.api = api; + } + + /** + * Imports URLs (one per line) from the file with the given file system path. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importurls(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("importurls", "action", "importurls", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/LocalProxies.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/LocalProxies.java new file mode 100644 index 0000000..402a737 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/LocalProxies.java @@ -0,0 +1,79 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2019 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** + * This file was automatically generated. + * + * @deprecated Use {@link Network} instead. + */ +@SuppressWarnings("javadoc") +@Deprecated(since = "1.11.0", forRemoval = true) +public class LocalProxies { + + private final ClientApi api; + + public LocalProxies(ClientApi api) { + this.api = api; + } + + /** Gets all of the additional proxies that have been configured. */ + public ApiResponse additionalProxies() throws ClientApiException { + return api.callApi("localProxies", "view", "additionalProxies", null); + } + + /** Adds an new proxy using the details supplied. */ + public ApiResponse addAdditionalProxy( + String address, + String port, + String behindnat, + String alwaysdecodezip, + String removeunsupportedencodings) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("address", address); + map.put("port", port); + if (behindnat != null) { + map.put("behindNat", behindnat); + } + if (alwaysdecodezip != null) { + map.put("alwaysDecodeZip", alwaysdecodezip); + } + if (removeunsupportedencodings != null) { + map.put("removeUnsupportedEncodings", removeunsupportedencodings); + } + return api.callApi("localProxies", "action", "addAdditionalProxy", map); + } + + /** Removes the additional proxy with the specified address and port. */ + public ApiResponse removeAdditionalProxy(String address, String port) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("address", address); + map.put("port", port); + return api.callApi("localProxies", "action", "removeAdditionalProxy", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Network.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Network.java new file mode 100644 index 0000000..141e8f9 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Network.java @@ -0,0 +1,621 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2022 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Network { + + private final ClientApi api; + + public Network(ClientApi api) { + this.api = api; + } + + /** + * Gets the Root CA certificate validity, in days. Used when generating a new Root CA + * certificate. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getRootCaCertValidity() throws ClientApiException { + return api.callApi("network", "view", "getRootCaCertValidity", null); + } + + /** + * Gets the server certificate validity, in days. Used when generating server certificates. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getServerCertValidity() throws ClientApiException { + return api.callApi("network", "view", "getServerCertValidity", null); + } + + /** + * Gets the aliases used to identify the local servers/proxies. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getAliases() throws ClientApiException { + return api.callApi("network", "view", "getAliases", null); + } + + /** + * Gets the local servers/proxies. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getLocalServers() throws ClientApiException { + return api.callApi("network", "view", "getLocalServers", null); + } + + /** + * Gets the authorities that will pass-through the local proxies. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getPassThroughs() throws ClientApiException { + return api.callApi("network", "view", "getPassThroughs", null); + } + + /** + * Gets the connection timeout, in seconds. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getConnectionTimeout() throws ClientApiException { + return api.callApi("network", "view", "getConnectionTimeout", null); + } + + /** + * Gets the default user-agent. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getDefaultUserAgent() throws ClientApiException { + return api.callApi("network", "view", "getDefaultUserAgent", null); + } + + /** + * Gets the TTL (in seconds) of successful DNS queries. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getDnsTtlSuccessfulQueries() throws ClientApiException { + return api.callApi("network", "view", "getDnsTtlSuccessfulQueries", null); + } + + /** + * Gets the HTTP proxy. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getHttpProxy() throws ClientApiException { + return api.callApi("network", "view", "getHttpProxy", null); + } + + /** + * Gets the HTTP proxy exclusions. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getHttpProxyExclusions() throws ClientApiException { + return api.callApi("network", "view", "getHttpProxyExclusions", null); + } + + /** + * Gets the SOCKS proxy. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getSocksProxy() throws ClientApiException { + return api.callApi("network", "view", "getSocksProxy", null); + } + + /** + * Tells whether or not the HTTP proxy authentication is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse isHttpProxyAuthEnabled() throws ClientApiException { + return api.callApi("network", "view", "isHttpProxyAuthEnabled", null); + } + + /** + * Tells whether or not the HTTP proxy is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse isHttpProxyEnabled() throws ClientApiException { + return api.callApi("network", "view", "isHttpProxyEnabled", null); + } + + /** + * Tells whether or not the SOCKS proxy is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse isSocksProxyEnabled() throws ClientApiException { + return api.callApi("network", "view", "isSocksProxyEnabled", null); + } + + /** + * Tells whether or not to use global HTTP state. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse isUseGlobalHttpState() throws ClientApiException { + return api.callApi("network", "view", "isUseGlobalHttpState", null); + } + + /** + * List of rate limit rules. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getRateLimitRules() throws ClientApiException { + return api.callApi("network", "view", "getRateLimitRules", null); + } + + /** + * Generates a new Root CA certificate, used to issue server certificates. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse generateRootCaCert() throws ClientApiException { + return api.callApi("network", "action", "generateRootCaCert", null); + } + + /** + * Imports a Root CA certificate to be used to issue server certificates. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importRootCaCert(String filepath) throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + return api.callApi("network", "action", "importRootCaCert", map); + } + + /** + * Sets the Root CA certificate validity. Used when generating a new Root CA certificate. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setRootCaCertValidity(String validity) throws ClientApiException { + Map map = new HashMap<>(); + map.put("validity", validity); + return api.callApi("network", "action", "setRootCaCertValidity", map); + } + + /** + * Sets the server certificate validity. Used when generating server certificates. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setServerCertValidity(String validity) throws ClientApiException { + Map map = new HashMap<>(); + map.put("validity", validity); + return api.callApi("network", "action", "setServerCertValidity", map); + } + + /** + * Adds an alias for the local servers/proxies. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addAlias(String name, String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("name", name); + if (enabled != null) { + map.put("enabled", enabled); + } + return api.callApi("network", "action", "addAlias", map); + } + + /** + * Adds a local server/proxy. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addLocalServer( + String address, + String port, + String api, + String proxy, + String behindnat, + String decoderesponse, + String removeacceptencoding) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("address", address); + map.put("port", port); + if (api != null) { + map.put("api", api); + } + if (proxy != null) { + map.put("proxy", proxy); + } + if (behindnat != null) { + map.put("behindNat", behindnat); + } + if (decoderesponse != null) { + map.put("decodeResponse", decoderesponse); + } + if (removeacceptencoding != null) { + map.put("removeAcceptEncoding", removeacceptencoding); + } + return this.api.callApi("network", "action", "addLocalServer", map); + } + + /** + * Adds an authority to pass-through the local proxies. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addPassThrough(String authority, String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("authority", authority); + if (enabled != null) { + map.put("enabled", enabled); + } + return api.callApi("network", "action", "addPassThrough", map); + } + + /** + * Removes an alias. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeAlias(String name) throws ClientApiException { + Map map = new HashMap<>(); + map.put("name", name); + return api.callApi("network", "action", "removeAlias", map); + } + + /** + * Removes a local server/proxy. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeLocalServer(String address, String port) throws ClientApiException { + Map map = new HashMap<>(); + map.put("address", address); + map.put("port", port); + return api.callApi("network", "action", "removeLocalServer", map); + } + + /** + * Removes a pass-through. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removePassThrough(String authority) throws ClientApiException { + Map map = new HashMap<>(); + map.put("authority", authority); + return api.callApi("network", "action", "removePassThrough", map); + } + + /** + * Sets whether or not an alias is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setAliasEnabled(String name, String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("name", name); + map.put("enabled", enabled); + return api.callApi("network", "action", "setAliasEnabled", map); + } + + /** + * Sets whether or not a pass-through is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setPassThroughEnabled(String authority, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("authority", authority); + map.put("enabled", enabled); + return api.callApi("network", "action", "setPassThroughEnabled", map); + } + + /** + * Sets the timeout, for reads and connects. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setConnectionTimeout(String timeout) throws ClientApiException { + Map map = new HashMap<>(); + map.put("timeout", timeout); + return api.callApi("network", "action", "setConnectionTimeout", map); + } + + /** + * Sets the default user-agent. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setDefaultUserAgent(String useragent) throws ClientApiException { + Map map = new HashMap<>(); + map.put("userAgent", useragent); + return api.callApi("network", "action", "setDefaultUserAgent", map); + } + + /** + * Sets the TTL of successful DNS queries. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setDnsTtlSuccessfulQueries(String ttl) throws ClientApiException { + Map map = new HashMap<>(); + map.put("ttl", ttl); + return api.callApi("network", "action", "setDnsTtlSuccessfulQueries", map); + } + + /** + * Adds a host to be excluded from the HTTP proxy. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addHttpProxyExclusion(String host, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("host", host); + if (enabled != null) { + map.put("enabled", enabled); + } + return api.callApi("network", "action", "addHttpProxyExclusion", map); + } + + /** + * Removes an HTTP proxy exclusion. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeHttpProxyExclusion(String host) throws ClientApiException { + Map map = new HashMap<>(); + map.put("host", host); + return api.callApi("network", "action", "removeHttpProxyExclusion", map); + } + + /** + * Sets the HTTP proxy configuration. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setHttpProxy( + String host, String port, String realm, String username, String password) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("host", host); + map.put("port", port); + if (realm != null) { + map.put("realm", realm); + } + if (username != null) { + map.put("username", username); + } + if (password != null) { + map.put("password", password); + } + return api.callApi("network", "action", "setHttpProxy", map); + } + + /** + * Sets whether or not the HTTP proxy authentication is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setHttpProxyAuthEnabled(String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("enabled", enabled); + return api.callApi("network", "action", "setHttpProxyAuthEnabled", map); + } + + /** + * Sets whether or not the HTTP proxy is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setHttpProxyEnabled(String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("enabled", enabled); + return api.callApi("network", "action", "setHttpProxyEnabled", map); + } + + /** + * Sets whether or not an HTTP proxy exclusion is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setHttpProxyExclusionEnabled(String host, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("host", host); + map.put("enabled", enabled); + return api.callApi("network", "action", "setHttpProxyExclusionEnabled", map); + } + + /** + * Sets the SOCKS proxy configuration. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setSocksProxy( + String host, + String port, + String version, + String usedns, + String username, + String password) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("host", host); + map.put("port", port); + if (version != null) { + map.put("version", version); + } + if (usedns != null) { + map.put("useDns", usedns); + } + if (username != null) { + map.put("username", username); + } + if (password != null) { + map.put("password", password); + } + return api.callApi("network", "action", "setSocksProxy", map); + } + + /** + * Sets whether or not the SOCKS proxy is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setSocksProxyEnabled(String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("enabled", enabled); + return api.callApi("network", "action", "setSocksProxyEnabled", map); + } + + /** + * Sets whether or not to use the global HTTP state. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setUseGlobalHttpState(String use) throws ClientApiException { + Map map = new HashMap<>(); + map.put("use", use); + return api.callApi("network", "action", "setUseGlobalHttpState", map); + } + + /** + * Adds a client certificate contained in a PKCS#12 file, the certificate is automatically set + * as active and used. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addPkcs12ClientCertificate(String filepath, String password, String index) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("filePath", filepath); + map.put("password", password); + if (index != null) { + map.put("index", index); + } + return api.callApi("network", "action", "addPkcs12ClientCertificate", map); + } + + /** + * Sets whether or not to use the active client certificate. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setUseClientCertificate(String use) throws ClientApiException { + Map map = new HashMap<>(); + map.put("use", use); + return api.callApi("network", "action", "setUseClientCertificate", map); + } + + /** + * Adds a rate limit rule + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addRateLimitRule( + String description, + String enabled, + String matchregex, + String matchstring, + String requestspersecond, + String groupby) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("description", description); + map.put("enabled", enabled); + map.put("matchRegex", matchregex); + map.put("matchString", matchstring); + map.put("requestsPerSecond", requestspersecond); + map.put("groupBy", groupby); + return api.callApi("network", "action", "addRateLimitRule", map); + } + + /** + * Remove a rate limit rule + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeRateLimitRule(String description) throws ClientApiException { + Map map = new HashMap<>(); + map.put("description", description); + return api.callApi("network", "action", "removeRateLimitRule", map); + } + + /** + * Set enabled state for a rate limit rule. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setRateLimitRuleEnabled(String description, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("description", description); + map.put("enabled", enabled); + return api.callApi("network", "action", "setRateLimitRuleEnabled", map); + } + + /** + * Provides a PAC file, proxying through the main proxy. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public byte[] proxypac() throws ClientApiException { + return api.callApiOther("network", "other", "proxy.pac", null); + } + + /** + * Sets the HTTP proxy configuration. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public byte[] setProxy(String proxy) throws ClientApiException { + Map map = new HashMap<>(); + map.put("proxy", proxy); + return api.callApiOther("network", "other", "setProxy", map); + } + + /** + * Gets the Root CA certificate used to issue server certificates. Suitable to import into + * client applications (e.g. browsers). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public byte[] rootCaCert() throws ClientApiException { + return api.callApiOther("network", "other", "rootCaCert", null); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Oast.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Oast.java new file mode 100644 index 0000000..70d5ead --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Oast.java @@ -0,0 +1,153 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2025 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Oast { + + private final ClientApi api; + + public Oast(ClientApi api) { + this.api = api; + } + + /** + * Gets the service used with the active scanner, if any. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getActiveScanService() throws ClientApiException { + return api.callApi("oast", "view", "getActiveScanService", null); + } + + /** + * Gets all of the services. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getServices() throws ClientApiException { + return api.callApi("oast", "view", "getServices", null); + } + + /** + * Gets the BOAST options. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getBoastOptions() throws ClientApiException { + return api.callApi("oast", "view", "getBoastOptions", null); + } + + /** + * Gets the Callback options. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getCallbackOptions() throws ClientApiException { + return api.callApi("oast", "view", "getCallbackOptions", null); + } + + /** + * Gets the Interactsh options. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getInteractshOptions() throws ClientApiException { + return api.callApi("oast", "view", "getInteractshOptions", null); + } + + /** + * Gets the number of days the OAST records will be kept for. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getDaysToKeepRecords() throws ClientApiException { + return api.callApi("oast", "view", "getDaysToKeepRecords", null); + } + + /** + * Sets the service used with the active scanner. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setActiveScanService(String name) throws ClientApiException { + Map map = new HashMap<>(); + map.put("name", name); + return api.callApi("oast", "action", "setActiveScanService", map); + } + + /** + * Sets the BOAST options. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setBoastOptions(String server, String pollinsecs) throws ClientApiException { + Map map = new HashMap<>(); + map.put("server", server); + map.put("pollInSecs", pollinsecs); + return api.callApi("oast", "action", "setBoastOptions", map); + } + + /** + * Sets the Callback options. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setCallbackOptions(String localaddress, String remoteaddress, String port) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("localAddress", localaddress); + map.put("remoteAddress", remoteaddress); + map.put("port", port); + return api.callApi("oast", "action", "setCallbackOptions", map); + } + + /** + * Sets the Interactsh options. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setInteractshOptions(String server, String pollinsecs, String authtoken) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("server", server); + map.put("pollInSecs", pollinsecs); + map.put("authToken", authtoken); + return api.callApi("oast", "action", "setInteractshOptions", map); + } + + /** + * Sets the number of days the OAST records will be kept for. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setDaysToKeepRecords(String days) throws ClientApiException { + Map map = new HashMap<>(); + map.put("days", days); + return api.callApi("oast", "action", "setDaysToKeepRecords", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Openapi.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Openapi.java new file mode 100644 index 0000000..e792ca8 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Openapi.java @@ -0,0 +1,80 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2016 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Openapi extends org.zaproxy.clientapi.gen.deprecated.OpenapiDeprecated { + + private final ClientApi api; + + public Openapi(ClientApi api) { + super(api); + this.api = api; + } + + /** + * Imports an OpenAPI definition from a local file. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importFile(String file, String target, String contextid, String userid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("file", file); + if (target != null) { + map.put("target", target); + } + if (contextid != null) { + map.put("contextId", contextid); + } + if (userid != null) { + map.put("userId", userid); + } + return api.callApi("openapi", "action", "importFile", map); + } + + /** + * Imports an OpenAPI definition from a URL. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importUrl(String url, String hostoverride, String contextid, String userid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("url", url); + if (hostoverride != null) { + map.put("hostOverride", hostoverride); + } + if (contextid != null) { + map.put("contextId", contextid); + } + if (userid != null) { + map.put("userId", userid); + } + return api.callApi("openapi", "action", "importUrl", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Params.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Params.java index 3f3a7dc..ceae677 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Params.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Params.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,28 +25,24 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") public class Params { - private ClientApi api = null; - - public Params(ClientApi api) { - this.api = api; - } - - /** - * Shows the parameters for the specified site, or for all sites if the site is not specified - */ - public ApiResponse params(String site) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (site != null) { - map.put("site", site); - } - return api.callApi("params", "view", "params", map); - } - + private final ClientApi api; + + public Params(ClientApi api) { + this.api = api; + } + + /** + * Shows the parameters for the specified site, or for all sites if the site is not specified + */ + public ApiResponse params(String site) throws ClientApiException { + Map map = new HashMap<>(); + if (site != null) { + map.put("site", site); + } + return api.callApi("params", "view", "params", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Pnh.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Pnh.java index 8afe4d3..4fe10bb 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Pnh.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Pnh.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2016 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,117 +25,63 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Pnh { - - private ClientApi api = null; - - public Pnh(ClientApi api) { - this.api = api; - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse monitor(String apikey, String id, String message) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - map.put("message", message); - return api.callApi("pnh", "action", "monitor", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse oracle(String apikey, String id) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - return api.callApi("pnh", "action", "oracle", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse startMonitoring(String apikey, String url) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("url", url); - return api.callApi("pnh", "action", "startMonitoring", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse stopMonitoring(String apikey, String id) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - return api.callApi("pnh", "action", "stopMonitoring", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public byte[] pnh(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApiOther("pnh", "other", "pnh", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public byte[] manifest(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApiOther("pnh", "other", "manifest", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public byte[] service(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApiOther("pnh", "other", "service", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public byte[] fx_pnhxpi(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApiOther("pnh", "other", "fx_pnh.xpi", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Pnh extends org.zaproxy.clientapi.gen.deprecated.PnhDeprecated { + + private final ClientApi api; + + public Pnh(ClientApi api) { + super(api); + this.api = api; + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse monitor(String id, String message) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + map.put("message", message); + return api.callApi("pnh", "action", "monitor", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse oracle(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("pnh", "action", "oracle", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse startMonitoring(String url) throws ClientApiException { + Map map = new HashMap<>(); + map.put("url", url); + return api.callApi("pnh", "action", "startMonitoring", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse stopMonitoring(String id) throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + return api.callApi("pnh", "action", "stopMonitoring", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public byte[] pnh() throws ClientApiException { + return api.callApiOther("pnh", "other", "pnh", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public byte[] manifest() throws ClientApiException { + return api.callApiOther("pnh", "other", "manifest", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public byte[] service() throws ClientApiException { + return api.callApiOther("pnh", "other", "service", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public byte[] fx_pnhxpi() throws ClientApiException { + return api.callApiOther("pnh", "other", "fx_pnh.xpi", null); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Postman.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Postman.java new file mode 100644 index 0000000..f8b46bd --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Postman.java @@ -0,0 +1,59 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2025 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Postman { + + private final ClientApi api; + + public Postman(ClientApi api) { + this.api = api; + } + + /** + * Imports a Postman collection from a file. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importFile(String file) throws ClientApiException { + Map map = new HashMap<>(); + map.put("file", file); + return api.callApi("postman", "action", "importFile", map); + } + + /** + * Imports a Postman collection from a URL. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importUrl(String url) throws ClientApiException { + Map map = new HashMap<>(); + map.put("url", url); + return api.callApi("postman", "action", "importUrl", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Pscan.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Pscan.java index b1f1ad9..e97caa1 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Pscan.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Pscan.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,109 +25,205 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Pscan { - - private ClientApi api = null; - - public Pscan(ClientApi api) { - this.api = api; - } - - /** - * The number of records the passive scanner still has to scan - */ - public ApiResponse recordsToScan() throws ClientApiException { - Map map = null; - return api.callApi("pscan", "view", "recordsToScan", map); - } - - /** - * Lists all passive scanners with its ID, name, enabled state and alert threshold. - */ - public ApiResponse scanners() throws ClientApiException { - Map map = null; - return api.callApi("pscan", "view", "scanners", map); - } - - /** - * Sets whether or not the passive scanning is enabled - */ - public ApiResponse setEnabled(String apikey, String enabled) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("enabled", enabled); - return api.callApi("pscan", "action", "setEnabled", map); - } - - /** - * Enables all passive scanners - */ - public ApiResponse enableAllScanners(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("pscan", "action", "enableAllScanners", map); - } - - /** - * Disables all passive scanners - */ - public ApiResponse disableAllScanners(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("pscan", "action", "disableAllScanners", map); - } - - /** - * Enables all passive scanners with the given IDs (comma separated list of IDs) - */ - public ApiResponse enableScanners(String apikey, String ids) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("ids", ids); - return api.callApi("pscan", "action", "enableScanners", map); - } - - /** - * Disables all passive scanners with the given IDs (comma separated list of IDs) - */ - public ApiResponse disableScanners(String apikey, String ids) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("ids", ids); - return api.callApi("pscan", "action", "disableScanners", map); - } - - /** - * Sets the alert threshold of the passive scanner with the given ID, accepted values for alert threshold: OFF, DEFAULT, LOW, MEDIUM and HIGH - */ - public ApiResponse setScannerAlertThreshold(String apikey, String id, String alertthreshold) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("id", id); - map.put("alertThreshold", alertthreshold); - return api.callApi("pscan", "action", "setScannerAlertThreshold", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Pscan extends org.zaproxy.clientapi.gen.deprecated.PscanDeprecated { + + private final ClientApi api; + + public Pscan(ClientApi api) { + super(api); + this.api = api; + } + + /** + * Tells whether or not the passive scan should be performed only on messages that are in scope. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scanOnlyInScope() throws ClientApiException { + return api.callApi("pscan", "view", "scanOnlyInScope", null); + } + + /** + * The number of records the passive scanner still has to scan. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse recordsToScan() throws ClientApiException { + return api.callApi("pscan", "view", "recordsToScan", null); + } + + /** + * Lists all passive scan rules with their ID, name, enabled state, and alert threshold. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scanners() throws ClientApiException { + return api.callApi("pscan", "view", "scanners", null); + } + + /** + * Shows information about the passive scan rule currently being run (if any). + * + *

This component is optional and therefore the API will only work if it is installed + * + * @deprecated + */ + @Deprecated + public ApiResponse currentRule() throws ClientApiException { + return api.callApi("pscan", "view", "currentRule", null); + } + + /** + * Shows information about the passive scan tasks currently being run (if any). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse currentTasks() throws ClientApiException { + return api.callApi("pscan", "view", "currentTasks", null); + } + + /** + * Gets the maximum number of alerts a passive scan rule should raise. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse maxAlertsPerRule() throws ClientApiException { + return api.callApi("pscan", "view", "maxAlertsPerRule", null); + } + + /** + * Gets the maximum body size in bytes that the passive scanner will scan. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse maxBodySizeInBytes() throws ClientApiException { + return api.callApi("pscan", "view", "maxBodySizeInBytes", null); + } + + /** + * Sets whether or not the passive scanning is enabled (Note: the enabled state is not + * persisted). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setEnabled(String enabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("enabled", enabled); + return api.callApi("pscan", "action", "setEnabled", map); + } + + /** + * Sets whether or not the passive scan should be performed only on messages that are in scope. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setScanOnlyInScope(String onlyinscope) throws ClientApiException { + Map map = new HashMap<>(); + map.put("onlyInScope", onlyinscope); + return api.callApi("pscan", "action", "setScanOnlyInScope", map); + } + + /** + * Enables all passive scan rules. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse enableAllScanners() throws ClientApiException { + return api.callApi("pscan", "action", "enableAllScanners", null); + } + + /** + * Disables all passive scan rules. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse disableAllScanners() throws ClientApiException { + return api.callApi("pscan", "action", "disableAllScanners", null); + } + + /** + * Enables passive scan rules. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse enableScanners(String ids) throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + return api.callApi("pscan", "action", "enableScanners", map); + } + + /** + * Disables passive scan rules. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse disableScanners(String ids) throws ClientApiException { + Map map = new HashMap<>(); + map.put("ids", ids); + return api.callApi("pscan", "action", "disableScanners", map); + } + + /** + * Sets the alert threshold of a passive scan rule. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setScannerAlertThreshold(String id, String alertthreshold) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("id", id); + map.put("alertThreshold", alertthreshold); + return api.callApi("pscan", "action", "setScannerAlertThreshold", map); + } + + /** + * Sets the maximum number of alerts a passive scan rule can raise. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setMaxAlertsPerRule(String maxalerts) throws ClientApiException { + Map map = new HashMap<>(); + map.put("maxAlerts", maxalerts); + return api.callApi("pscan", "action", "setMaxAlertsPerRule", map); + } + + /** + * Sets the maximum body size in bytes that the passive scanner will scan. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setMaxBodySizeInBytes(String maxsize) throws ClientApiException { + Map map = new HashMap<>(); + map.put("maxSize", maxsize); + return api.callApi("pscan", "action", "setMaxBodySizeInBytes", map); + } + + /** + * Disables all passive scan tags. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse disableAllTags() throws ClientApiException { + return api.callApi("pscan", "action", "disableAllTags", null); + } + + /** + * Enables all passive scan tags. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse enableAllTags() throws ClientApiException { + return api.callApi("pscan", "action", "enableAllTags", null); + } + + /** + * Clears the passive scan queue. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse clearQueue() throws ClientApiException { + return api.callApi("pscan", "action", "clearQueue", null); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Replacer.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Replacer.java new file mode 100644 index 0000000..281f092 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Replacer.java @@ -0,0 +1,110 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; +import org.zaproxy.clientapi.gen.deprecated.ReplacerDeprecated; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Replacer extends ReplacerDeprecated { + + private final ClientApi api; + + public Replacer(ClientApi api) { + super(api); + this.api = api; + } + + /** + * Returns full details of all of the rules + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse rules() throws ClientApiException { + return api.callApi("replacer", "view", "rules", null); + } + + /** + * 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 Request Initiator Constants + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addRule( + String description, + String enabled, + String matchtype, + String matchregex, + String matchstring, + String replacement, + String initiators, + String url) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("description", description); + map.put("enabled", enabled); + map.put("matchType", matchtype); + map.put("matchRegex", matchregex); + map.put("matchString", matchstring); + if (replacement != null) { + map.put("replacement", replacement); + } + if (initiators != null) { + map.put("initiators", initiators); + } + if (url != null) { + map.put("url", url); + } + return api.callApi("replacer", "action", "addRule", map); + } + + /** + * Removes the rule with the given description + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeRule(String description) throws ClientApiException { + Map map = new HashMap<>(); + map.put("description", description); + return api.callApi("replacer", "action", "removeRule", map); + } + + /** + * Enables or disables the rule with the given description based on the bool parameter + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setEnabled(String description, String bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("description", description); + map.put("bool", bool); + return api.callApi("replacer", "action", "setEnabled", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Reports.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Reports.java new file mode 100644 index 0000000..5ec8516 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Reports.java @@ -0,0 +1,116 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2021 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Reports { + + private final ClientApi api; + + public Reports(ClientApi api) { + this.api = api; + } + + /** + * View available templates. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse templates() throws ClientApiException { + return api.callApi("reports", "view", "templates", null); + } + + /** + * View details of the specified template. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse templateDetails(String template) throws ClientApiException { + Map map = new HashMap<>(); + map.put("template", template); + return api.callApi("reports", "view", "templateDetails", map); + } + + /** + * Generate a report with the supplied parameters. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse generate( + String title, + String template, + String theme, + String description, + String contexts, + String sites, + String sections, + String includedconfidences, + String includedrisks, + String reportfilename, + String reportfilenamepattern, + String reportdir, + String display) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("title", title); + map.put("template", template); + if (theme != null) { + map.put("theme", theme); + } + if (description != null) { + map.put("description", description); + } + if (contexts != null) { + map.put("contexts", contexts); + } + if (sites != null) { + map.put("sites", sites); + } + if (sections != null) { + map.put("sections", sections); + } + if (includedconfidences != null) { + map.put("includedConfidences", includedconfidences); + } + if (includedrisks != null) { + map.put("includedRisks", includedrisks); + } + if (reportfilename != null) { + map.put("reportFileName", reportfilename); + } + if (reportfilenamepattern != null) { + map.put("reportFileNamePattern", reportfilenamepattern); + } + if (reportdir != null) { + map.put("reportDir", reportdir); + } + if (display != null) { + map.put("display", display); + } + return api.callApi("reports", "action", "generate", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Retest.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Retest.java new file mode 100644 index 0000000..c1a566c --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Retest.java @@ -0,0 +1,44 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2021 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Retest { + + private final ClientApi api; + + public Retest(ClientApi api) { + this.api = api; + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse retest(String alertids) throws ClientApiException { + Map map = new HashMap<>(); + map.put("alertIds", alertids); + return api.callApi("retest", "action", "retest", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Reveal.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Reveal.java index 0f74cf2..45dc7df 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Reveal.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Reveal.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,37 +25,34 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Reveal { - - private ClientApi api = null; - - public Reveal(ClientApi api) { - this.api = api; - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse reveal() throws ClientApiException { - Map map = null; - return api.callApi("reveal", "view", "reveal", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setReveal(String apikey, String reveal) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("reveal", reveal); - return api.callApi("reveal", "action", "setReveal", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Reveal extends org.zaproxy.clientapi.gen.deprecated.RevealDeprecated { + + private final ClientApi api; + + public Reveal(ClientApi api) { + super(api); + this.api = api; + } + + /** + * Tells if shows hidden fields and enables disabled fields + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse reveal() throws ClientApiException { + return api.callApi("reveal", "view", "reveal", null); + } + + /** + * Sets if shows hidden fields and enables disabled fields + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setReveal(String reveal) throws ClientApiException { + Map map = new HashMap<>(); + map.put("reveal", reveal); + return api.callApi("reveal", "action", "setReveal", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Revisit.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Revisit.java new file mode 100644 index 0000000..5626c86 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Revisit.java @@ -0,0 +1,59 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2020 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Revisit { + + private final ClientApi api; + + public Revisit(ClientApi api) { + this.api = api; + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse revisitList() throws ClientApiException { + return api.callApi("revisit", "view", "revisitList", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse revisitSiteOn(String site, String starttime, String endtime) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + map.put("startTime", starttime); + map.put("endTime", endtime); + return api.callApi("revisit", "action", "revisitSiteOn", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse revisitSiteOff(String site) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + return api.callApi("revisit", "action", "revisitSiteOff", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/RuleConfig.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/RuleConfig.java new file mode 100644 index 0000000..dc1a7c4 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/RuleConfig.java @@ -0,0 +1,71 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2019 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class RuleConfig { + + private final ClientApi api; + + public RuleConfig(ClientApi api) { + this.api = api; + } + + /** Show the specified rule configuration */ + public ApiResponse ruleConfigValue(String key) throws ClientApiException { + Map map = new HashMap<>(); + map.put("key", key); + return api.callApi("ruleConfig", "view", "ruleConfigValue", map); + } + + /** Show all of the rule configurations */ + public ApiResponse allRuleConfigs() throws ClientApiException { + return api.callApi("ruleConfig", "view", "allRuleConfigs", null); + } + + /** Reset the specified rule configuration, which must already exist */ + public ApiResponse resetRuleConfigValue(String key) throws ClientApiException { + Map map = new HashMap<>(); + map.put("key", key); + return api.callApi("ruleConfig", "action", "resetRuleConfigValue", map); + } + + /** Reset all of the rule configurations */ + public ApiResponse resetAllRuleConfigValues() throws ClientApiException { + return api.callApi("ruleConfig", "action", "resetAllRuleConfigValues", null); + } + + /** Set the specified rule configuration, which must already exist */ + public ApiResponse setRuleConfigValue(String key, String value) throws ClientApiException { + Map map = new HashMap<>(); + map.put("key", key); + if (value != null) { + map.put("value", value); + } + return api.callApi("ruleConfig", "action", "setRuleConfigValue", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Script.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Script.java index 66b6839..c9d255d 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Script.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Script.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,113 +17,316 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; import org.zaproxy.clientapi.core.ApiResponse; import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Script extends org.zaproxy.clientapi.gen.deprecated.ScriptDeprecated { -/** - * This file was automatically generated. - */ -public class Script { - - private ClientApi api = null; - - public Script(ClientApi api) { - this.api = api; - } - - /** - * Lists the script engines available - */ - public ApiResponse listEngines() throws ClientApiException { - Map map = null; - return api.callApi("script", "view", "listEngines", map); - } - - /** - * Lists the scripts available, with its engine, name, description, type and error state. - */ - public ApiResponse listScripts() throws ClientApiException { - Map map = null; - return api.callApi("script", "view", "listScripts", map); - } - - /** - * Enables the script with the given name - */ - public ApiResponse enable(String apikey, String scriptname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scriptName", scriptname); - return api.callApi("script", "action", "enable", map); - } - - /** - * Disables the script with the given name - */ - public ApiResponse disable(String apikey, String scriptname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scriptName", scriptname); - return api.callApi("script", "action", "disable", map); - } - - /** - * Loads a script into ZAP from the given local file, with the given name, type and engine, optionally with a description - */ - public ApiResponse load(String apikey, String scriptname, String scripttype, String scriptengine, String filename, String scriptdescription) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scriptName", scriptname); - map.put("scriptType", scripttype); - map.put("scriptEngine", scriptengine); - map.put("fileName", filename); - if (scriptdescription != null) { - map.put("scriptDescription", scriptdescription); - } - return api.callApi("script", "action", "load", map); - } - - /** - * Removes the script with the given name - */ - public ApiResponse remove(String apikey, String scriptname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scriptName", scriptname); - return api.callApi("script", "action", "remove", map); - } - - /** - * Runs the stand alone script with the give name - */ - public ApiResponse runStandAloneScript(String apikey, String scriptname) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scriptName", scriptname); - return api.callApi("script", "action", "runStandAloneScript", map); - } + private final ClientApi api; + + public Script(ClientApi api) { + super(api); + this.api = api; + } + + /** + * Lists the script engines available + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse listEngines() throws ClientApiException { + return api.callApi("script", "view", "listEngines", null); + } + + /** + * Lists the script types available. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse listTypes() throws ClientApiException { + return api.callApi("script", "view", "listTypes", null); + } + + /** + * Lists the scripts available, with its engine, name, description, type and error state. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse listScripts() throws ClientApiException { + return api.callApi("script", "view", "listScripts", null); + } + + /** + * Gets the value of the global variable with the given key. Returns an API error + * (DOES_NOT_EXIST) if no value was previously set. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse globalVar(String varkey) throws ClientApiException { + Map map = new HashMap<>(); + map.put("varKey", varkey); + return api.callApi("script", "view", "globalVar", map); + } + + /** + * Gets the value (string representation) of a global custom variable. Returns an API error + * (DOES_NOT_EXIST) if no value was previously set. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse globalCustomVar(String varkey) throws ClientApiException { + Map map = new HashMap<>(); + map.put("varKey", varkey); + return api.callApi("script", "view", "globalCustomVar", map); + } + + /** + * Gets all the global variables (key/value pairs). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse globalVars() throws ClientApiException { + return api.callApi("script", "view", "globalVars", null); + } + + /** + * Gets all the global custom variables (key/value pairs, the value is the string + * representation). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse globalCustomVars() throws ClientApiException { + return api.callApi("script", "view", "globalCustomVars", null); + } + + /** + * 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. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scriptVar(String scriptname, String varkey) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + map.put("varKey", varkey); + return api.callApi("script", "view", "scriptVar", map); + } + + /** + * Gets the value (string representation) of a custom variable. Returns an API error + * (DOES_NOT_EXIST) if no script with the given name exists or if no value was previously set. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scriptCustomVar(String scriptname, String varkey) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + map.put("varKey", varkey); + return api.callApi("script", "view", "scriptCustomVar", map); + } + + /** + * 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. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scriptVars(String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + return api.callApi("script", "view", "scriptVars", map); + } + + /** + * Gets all the custom variables (key/value pairs, the value is the string representation) of a + * script. Returns an API error (DOES_NOT_EXIST) if no script with the given name exists. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scriptCustomVars(String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + return api.callApi("script", "view", "scriptCustomVars", map); + } + + /** + * Enables the script with the given name + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse enable(String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + return api.callApi("script", "action", "enable", map); + } + + /** + * Disables the script with the given name + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse disable(String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + return api.callApi("script", "action", "disable", map); + } + + /** + * 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). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse load( + String scriptname, + String scripttype, + String scriptengine, + String filename, + String scriptdescription, + Charset charset) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + map.put("scriptType", scripttype); + map.put("scriptEngine", scriptengine); + map.put("fileName", filename); + if (scriptdescription != null) { + map.put("scriptDescription", scriptdescription); + } + if (charset != null) { + map.put("charset", charset.name()); + } + return api.callApi("script", "action", "load", map); + } + + /** + * Removes the script with the given name + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse remove(String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + return api.callApi("script", "action", "remove", map); + } + + /** + * Runs the stand alone script with the given name + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse runStandAloneScript(String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + return api.callApi("script", "action", "runStandAloneScript", map); + } + + /** + * Clears the global variable with the given key. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse clearGlobalVar(String varkey) throws ClientApiException { + Map map = new HashMap<>(); + map.put("varKey", varkey); + return api.callApi("script", "action", "clearGlobalVar", map); + } + + /** + * Clears a global custom variable. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse clearGlobalCustomVar(String varkey) throws ClientApiException { + Map map = new HashMap<>(); + map.put("varKey", varkey); + return api.callApi("script", "action", "clearGlobalCustomVar", map); + } + + /** + * Clears the global variables. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse clearGlobalVars() throws ClientApiException { + return api.callApi("script", "action", "clearGlobalVars", null); + } + + /** + * 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. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse clearScriptVar(String scriptname, String varkey) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + map.put("varKey", varkey); + return api.callApi("script", "action", "clearScriptVar", map); + } + + /** + * Clears a script custom variable. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse clearScriptCustomVar(String scriptname, String varkey) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + map.put("varKey", varkey); + return api.callApi("script", "action", "clearScriptCustomVar", map); + } + + /** + * Clears the variables of the given script. Returns an API error (DOES_NOT_EXIST) if no script + * with the given name exists. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse clearScriptVars(String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + return api.callApi("script", "action", "clearScriptVars", map); + } + + /** + * 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. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setScriptVar(String scriptname, String varkey, String varvalue) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + map.put("varKey", varkey); + if (varvalue != null) { + map.put("varValue", varvalue); + } + return api.callApi("script", "action", "setScriptVar", map); + } + /** + * Sets the value of the global variable with the given key. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setGlobalVar(String varkey, String varvalue) throws ClientApiException { + Map map = new HashMap<>(); + map.put("varKey", varkey); + if (varvalue != null) { + map.put("varValue", varvalue); + } + return api.callApi("script", "action", "setGlobalVar", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Search.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Search.java index a27bb40..37e35c0 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Search.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Search.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,220 +25,380 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Search extends org.zaproxy.clientapi.gen.deprecated.SearchDeprecated { -/** - * This file was automatically generated. - */ -public class Search { - - private ClientApi api = null; - - public Search(ClientApi api) { - this.api = api; - } - - public ApiResponse urlsByUrlRegex(String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("search", "view", "urlsByUrlRegex", map); - } - - public ApiResponse urlsByRequestRegex(String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("search", "view", "urlsByRequestRegex", map); - } - - public ApiResponse urlsByResponseRegex(String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("search", "view", "urlsByResponseRegex", map); - } - - public ApiResponse urlsByHeaderRegex(String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("search", "view", "urlsByHeaderRegex", map); - } - - public ApiResponse messagesByUrlRegex(String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("search", "view", "messagesByUrlRegex", map); - } - - public ApiResponse messagesByRequestRegex(String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("search", "view", "messagesByRequestRegex", map); - } - - public ApiResponse messagesByResponseRegex(String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("search", "view", "messagesByResponseRegex", map); - } - - public ApiResponse messagesByHeaderRegex(String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApi("search", "view", "messagesByHeaderRegex", map); - } - - public byte[] harByUrlRegex(String apikey, String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApiOther("search", "other", "harByUrlRegex", map); - } - - public byte[] harByRequestRegex(String apikey, String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApiOther("search", "other", "harByRequestRegex", map); - } - - public byte[] harByResponseRegex(String apikey, String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApiOther("search", "other", "harByResponseRegex", map); - } - - public byte[] harByHeaderRegex(String apikey, String regex, String baseurl, String start, String count) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("regex", regex); - if (baseurl != null) { - map.put("baseurl", baseurl); - } - if (start != null) { - map.put("start", start); - } - if (count != null) { - map.put("count", count); - } - return api.callApiOther("search", "other", "harByHeaderRegex", map); - } + private final ClientApi api; + + public Search(ClientApi api) { + super(api); + this.api = api; + } + + /** + * 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. + */ + public ApiResponse urlsByUrlRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "urlsByUrlRegex", map); + } + + /** + * Returns the URLs of the HTTP messages that match the given regular expression in their + * history Tags optionally filtered by URL and paginated with 'start' position and 'count' of + * messages. + */ + public ApiResponse urlsByTagRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "urlsByTagRegex", map); + } + + /** + * Returns the URLs of the HTTP messages that match the given regular expression in their note + * optionally filtered by URL and paginated with 'start' position and 'count' of messages. + */ + public ApiResponse urlsByNoteRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "urlsByNoteRegex", map); + } + + /** + * 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. + */ + public ApiResponse urlsByRequestRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "urlsByRequestRegex", map); + } + + /** + * 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. + */ + public ApiResponse urlsByResponseRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "urlsByResponseRegex", map); + } + + /** + * 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. + */ + public ApiResponse urlsByHeaderRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "urlsByHeaderRegex", map); + } + + /** + * 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. + */ + public ApiResponse messagesByUrlRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "messagesByUrlRegex", map); + } + + /** + * Returns the HTTP messages that match the given regular expression in their history Tags + * optionally filtered by URL and paginated with 'start' position and 'count' of messages. + */ + public ApiResponse messagesByTagRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "messagesByTagRegex", map); + } + + /** + * Returns the HTTP messages that match the given regular expression in their note optionally + * filtered by URL and paginated with 'start' position and 'count' of messages. + */ + public ApiResponse messagesByNoteRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "messagesByNoteRegex", map); + } + + /** + * 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. + */ + public ApiResponse messagesByRequestRegex( + String regex, String baseurl, String start, String count) throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "messagesByRequestRegex", map); + } + + /** + * 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. + */ + public ApiResponse messagesByResponseRegex( + String regex, String baseurl, String start, String count) throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "messagesByResponseRegex", map); + } + + /** + * 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. + */ + public ApiResponse messagesByHeaderRegex( + String regex, String baseurl, String start, String count) throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("search", "view", "messagesByHeaderRegex", map); + } + + /** + * 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. + */ + public byte[] harByUrlRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByUrlRegex", map); + } + + /** + * Returns the HTTP messages, in HAR format, that match the given regular expression in their + * history Tags optionally filtered by URL and paginated with 'start' position and 'count' of + * messages. + */ + public byte[] harByTagRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByTagRegex", map); + } + + /** + * Returns the HTTP messages, in HAR format, that match the given regular expression in their + * note optionally filtered by URL and paginated with 'start' position and 'count' of messages. + */ + public byte[] harByNoteRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByNoteRegex", map); + } + + /** + * 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. + */ + public byte[] harByRequestRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByRequestRegex", map); + } + + /** + * 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. + */ + public byte[] harByResponseRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByResponseRegex", map); + } + /** + * 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. + */ + public byte[] harByHeaderRegex(String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByHeaderRegex", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Selenium.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Selenium.java index 809bf2f..63e8f54 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Selenium.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Selenium.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2016 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,92 +25,256 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Selenium extends org.zaproxy.clientapi.gen.deprecated.SeleniumDeprecated { -/** - * This file was automatically generated. - */ -public class Selenium { - - private final ClientApi api; - - public Selenium(ClientApi api) { - this.api = api; - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionChromeDriverPath() throws ClientApiException { - return api.callApi("selenium", "view", "optionChromeDriverPath", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionFirefoxBinaryPath() throws ClientApiException { - return api.callApi("selenium", "view", "optionFirefoxBinaryPath", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionIeDriverPath() throws ClientApiException { - return api.callApi("selenium", "view", "optionIeDriverPath", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse optionPhantomJsBinaryPath() throws ClientApiException { - return api.callApi("selenium", "view", "optionPhantomJsBinaryPath", null); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionChromeDriverPath(String apikey, String string) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("selenium", "action", "setOptionChromeDriverPath", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionFirefoxBinaryPath(String apikey, String string) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("selenium", "action", "setOptionFirefoxBinaryPath", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionIeDriverPath(String apikey, String string) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("selenium", "action", "setOptionIeDriverPath", map); - } - - /** - * This component is optional and therefore the API will only work if it is installed - */ - public ApiResponse setOptionPhantomJsBinaryPath(String apikey, String string) throws ClientApiException { - Map map = new HashMap<>(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("selenium", "action", "setOptionPhantomJsBinaryPath", map); - } + private final ClientApi api; + + public Selenium(ClientApi api) { + super(api); + this.api = api; + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionBrowserExtensions() throws ClientApiException { + return api.callApi("selenium", "view", "optionBrowserExtensions", null); + } + + /** + * Returns the current path to Chrome binary + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionChromeBinaryPath() throws ClientApiException { + return api.callApi("selenium", "view", "optionChromeBinaryPath", null); + } + + /** + * Returns the current path to ChromeDriver + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionChromeDriverPath() throws ClientApiException { + return api.callApi("selenium", "view", "optionChromeDriverPath", null); + } + + /** + * Returns the current path to Edge binary + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionEdgeBinaryPath() throws ClientApiException { + return api.callApi("selenium", "view", "optionEdgeBinaryPath", null); + } + + /** + * Returns the current path to EdgeDriver + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionEdgeDriverPath() throws ClientApiException { + return api.callApi("selenium", "view", "optionEdgeDriverPath", null); + } + + /** + * Returns the current path to Firefox binary + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionFirefoxBinaryPath() throws ClientApiException { + return api.callApi("selenium", "view", "optionFirefoxBinaryPath", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionFirefoxDefaultProfile() throws ClientApiException { + return api.callApi("selenium", "view", "optionFirefoxDefaultProfile", null); + } + + /** + * Returns the current path to Firefox driver (geckodriver) + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionFirefoxDriverPath() throws ClientApiException { + return api.callApi("selenium", "view", "optionFirefoxDriverPath", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + @Deprecated + public ApiResponse optionIeDriverPath() throws ClientApiException { + return api.callApi("selenium", "view", "optionIeDriverPath", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionLastDirectory() throws ClientApiException { + return api.callApi("selenium", "view", "optionLastDirectory", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + @Deprecated + public ApiResponse optionPhantomJsBinaryPath() throws ClientApiException { + return api.callApi("selenium", "view", "optionPhantomJsBinaryPath", null); + } + + /** + * Gets the browser arguments. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse getBrowserArguments(String browser) throws ClientApiException { + Map map = new HashMap<>(); + map.put("browser", browser); + return api.callApi("selenium", "view", "getBrowserArguments", map); + } + + /** + * Sets the current path to Chrome binary + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionChromeBinaryPath(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionChromeBinaryPath", map); + } + + /** + * Sets the current path to ChromeDriver + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionChromeDriverPath(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionChromeDriverPath", map); + } + + /** + * Sets the current path to Edge binary + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionEdgeBinaryPath(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionEdgeBinaryPath", map); + } + + /** + * Sets the current path to EdgeDriver + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionEdgeDriverPath(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionEdgeDriverPath", map); + } + + /** + * Sets the current path to Firefox binary + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionFirefoxBinaryPath(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionFirefoxBinaryPath", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionFirefoxDefaultProfile(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionFirefoxDefaultProfile", map); + } + + /** + * Sets the current path to Firefox driver (geckodriver) + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionFirefoxDriverPath(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionFirefoxDriverPath", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + @Deprecated + public ApiResponse setOptionIeDriverPath(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionIeDriverPath", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionLastDirectory(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionLastDirectory", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + @Deprecated + public ApiResponse setOptionPhantomJsBinaryPath(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("selenium", "action", "setOptionPhantomJsBinaryPath", map); + } + + /** + * Adds a browser argument. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addBrowserArgument(String browser, String argument, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("browser", browser); + map.put("argument", argument); + if (enabled != null) { + map.put("enabled", enabled); + } + return api.callApi("selenium", "action", "addBrowserArgument", map); + } + + /** + * Launches a browser proxying through ZAP, for manual usage. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse launchBrowser(String browser) throws ClientApiException { + Map map = new HashMap<>(); + map.put("browser", browser); + return api.callApi("selenium", "action", "launchBrowser", map); + } + + /** + * Removes a browser argument. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeBrowserArgument(String browser, String argument) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("browser", browser); + map.put("argument", argument); + return api.callApi("selenium", "action", "removeBrowserArgument", map); + } + /** + * Sets whether or not a browser argument is enabled. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setBrowserArgumentEnabled(String browser, String argument, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("browser", browser); + map.put("argument", argument); + map.put("enabled", enabled); + return api.callApi("selenium", "action", "setBrowserArgumentEnabled", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/SessionManagement.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/SessionManagement.java index e83fc55..683bdd2 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/SessionManagement.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/SessionManagement.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,49 +25,50 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class SessionManagement + extends org.zaproxy.clientapi.gen.deprecated.SessionManagementDeprecated { -/** - * This file was automatically generated. - */ -public class SessionManagement { - - private ClientApi api = null; - - public SessionManagement(ClientApi api) { - this.api = api; - } + private final ClientApi api; - public ApiResponse getSupportedSessionManagementMethods() throws ClientApiException { - Map map = null; - return api.callApi("sessionManagement", "view", "getSupportedSessionManagementMethods", map); - } + public SessionManagement(ClientApi api) { + super(api); + this.api = api; + } - public ApiResponse getSessionManagementMethodConfigParams(String methodname) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("methodName", methodname); - return api.callApi("sessionManagement", "view", "getSessionManagementMethodConfigParams", map); - } + /** Gets the name of the session management methods. */ + public ApiResponse getSupportedSessionManagementMethods() throws ClientApiException { + return api.callApi( + "sessionManagement", "view", "getSupportedSessionManagementMethods", null); + } - public ApiResponse getSessionManagementMethod(String contextid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextId", contextid); - return api.callApi("sessionManagement", "view", "getSessionManagementMethod", map); - } + /** Gets the configuration parameters for the session management method with the given name. */ + public ApiResponse getSessionManagementMethodConfigParams(String methodname) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("methodName", methodname); + return api.callApi( + "sessionManagement", "view", "getSessionManagementMethodConfigParams", map); + } - public ApiResponse setSessionManagementMethod(String apikey, String contextid, String methodname, String methodconfigparams) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("methodName", methodname); - if (methodconfigparams != null) { - map.put("methodConfigParams", methodconfigparams); - } - return api.callApi("sessionManagement", "action", "setSessionManagementMethod", map); - } + /** Gets the name of the session management method for the context with the given ID. */ + public ApiResponse getSessionManagementMethod(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("sessionManagement", "view", "getSessionManagementMethod", map); + } + /** Sets the session management method for the context with the given ID. */ + public ApiResponse setSessionManagementMethod( + String contextid, String methodname, String methodconfigparams) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("methodName", methodname); + if (methodconfigparams != null) { + map.put("methodConfigParams", methodconfigparams); + } + return api.callApi("sessionManagement", "action", "setSessionManagementMethod", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Soap.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Soap.java new file mode 100644 index 0000000..fd617f2 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Soap.java @@ -0,0 +1,59 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2018 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Soap { + + private final ClientApi api; + + public Soap(ClientApi api) { + this.api = api; + } + + /** + * Import a WSDL definition from local file. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importFile(String file) throws ClientApiException { + Map map = new HashMap<>(); + map.put("file", file); + return api.callApi("soap", "action", "importFile", map); + } + + /** + * Import a WSDL definition from a URL. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importUrl(String url) throws ClientApiException { + Map map = new HashMap<>(); + map.put("url", url); + return api.callApi("soap", "action", "importUrl", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Spider.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Spider.java index 92b4414..2c98443 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Spider.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Spider.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,504 +25,652 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Spider { - - private ClientApi api = null; - - public Spider(ClientApi api) { - this.api = api; - } - - public ApiResponse status(String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (scanid != null) { - map.put("scanId", scanid); - } - return api.callApi("spider", "view", "status", map); - } - - public ApiResponse results(String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (scanid != null) { - map.put("scanId", scanid); - } - return api.callApi("spider", "view", "results", map); - } - - public ApiResponse fullResults(String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("scanId", scanid); - return api.callApi("spider", "view", "fullResults", map); - } - - public ApiResponse scans() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "scans", map); - } - - public ApiResponse excludedFromScan() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "excludedFromScan", map); - } - - public ApiResponse optionDomainsAlwaysInScope() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionDomainsAlwaysInScope", map); - } - - public ApiResponse optionDomainsAlwaysInScopeEnabled() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionDomainsAlwaysInScopeEnabled", map); - } - - public ApiResponse optionHandleParameters() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionHandleParameters", map); - } - - public ApiResponse optionMaxDepth() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionMaxDepth", map); - } - - public ApiResponse optionMaxDuration() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionMaxDuration", map); - } - - public ApiResponse optionMaxScansInUI() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionMaxScansInUI", map); - } - - public ApiResponse optionRequestWaitTime() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionRequestWaitTime", map); - } - - public ApiResponse optionScope() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionScope", map); - } - - public ApiResponse optionScopeText() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionScopeText", map); - } - - public ApiResponse optionSkipURLString() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionSkipURLString", map); - } - - public ApiResponse optionThreadCount() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionThreadCount", map); - } - - public ApiResponse optionUserAgent() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionUserAgent", map); - } - - public ApiResponse optionHandleODataParametersVisited() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionHandleODataParametersVisited", map); - } - - public ApiResponse optionParseComments() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionParseComments", map); - } - - public ApiResponse optionParseGit() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionParseGit", map); - } - - public ApiResponse optionParseRobotsTxt() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionParseRobotsTxt", map); - } - - public ApiResponse optionParseSVNEntries() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionParseSVNEntries", map); - } - - public ApiResponse optionParseSitemapXml() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionParseSitemapXml", map); - } - - public ApiResponse optionPostForm() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionPostForm", map); - } - - public ApiResponse optionProcessForm() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionProcessForm", map); - } - - /** - * Sets whether or not the 'Referer' header should be sent while spidering - */ - public ApiResponse optionSendRefererHeader() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionSendRefererHeader", map); - } - - public ApiResponse optionShowAdvancedDialog() throws ClientApiException { - Map map = null; - return api.callApi("spider", "view", "optionShowAdvancedDialog", map); - } - - /** - * 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'). - */ - public ApiResponse scan(String apikey, String url, String maxchildren, String recurse, String contextname, String subtreeonly) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (url != null) { - map.put("url", url); - } - if (maxchildren != null) { - map.put("maxChildren", maxchildren); - } - if (recurse != null) { - map.put("recurse", recurse); - } - if (contextname != null) { - map.put("contextName", contextname); - } - if (subtreeonly != null) { - map.put("subtreeOnly", subtreeonly); - } - return api.callApi("spider", "action", "scan", map); - } - - /** - * Runs the spider from the perspective of a User, obtained using the given Context ID and User ID. See 'scan' action for more details. - */ - public ApiResponse scanAsUser(String apikey, String contextid, String userid, String url, String maxchildren, String recurse, String subtreeonly) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("userId", userid); - if (url != null) { - map.put("url", url); - } - if (maxchildren != null) { - map.put("maxChildren", maxchildren); - } - if (recurse != null) { - map.put("recurse", recurse); - } - if (subtreeonly != null) { - map.put("subtreeOnly", subtreeonly); - } - return api.callApi("spider", "action", "scanAsUser", map); - } - - public ApiResponse pause(String apikey, String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanId", scanid); - return api.callApi("spider", "action", "pause", map); - } - - public ApiResponse resume(String apikey, String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanId", scanid); - return api.callApi("spider", "action", "resume", map); - } - - public ApiResponse stop(String apikey, String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (scanid != null) { - map.put("scanId", scanid); - } - return api.callApi("spider", "action", "stop", map); - } - - public ApiResponse removeScan(String apikey, String scanid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("scanId", scanid); - return api.callApi("spider", "action", "removeScan", map); - } - - public ApiResponse pauseAllScans(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("spider", "action", "pauseAllScans", map); - } - - public ApiResponse resumeAllScans(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("spider", "action", "resumeAllScans", map); - } - - public ApiResponse stopAllScans(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("spider", "action", "stopAllScans", map); - } - - public ApiResponse removeAllScans(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("spider", "action", "removeAllScans", map); - } - - public ApiResponse clearExcludedFromScan(String apikey) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - return api.callApi("spider", "action", "clearExcludedFromScan", map); - } - - public ApiResponse excludeFromScan(String apikey, String regex) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("regex", regex); - return api.callApi("spider", "action", "excludeFromScan", map); - } - - public ApiResponse setOptionHandleParameters(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("spider", "action", "setOptionHandleParameters", map); - } - - public ApiResponse setOptionScopeString(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("spider", "action", "setOptionScopeString", map); - } - - public ApiResponse setOptionSkipURLString(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("spider", "action", "setOptionSkipURLString", map); - } - - public ApiResponse setOptionUserAgent(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("spider", "action", "setOptionUserAgent", map); - } - - public ApiResponse setOptionHandleODataParametersVisited(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionHandleODataParametersVisited", map); - } - - public ApiResponse setOptionMaxDepth(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("spider", "action", "setOptionMaxDepth", map); - } - - public ApiResponse setOptionMaxDuration(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("spider", "action", "setOptionMaxDuration", map); - } - - public ApiResponse setOptionMaxScansInUI(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("spider", "action", "setOptionMaxScansInUI", map); - } - - public ApiResponse setOptionParseComments(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionParseComments", map); - } - - public ApiResponse setOptionParseGit(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionParseGit", map); - } - - public ApiResponse setOptionParseRobotsTxt(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionParseRobotsTxt", map); - } - - public ApiResponse setOptionParseSVNEntries(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionParseSVNEntries", map); - } - - public ApiResponse setOptionParseSitemapXml(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionParseSitemapXml", map); - } - - public ApiResponse setOptionPostForm(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionPostForm", map); - } - - public ApiResponse setOptionProcessForm(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionProcessForm", map); - } - - public ApiResponse setOptionRequestWaitTime(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("spider", "action", "setOptionRequestWaitTime", map); - } - - public ApiResponse setOptionSendRefererHeader(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionSendRefererHeader", map); - } - - public ApiResponse setOptionShowAdvancedDialog(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("spider", "action", "setOptionShowAdvancedDialog", map); - } - - public ApiResponse setOptionThreadCount(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("spider", "action", "setOptionThreadCount", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Spider extends org.zaproxy.clientapi.gen.deprecated.SpiderDeprecated { + + private final ClientApi api; + + public Spider(ClientApi api) { + super(api); + this.api = api; + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse status(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (scanid != null) { + map.put("scanId", scanid); + } + return api.callApi("spider", "view", "status", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse results(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (scanid != null) { + map.put("scanId", scanid); + } + return api.callApi("spider", "view", "results", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse fullResults(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("spider", "view", "fullResults", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse scans() throws ClientApiException { + return api.callApi("spider", "view", "scans", null); + } + + /** + * Gets the regexes of URLs excluded from the spider scans. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse excludedFromScan() throws ClientApiException { + return api.callApi("spider", "view", "excludedFromScan", null); + } + + /** + * Returns a list of unique URLs from the history table based on HTTP messages added by the + * Spider. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse allUrls() throws ClientApiException { + return api.callApi("spider", "view", "allUrls", null); + } + + /** + * Returns a list of the names of the nodes added to the Sites tree by the specified scan. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addedNodes(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (scanid != null) { + map.put("scanId", scanid); + } + return api.callApi("spider", "view", "addedNodes", map); + } + + /** + * 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. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse domainsAlwaysInScope() throws ClientApiException { + return api.callApi("spider", "view", "domainsAlwaysInScope", null); + } + + /** + * Use view domainsAlwaysInScope instead. + * + *

This component is optional and therefore the API will only work if it is installed + * + * @deprecated + */ + @Deprecated + public ApiResponse optionDomainsAlwaysInScope() throws ClientApiException { + return api.callApi("spider", "view", "optionDomainsAlwaysInScope", null); + } + + /** + * Use view domainsAlwaysInScope instead. + * + *

This component is optional and therefore the API will only work if it is installed + * + * @deprecated + */ + @Deprecated + public ApiResponse optionDomainsAlwaysInScopeEnabled() throws ClientApiException { + return api.callApi("spider", "view", "optionDomainsAlwaysInScopeEnabled", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionHandleParameters() throws ClientApiException { + return api.callApi("spider", "view", "optionHandleParameters", null); + } + + /** + * Gets the maximum number of child nodes (per node) that can be crawled, 0 means no limit. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxChildren() throws ClientApiException { + return api.callApi("spider", "view", "optionMaxChildren", null); + } + + /** + * Gets the maximum depth the spider can crawl, 0 if unlimited. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxDepth() throws ClientApiException { + return api.callApi("spider", "view", "optionMaxDepth", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionMaxDuration() throws ClientApiException { + return api.callApi("spider", "view", "optionMaxDuration", null); + } + + /** + * Gets the maximum size, in bytes, that a response might have to be parsed, or 0 for unlimited. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionMaxParseSizeBytes() throws ClientApiException { + return api.callApi("spider", "view", "optionMaxParseSizeBytes", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionMaxScansInUI() throws ClientApiException { + return api.callApi("spider", "view", "optionMaxScansInUI", null); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated + */ + @Deprecated + public ApiResponse optionRequestWaitTime() throws ClientApiException { + return api.callApi("spider", "view", "optionRequestWaitTime", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionSkipURLString() throws ClientApiException { + return api.callApi("spider", "view", "optionSkipURLString", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionThreadCount() throws ClientApiException { + return api.callApi("spider", "view", "optionThreadCount", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionUserAgent() throws ClientApiException { + return api.callApi("spider", "view", "optionUserAgent", null); + } + + /** + * Gets whether or not a spider process should accept cookies while spidering. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionAcceptCookies() throws ClientApiException { + return api.callApi("spider", "view", "optionAcceptCookies", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionHandleODataParametersVisited() throws ClientApiException { + return api.callApi("spider", "view", "optionHandleODataParametersVisited", null); + } + + /** + * Gets whether or not the spider should attempt to avoid logout related paths/functionality. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionLogoutAvoidance() throws ClientApiException { + return api.callApi("spider", "view", "optionLogoutAvoidance", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionParseComments() throws ClientApiException { + return api.callApi("spider", "view", "optionParseComments", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionParseDsStore() throws ClientApiException { + return api.callApi("spider", "view", "optionParseDsStore", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionParseGit() throws ClientApiException { + return api.callApi("spider", "view", "optionParseGit", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionParseRobotsTxt() throws ClientApiException { + return api.callApi("spider", "view", "optionParseRobotsTxt", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionParseSVNEntries() throws ClientApiException { + return api.callApi("spider", "view", "optionParseSVNEntries", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionParseSitemapXml() throws ClientApiException { + return api.callApi("spider", "view", "optionParseSitemapXml", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionPostForm() throws ClientApiException { + return api.callApi("spider", "view", "optionPostForm", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionProcessForm() throws ClientApiException { + return api.callApi("spider", "view", "optionProcessForm", null); + } + + /** + * Gets whether or not the 'Referer' header should be sent while spidering. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse optionSendRefererHeader() throws ClientApiException { + return api.callApi("spider", "view", "optionSendRefererHeader", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse optionShowAdvancedDialog() throws ClientApiException { + return api.callApi("spider", "view", "optionShowAdvancedDialog", null); + } + + /** + * 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'). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scan( + String url, String maxchildren, String recurse, String contextname, String subtreeonly) + throws ClientApiException { + Map map = new HashMap<>(); + if (url != null) { + map.put("url", url); + } + if (maxchildren != null) { + map.put("maxChildren", maxchildren); + } + if (recurse != null) { + map.put("recurse", recurse); + } + if (contextname != null) { + map.put("contextName", contextname); + } + if (subtreeonly != null) { + map.put("subtreeOnly", subtreeonly); + } + return api.callApi("spider", "action", "scan", map); + } + + /** + * Runs the spider from the perspective of a User, obtained using the given Context ID and User + * ID. See 'scan' action for more details. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse scanAsUser( + String contextid, + String userid, + String url, + String maxchildren, + String recurse, + String subtreeonly) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + if (url != null) { + map.put("url", url); + } + if (maxchildren != null) { + map.put("maxChildren", maxchildren); + } + if (recurse != null) { + map.put("recurse", recurse); + } + if (subtreeonly != null) { + map.put("subtreeOnly", subtreeonly); + } + return api.callApi("spider", "action", "scanAsUser", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse pause(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("spider", "action", "pause", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse resume(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("spider", "action", "resume", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse stop(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (scanid != null) { + map.put("scanId", scanid); + } + return api.callApi("spider", "action", "stop", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse removeScan(String scanid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("scanId", scanid); + return api.callApi("spider", "action", "removeScan", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse pauseAllScans() throws ClientApiException { + return api.callApi("spider", "action", "pauseAllScans", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse resumeAllScans() throws ClientApiException { + return api.callApi("spider", "action", "resumeAllScans", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse stopAllScans() throws ClientApiException { + return api.callApi("spider", "action", "stopAllScans", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse removeAllScans() throws ClientApiException { + return api.callApi("spider", "action", "removeAllScans", null); + } + + /** + * Clears the regexes of URLs excluded from the spider scans. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse clearExcludedFromScan() throws ClientApiException { + return api.callApi("spider", "action", "clearExcludedFromScan", null); + } + + /** + * Adds a regex of URLs that should be excluded from the spider scans. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse excludeFromScan(String regex) throws ClientApiException { + Map map = new HashMap<>(); + map.put("regex", regex); + return api.callApi("spider", "action", "excludeFromScan", map); + } + + /** + * 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). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addDomainAlwaysInScope(String value, String isregex, String isenabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("value", value); + if (isregex != null) { + map.put("isRegex", isregex); + } + if (isenabled != null) { + map.put("isEnabled", isenabled); + } + return api.callApi("spider", "action", "addDomainAlwaysInScope", map); + } + + /** + * 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. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse modifyDomainAlwaysInScope( + String idx, String value, String isregex, String isenabled) throws ClientApiException { + Map map = new HashMap<>(); + map.put("idx", idx); + if (value != null) { + map.put("value", value); + } + if (isregex != null) { + map.put("isRegex", isregex); + } + if (isenabled != null) { + map.put("isEnabled", isenabled); + } + return api.callApi("spider", "action", "modifyDomainAlwaysInScope", map); + } + + /** + * Removes a domain that's always in scope, with the given index. The index can be obtained with + * the view domainsAlwaysInScope. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeDomainAlwaysInScope(String idx) throws ClientApiException { + Map map = new HashMap<>(); + map.put("idx", idx); + return api.callApi("spider", "action", "removeDomainAlwaysInScope", map); + } + + /** + * Enables all domains that are always in scope. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse enableAllDomainsAlwaysInScope() throws ClientApiException { + return api.callApi("spider", "action", "enableAllDomainsAlwaysInScope", null); + } + + /** + * Disables all domains that are always in scope. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse disableAllDomainsAlwaysInScope() throws ClientApiException { + return api.callApi("spider", "action", "disableAllDomainsAlwaysInScope", null); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionHandleParameters(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("spider", "action", "setOptionHandleParameters", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionSkipURLString(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("spider", "action", "setOptionSkipURLString", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionUserAgent(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("spider", "action", "setOptionUserAgent", map); + } + + /** + * Sets whether or not a spider process should accept cookies while spidering. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionAcceptCookies(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionAcceptCookies", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionHandleODataParametersVisited(boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionHandleODataParametersVisited", map); + } + + /** + * Sets whether or not the Spider should attempt to avoid logout related paths/functionality. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionLogoutAvoidance(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionLogoutAvoidance", map); + } + + /** + * Sets the maximum number of child nodes (per node) that can be crawled, 0 means no limit. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxChildren(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionMaxChildren", map); + } + + /** + * Sets the maximum depth the spider can crawl, 0 for unlimited depth. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxDepth(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionMaxDepth", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionMaxDuration(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionMaxDuration", map); + } + + /** + * Sets the maximum size, in bytes, that a response might have to be parsed. This allows the + * spider to skip big responses/files. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionMaxParseSizeBytes(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionMaxParseSizeBytes", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionMaxScansInUI(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionMaxScansInUI", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionParseComments(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseComments", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionParseDsStore(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseDsStore", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionParseGit(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseGit", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionParseRobotsTxt(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseRobotsTxt", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionParseSVNEntries(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseSVNEntries", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionParseSitemapXml(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseSitemapXml", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionPostForm(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionPostForm", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionProcessForm(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionProcessForm", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated + */ + @Deprecated + public ApiResponse setOptionRequestWaitTime(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionRequestWaitTime", map); + } + + /** + * Sets whether or not the 'Referer' header should be sent while spidering. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setOptionSendRefererHeader(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionSendRefererHeader", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionShowAdvancedDialog(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionShowAdvancedDialog", map); + } + + /** This component is optional and therefore the API will only work if it is installed */ + public ApiResponse setOptionThreadCount(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionThreadCount", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Stats.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Stats.java index 7bcff0c..ed493f8 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Stats.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Stats.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,160 +25,106 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Stats { - - private ClientApi api = null; - - public Stats(ClientApi api) { - this.api = api; - } - - /** - * Statistics - */ - public ApiResponse stats(String keyprefix) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (keyprefix != null) { - map.put("keyPrefix", keyprefix); - } - return api.callApi("stats", "view", "stats", map); - } - - /** - * Gets all of the site based statistics, optionally filtered by a key prefix - */ - public ApiResponse allSitesStats(String keyprefix) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (keyprefix != null) { - map.put("keyPrefix", keyprefix); - } - return api.callApi("stats", "view", "allSitesStats", map); - } - - /** - * Gets all of the global statistics, optionally filtered by a key prefix - */ - public ApiResponse siteStats(String site, String keyprefix) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("site", site); - if (keyprefix != null) { - map.put("keyPrefix", keyprefix); - } - return api.callApi("stats", "view", "siteStats", map); - } - - /** - * Gets the Statsd service hostname - */ - public ApiResponse optionStatsdHost() throws ClientApiException { - Map map = null; - return api.callApi("stats", "view", "optionStatsdHost", map); - } - - /** - * Gets the Statsd service port - */ - public ApiResponse optionStatsdPort() throws ClientApiException { - Map map = null; - return api.callApi("stats", "view", "optionStatsdPort", map); - } - - /** - * Gets the prefix to be applied to all stats sent to the configured Statsd service - */ - public ApiResponse optionStatsdPrefix() throws ClientApiException { - Map map = null; - return api.callApi("stats", "view", "optionStatsdPrefix", map); - } - - /** - * Returns 'true' if in memory statistics are enabled, otherwise returns 'false' - */ - public ApiResponse optionInMemoryEnabled() throws ClientApiException { - Map map = null; - return api.callApi("stats", "view", "optionInMemoryEnabled", map); - } - - /** - * Returns 'true' if a Statsd server has been correctly configured, otherwise returns 'false' - */ - public ApiResponse optionStatsdEnabled() throws ClientApiException { - Map map = null; - return api.callApi("stats", "view", "optionStatsdEnabled", map); - } - - /** - * Clears all of the statistics - */ - public ApiResponse clearStats(String apikey, String keyprefix) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - if (keyprefix != null) { - map.put("keyPrefix", keyprefix); - } - return api.callApi("stats", "action", "clearStats", map); - } - - /** - * Sets the Statsd service hostname, supply an empty string to stop using a Statsd service - */ - public ApiResponse setOptionStatsdHost(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("stats", "action", "setOptionStatsdHost", map); - } - - /** - * Sets the prefix to be applied to all stats sent to the configured Statsd service - */ - public ApiResponse setOptionStatsdPrefix(String apikey, String string) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("String", string); - return api.callApi("stats", "action", "setOptionStatsdPrefix", map); - } - - /** - * Sets whether in memory statistics are enabled - */ - public ApiResponse setOptionInMemoryEnabled(String apikey, boolean bool) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Boolean", Boolean.toString(bool)); - return api.callApi("stats", "action", "setOptionInMemoryEnabled", map); - } - - /** - * Sets the Statsd service port - */ - public ApiResponse setOptionStatsdPort(String apikey, int i) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("Integer", Integer.toString(i)); - return api.callApi("stats", "action", "setOptionStatsdPort", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Stats extends org.zaproxy.clientapi.gen.deprecated.StatsDeprecated { + + private final ClientApi api; + + public Stats(ClientApi api) { + super(api); + this.api = api; + } + + /** Statistics */ + public ApiResponse stats(String keyprefix) throws ClientApiException { + Map map = new HashMap<>(); + if (keyprefix != null) { + map.put("keyPrefix", keyprefix); + } + return api.callApi("stats", "view", "stats", map); + } + + /** Gets all of the site based statistics, optionally filtered by a key prefix */ + public ApiResponse allSitesStats(String keyprefix) throws ClientApiException { + Map map = new HashMap<>(); + if (keyprefix != null) { + map.put("keyPrefix", keyprefix); + } + return api.callApi("stats", "view", "allSitesStats", map); + } + + /** Gets all of the global statistics, optionally filtered by a key prefix */ + public ApiResponse siteStats(String site, String keyprefix) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + if (keyprefix != null) { + map.put("keyPrefix", keyprefix); + } + return api.callApi("stats", "view", "siteStats", map); + } + + /** Gets the Statsd service hostname */ + public ApiResponse optionStatsdHost() throws ClientApiException { + return api.callApi("stats", "view", "optionStatsdHost", null); + } + + /** Gets the Statsd service port */ + public ApiResponse optionStatsdPort() throws ClientApiException { + return api.callApi("stats", "view", "optionStatsdPort", null); + } + + /** Gets the prefix to be applied to all stats sent to the configured Statsd service */ + public ApiResponse optionStatsdPrefix() throws ClientApiException { + return api.callApi("stats", "view", "optionStatsdPrefix", null); + } + + /** Returns 'true' if in memory statistics are enabled, otherwise returns 'false' */ + public ApiResponse optionInMemoryEnabled() throws ClientApiException { + return api.callApi("stats", "view", "optionInMemoryEnabled", null); + } + + /** + * Returns 'true' if a Statsd server has been correctly configured, otherwise returns 'false' + */ + public ApiResponse optionStatsdEnabled() throws ClientApiException { + return api.callApi("stats", "view", "optionStatsdEnabled", null); + } + + /** Clears all of the statistics */ + public ApiResponse clearStats(String keyprefix) throws ClientApiException { + Map map = new HashMap<>(); + if (keyprefix != null) { + map.put("keyPrefix", keyprefix); + } + return api.callApi("stats", "action", "clearStats", map); + } + + /** Sets the Statsd service hostname, supply an empty string to stop using a Statsd service */ + public ApiResponse setOptionStatsdHost(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("stats", "action", "setOptionStatsdHost", map); + } + + /** Sets the prefix to be applied to all stats sent to the configured Statsd service */ + public ApiResponse setOptionStatsdPrefix(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("stats", "action", "setOptionStatsdPrefix", map); + } + + /** Sets whether in memory statistics are enabled */ + public ApiResponse setOptionInMemoryEnabled(boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("stats", "action", "setOptionInMemoryEnabled", map); + } + + /** Sets the Statsd service port */ + public ApiResponse setOptionStatsdPort(int i) throws ClientApiException { + Map map = new HashMap<>(); + map.put("Integer", Integer.toString(i)); + return api.callApi("stats", "action", "setOptionStatsdPort", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Users.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Users.java index 22500e8..a84056a 100644 --- a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Users.java +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Users.java @@ -1,14 +1,15 @@ -/* Zed Attack Proxy (ZAP) and its related class files. +/* + * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * - * Copyright 2016 the ZAP development team + * Copyright 2017 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -16,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.zaproxy.clientapi.gen; import java.util.HashMap; @@ -26,112 +25,209 @@ import org.zaproxy.clientapi.core.ClientApi; import org.zaproxy.clientapi.core.ClientApiException; - -/** - * This file was automatically generated. - */ -public class Users { - - private ClientApi api = null; - - public Users(ClientApi api) { - this.api = api; - } - - public ApiResponse usersList(String contextid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (contextid != null) { - map.put("contextId", contextid); - } - return api.callApi("users", "view", "usersList", map); - } - - public ApiResponse getUserById(String contextid, String userid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (contextid != null) { - map.put("contextId", contextid); - } - if (userid != null) { - map.put("userId", userid); - } - return api.callApi("users", "view", "getUserById", map); - } - - public ApiResponse getAuthenticationCredentialsConfigParams(String contextid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextId", contextid); - return api.callApi("users", "view", "getAuthenticationCredentialsConfigParams", map); - } - - public ApiResponse getAuthenticationCredentials(String contextid, String userid) throws ClientApiException { - Map map = null; - map = new HashMap(); - map.put("contextId", contextid); - map.put("userId", userid); - return api.callApi("users", "view", "getAuthenticationCredentials", map); - } - - public ApiResponse newUser(String apikey, String contextid, String name) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("name", name); - return api.callApi("users", "action", "newUser", map); - } - - public ApiResponse removeUser(String apikey, String contextid, String userid) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("userId", userid); - return api.callApi("users", "action", "removeUser", map); - } - - public ApiResponse setUserEnabled(String apikey, String contextid, String userid, String enabled) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("userId", userid); - map.put("enabled", enabled); - return api.callApi("users", "action", "setUserEnabled", map); - } - - public ApiResponse setUserName(String apikey, String contextid, String userid, String name) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("userId", userid); - map.put("name", name); - return api.callApi("users", "action", "setUserName", map); - } - - public ApiResponse setAuthenticationCredentials(String apikey, String contextid, String userid, String authcredentialsconfigparams) throws ClientApiException { - Map map = null; - map = new HashMap(); - if (apikey != null) { - map.put("apikey", apikey); - } - map.put("contextId", contextid); - map.put("userId", userid); - if (authcredentialsconfigparams != null) { - map.put("authCredentialsConfigParams", authcredentialsconfigparams); - } - return api.callApi("users", "action", "setAuthenticationCredentials", map); - } - +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Users extends org.zaproxy.clientapi.gen.deprecated.UsersDeprecated { + + private final ClientApi api; + + public Users(ClientApi api) { + super(api); + this.api = api; + } + + /** + * Gets a list of users that belong to the context with the given ID, or all users if none + * provided. + */ + public ApiResponse usersList(String contextid) throws ClientApiException { + Map map = new HashMap<>(); + if (contextid != null) { + map.put("contextId", contextid); + } + return api.callApi("users", "view", "usersList", map); + } + + /** + * Gets the data of the user with the given ID that belongs to the context with the given ID. + */ + public ApiResponse getUserById(String contextid, String userid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("users", "view", "getUserById", map); + } + + /** Gets the configuration parameters for the credentials of the context with the given ID. */ + public ApiResponse getAuthenticationCredentialsConfigParams(String contextid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + return api.callApi("users", "view", "getAuthenticationCredentialsConfigParams", map); + } + + /** + * Gets the authentication credentials of the user with given ID that belongs to the context + * with the given ID. + */ + public ApiResponse getAuthenticationCredentials(String contextid, String userid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("users", "view", "getAuthenticationCredentials", map); + } + + /** + * Gets the authentication state information for the user identified by the Context and User + * Ids. + */ + public ApiResponse getAuthenticationState(String contextid, String userid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("users", "view", "getAuthenticationState", map); + } + + /** + * Gets the authentication session information for the user identified by the Context and User + * Ids, e.g. cookies and realm credentials. + */ + public ApiResponse getAuthenticationSession(String contextid, String userid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("users", "view", "getAuthenticationSession", map); + } + + /** Creates a new user with the given name for the context with the given ID. */ + public ApiResponse newUser(String contextid, String name) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("name", name); + return api.callApi("users", "action", "newUser", map); + } + + /** Removes the user with the given ID that belongs to the context with the given ID. */ + public ApiResponse removeUser(String contextid, String userid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("users", "action", "removeUser", map); + } + + /** + * Sets whether or not the user, with the given ID that belongs to the context with the given + * ID, should be enabled. + */ + public ApiResponse setUserEnabled(String contextid, String userid, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + map.put("enabled", enabled); + return api.callApi("users", "action", "setUserEnabled", map); + } + + /** Renames the user with the given ID that belongs to the context with the given ID. */ + public ApiResponse setUserName(String contextid, String userid, String name) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + map.put("name", name); + return api.callApi("users", "action", "setUserName", map); + } + + /** + * Sets the authentication credentials for the user with the given ID that belongs to the + * context with the given ID. + */ + public ApiResponse setAuthenticationCredentials( + String contextid, String userid, String authcredentialsconfigparams) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + if (authcredentialsconfigparams != null) { + map.put("authCredentialsConfigParams", authcredentialsconfigparams); + } + return api.callApi("users", "action", "setAuthenticationCredentials", map); + } + + /** + * Tries to authenticate as the identified user, returning the authentication request and + * whether it appears to have succeeded. + */ + public ApiResponse authenticateAsUser(String contextid, String userid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("users", "action", "authenticateAsUser", map); + } + + /** + * Tries to poll as the identified user, returning the authentication request and whether it + * appears to have succeeded. This will only work if the polling verification strategy has been + * configured. + */ + public ApiResponse pollAsUser(String contextid, String userid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("users", "action", "pollAsUser", map); + } + + /** + * Sets fields in the authentication state for the user identified by the Context and User Ids. + */ + public ApiResponse setAuthenticationState( + String contextid, + String userid, + String lastpollresult, + String lastpolltimeinms, + String requestssincelastpoll) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + if (lastpollresult != null) { + map.put("lastPollResult", lastpollresult); + } + if (lastpolltimeinms != null) { + map.put("lastPollTimeInMs", lastpolltimeinms); + } + if (requestssincelastpoll != null) { + map.put("requestsSinceLastPoll", requestssincelastpoll); + } + return api.callApi("users", "action", "setAuthenticationState", map); + } + + /** Sets the specified cookie for the user identified by the Context and User Ids. */ + public ApiResponse setCookie( + String contextid, + String userid, + String domain, + String name, + String value, + String path, + String secure) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("contextId", contextid); + map.put("userId", userid); + map.put("domain", domain); + map.put("name", name); + map.put("value", value); + if (path != null) { + map.put("path", path); + } + if (secure != null) { + map.put("secure", secure); + } + return api.callApi("users", "action", "setCookie", map); + } } diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Wappalyzer.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Wappalyzer.java new file mode 100644 index 0000000..465de02 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Wappalyzer.java @@ -0,0 +1,66 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2020 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Wappalyzer { + + private final ClientApi api; + + public Wappalyzer(ClientApi api) { + this.api = api; + } + + /** + * Lists all the sites recognized by the Technology Detection add-on. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse listSites() throws ClientApiException { + return api.callApi("wappalyzer", "view", "listSites", null); + } + + /** + * Lists all sites and their associated applications (technologies). + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse listAll() throws ClientApiException { + return api.callApi("wappalyzer", "view", "listAll", null); + } + + /** + * Lists all the applications (technologies) associated with a specific site. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse listSite(String site) throws ClientApiException { + Map map = new HashMap<>(); + map.put("site", site); + return api.callApi("wappalyzer", "view", "listSite", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Websocket.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Websocket.java new file mode 100644 index 0000000..799c0ac --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/Websocket.java @@ -0,0 +1,123 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2018 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** This file was automatically generated. */ +@SuppressWarnings("javadoc") +public class Websocket { + + private final ClientApi api; + + public Websocket(ClientApi api) { + this.api = api; + } + + /** + * Returns all of the registered web socket channels + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse channels() throws ClientApiException { + return api.callApi("websocket", "view", "channels", null); + } + + /** + * Returns full details of the message specified by the channelId and messageId + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse message(String channelid, String messageid) throws ClientApiException { + Map map = new HashMap<>(); + map.put("channelId", channelid); + map.put("messageId", messageid); + return api.callApi("websocket", "view", "message", map); + } + + /** + * 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 + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse messages( + String channelid, String start, String count, String payloadpreviewlength) + throws ClientApiException { + Map map = new HashMap<>(); + if (channelid != null) { + map.put("channelId", channelid); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + if (payloadpreviewlength != null) { + map.put("payloadPreviewLength", payloadpreviewlength); + } + return api.callApi("websocket", "view", "messages", map); + } + + /** + * Returns a text representation of an intercepted websockets message + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse breakTextMessage() throws ClientApiException { + return api.callApi("websocket", "view", "breakTextMessage", null); + } + + /** + * 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 + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse sendTextMessage(String channelid, String outgoing, String message) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("channelId", channelid); + map.put("outgoing", outgoing); + map.put("message", message); + return api.callApi("websocket", "action", "sendTextMessage", map); + } + + /** + * Sets the text message for an intercepted websockets message + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse setBreakTextMessage(String message, String outgoing) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("message", message); + map.put("outgoing", outgoing); + return api.callApi("websocket", "action", "setBreakTextMessage", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AcsrfDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AcsrfDeprecated.java new file mode 100644 index 0000000..de47511 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AcsrfDeprecated.java @@ -0,0 +1,92 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class AcsrfDeprecated { + + private final ClientApi api; + + public AcsrfDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse addOptionToken(String apikey, String string) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("acsrf", "action", "addOptionToken", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeOptionToken(String apikey, String string) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("acsrf", "action", "removeOptionToken", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] genForm(String apikey, String hrefid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("hrefId", hrefid); + return api.callApiOther("acsrf", "other", "genForm", map); + } + + /** Generate a form for testing lack of anti-CSRF tokens - typically invoked via ZAP */ + public byte[] genFormWithUrl(String hrefid, String actionurl) throws ClientApiException { + Map map = new HashMap<>(); + map.put("hrefId", hrefid); + if (actionurl != null) { + map.put("actionUrl", actionurl); + } + return api.callApiOther("acsrf", "other", "genForm", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AjaxSpiderDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AjaxSpiderDeprecated.java new file mode 100644 index 0000000..870391c --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AjaxSpiderDeprecated.java @@ -0,0 +1,248 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class AjaxSpiderDeprecated { + + private final ClientApi api; + + public AjaxSpiderDeprecated(ClientApi api) { + this.api = api; + } + + /** + * This component is optional and therefore the API will only work if it is installed. + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse scan(String apikey, String url, String inscope) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (url != null) { + map.put("url", url); + } + if (inscope != null) { + map.put("inScope", inscope); + } + return api.callApi("ajaxSpider", "action", "scan", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse stop(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("ajaxSpider", "action", "stop", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionBrowserId(String apikey, String string) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("ajaxSpider", "action", "setOptionBrowserId", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionClickDefaultElems(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ajaxSpider", "action", "setOptionClickDefaultElems", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionClickElemsOnce(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ajaxSpider", "action", "setOptionClickElemsOnce", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionEventWait(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionEventWait", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxCrawlDepth(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionMaxCrawlDepth", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxCrawlStates(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionMaxCrawlStates", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxDuration(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionMaxDuration", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionNumberOfBrowsers(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionNumberOfBrowsers", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionRandomInputs(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ajaxSpider", "action", "setOptionRandomInputs", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionReloadWait(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ajaxSpider", "action", "setOptionReloadWait", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AlertFilterDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AlertFilterDeprecated.java new file mode 100644 index 0000000..71a5e17 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AlertFilterDeprecated.java @@ -0,0 +1,304 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2023 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public abstract class AlertFilterDeprecated { + + /** + * Adds a new alert filter for the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addAlertFilter( + String contextid, + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled) + throws ClientApiException { + return addAlertFilter( + contextid, + ruleid, + newlevel, + url, + urlisregex, + parameter, + enabled, + null, + null, + null, + null, + null); + } + + /** + * Adds a new alert filter for the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addAlertFilter( + String contextid, + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex) + throws ClientApiException { + return addAlertFilter( + contextid, + ruleid, + newlevel, + url, + urlisregex, + parameter, + enabled, + parameterisregex, + attack, + attackisregex, + evidence, + evidenceisregex, + null); + } + + /** + * Adds a new alert filter for the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public abstract ApiResponse addAlertFilter( + String contextid, + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex, + String methods) + throws ClientApiException; + + /** + * Adds a new global alert filter. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse addGlobalAlertFilter( + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex) + throws ClientApiException { + return addGlobalAlertFilter( + ruleid, + newlevel, + url, + urlisregex, + parameter, + enabled, + parameterisregex, + attack, + attackisregex, + evidence, + evidenceisregex, + null); + } + + /** + * Adds a new global alert filter. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public abstract ApiResponse addGlobalAlertFilter( + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex, + String methods) + throws ClientApiException; + + /** + * Removes an alert filter from the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeAlertFilter( + String contextid, + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled) + throws ClientApiException { + return removeAlertFilter( + contextid, + ruleid, + newlevel, + url, + urlisregex, + parameter, + enabled, + null, + null, + null, + null, + null); + } + + /** + * Removes an alert filter from the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeAlertFilter( + String contextid, + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex) + throws ClientApiException { + return removeAlertFilter( + contextid, + ruleid, + newlevel, + url, + urlisregex, + parameter, + enabled, + parameterisregex, + attack, + attackisregex, + evidence, + evidenceisregex, + null); + } + + /** + * Removes an alert filter from the context with the given ID. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public abstract ApiResponse removeAlertFilter( + String contextid, + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex, + String methods) + throws ClientApiException; + + /** + * Removes a global alert filter. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse removeGlobalAlertFilter( + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex) + throws ClientApiException { + return removeGlobalAlertFilter( + ruleid, + newlevel, + url, + urlisregex, + parameter, + enabled, + parameterisregex, + attack, + attackisregex, + evidence, + evidenceisregex, + null); + } + + /** + * Removes a global alert filter. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public abstract ApiResponse removeGlobalAlertFilter( + String ruleid, + String newlevel, + String url, + String urlisregex, + String parameter, + String enabled, + String parameterisregex, + String attack, + String attackisregex, + String evidence, + String evidenceisregex, + String methods) + throws ClientApiException; +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AscanDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AscanDeprecated.java new file mode 100644 index 0000000..71c5f05 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AscanDeprecated.java @@ -0,0 +1,754 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class AscanDeprecated { + + private final ClientApi api; + + public AscanDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse scan( + String apikey, + String url, + String recurse, + String inscopeonly, + String scanpolicyname, + String method, + String postdata) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("url", url); + if (recurse != null) { + map.put("recurse", recurse); + } + if (inscopeonly != null) { + map.put("inScopeOnly", inscopeonly); + } + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + if (method != null) { + map.put("method", method); + } + if (postdata != null) { + map.put("postData", postdata); + } + return api.callApi("ascan", "action", "scan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse scanAsUser( + String apikey, + String url, + String contextid, + String userid, + String recurse, + String scanpolicyname, + String method, + String postdata) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("url", url); + map.put("contextId", contextid); + map.put("userId", userid); + if (recurse != null) { + map.put("recurse", recurse); + } + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + if (method != null) { + map.put("method", method); + } + if (postdata != null) { + map.put("postData", postdata); + } + return api.callApi("ascan", "action", "scanAsUser", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse pause(String apikey, String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanId", scanid); + return api.callApi("ascan", "action", "pause", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse resume(String apikey, String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanId", scanid); + return api.callApi("ascan", "action", "resume", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse stop(String apikey, String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanId", scanid); + return api.callApi("ascan", "action", "stop", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeScan(String apikey, String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanId", scanid); + return api.callApi("ascan", "action", "removeScan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse pauseAllScans(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("ascan", "action", "pauseAllScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse resumeAllScans(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("ascan", "action", "resumeAllScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse stopAllScans(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("ascan", "action", "stopAllScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeAllScans(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("ascan", "action", "removeAllScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse clearExcludedFromScan(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("ascan", "action", "clearExcludedFromScan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse excludeFromScan(String apikey, String regex) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("regex", regex); + return api.callApi("ascan", "action", "excludeFromScan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse enableAllScanners(String apikey, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "enableAllScanners", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse disableAllScanners(String apikey, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "disableAllScanners", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse enableScanners(String apikey, String ids, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("ids", ids); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "enableScanners", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse disableScanners(String apikey, String ids, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("ids", ids); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "disableScanners", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setEnabledPolicies(String apikey, String ids, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("ids", ids); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setEnabledPolicies", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setPolicyAttackStrength( + String apikey, String id, String attackstrength, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + map.put("attackStrength", attackstrength); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setPolicyAttackStrength", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setPolicyAlertThreshold( + String apikey, String id, String alertthreshold, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + map.put("alertThreshold", alertthreshold); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setPolicyAlertThreshold", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setScannerAttackStrength( + String apikey, String id, String attackstrength, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + map.put("attackStrength", attackstrength); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setScannerAttackStrength", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setScannerAlertThreshold( + String apikey, String id, String alertthreshold, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + map.put("alertThreshold", alertthreshold); + if (scanpolicyname != null) { + map.put("scanPolicyName", scanpolicyname); + } + return api.callApi("ascan", "action", "setScannerAlertThreshold", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse addScanPolicy(String apikey, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanPolicyName", scanpolicyname); + return api.callApi("ascan", "action", "addScanPolicy", map); + } + + @Deprecated + public ApiResponse addScanPolicy(String scanpolicyname) throws ClientApiException { + return addScanPolicy(scanpolicyname, null); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeScanPolicy(String apikey, String scanpolicyname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanPolicyName", scanpolicyname); + return api.callApi("ascan", "action", "removeScanPolicy", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionAttackPolicy(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("ascan", "action", "setOptionAttackPolicy", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionDefaultPolicy(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("ascan", "action", "setOptionDefaultPolicy", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionAllowAttackOnStart(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionAllowAttackOnStart", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionDelayInMs(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionDelayInMs", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionHandleAntiCSRFTokens(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionHandleAntiCSRFTokens", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionHostPerScan(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionHostPerScan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionInjectPluginIdInHeader(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionInjectPluginIdInHeader", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxChartTimeInMins(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxChartTimeInMins", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxResultsToList(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxResultsToList", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxScansInUI(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionMaxScansInUI", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionPromptInAttackMode(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionPromptInAttackMode", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionPromptToClearFinishedScans(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionPromptToClearFinishedScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionRescanInAttackMode(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionRescanInAttackMode", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionScanHeadersAllRequests(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionScanHeadersAllRequests", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionShowAdvancedDialog(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("ascan", "action", "setOptionShowAdvancedDialog", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionTargetParamsEnabledRPC(String apikey, int i) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionTargetParamsEnabledRPC", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionTargetParamsInjectable(String apikey, int i) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionTargetParamsInjectable", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionThreadPerHost(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("ascan", "action", "setOptionThreadPerHost", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AuthenticationDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AuthenticationDeprecated.java new file mode 100644 index 0000000..19d1f39 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AuthenticationDeprecated.java @@ -0,0 +1,94 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class AuthenticationDeprecated { + + private final ClientApi api; + + public AuthenticationDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setAuthenticationMethod( + String apikey, String contextid, String authmethodname, String authmethodconfigparams) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("authMethodName", authmethodname); + if (authmethodconfigparams != null) { + map.put("authMethodConfigParams", authmethodconfigparams); + } + return api.callApi("authentication", "action", "setAuthenticationMethod", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setLoggedInIndicator( + String apikey, String contextid, String loggedinindicatorregex) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("loggedInIndicatorRegex", loggedinindicatorregex); + return api.callApi("authentication", "action", "setLoggedInIndicator", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setLoggedOutIndicator( + String apikey, String contextid, String loggedoutindicatorregex) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("loggedOutIndicatorRegex", loggedoutindicatorregex); + return api.callApi("authentication", "action", "setLoggedOutIndicator", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AuthorizationDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AuthorizationDeprecated.java new file mode 100644 index 0000000..2cb0ec4 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AuthorizationDeprecated.java @@ -0,0 +1,71 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class AuthorizationDeprecated { + + private final ClientApi api; + + public AuthorizationDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setBasicAuthorizationDetectionMethod( + String apikey, + String contextid, + String headerregex, + String bodyregex, + String statuscode, + String logicaloperator) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + if (headerregex != null) { + map.put("headerRegex", headerregex); + } + if (bodyregex != null) { + map.put("bodyRegex", bodyregex); + } + if (statuscode != null) { + map.put("statusCode", statuscode); + } + if (logicaloperator != null) { + map.put("logicalOperator", logicaloperator); + } + return api.callApi("authorization", "action", "setBasicAuthorizationDetectionMethod", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AutoupdateDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AutoupdateDeprecated.java new file mode 100644 index 0000000..5947eaf --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/AutoupdateDeprecated.java @@ -0,0 +1,179 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class AutoupdateDeprecated { + + private final ClientApi api; + + public AutoupdateDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse downloadLatestRelease(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("autoupdate", "action", "downloadLatestRelease", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionCheckAddonUpdates(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionCheckAddonUpdates", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionCheckOnStart(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionCheckOnStart", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionDownloadNewRelease(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionDownloadNewRelease", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionInstallAddonUpdates(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionInstallAddonUpdates", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionInstallScannerRules(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionInstallScannerRules", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionReportAlphaAddons(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionReportAlphaAddons", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionReportBetaAddons(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionReportBetaAddons", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionReportReleaseAddons(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("autoupdate", "action", "setOptionReportReleaseAddons", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/BreakDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/BreakDeprecated.java new file mode 100644 index 0000000..1f12222 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/BreakDeprecated.java @@ -0,0 +1,107 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class BreakDeprecated { + + private final ClientApi api; + + public BreakDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse brk(String apikey, String type, String scope, String state) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("type", type); + map.put("scope", scope); + map.put("state", state); + return api.callApi("break", "action", "break", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse addHttpBreakpoint( + String apikey, + String string, + String location, + String match, + String inverse, + String ignorecase) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("string", string); + map.put("location", location); + map.put("match", match); + map.put("inverse", inverse); + map.put("ignorecase", ignorecase); + return api.callApi("break", "action", "addHttpBreakpoint", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeHttpBreakpoint( + String apikey, + String string, + String location, + String match, + String inverse, + String ignorecase) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("string", string); + map.put("location", location); + map.put("match", match); + map.put("inverse", inverse); + map.put("ignorecase", ignorecase); + return api.callApi("break", "action", "removeHttpBreakpoint", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ContextDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ContextDeprecated.java new file mode 100644 index 0000000..d9990e0 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ContextDeprecated.java @@ -0,0 +1,216 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class ContextDeprecated { + + private final ClientApi api; + + public ContextDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse excludeFromContext(String apikey, String contextname, String regex) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + map.put("regex", regex); + return api.callApi("context", "action", "excludeFromContext", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse includeInContext(String apikey, String contextname, String regex) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + map.put("regex", regex); + return api.callApi("context", "action", "includeInContext", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse newContext(String apikey, String contextname) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + return api.callApi("context", "action", "newContext", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeContext(String apikey, String contextname) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + return api.callApi("context", "action", "removeContext", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse exportContext(String apikey, String contextname, String contextfile) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + map.put("contextFile", contextfile); + return api.callApi("context", "action", "exportContext", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse importContext(String apikey, String contextfile) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextFile", contextfile); + return api.callApi("context", "action", "importContext", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse includeContextTechnologies( + String apikey, String contextname, String technologynames) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + map.put("technologyNames", technologynames); + return api.callApi("context", "action", "includeContextTechnologies", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse includeAllContextTechnologies(String apikey, String contextname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + return api.callApi("context", "action", "includeAllContextTechnologies", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse excludeContextTechnologies( + String apikey, String contextname, String technologynames) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + map.put("technologyNames", technologynames); + return api.callApi("context", "action", "excludeContextTechnologies", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse excludeAllContextTechnologies(String apikey, String contextname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + return api.callApi("context", "action", "excludeAllContextTechnologies", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setContextInScope(String apikey, String contextname, String booleaninscope) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextName", contextname); + map.put("booleanInScope", booleaninscope); + return api.callApi("context", "action", "setContextInScope", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/CoreDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/CoreDeprecated.java new file mode 100644 index 0000000..31353b8 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/CoreDeprecated.java @@ -0,0 +1,653 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class CoreDeprecated { + + private final ClientApi api; + + public CoreDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse accessUrl(String apikey, String url, String followredirects) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("url", url); + if (followredirects != null) { + map.put("followRedirects", followredirects); + } + return api.callApi("core", "action", "accessUrl", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse shutdown(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("core", "action", "shutdown", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse newSession(String apikey, String name, String overwrite) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (name != null) { + map.put("name", name); + } + if (overwrite != null) { + map.put("overwrite", overwrite); + } + return api.callApi("core", "action", "newSession", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse loadSession(String apikey, String name) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("name", name); + return api.callApi("core", "action", "loadSession", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse saveSession(String apikey, String name, String overwrite) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("name", name); + if (overwrite != null) { + map.put("overwrite", overwrite); + } + return api.callApi("core", "action", "saveSession", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse snapshotSession(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("core", "action", "snapshotSession", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse clearExcludedFromProxy(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("core", "action", "clearExcludedFromProxy", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse excludeFromProxy(String apikey, String regex) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("regex", regex); + return api.callApi("core", "action", "excludeFromProxy", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setHomeDirectory(String apikey, String dir) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("dir", dir); + return api.callApi("core", "action", "setHomeDirectory", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setMode(String apikey, String mode) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("mode", mode); + return api.callApi("core", "action", "setMode", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse generateRootCA(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("core", "action", "generateRootCA", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse sendRequest(String apikey, String request, String followredirects) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("request", request); + if (followredirects != null) { + map.put("followRedirects", followredirects); + } + return api.callApi("core", "action", "sendRequest", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse deleteAllAlerts(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("core", "action", "deleteAllAlerts", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse runGarbageCollection(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("core", "action", "runGarbageCollection", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse deleteSiteNode(String apikey, String url, String method, String postdata) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("url", url); + if (method != null) { + map.put("method", method); + } + if (postdata != null) { + map.put("postData", postdata); + } + return api.callApi("core", "action", "deleteSiteNode", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionDefaultUserAgent(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("core", "action", "setOptionDefaultUserAgent", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionProxyChainName(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainName", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionProxyChainPassword(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainPassword", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionProxyChainRealm(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainRealm", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionProxyChainSkipName(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainSkipName", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionProxyChainUserName(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("core", "action", "setOptionProxyChainUserName", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionHttpStateEnabled(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionHttpStateEnabled", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionProxyChainPort(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("core", "action", "setOptionProxyChainPort", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionProxyChainPrompt(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionProxyChainPrompt", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionSingleCookieRequestHeader(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionSingleCookieRequestHeader", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionTimeoutInSecs(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("core", "action", "setOptionTimeoutInSecs", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionUseProxyChain(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionUseProxyChain", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionUseProxyChainAuth(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("core", "action", "setOptionUseProxyChainAuth", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] proxypac(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApiOther("core", "other", "proxy.pac", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] rootcert(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApiOther("core", "other", "rootcert", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] setproxy(String apikey, String proxy) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("proxy", proxy); + return api.callApiOther("core", "other", "setproxy", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] xmlreport(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApiOther("core", "other", "xmlreport", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] htmlreport(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApiOther("core", "other", "htmlreport", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] messageHar(String apikey, String id) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + return api.callApiOther("core", "other", "messageHar", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] messagesHar(String apikey, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("core", "other", "messagesHar", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] sendHarRequest(String apikey, String request, String followredirects) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("request", request); + if (followredirects != null) { + map.put("followRedirects", followredirects); + } + return api.callApiOther("core", "other", "sendHarRequest", map); + } + + /** + * Gets the alerts raised by ZAP, optionally filtering by URL and paginating with 'start' + * position and 'count' of alerts + */ + public ApiResponse alerts(String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApi("core", "view", "alerts", map); + } + + /** Gets the number of alerts, optionally filtering by URL */ + public ApiResponse numberOfAlerts(String baseurl) throws ClientApiException { + Map map = new HashMap<>(); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + return api.callApi("core", "view", "numberOfAlerts", map); + } + + /** Gets the URLs accessed through/by ZAP */ + public ApiResponse urls() throws ClientApiException { + return api.callApi("core", "view", "urls", null); + } + + public ApiResponse snapshotSession() throws ClientApiException { + return api.callApi("core", "action", "snapshotSession", null); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ForcedUserDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ForcedUserDeprecated.java new file mode 100644 index 0000000..67057a4 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ForcedUserDeprecated.java @@ -0,0 +1,70 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class ForcedUserDeprecated { + + private final ClientApi api; + + public ForcedUserDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setForcedUser(String apikey, String contextid, String userid) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("forcedUser", "action", "setForcedUser", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setForcedUserModeEnabled(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("boolean", Boolean.toString(bool)); + return api.callApi("forcedUser", "action", "setForcedUserModeEnabled", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/HttpSessionsDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/HttpSessionsDeprecated.java new file mode 100644 index 0000000..2e5fa47 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/HttpSessionsDeprecated.java @@ -0,0 +1,178 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class HttpSessionsDeprecated { + + private final ClientApi api; + + public HttpSessionsDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse createEmptySession(String apikey, String site, String session) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("site", site); + if (session != null) { + map.put("session", session); + } + return api.callApi("httpSessions", "action", "createEmptySession", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeSession(String apikey, String site, String session) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("site", site); + map.put("session", session); + return api.callApi("httpSessions", "action", "removeSession", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setActiveSession(String apikey, String site, String session) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("site", site); + map.put("session", session); + return api.callApi("httpSessions", "action", "setActiveSession", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse unsetActiveSession(String apikey, String site) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("site", site); + return api.callApi("httpSessions", "action", "unsetActiveSession", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse addSessionToken(String apikey, String site, String sessiontoken) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("site", site); + map.put("sessionToken", sessiontoken); + return api.callApi("httpSessions", "action", "addSessionToken", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeSessionToken(String apikey, String site, String sessiontoken) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("site", site); + map.put("sessionToken", sessiontoken); + return api.callApi("httpSessions", "action", "removeSessionToken", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setSessionTokenValue( + String apikey, String site, String session, String sessiontoken, String tokenvalue) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("site", site); + map.put("session", session); + map.put("sessionToken", sessiontoken); + map.put("tokenValue", tokenvalue); + return api.callApi("httpSessions", "action", "setSessionTokenValue", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse renameSession( + String apikey, String site, String oldsessionname, String newsessionname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("site", site); + map.put("oldSessionName", oldsessionname); + map.put("newSessionName", newsessionname); + return api.callApi("httpSessions", "action", "renameSession", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ImportLogFilesDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ImportLogFilesDeprecated.java new file mode 100644 index 0000000..876e000 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ImportLogFilesDeprecated.java @@ -0,0 +1,130 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class ImportLogFilesDeprecated { + + private final ClientApi api; + + public ImportLogFilesDeprecated(ClientApi api) { + this.api = api; + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse ImportZAPLogFromFile(String apikey, String filepath) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("FilePath", filepath); + return api.callApi("importLogFiles", "action", "ImportZAPLogFromFile", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse ImportModSecurityLogFromFile(String apikey, String filepath) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("FilePath", filepath); + return api.callApi("importLogFiles", "action", "ImportModSecurityLogFromFile", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse ImportZAPHttpRequestResponsePair( + String apikey, String httprequest, String httpresponse) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("HTTPRequest", httprequest); + map.put("HTTPResponse", httpresponse); + return api.callApi("importLogFiles", "action", "ImportZAPHttpRequestResponsePair", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse PostModSecurityAuditEvent(String apikey, String auditeventstring) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (auditeventstring != null) { + map.put("AuditEventString", auditeventstring); + } + return api.callApi("importLogFiles", "action", "PostModSecurityAuditEvent", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] OtherPostModSecurityAuditEvent(String apikey, String auditeventstring) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("AuditEventString", auditeventstring); + return api.callApiOther("importLogFiles", "other", "OtherPostModSecurityAuditEvent", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/OpenapiDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/OpenapiDeprecated.java new file mode 100644 index 0000000..9d948b1 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/OpenapiDeprecated.java @@ -0,0 +1,110 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2021 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class OpenapiDeprecated { + + private final ClientApi api; + + public OpenapiDeprecated(ClientApi api) { + this.api = api; + } + + /** + * Imports an Open API definition from a local file. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importFile(String file) throws ClientApiException { + return importFile(file, null); + } + + /** + * Imports an OpenAPI definition from a local file. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importFile(String file, String target) throws ClientApiException { + Map map = new HashMap<>(); + map.put("file", file); + if (target != null) { + map.put("target", target); + } + return api.callApi("openapi", "action", "importFile", map); + } + + /** + * Imports an OpenAPI definition from a local file. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importFile(String file, String target, String contextid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("file", file); + if (target != null) { + map.put("target", target); + } + if (contextid != null) { + map.put("contextId", contextid); + } + return api.callApi("openapi", "action", "importFile", map); + } + + /** + * Imports an OpenAPI definition from a URL. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importUrl(String url, String hostoverride) throws ClientApiException { + Map map = new HashMap<>(); + map.put("url", url); + if (hostoverride != null) { + map.put("hostOverride", hostoverride); + } + return api.callApi("openapi", "action", "importUrl", map); + } + + /** + * Imports an OpenAPI definition from a URL. + * + *

This component is optional and therefore the API will only work if it is installed + */ + public ApiResponse importUrl(String url, String hostoverride, String contextid) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("url", url); + if (hostoverride != null) { + map.put("hostOverride", hostoverride); + } + if (contextid != null) { + map.put("contextId", contextid); + } + return api.callApi("openapi", "action", "importUrl", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/PnhDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/PnhDeprecated.java new file mode 100644 index 0000000..2a9df9a --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/PnhDeprecated.java @@ -0,0 +1,170 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class PnhDeprecated { + + private final ClientApi api; + + public PnhDeprecated(ClientApi api) { + this.api = api; + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse monitor(String apikey, String id, String message) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + map.put("message", message); + return api.callApi("pnh", "action", "monitor", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse oracle(String apikey, String id) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + return api.callApi("pnh", "action", "oracle", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse startMonitoring(String apikey, String url) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("url", url); + return api.callApi("pnh", "action", "startMonitoring", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse stopMonitoring(String apikey, String id) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + return api.callApi("pnh", "action", "stopMonitoring", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] pnh(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApiOther("pnh", "other", "pnh", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] manifest(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApiOther("pnh", "other", "manifest", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] service(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApiOther("pnh", "other", "service", map); + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] fx_pnhxpi(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApiOther("pnh", "other", "fx_pnh.xpi", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/PscanDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/PscanDeprecated.java new file mode 100644 index 0000000..427dc88 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/PscanDeprecated.java @@ -0,0 +1,127 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class PscanDeprecated { + + private final ClientApi api; + + public PscanDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setEnabled(String apikey, String enabled) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("enabled", enabled); + return api.callApi("pscan", "action", "setEnabled", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse enableAllScanners(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("pscan", "action", "enableAllScanners", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse disableAllScanners(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("pscan", "action", "disableAllScanners", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse enableScanners(String apikey, String ids) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("ids", ids); + return api.callApi("pscan", "action", "enableScanners", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse disableScanners(String apikey, String ids) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("ids", ids); + return api.callApi("pscan", "action", "disableScanners", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setScannerAlertThreshold(String apikey, String id, String alertthreshold) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("id", id); + map.put("alertThreshold", alertthreshold); + return api.callApi("pscan", "action", "setScannerAlertThreshold", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ReplacerDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ReplacerDeprecated.java new file mode 100644 index 0000000..32a41dc --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ReplacerDeprecated.java @@ -0,0 +1,65 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2022 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class ReplacerDeprecated { + + private final ClientApi api; + + public ReplacerDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.11.0) Use the method with the url. + */ + @Deprecated + public ApiResponse addRule( + String description, + String enabled, + String matchtype, + String matchregex, + String matchstring, + String replacement, + String initiators) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("description", description); + map.put("enabled", enabled); + map.put("matchType", matchtype); + map.put("matchRegex", matchregex); + map.put("matchString", matchstring); + if (replacement != null) { + map.put("replacement", replacement); + } + if (initiators != null) { + map.put("initiators", initiators); + } + return api.callApi("replacer", "action", "addRule", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/RevealDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/RevealDeprecated.java new file mode 100644 index 0000000..c60aea5 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/RevealDeprecated.java @@ -0,0 +1,54 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class RevealDeprecated { + + private final ClientApi api; + + public RevealDeprecated(ClientApi api) { + this.api = api; + } + + /** + * This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setReveal(String apikey, String reveal) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("reveal", reveal); + return api.callApi("reveal", "action", "setReveal", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ScriptDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ScriptDeprecated.java new file mode 100644 index 0000000..e62b008 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/ScriptDeprecated.java @@ -0,0 +1,148 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class ScriptDeprecated { + + private final ClientApi api; + + public ScriptDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse enable(String apikey, String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scriptName", scriptname); + return api.callApi("script", "action", "enable", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse disable(String apikey, String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scriptName", scriptname); + return api.callApi("script", "action", "disable", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse load( + String apikey, + String scriptname, + String scripttype, + String scriptengine, + String filename, + String scriptdescription) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scriptName", scriptname); + map.put("scriptType", scripttype); + map.put("scriptEngine", scriptengine); + map.put("fileName", filename); + if (scriptdescription != null) { + map.put("scriptDescription", scriptdescription); + } + return api.callApi("script", "action", "load", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse remove(String apikey, String scriptname) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scriptName", scriptname); + return api.callApi("script", "action", "remove", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse runStandAloneScript(String apikey, String scriptname) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scriptName", scriptname); + return api.callApi("script", "action", "runStandAloneScript", map); + } + + /** + * Loads a script into ZAP from the given local file, with the given name, type and engine, + * optionally with a description + */ + public ApiResponse load( + String scriptname, + String scripttype, + String scriptengine, + String filename, + String scriptdescription) + throws ClientApiException { + Map map = new HashMap<>(); + map.put("scriptName", scriptname); + map.put("scriptType", scripttype); + map.put("scriptEngine", scriptengine); + map.put("fileName", filename); + if (scriptdescription != null) { + map.put("scriptDescription", scriptdescription); + } + return api.callApi("script", "action", "load", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SearchDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SearchDeprecated.java new file mode 100644 index 0000000..d9a397e --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SearchDeprecated.java @@ -0,0 +1,140 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class SearchDeprecated { + + private final ClientApi api; + + public SearchDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] harByUrlRegex( + String apikey, String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByUrlRegex", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] harByRequestRegex( + String apikey, String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByRequestRegex", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] harByResponseRegex( + String apikey, String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByResponseRegex", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public byte[] harByHeaderRegex( + String apikey, String regex, String baseurl, String start, String count) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("regex", regex); + if (baseurl != null) { + map.put("baseurl", baseurl); + } + if (start != null) { + map.put("start", start); + } + if (count != null) { + map.put("count", count); + } + return api.callApiOther("search", "other", "harByHeaderRegex", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SeleniumDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SeleniumDeprecated.java new file mode 100644 index 0000000..330d63a --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SeleniumDeprecated.java @@ -0,0 +1,137 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class SeleniumDeprecated { + + private final ClientApi api; + + public SeleniumDeprecated(ClientApi api) { + this.api = api; + } + + /** + * Sets the current path to ChromeDriver + * + *

This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionChromeDriverPath(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("selenium", "action", "setOptionChromeDriverPath", map); + } + + /** + * Sets the current path to Firefox binary + * + *

This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionFirefoxBinaryPath(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("selenium", "action", "setOptionFirefoxBinaryPath", map); + } + + /** + * Sets the current path to Firefox driver (geckodriver) + * + *

This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionFirefoxDriverPath(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("selenium", "action", "setOptionFirefoxDriverPath", map); + } + + /** + * Sets the current path to IEDriverServer + * + *

This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionIeDriverPath(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("selenium", "action", "setOptionIeDriverPath", map); + } + + /** + * Sets the current path to PhantomJS binary + * + *

This component is optional and therefore the API will only work if it is installed + * + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionPhantomJsBinaryPath(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("selenium", "action", "setOptionPhantomJsBinaryPath", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SessionManagementDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SessionManagementDeprecated.java new file mode 100644 index 0000000..ccc6cfb --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SessionManagementDeprecated.java @@ -0,0 +1,58 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class SessionManagementDeprecated { + + private final ClientApi api; + + public SessionManagementDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setSessionManagementMethod( + String apikey, String contextid, String methodname, String methodconfigparams) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("methodName", methodname); + if (methodconfigparams != null) { + map.put("methodConfigParams", methodconfigparams); + } + return api.callApi("sessionManagement", "action", "setSessionManagementMethod", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SpiderDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SpiderDeprecated.java new file mode 100644 index 0000000..12fdb40 --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/SpiderDeprecated.java @@ -0,0 +1,579 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class SpiderDeprecated { + + private final ClientApi api; + + public SpiderDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse scan( + String apikey, + String url, + String maxchildren, + String recurse, + String contextname, + String subtreeonly) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (url != null) { + map.put("url", url); + } + if (maxchildren != null) { + map.put("maxChildren", maxchildren); + } + if (recurse != null) { + map.put("recurse", recurse); + } + if (contextname != null) { + map.put("contextName", contextname); + } + if (subtreeonly != null) { + map.put("subtreeOnly", subtreeonly); + } + return api.callApi("spider", "action", "scan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse scanAsUser( + String apikey, + String contextid, + String userid, + String url, + String maxchildren, + String recurse, + String subtreeonly) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("userId", userid); + if (url != null) { + map.put("url", url); + } + if (maxchildren != null) { + map.put("maxChildren", maxchildren); + } + if (recurse != null) { + map.put("recurse", recurse); + } + if (subtreeonly != null) { + map.put("subtreeOnly", subtreeonly); + } + return api.callApi("spider", "action", "scanAsUser", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse pause(String apikey, String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanId", scanid); + return api.callApi("spider", "action", "pause", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse resume(String apikey, String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanId", scanid); + return api.callApi("spider", "action", "resume", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse stop(String apikey, String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (scanid != null) { + map.put("scanId", scanid); + } + return api.callApi("spider", "action", "stop", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeScan(String apikey, String scanid) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("scanId", scanid); + return api.callApi("spider", "action", "removeScan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse pauseAllScans(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("spider", "action", "pauseAllScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse resumeAllScans(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("spider", "action", "resumeAllScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse stopAllScans(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("spider", "action", "stopAllScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeAllScans(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("spider", "action", "removeAllScans", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse clearExcludedFromScan(String apikey) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + return api.callApi("spider", "action", "clearExcludedFromScan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse excludeFromScan(String apikey, String regex) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("regex", regex); + return api.callApi("spider", "action", "excludeFromScan", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionHandleParameters(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("spider", "action", "setOptionHandleParameters", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionScopeString(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("spider", "action", "setOptionScopeString", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionSkipURLString(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("spider", "action", "setOptionSkipURLString", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionUserAgent(String apikey, String string) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("spider", "action", "setOptionUserAgent", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionHandleODataParametersVisited(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionHandleODataParametersVisited", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxDepth(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionMaxDepth", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxDuration(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionMaxDuration", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionMaxScansInUI(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionMaxScansInUI", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionParseComments(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseComments", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionParseGit(String apikey, boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseGit", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionParseRobotsTxt(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseRobotsTxt", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionParseSVNEntries(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseSVNEntries", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionParseSitemapXml(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionParseSitemapXml", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionPostForm(String apikey, boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionPostForm", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionProcessForm(String apikey, boolean bool) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionProcessForm", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionRequestWaitTime(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionRequestWaitTime", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionSendRefererHeader(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionSendRefererHeader", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionShowAdvancedDialog(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("spider", "action", "setOptionShowAdvancedDialog", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionThreadCount(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("spider", "action", "setOptionThreadCount", map); + } + + /** + * @deprecated Option no longer in effective use. + */ + @Deprecated + public ApiResponse optionScope() throws ClientApiException { + return api.callApi("spider", "view", "optionScope", null); + } + + /** + * @deprecated Option no longer in effective use. + */ + @Deprecated + public ApiResponse optionScopeText() throws ClientApiException { + return api.callApi("spider", "view", "optionScopeText", null); + } + + /** + * Use actions [add|modify|remove]DomainAlwaysInScope instead. + * + * @deprecated Option no longer in effective use. + */ + @Deprecated + public ApiResponse setOptionScopeString(String string) throws ClientApiException { + Map map = new HashMap<>(); + map.put("String", string); + return api.callApi("spider", "action", "setOptionScopeString", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/StatsDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/StatsDeprecated.java new file mode 100644 index 0000000..d15090c --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/StatsDeprecated.java @@ -0,0 +1,116 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class StatsDeprecated { + + private final ClientApi api; + + public StatsDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse clearStats(String apikey, String keyprefix) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + if (keyprefix != null) { + map.put("keyPrefix", keyprefix); + } + return api.callApi("stats", "action", "clearStats", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionStatsdHost(String apikey, String string) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("stats", "action", "setOptionStatsdHost", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionStatsdPrefix(String apikey, String string) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("String", string); + return api.callApi("stats", "action", "setOptionStatsdPrefix", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionInMemoryEnabled(String apikey, boolean bool) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Boolean", Boolean.toString(bool)); + return api.callApi("stats", "action", "setOptionInMemoryEnabled", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setOptionStatsdPort(String apikey, int i) throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("Integer", Integer.toString(i)); + return api.callApi("stats", "action", "setOptionStatsdPort", map); + } +} diff --git a/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/UsersDeprecated.java b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/UsersDeprecated.java new file mode 100644 index 0000000..4932aec --- /dev/null +++ b/subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/gen/deprecated/UsersDeprecated.java @@ -0,0 +1,129 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2017 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.clientapi.gen.deprecated; + +import java.util.HashMap; +import java.util.Map; +import org.zaproxy.clientapi.core.ApiResponse; +import org.zaproxy.clientapi.core.ClientApi; +import org.zaproxy.clientapi.core.ClientApiException; + +/** API implementation with deprecated methods, (re)moved from generated class. */ +@SuppressWarnings("javadoc") +public class UsersDeprecated { + + private final ClientApi api; + + public UsersDeprecated(ClientApi api) { + this.api = api; + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse newUser(String apikey, String contextid, String name) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("name", name); + return api.callApi("users", "action", "newUser", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse removeUser(String apikey, String contextid, String userid) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("userId", userid); + return api.callApi("users", "action", "removeUser", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setUserEnabled( + String apikey, String contextid, String userid, String enabled) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("userId", userid); + map.put("enabled", enabled); + return api.callApi("users", "action", "setUserEnabled", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setUserName(String apikey, String contextid, String userid, String name) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("userId", userid); + map.put("name", name); + return api.callApi("users", "action", "setUserName", map); + } + + /** + * @deprecated (1.1.0) Use the method without the API key and use one of the {@code ClientApi} + * constructors that allow to set the API key (e.g. {@link ClientApi#ClientApi(String, int, + * String)}). + */ + @Deprecated + public ApiResponse setAuthenticationCredentials( + String apikey, String contextid, String userid, String authcredentialsconfigparams) + throws ClientApiException { + Map map = new HashMap<>(); + if (apikey != null) { + map.put("apikey", apikey); + } + map.put("contextId", contextid); + map.put("userId", userid); + if (authcredentialsconfigparams != null) { + map.put("authCredentialsConfigParams", authcredentialsconfigparams); + } + return api.callApi("users", "action", "setAuthenticationCredentials", map); + } +} diff --git a/subprojects/zap-clientapi/zap-clientapi.gradle b/subprojects/zap-clientapi/zap-clientapi.gradle index ac20ab4..8fa565e 100644 --- a/subprojects/zap-clientapi/zap-clientapi.gradle +++ b/subprojects/zap-clientapi/zap-clientapi.gradle @@ -1,51 +1,78 @@ plugins { - id "me.champeau.gradle.japicmp" version "0.1.2" + id "maven-publish" + id "signing" + id "me.champeau.gradle.japicmp" version "0.4.3" } -apply plugin: 'maven' -apply plugin: 'signing' +sourceSets { examples } -version '1.1.0-SNAPSHOT' -ext.versionBC = '1.0.0' +assemble.dependsOn examplesClasses -dependencies { compile 'org.jdom:jdom:1.1.3' } +dependencies { + // XXX Change to implementation (it's not exposed in public API) when bumping major version. + api 'org.jdom:jdom:1.1.3' -sourceSets { examples } + examplesImplementation sourceSets.main.output +} jar { manifest { - attributes 'Implementation-Title': 'OWASP ZAP API Client', - 'Implementation-Version': version, + attributes 'Implementation-Title': 'ZAP API Client', + 'Implementation-Version': archiveVersion.get(), 'Main-Class': 'org.zaproxy.clientapi.core.ClientApiMain', 'Create-Date': new Date().format("yyyy-MM-dd") } } -task japicmp(dependsOn: jar, type: me.champeau.gradle.ArtifactJapicmpTask) { - baseline = "${project.group}:${project.name}:${versionBC}@jar" - to = jar.archivePath - onlyBinaryIncompatibleModified = true - failOnModification = true - htmlOutputFile = file("$buildDir/reports/japi.html") +File clientapiJar(version) { + def oldGroup = group + try { + // https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6 + group = "virtual_group_for_japicmp" + def conf = configurations.detachedConfiguration(dependencies.create("$oldGroup:$name:$version")) + conf.transitive = false + return conf.singleFile + } finally { + group = oldGroup + } +} + +task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask) { + group = 'verification' + description = "Checks artifacts' binary compatibility with latest (released) version '$versionBC'." + + oldClasspath.from(files(clientapiJar(versionBC))) + newClasspath.from(tasks.named(JavaPlugin.JAR_TASK_NAME)) + onlyBinaryIncompatibleModified.set(true) + failOnModification.set(true) + ignoreMissingClasses.set(true) + + richReport { + destinationDir.set(file("$buildDir/reports/")) + reportName.set("japi.html") + addDefaultRules.set(true) + } } +check.dependsOn(japicmp) + task javadocJar(type: Jar) { - classifier = 'javadoc' + archiveClassifier = 'javadoc' from javadoc } task sourcesJar(type: Jar) { from sourceSets.main.allJava - classifier "sources" + archiveClassifier = "sources" } task uberJar(type: Jar) { - group 'build' - description 'Assembles a jar archive containing the main jar and its dependencies.' - baseName 'zap-api' + group = 'build' + description = 'Assembles a jar archive containing the main jar and its dependencies.' + archiveBaseName.set('zap-api') manifest.from jar.manifest from { - configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } { exclude "META-INF/*.SF" exclude "META-INF/*.DSA" @@ -54,81 +81,82 @@ task uberJar(type: Jar) { with jar } -artifacts { archives sourcesJar, javadocJar } +build.dependsOn 'uberJar' -signing { - if (project.hasProperty('signing.keyId')) { - sign configurations.archives - } -} - -uploadArchives { +publishing { repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> - signing.signPom(deployment) - } - - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { - authentication(userName: ossrhUsername, password: ossrhPassword) + maven { + def releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/" + def snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/" + url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl + + if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { + credentials { + username = ossrhUsername + password = ossrhPassword } } + } + } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - } + publications { + clientApi(MavenPublication) { + from components.java + artifact sourcesJar + artifact javadocJar + pom { - project { - name 'OWASP ZAP API Client' - packaging 'jar' - description 'Java implementation to access OWASP ZAP API.' - url 'https://github.com/zaproxy/zap-api-java' - - organization { - name 'OWASP' - url 'https://www.owasp.org/index.php/ZAP' - } + name = 'ZAP API Client' + description = 'Java implementation to access ZAP API.' + url = 'https://github.com/zaproxy/zap-api-java' - mailingLists { - mailingList { - name 'OWASP ZAP User Group' - post 'zaproxy-users@googlegroups.com' - archive 'https://groups.google.com/group/zaproxy-users' - } - mailingList { - name 'OWASP ZAP Developer Group' - post 'zaproxy-develop@googlegroups.com' - archive 'https://groups.google.com/group/zaproxy-develop' - } - } + organization { + name = 'ZAP' + url = 'https://www.zaproxy.org/' + } - scm { - url 'https://github.com/zaproxy/zap-api-java' - connection 'scm:git:https://github.com/zaproxy/zap-api-java.git' - developerConnection 'scm:git:https://github.com/zaproxy/zap-api-java.git' + mailingLists { + mailingList { + name = 'ZAP User Group' + post = 'zaproxy-users@googlegroups.com' + archive = 'https://groups.google.com/group/zaproxy-users' + } + mailingList { + name = 'ZAP Developer Group' + post = 'zaproxy-develop@googlegroups.com' + archive = 'https://groups.google.com/group/zaproxy-develop' } + } - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } + scm { + url = 'https://github.com/zaproxy/zap-api-java' + connection = 'scm:git:https://github.com/zaproxy/zap-api-java.git' + developerConnection = 'scm:git:https://github.com/zaproxy/zap-api-java.git' + } + + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution = 'repo' } + } - developers { - developer { - id 'psiinon' - name 'Simon Bennetts' - email 'psiinon@gmail.com' - } + developers { + developer { + id = 'psiinon' + name = 'Simon Bennetts' + email = 'psiinon@gmail.com' } } } } } -} \ No newline at end of file +} + +signing { + if (project.hasProperty('signing.keyId')) { + sign publishing.publications.clientApi + } +}