From cdf9cfd49486f0b3f69c425b5513bfeab18e70f0 Mon Sep 17 00:00:00 2001 From: Woolworths Date: Sun, 5 Jun 2016 11:25:28 +1000 Subject: [PATCH] Update for Python 3 Change library to support Python 3: - Update print statements; - Use six library in the generated code. Add Python 3 (3.3) to TravisCI build configuration file. Add API of OpenAPI add-on. Bump version to 0.0.10. --- .travis.yml | 1 + setup.py | 19 +-- src/examples/basic-spider-scan.py | 22 ++-- src/zapv2/__init__.py | 61 +++++----- src/zapv2/acsrf.py | 13 +- src/zapv2/ajaxSpider.py | 63 +++++----- src/zapv2/ascan.py | 195 +++++++++++++++--------------- src/zapv2/authentication.py | 23 ++-- src/zapv2/authorization.py | 11 +- src/zapv2/autoupdate.py | 65 +++++----- src/zapv2/brk.py | 31 ++--- src/zapv2/context.py | 41 ++++--- src/zapv2/core.py | 169 +++++++++++++------------- src/zapv2/forcedUser.py | 13 +- src/zapv2/httpSessions.py | 33 ++--- src/zapv2/importLogFiles.py | 17 +-- src/zapv2/openapi.py | 40 ++++++ src/zapv2/params.py | 7 +- src/zapv2/pnh.py | 21 ++-- src/zapv2/pscan.py | 25 ++-- src/zapv2/reveal.py | 9 +- src/zapv2/script.py | 21 ++-- src/zapv2/search.py | 45 +++---- src/zapv2/selenium.py | 25 ++-- src/zapv2/sessionManagement.py | 15 +-- src/zapv2/spider.py | 149 +++++++++++------------ src/zapv2/stats.py | 35 +++--- src/zapv2/users.py | 25 ++-- 28 files changed, 630 insertions(+), 564 deletions(-) create mode 100644 src/zapv2/openapi.py diff --git a/.travis.yml b/.travis.yml index 7c545e6..8808f52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ sudo: false language: python python: - '2.7' + - '3.3' install: - pip install -U --force setuptools pip - ./setup.py develop diff --git a/setup.py b/setup.py index 641bd5f..420f730 100755 --- a/setup.py +++ b/setup.py @@ -9,12 +9,13 @@ try: from setuptools import setup, find_packages except ImportError: - print "You must have setuptools installed to use setup.py. Exiting..." + print('You must have setuptools installed to use setup.py. Exiting...') raise SystemExit(1) install_dependencies = ( - 'requests' + 'requests', + 'six' ) test_requirements = ( 'mock', @@ -24,22 +25,19 @@ ) setup( name="python-owasp-zap-v2.4", - version="0.0.9", + version="0.0.10", description="OWASP ZAP 2.6 API client", long_description="OWASP Zed Attack Proxy 2.6 API python client (the 2.4 package name has been kept to make it easier to upgrade)", author="ZAP development team", author_email='', url="https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project", - download_url="https://github.com/zaproxy/zap-api-python/releases/tag/0.0.9", + download_url="https://github.com/zaproxy/zap-api-python/releases/tag/0.0.10", platforms=['any'], - license="ASL2.0", - package_dir={ '': 'src', }, packages=find_packages('src'), - classifiers=[ 'License :: OSI Approved :: Apache Software License', 'Development Status :: 5 - Production/Stable', @@ -47,7 +45,12 @@ 'Topic :: Software Development :: Libraries :: Python Modules', 'Intended Audience :: Developers', 'Intended Audience :: Information Technology', - 'Programming Language :: Python'], + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + ], install_requires=install_dependencies, tests_require=test_requirements, extras_require={'tests': test_requirements} diff --git a/src/examples/basic-spider-scan.py b/src/examples/basic-spider-scan.py index 0e3713c..b1e1823 100644 --- a/src/examples/basic-spider-scan.py +++ b/src/examples/basic-spider-scan.py @@ -14,39 +14,39 @@ # zap = ZAPv2(apikey=apikey, proxies={'http': 'http://127.0.0.1:8090', 'https': 'http://127.0.0.1:8090'}) # Proxy a request to the target so that ZAP has something to deal with -print 'Accessing target %s' % target +print('Accessing target {}'.format(target)) zap.urlopen(target) # Give the sites tree a chance to get updated time.sleep(2) -print 'Spidering target %s' % target +print('Spidering target {}'.format(target)) scanid = zap.spider.scan(target) # Give the Spider a chance to start time.sleep(2) while (int(zap.spider.status(scanid)) < 100): # Loop until the spider has finished - print 'Spider progress %: ' + zap.spider.status(scanid) + print('Spider progress %: {}'.format(zap.spider.status(scanid))) time.sleep(2) -print 'Spider completed' +print ('Spider completed') while (int(zap.pscan.records_to_scan) > 0): - print ('Records to passive scan : ' + zap.pscan.records_to_scan) + print ('Records to passive scan : {}'.format(zap.pscan.records_to_scan)) time.sleep(2) -print 'Passive Scan completed' +print ('Passive Scan completed') -print 'Active Scanning target %s' % target +print ('Active Scanning target {}'.format(target)) scanid = zap.ascan.scan(target) while (int(zap.ascan.status(scanid)) < 100): # Loop until the scanner has finished - print 'Scan progress %: ' + zap.ascan.status(scanid) + print ('Scan progress %: {}'.format(zap.ascan.status(scanid))) time.sleep(5) -print 'Active Scan completed' +print ('Active Scan completed') # Report the results -print 'Hosts: ' + ', '.join(zap.core.hosts) -print 'Alerts: ' +print ('Hosts: {}'.format(', '.join(zap.core.hosts))) +print ('Alerts: ') pprint (zap.core.alerts()) diff --git a/src/zapv2/__init__.py b/src/zapv2/__init__.py index 91c2995..544a320 100644 --- a/src/zapv2/__init__.py +++ b/src/zapv2/__init__.py @@ -20,44 +20,41 @@ """ __docformat__ = 'restructuredtext' -__version__ = '0.0.9' +__version__ = '0.0.10' import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning -from acsrf import acsrf -from ascan import ascan -from ajaxSpider import ajaxSpider -from authentication import authentication -from authorization import authorization -from autoupdate import autoupdate -from brk import brk -from context import context -from core import core -from forcedUser import forcedUser -from httpSessions import httpSessions -from importLogFiles import importLogFiles -from params import params -from pnh import pnh -from pscan import pscan -from reveal import reveal -from script import script -from search import search -from selenium import selenium -from sessionManagement import sessionManagement -from spider import spider -from stats import stats -from users import users +from .acsrf import acsrf +from .ascan import ascan +from .ajaxSpider import ajaxSpider +from .authentication import authentication +from .authorization import authorization +from .autoupdate import autoupdate +from .brk import brk +from .context import context +from .core import core +from .forcedUser import forcedUser +from .httpSessions import httpSessions +from .importLogFiles import importLogFiles +from .params import params +from .pnh import pnh +from .pscan import pscan +from .reveal import reveal +from .script import script +from .search import search +from .selenium import selenium +from .sessionManagement import sessionManagement +from .spider import spider +from .stats import stats +from .users import users class ZAPv2(object): """ Client API implementation for integrating with ZAP v2. """ - # base JSON api url base = 'http://zap/JSON/' - - # base OTHER api url base_other = 'http://zap/OTHER/' def __init__(self, proxies=None, apikey=None): @@ -109,7 +106,7 @@ def __init__(self, proxies=None, apikey=None): #if apikey is not None: # self.session.headers['X-ZAP-API-Key'] = apikey - def urlopen(self, *args, **kwargs): + def urlopen(self, url, *args, **kwargs): """ Opens a url forcing the proxies to be used. @@ -118,7 +115,7 @@ def urlopen(self, *args, **kwargs): - `kwargs`: all other keyword arguments. """ # Must never leak the API key via proxied requests - return requests.get(*args, proxies=self.__proxies, verify=False, **kwargs).text + return requests.get(url, proxies=self.__proxies, verify=False, *args, **kwargs).text def _request_api(self, url, query=None): """ @@ -153,7 +150,8 @@ def _request(self, url, get=None): - `url`: the url to GET at. - `get`: the dictionary to turn into GET variables. """ - return self._request_api(url, get).json() + data = self._request_api(url, get) + return data.json() def _request_other(self, url, get=None): """ @@ -163,4 +161,5 @@ def _request_other(self, url, get=None): - `url`: the url to GET at. - `get`: the dictionary to turn into GET variables. """ - return self._request_api(url, get).text + data = self._request_api(url, get) + return data.text diff --git a/src/zapv2/acsrf.py b/src/zapv2/acsrf.py index 725df74..7c6bc70 100644 --- a/src/zapv2/acsrf.py +++ b/src/zapv2/acsrf.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class acsrf(object): def __init__(self, zap): @@ -29,24 +32,22 @@ def option_tokens_names(self): """ Lists the names of all anti-CSRF tokens """ - return next(self.zap._request(self.zap.base + 'acsrf/view/optionTokensNames/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'acsrf/view/optionTokensNames/'))) def add_option_token(self, string, apikey=''): """ Adds an anti-CSRF token with the given name, enabled by default """ - return next(self.zap._request(self.zap.base + 'acsrf/action/addOptionToken/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'acsrf/action/addOptionToken/', {'String': string, 'apikey': apikey}))) def remove_option_token(self, string, apikey=''): """ Removes the anti-CSRF token with the given name """ - return next(self.zap._request(self.zap.base + 'acsrf/action/removeOptionToken/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'acsrf/action/removeOptionToken/', {'String': string, 'apikey': apikey}))) def gen_form(self, hrefid, apikey=''): """ Generate a form for testing lack of anti-CSRF tokens - typically invoked via ZAP """ - return (self.zap._request_other(self.zap.base_other + 'acsrf/other/genForm/', {'hrefId' : hrefid, 'apikey' : apikey})) - - + return (self.zap._request_other(self.zap.base_other + 'acsrf/other/genForm/', {'hrefId': hrefid, 'apikey': apikey})) diff --git a/src/zapv2/ajaxSpider.py b/src/zapv2/ajaxSpider.py index 72c4d78..3a6885c 100644 --- a/src/zapv2/ajaxSpider.py +++ b/src/zapv2/ajaxSpider.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class ajaxSpider(object): def __init__(self, zap): @@ -29,7 +32,7 @@ def status(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/status/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/status/'))) def results(self, start=None, count=None): """ @@ -40,97 +43,97 @@ def results(self, start=None, count=None): params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/results/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/results/', params))) @property def number_of_results(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/numberOfResults/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/numberOfResults/'))) @property def full_results(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/fullResults/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/fullResults/'))) @property def option_browser_id(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionBrowserId/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionBrowserId/'))) @property def option_event_wait(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionEventWait/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionEventWait/'))) @property def option_max_crawl_depth(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionMaxCrawlDepth/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionMaxCrawlDepth/'))) @property def option_max_crawl_states(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionMaxCrawlStates/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionMaxCrawlStates/'))) @property def option_max_duration(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionMaxDuration/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionMaxDuration/'))) @property def option_number_of_browsers(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionNumberOfBrowsers/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionNumberOfBrowsers/'))) @property def option_reload_wait(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionReloadWait/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionReloadWait/'))) @property def option_click_default_elems(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionClickDefaultElems/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionClickDefaultElems/'))) @property def option_click_elems_once(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionClickElemsOnce/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionClickElemsOnce/'))) @property def option_random_inputs(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/view/optionRandomInputs/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/view/optionRandomInputs/'))) def scan(self, url=None, inscope=None, contextname=None, subtreeonly=None, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - params = {'apikey' : apikey} + params = {'apikey': apikey} if url is not None: params['url'] = url if inscope is not None: @@ -139,83 +142,81 @@ def scan(self, url=None, inscope=None, contextname=None, subtreeonly=None, apike params['contextName'] = contextname if subtreeonly is not None: params['subtreeOnly'] = subtreeonly - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/scan/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/scan/', params))) def scan_as_user(self, contextname, username, url=None, subtreeonly=None, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - params = {'contextName' : contextname, 'userName' : username, 'apikey' : apikey} + params = {'contextName': contextname, 'userName': username, 'apikey': apikey} if url is not None: params['url'] = url if subtreeonly is not None: params['subtreeOnly'] = subtreeonly - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/scanAsUser/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/scanAsUser/', params))) def stop(self, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/stop/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/stop/', {'apikey': apikey}))) def set_option_browser_id(self, string, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionBrowserId/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionBrowserId/', {'String': string, 'apikey': apikey}))) def set_option_click_default_elems(self, boolean, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionClickDefaultElems/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionClickDefaultElems/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_click_elems_once(self, boolean, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionClickElemsOnce/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionClickElemsOnce/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_event_wait(self, integer, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionEventWait/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionEventWait/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_crawl_depth(self, integer, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionMaxCrawlDepth/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionMaxCrawlDepth/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_crawl_states(self, integer, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionMaxCrawlStates/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionMaxCrawlStates/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_duration(self, integer, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionMaxDuration/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionMaxDuration/', {'Integer': integer, 'apikey': apikey}))) def set_option_number_of_browsers(self, integer, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionNumberOfBrowsers/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionNumberOfBrowsers/', {'Integer': integer, 'apikey': apikey}))) def set_option_random_inputs(self, boolean, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionRandomInputs/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionRandomInputs/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_reload_wait(self, integer, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionReloadWait/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionReloadWait/', {'Integer': integer, 'apikey': apikey}))) diff --git a/src/zapv2/ascan.py b/src/zapv2/ascan.py index 02ef2df..0ec05df 100644 --- a/src/zapv2/ascan.py +++ b/src/zapv2/ascan.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class ascan(object): def __init__(self, zap): @@ -28,34 +31,34 @@ def status(self, scanid=None): params = {} if scanid is not None: params['scanId'] = scanid - return next(self.zap._request(self.zap.base + 'ascan/view/status/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/status/', params))) def scan_progress(self, scanid=None): params = {} if scanid is not None: params['scanId'] = scanid - return next(self.zap._request(self.zap.base + 'ascan/view/scanProgress/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/scanProgress/', params))) def messages_ids(self, scanid): - return next(self.zap._request(self.zap.base + 'ascan/view/messagesIds/', {'scanId' : scanid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/messagesIds/', {'scanId': scanid}))) def alerts_ids(self, scanid): - return next(self.zap._request(self.zap.base + 'ascan/view/alertsIds/', {'scanId' : scanid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/alertsIds/', {'scanId': scanid}))) @property def scans(self): - return next(self.zap._request(self.zap.base + 'ascan/view/scans/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/scans/'))) @property def scan_policy_names(self): - return next(self.zap._request(self.zap.base + 'ascan/view/scanPolicyNames/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/scanPolicyNames/'))) @property def excluded_from_scan(self): """ Gets the regexes of URLs excluded from the active scans. """ - return next(self.zap._request(self.zap.base + 'ascan/view/excludedFromScan/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/excludedFromScan/'))) def scanners(self, scanpolicyname=None, policyid=None): params = {} @@ -63,7 +66,7 @@ def scanners(self, scanpolicyname=None, policyid=None): params['scanPolicyName'] = scanpolicyname if policyid is not None: params['policyId'] = policyid - return next(self.zap._request(self.zap.base + 'ascan/view/scanners/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/scanners/', params))) def policies(self, scanpolicyname=None, policyid=None): params = {} @@ -71,124 +74,124 @@ def policies(self, scanpolicyname=None, policyid=None): params['scanPolicyName'] = scanpolicyname if policyid is not None: params['policyId'] = policyid - return next(self.zap._request(self.zap.base + 'ascan/view/policies/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/policies/', params))) @property def attack_mode_queue(self): - return next(self.zap._request(self.zap.base + 'ascan/view/attackModeQueue/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/attackModeQueue/'))) @property def excluded_params(self): """ Gets all the parameters that are excluded. For each parameter the following are shown: the name, the URL, and the parameter type. """ - return next(self.zap._request(self.zap.base + 'ascan/view/excludedParams/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/excludedParams/'))) @property def option_excluded_param_list(self): """ Use view excludedParams instead. """ - return next(self.zap._request(self.zap.base + 'ascan/view/optionExcludedParamList/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionExcludedParamList/'))) @property def excluded_param_types(self): """ Gets all the types of excluded parameters. For each type the following are shown: the ID and the name. """ - return next(self.zap._request(self.zap.base + 'ascan/view/excludedParamTypes/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/excludedParamTypes/'))) @property def option_attack_policy(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionAttackPolicy/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionAttackPolicy/'))) @property def option_default_policy(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionDefaultPolicy/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionDefaultPolicy/'))) @property def option_delay_in_ms(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionDelayInMs/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionDelayInMs/'))) @property def option_handle_anti_csrf_tokens(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionHandleAntiCSRFTokens/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionHandleAntiCSRFTokens/'))) @property def option_host_per_scan(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionHostPerScan/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionHostPerScan/'))) @property def option_max_chart_time_in_mins(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionMaxChartTimeInMins/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionMaxChartTimeInMins/'))) @property def option_max_results_to_list(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionMaxResultsToList/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionMaxResultsToList/'))) @property def option_max_rule_duration_in_mins(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionMaxRuleDurationInMins/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionMaxRuleDurationInMins/'))) @property def option_max_scan_duration_in_mins(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionMaxScanDurationInMins/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionMaxScanDurationInMins/'))) @property def option_max_scans_in_ui(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionMaxScansInUI/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionMaxScansInUI/'))) @property def option_target_params_enabled_rpc(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionTargetParamsEnabledRPC/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionTargetParamsEnabledRPC/'))) @property def option_target_params_injectable(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionTargetParamsInjectable/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionTargetParamsInjectable/'))) @property def option_thread_per_host(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionThreadPerHost/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionThreadPerHost/'))) @property def option_allow_attack_on_start(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionAllowAttackOnStart/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionAllowAttackOnStart/'))) @property def option_inject_plugin_id_in_header(self): """ Tells whether or not the active scanner should inject the HTTP request header X-ZAP-Scan-ID, with the ID of the scanner that's sending the requests. """ - return next(self.zap._request(self.zap.base + 'ascan/view/optionInjectPluginIdInHeader/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionInjectPluginIdInHeader/'))) @property def option_prompt_in_attack_mode(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionPromptInAttackMode/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionPromptInAttackMode/'))) @property def option_prompt_to_clear_finished_scans(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionPromptToClearFinishedScans/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionPromptToClearFinishedScans/'))) @property def option_rescan_in_attack_mode(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionRescanInAttackMode/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionRescanInAttackMode/'))) @property def option_scan_headers_all_requests(self): """ 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. """ - return next(self.zap._request(self.zap.base + 'ascan/view/optionScanHeadersAllRequests/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionScanHeadersAllRequests/'))) @property def option_show_advanced_dialog(self): - return next(self.zap._request(self.zap.base + 'ascan/view/optionShowAdvancedDialog/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionShowAdvancedDialog/'))) def scan(self, url=None, recurse=None, inscopeonly=None, scanpolicyname=None, method=None, postdata=None, contextid=None, apikey=''): """ Runs the active scanner against the given URL and/or Context. Optionally, the 'recurse' parameter can be used to scan URLs under the given URL, the parameter 'inScopeOnly' can be used to constrain the scan to URLs that are in scope (ignored if a Context is specified), the parameter 'scanPolicyName' allows to specify the scan policy (if none is given it uses the default scan policy), the parameters 'method' and 'postData' allow to select a given request in conjunction with the given URL. """ - params = {'apikey' : apikey} + params = {'apikey': apikey} if url is not None: params['url'] = url if recurse is not None: @@ -203,13 +206,13 @@ def scan(self, url=None, recurse=None, inscopeonly=None, scanpolicyname=None, me params['postData'] = postdata if contextid is not None: params['contextId'] = contextid - return next(self.zap._request(self.zap.base + 'ascan/action/scan/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/scan/', params))) def scan_as_user(self, url=None, contextid=None, userid=None, recurse=None, scanpolicyname=None, method=None, postdata=None, apikey=''): """ Active Scans from the perspective of a User, obtained using the given Context ID and User ID. See 'scan' action for more details. """ - params = {'apikey' : apikey} + params = {'apikey': apikey} if url is not None: params['url'] = url if contextid is not None: @@ -224,211 +227,209 @@ def scan_as_user(self, url=None, contextid=None, userid=None, recurse=None, scan params['method'] = method if postdata is not None: params['postData'] = postdata - return next(self.zap._request(self.zap.base + 'ascan/action/scanAsUser/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/scanAsUser/', params))) def pause(self, scanid, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/pause/', {'scanId' : scanid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/pause/', {'scanId': scanid, 'apikey': apikey}))) def resume(self, scanid, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/resume/', {'scanId' : scanid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/resume/', {'scanId': scanid, 'apikey': apikey}))) def stop(self, scanid, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/stop/', {'scanId' : scanid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/stop/', {'scanId': scanid, 'apikey': apikey}))) def remove_scan(self, scanid, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/removeScan/', {'scanId' : scanid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/removeScan/', {'scanId': scanid, 'apikey': apikey}))) def pause_all_scans(self, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/pauseAllScans/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/pauseAllScans/', {'apikey': apikey}))) def resume_all_scans(self, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/resumeAllScans/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/resumeAllScans/', {'apikey': apikey}))) def stop_all_scans(self, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/stopAllScans/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/stopAllScans/', {'apikey': apikey}))) def remove_all_scans(self, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/removeAllScans/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/removeAllScans/', {'apikey': apikey}))) def clear_excluded_from_scan(self, apikey=''): """ Clears the regexes of URLs excluded from the active scans. """ - return next(self.zap._request(self.zap.base + 'ascan/action/clearExcludedFromScan/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/clearExcludedFromScan/', {'apikey': apikey}))) def exclude_from_scan(self, regex, apikey=''): """ Adds a regex of URLs that should be excluded from the active scans. """ - return next(self.zap._request(self.zap.base + 'ascan/action/excludeFromScan/', {'regex' : regex, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/excludeFromScan/', {'regex': regex, 'apikey': apikey}))) def enable_all_scanners(self, scanpolicyname=None, apikey=''): - params = {'apikey' : apikey} + params = {'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/enableAllScanners/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/enableAllScanners/', params))) def disable_all_scanners(self, scanpolicyname=None, apikey=''): - params = {'apikey' : apikey} + params = {'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/disableAllScanners/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/disableAllScanners/', params))) def enable_scanners(self, ids, scanpolicyname=None, apikey=''): - params = {'ids' : ids, 'apikey' : apikey} + params = {'ids': ids, 'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/enableScanners/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/enableScanners/', params))) def disable_scanners(self, ids, scanpolicyname=None, apikey=''): - params = {'ids' : ids, 'apikey' : apikey} + params = {'ids': ids, 'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/disableScanners/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/disableScanners/', params))) def set_enabled_policies(self, ids, scanpolicyname=None, apikey=''): - params = {'ids' : ids, 'apikey' : apikey} + params = {'ids': ids, 'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/setEnabledPolicies/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setEnabledPolicies/', params))) def set_policy_attack_strength(self, id, attackstrength, scanpolicyname=None, apikey=''): - params = {'id' : id, 'attackStrength' : attackstrength, 'apikey' : apikey} + params = {'id': id, 'attackStrength': attackstrength, 'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/setPolicyAttackStrength/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setPolicyAttackStrength/', params))) def set_policy_alert_threshold(self, id, alertthreshold, scanpolicyname=None, apikey=''): - params = {'id' : id, 'alertThreshold' : alertthreshold, 'apikey' : apikey} + params = {'id': id, 'alertThreshold': alertthreshold, 'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/setPolicyAlertThreshold/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setPolicyAlertThreshold/', params))) def set_scanner_attack_strength(self, id, attackstrength, scanpolicyname=None, apikey=''): - params = {'id' : id, 'attackStrength' : attackstrength, 'apikey' : apikey} + params = {'id': id, 'attackStrength': attackstrength, 'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/setScannerAttackStrength/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setScannerAttackStrength/', params))) def set_scanner_alert_threshold(self, id, alertthreshold, scanpolicyname=None, apikey=''): - params = {'id' : id, 'alertThreshold' : alertthreshold, 'apikey' : apikey} + params = {'id': id, 'alertThreshold': alertthreshold, 'apikey': apikey} if scanpolicyname is not None: params['scanPolicyName'] = scanpolicyname - return next(self.zap._request(self.zap.base + 'ascan/action/setScannerAlertThreshold/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setScannerAlertThreshold/', params))) def add_scan_policy(self, scanpolicyname, alertthreshold=None, attackstrength=None, apikey=''): - params = {'scanPolicyName' : scanpolicyname, 'apikey' : apikey} + params = {'scanPolicyName': scanpolicyname, 'apikey': apikey} if alertthreshold is not None: params['alertThreshold'] = alertthreshold if attackstrength is not None: params['attackStrength'] = attackstrength - return next(self.zap._request(self.zap.base + 'ascan/action/addScanPolicy/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/addScanPolicy/', params))) def remove_scan_policy(self, scanpolicyname, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/removeScanPolicy/', {'scanPolicyName' : scanpolicyname, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/removeScanPolicy/', {'scanPolicyName': scanpolicyname, 'apikey': apikey}))) def update_scan_policy(self, scanpolicyname, alertthreshold=None, attackstrength=None, apikey=''): - params = {'scanPolicyName' : scanpolicyname, 'apikey' : apikey} + params = {'scanPolicyName': scanpolicyname, 'apikey': apikey} if alertthreshold is not None: params['alertThreshold'] = alertthreshold if attackstrength is not None: params['attackStrength'] = attackstrength - return next(self.zap._request(self.zap.base + 'ascan/action/updateScanPolicy/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/updateScanPolicy/', params))) def add_excluded_param(self, name, type=None, url=None, apikey=''): """ 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. """ - params = {'name' : name, 'apikey' : apikey} + params = {'name': name, 'apikey': apikey} if type is not None: params['type'] = type if url is not None: params['url'] = url - return next(self.zap._request(self.zap.base + 'ascan/action/addExcludedParam/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/addExcludedParam/', params))) def modify_excluded_param(self, idx, name=None, type=None, url=None, apikey=''): """ 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. """ - params = {'idx' : idx, 'apikey' : apikey} + params = {'idx': idx, 'apikey': apikey} if name is not None: params['name'] = name if type is not None: params['type'] = type if url is not None: params['url'] = url - return next(self.zap._request(self.zap.base + 'ascan/action/modifyExcludedParam/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/modifyExcludedParam/', params))) def remove_excluded_param(self, idx, apikey=''): """ Removes a parameter excluded from the scan, with the given index. The index can be obtained with the view excludedParams. """ - return next(self.zap._request(self.zap.base + 'ascan/action/removeExcludedParam/', {'idx' : idx, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/removeExcludedParam/', {'idx': idx, 'apikey': apikey}))) def set_option_attack_policy(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionAttackPolicy/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionAttackPolicy/', {'String': string, 'apikey': apikey}))) def set_option_default_policy(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionDefaultPolicy/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionDefaultPolicy/', {'String': string, 'apikey': apikey}))) def set_option_allow_attack_on_start(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionAllowAttackOnStart/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionAllowAttackOnStart/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_delay_in_ms(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionDelayInMs/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionDelayInMs/', {'Integer': integer, 'apikey': apikey}))) def set_option_handle_anti_csrf_tokens(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionHandleAntiCSRFTokens/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionHandleAntiCSRFTokens/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_host_per_scan(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionHostPerScan/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionHostPerScan/', {'Integer': integer, 'apikey': apikey}))) def set_option_inject_plugin_id_in_header(self, boolean, apikey=''): """ Sets whether or not the active scanner should inject the HTTP request header X-ZAP-Scan-ID, with the ID of the scanner that's sending the requests. """ - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionInjectPluginIdInHeader/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionInjectPluginIdInHeader/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_max_chart_time_in_mins(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxChartTimeInMins/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxChartTimeInMins/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_results_to_list(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxResultsToList/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxResultsToList/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_rule_duration_in_mins(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxRuleDurationInMins/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxRuleDurationInMins/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_scan_duration_in_mins(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxScanDurationInMins/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxScanDurationInMins/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_scans_in_ui(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxScansInUI/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionMaxScansInUI/', {'Integer': integer, 'apikey': apikey}))) def set_option_prompt_in_attack_mode(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionPromptInAttackMode/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionPromptInAttackMode/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_prompt_to_clear_finished_scans(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionPromptToClearFinishedScans/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionPromptToClearFinishedScans/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_rescan_in_attack_mode(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionRescanInAttackMode/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionRescanInAttackMode/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_scan_headers_all_requests(self, boolean, apikey=''): """ 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. """ - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionScanHeadersAllRequests/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionScanHeadersAllRequests/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_show_advanced_dialog(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionShowAdvancedDialog/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionShowAdvancedDialog/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_target_params_enabled_rpc(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionTargetParamsEnabledRPC/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionTargetParamsEnabledRPC/', {'Integer': integer, 'apikey': apikey}))) def set_option_target_params_injectable(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionTargetParamsInjectable/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionTargetParamsInjectable/', {'Integer': integer, 'apikey': apikey}))) def set_option_thread_per_host(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'ascan/action/setOptionThreadPerHost/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionThreadPerHost/', {'Integer': integer, 'apikey': apikey}))) diff --git a/src/zapv2/authentication.py b/src/zapv2/authentication.py index 206d233..4a8d7bd 100644 --- a/src/zapv2/authentication.py +++ b/src/zapv2/authentication.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class authentication(object): def __init__(self, zap): @@ -26,30 +29,28 @@ def __init__(self, zap): @property def get_supported_authentication_methods(self): - return next(self.zap._request(self.zap.base + 'authentication/view/getSupportedAuthenticationMethods/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authentication/view/getSupportedAuthenticationMethods/'))) def get_authentication_method_config_params(self, authmethodname): - return next(self.zap._request(self.zap.base + 'authentication/view/getAuthenticationMethodConfigParams/', {'authMethodName' : authmethodname}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authentication/view/getAuthenticationMethodConfigParams/', {'authMethodName': authmethodname}))) def get_authentication_method(self, contextid): - return next(self.zap._request(self.zap.base + 'authentication/view/getAuthenticationMethod/', {'contextId' : contextid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authentication/view/getAuthenticationMethod/', {'contextId': contextid}))) def get_logged_in_indicator(self, contextid): - return next(self.zap._request(self.zap.base + 'authentication/view/getLoggedInIndicator/', {'contextId' : contextid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authentication/view/getLoggedInIndicator/', {'contextId': contextid}))) def get_logged_out_indicator(self, contextid): - return next(self.zap._request(self.zap.base + 'authentication/view/getLoggedOutIndicator/', {'contextId' : contextid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authentication/view/getLoggedOutIndicator/', {'contextId': contextid}))) def set_authentication_method(self, contextid, authmethodname, authmethodconfigparams=None, apikey=''): - params = {'contextId' : contextid, 'authMethodName' : authmethodname, 'apikey' : apikey} + params = {'contextId': contextid, 'authMethodName': authmethodname, 'apikey': apikey} if authmethodconfigparams is not None: params['authMethodConfigParams'] = authmethodconfigparams - return next(self.zap._request(self.zap.base + 'authentication/action/setAuthenticationMethod/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authentication/action/setAuthenticationMethod/', params))) def set_logged_in_indicator(self, contextid, loggedinindicatorregex, apikey=''): - return next(self.zap._request(self.zap.base + 'authentication/action/setLoggedInIndicator/', {'contextId' : contextid, 'loggedInIndicatorRegex' : loggedinindicatorregex, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authentication/action/setLoggedInIndicator/', {'contextId': contextid, 'loggedInIndicatorRegex': loggedinindicatorregex, 'apikey': apikey}))) def set_logged_out_indicator(self, contextid, loggedoutindicatorregex, apikey=''): - return next(self.zap._request(self.zap.base + 'authentication/action/setLoggedOutIndicator/', {'contextId' : contextid, 'loggedOutIndicatorRegex' : loggedoutindicatorregex, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authentication/action/setLoggedOutIndicator/', {'contextId': contextid, 'loggedOutIndicatorRegex': loggedoutindicatorregex, 'apikey': apikey}))) diff --git a/src/zapv2/authorization.py b/src/zapv2/authorization.py index 763110b..edda5b5 100644 --- a/src/zapv2/authorization.py +++ b/src/zapv2/authorization.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class authorization(object): def __init__(self, zap): @@ -28,13 +31,13 @@ def get_authorization_detection_method(self, contextid): """ Obtains all the configuration of the authorization detection method that is currently set for a context. """ - return next(self.zap._request(self.zap.base + 'authorization/view/getAuthorizationDetectionMethod/', {'contextId' : contextid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authorization/view/getAuthorizationDetectionMethod/', {'contextId': contextid}))) def set_basic_authorization_detection_method(self, contextid, headerregex=None, bodyregex=None, statuscode=None, logicaloperator=None, apikey=''): """ 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". """ - params = {'contextId' : contextid, 'apikey' : apikey} + params = {'contextId': contextid, 'apikey': apikey} if headerregex is not None: params['headerRegex'] = headerregex if bodyregex is not None: @@ -43,6 +46,4 @@ def set_basic_authorization_detection_method(self, contextid, headerregex=None, params['statusCode'] = statuscode if logicaloperator is not None: params['logicalOperator'] = logicaloperator - return next(self.zap._request(self.zap.base + 'authorization/action/setBasicAuthorizationDetectionMethod/', params).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'authorization/action/setBasicAuthorizationDetectionMethod/', params))) diff --git a/src/zapv2/autoupdate.py b/src/zapv2/autoupdate.py index ac2135a..7837d75 100644 --- a/src/zapv2/autoupdate.py +++ b/src/zapv2/autoupdate.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class autoupdate(object): def __init__(self, zap): @@ -29,135 +32,133 @@ def latest_version_number(self): """ Returns the latest version number """ - return next(self.zap._request(self.zap.base + 'autoupdate/view/latestVersionNumber/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/latestVersionNumber/'))) @property def is_latest_version(self): """ Returns 'true' if ZAP is on the latest version """ - return next(self.zap._request(self.zap.base + 'autoupdate/view/isLatestVersion/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/isLatestVersion/'))) @property def installed_addons(self): """ Return a list of all of the installed add-ons """ - return next(self.zap._request(self.zap.base + 'autoupdate/view/installedAddons/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/installedAddons/'))) @property def new_addons(self): """ Return a list of any add-ons that have been added to the Marketplace since the last check for updates """ - return next(self.zap._request(self.zap.base + 'autoupdate/view/newAddons/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/newAddons/'))) @property def updated_addons(self): """ Return a list of any add-ons that have been changed in the Marketplace since the last check for updates """ - return next(self.zap._request(self.zap.base + 'autoupdate/view/updatedAddons/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/updatedAddons/'))) @property def marketplace_addons(self): """ Return a list of all of the add-ons on the ZAP Marketplace (this information is read once and then cached) """ - return next(self.zap._request(self.zap.base + 'autoupdate/view/marketplaceAddons/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/marketplaceAddons/'))) @property def option_addon_directories(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionAddonDirectories/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionAddonDirectories/'))) @property def option_day_last_checked(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionDayLastChecked/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionDayLastChecked/'))) @property def option_day_last_install_warned(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionDayLastInstallWarned/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionDayLastInstallWarned/'))) @property def option_day_last_update_warned(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionDayLastUpdateWarned/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionDayLastUpdateWarned/'))) @property def option_download_directory(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionDownloadDirectory/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionDownloadDirectory/'))) @property def option_check_addon_updates(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionCheckAddonUpdates/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionCheckAddonUpdates/'))) @property def option_check_on_start(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionCheckOnStart/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionCheckOnStart/'))) @property def option_download_new_release(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionDownloadNewRelease/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionDownloadNewRelease/'))) @property def option_install_addon_updates(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionInstallAddonUpdates/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionInstallAddonUpdates/'))) @property def option_install_scanner_rules(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionInstallScannerRules/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionInstallScannerRules/'))) @property def option_report_alpha_addons(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionReportAlphaAddons/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionReportAlphaAddons/'))) @property def option_report_beta_addons(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionReportBetaAddons/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionReportBetaAddons/'))) @property def option_report_release_addons(self): - return next(self.zap._request(self.zap.base + 'autoupdate/view/optionReportReleaseAddons/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/view/optionReportReleaseAddons/'))) def download_latest_release(self, apikey=''): """ Downloads the latest release, if any """ - return next(self.zap._request(self.zap.base + 'autoupdate/action/downloadLatestRelease/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/downloadLatestRelease/', {'apikey': apikey}))) def install_addon(self, id, apikey=''): """ Installs or updates the specified add-on, returning when complete (ie not asynchronously) """ - return next(self.zap._request(self.zap.base + 'autoupdate/action/installAddon/', {'id' : id, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/installAddon/', {'id': id, 'apikey': apikey}))) def uninstall_addon(self, id, apikey=''): """ Uninstalls the specified add-on """ - return next(self.zap._request(self.zap.base + 'autoupdate/action/uninstallAddon/', {'id' : id, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/uninstallAddon/', {'id': id, 'apikey': apikey}))) def set_option_check_addon_updates(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'autoupdate/action/setOptionCheckAddonUpdates/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/setOptionCheckAddonUpdates/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_check_on_start(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'autoupdate/action/setOptionCheckOnStart/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/setOptionCheckOnStart/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_download_new_release(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'autoupdate/action/setOptionDownloadNewRelease/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/setOptionDownloadNewRelease/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_install_addon_updates(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'autoupdate/action/setOptionInstallAddonUpdates/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/setOptionInstallAddonUpdates/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_install_scanner_rules(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'autoupdate/action/setOptionInstallScannerRules/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/setOptionInstallScannerRules/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_report_alpha_addons(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'autoupdate/action/setOptionReportAlphaAddons/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/setOptionReportAlphaAddons/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_report_beta_addons(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'autoupdate/action/setOptionReportBetaAddons/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/setOptionReportBetaAddons/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_report_release_addons(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'autoupdate/action/setOptionReportReleaseAddons/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'autoupdate/action/setOptionReportReleaseAddons/', {'Boolean': boolean, 'apikey': apikey}))) diff --git a/src/zapv2/brk.py b/src/zapv2/brk.py index 6b8f4d1..6b8fcec 100644 --- a/src/zapv2/brk.py +++ b/src/zapv2/brk.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class brk(object): def __init__(self, zap): @@ -29,75 +32,73 @@ def is_break_all(self): """ Returns True if ZAP will break on both requests and responses """ - return next(self.zap._request(self.zap.base + 'break/view/isBreakAll/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/view/isBreakAll/'))) @property def is_break_request(self): """ Returns True if ZAP will break on requests """ - return next(self.zap._request(self.zap.base + 'break/view/isBreakRequest/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/view/isBreakRequest/'))) @property def is_break_response(self): """ Returns True if ZAP will break on responses """ - return next(self.zap._request(self.zap.base + 'break/view/isBreakResponse/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/view/isBreakResponse/'))) @property def http_message(self): """ Returns the HTTP message currently intercepted (if any) """ - return next(self.zap._request(self.zap.base + 'break/view/httpMessage/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/view/httpMessage/'))) def brk(self, type, state, scope=None, apikey=''): """ 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. """ - params = {'type' : type, 'state' : state, 'apikey' : apikey} + params = {'type': type, 'state': state, 'apikey': apikey} if scope is not None: params['scope'] = scope - return next(self.zap._request(self.zap.base + 'break/action/break/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/action/break/', params))) def set_http_message(self, httpheader, httpbody=None, apikey=''): """ Overwrites the currently intercepted message with the data provided """ - params = {'httpHeader' : httpheader, 'apikey' : apikey} + params = {'httpHeader': httpheader, 'apikey': apikey} if httpbody is not None: params['httpBody'] = httpbody - return next(self.zap._request(self.zap.base + 'break/action/setHttpMessage/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/action/setHttpMessage/', params))) def cont(self, apikey=''): """ Submits the currently intercepted message and unsets the global request/response break points """ - return next(self.zap._request(self.zap.base + 'break/action/continue/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/action/continue/', {'apikey': apikey}))) def step(self, apikey=''): """ Submits the currently intercepted message, the next request or response will automatically be intercepted """ - return next(self.zap._request(self.zap.base + 'break/action/step/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/action/step/', {'apikey': apikey}))) def drop(self, apikey=''): """ Drops the currently intercepted message """ - return next(self.zap._request(self.zap.base + 'break/action/drop/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/action/drop/', {'apikey': apikey}))) def add_http_breakpoint(self, string, location, match, inverse, ignorecase, apikey=''): """ Adds a custom HTTP breakpont. The string is the string to match. Location may be one of: url, request_header, request_body, response_header or response_body. Match may be: contains or regex. Inverse (match) may be true or false. Lastly, ignorecase (when matching the string) may be true or false. """ - return next(self.zap._request(self.zap.base + 'break/action/addHttpBreakpoint/', {'string' : string, 'location' : location, 'match' : match, 'inverse' : inverse, 'ignorecase' : ignorecase, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/action/addHttpBreakpoint/', {'string': string, 'location': location, 'match': match, 'inverse': inverse, 'ignorecase': ignorecase, 'apikey': apikey}))) def remove_http_breakpoint(self, string, location, match, inverse, ignorecase, apikey=''): """ Removes the specified break point """ - return next(self.zap._request(self.zap.base + 'break/action/removeHttpBreakpoint/', {'string' : string, 'location' : location, 'match' : match, 'inverse' : inverse, 'ignorecase' : ignorecase, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'break/action/removeHttpBreakpoint/', {'string': string, 'location': location, 'match': match, 'inverse': inverse, 'ignorecase': ignorecase, 'apikey': apikey}))) diff --git a/src/zapv2/context.py b/src/zapv2/context.py index 9f0a637..dae0335 100644 --- a/src/zapv2/context.py +++ b/src/zapv2/context.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class context(object): def __init__(self, zap): @@ -29,109 +32,107 @@ def context_list(self): """ List context names of current session """ - return next(self.zap._request(self.zap.base + 'context/view/contextList/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/view/contextList/'))) def exclude_regexs(self, contextname): """ List excluded regexs for context """ - return next(self.zap._request(self.zap.base + 'context/view/excludeRegexs/', {'contextName' : contextname}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/view/excludeRegexs/', {'contextName': contextname}))) def include_regexs(self, contextname): """ List included regexs for context """ - return next(self.zap._request(self.zap.base + 'context/view/includeRegexs/', {'contextName' : contextname}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/view/includeRegexs/', {'contextName': contextname}))) def context(self, contextname): """ List the information about the named context """ - return next(self.zap._request(self.zap.base + 'context/view/context/', {'contextName' : contextname}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/view/context/', {'contextName': contextname}))) @property def technology_list(self): """ Lists the names of all built in technologies """ - return next(self.zap._request(self.zap.base + 'context/view/technologyList/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/view/technologyList/'))) def included_technology_list(self, contextname): """ Lists the names of all technologies included in a context """ - return next(self.zap._request(self.zap.base + 'context/view/includedTechnologyList/', {'contextName' : contextname}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/view/includedTechnologyList/', {'contextName': contextname}))) def excluded_technology_list(self, contextname): """ Lists the names of all technologies excluded from a context """ - return next(self.zap._request(self.zap.base + 'context/view/excludedTechnologyList/', {'contextName' : contextname}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/view/excludedTechnologyList/', {'contextName': contextname}))) def exclude_from_context(self, contextname, regex, apikey=''): """ Add exclude regex to context """ - return next(self.zap._request(self.zap.base + 'context/action/excludeFromContext/', {'contextName' : contextname, 'regex' : regex, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/excludeFromContext/', {'contextName': contextname, 'regex': regex, 'apikey': apikey}))) def include_in_context(self, contextname, regex, apikey=''): """ Add include regex to context """ - return next(self.zap._request(self.zap.base + 'context/action/includeInContext/', {'contextName' : contextname, 'regex' : regex, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/includeInContext/', {'contextName': contextname, 'regex': regex, 'apikey': apikey}))) def new_context(self, contextname, apikey=''): """ Creates a new context with the given name in the current session """ - return next(self.zap._request(self.zap.base + 'context/action/newContext/', {'contextName' : contextname, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/newContext/', {'contextName': contextname, 'apikey': apikey}))) def remove_context(self, contextname, apikey=''): """ Removes a context in the current session """ - return next(self.zap._request(self.zap.base + 'context/action/removeContext/', {'contextName' : contextname, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/removeContext/', {'contextName': contextname, 'apikey': apikey}))) def export_context(self, contextname, contextfile, apikey=''): """ 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. """ - return next(self.zap._request(self.zap.base + 'context/action/exportContext/', {'contextName' : contextname, 'contextFile' : contextfile, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/exportContext/', {'contextName': contextname, 'contextFile': contextfile, 'apikey': apikey}))) def import_context(self, contextfile, apikey=''): """ 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. """ - return next(self.zap._request(self.zap.base + 'context/action/importContext/', {'contextFile' : contextfile, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/importContext/', {'contextFile': contextfile, 'apikey': apikey}))) def include_context_technologies(self, contextname, technologynames, apikey=''): """ Includes technologies with the given names, separated by a comma, to a context """ - return next(self.zap._request(self.zap.base + 'context/action/includeContextTechnologies/', {'contextName' : contextname, 'technologyNames' : technologynames, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/includeContextTechnologies/', {'contextName': contextname, 'technologyNames': technologynames, 'apikey': apikey}))) def include_all_context_technologies(self, contextname, apikey=''): """ Includes all built in technologies in to a context """ - return next(self.zap._request(self.zap.base + 'context/action/includeAllContextTechnologies/', {'contextName' : contextname, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/includeAllContextTechnologies/', {'contextName': contextname, 'apikey': apikey}))) def exclude_context_technologies(self, contextname, technologynames, apikey=''): """ Excludes technologies with the given names, separated by a comma, from a context """ - return next(self.zap._request(self.zap.base + 'context/action/excludeContextTechnologies/', {'contextName' : contextname, 'technologyNames' : technologynames, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/excludeContextTechnologies/', {'contextName': contextname, 'technologyNames': technologynames, 'apikey': apikey}))) def exclude_all_context_technologies(self, contextname, apikey=''): """ Excludes all built in technologies from a context """ - return next(self.zap._request(self.zap.base + 'context/action/excludeAllContextTechnologies/', {'contextName' : contextname, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/excludeAllContextTechnologies/', {'contextName': contextname, 'apikey': apikey}))) def set_context_in_scope(self, contextname, booleaninscope, apikey=''): """ Sets a context to in scope (contexts are in scope by default) """ - return next(self.zap._request(self.zap.base + 'context/action/setContextInScope/', {'contextName' : contextname, 'booleanInScope' : booleaninscope, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'context/action/setContextInScope/', {'contextName': contextname, 'booleanInScope': booleaninscope, 'apikey': apikey}))) diff --git a/src/zapv2/core.py b/src/zapv2/core.py index 2919668..c3b3b7a 100644 --- a/src/zapv2/core.py +++ b/src/zapv2/core.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class core(object): def __init__(self, zap): @@ -28,7 +31,7 @@ def alert(self, id): """ Gets the alert with the given ID, the corresponding HTTP message can be obtained with the 'messageId' field and 'message' API method """ - return next(self.zap._request(self.zap.base + 'core/view/alert/', {'id' : id}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/alert/', {'id': id}))) def alerts(self, baseurl=None, start=None, count=None): """ @@ -41,7 +44,7 @@ def alerts(self, baseurl=None, start=None, count=None): params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'core/view/alerts/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/alerts/', params))) def number_of_alerts(self, baseurl=None): """ @@ -50,34 +53,34 @@ def number_of_alerts(self, baseurl=None): params = {} if baseurl is not None: params['baseurl'] = baseurl - return next(self.zap._request(self.zap.base + 'core/view/numberOfAlerts/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/numberOfAlerts/', params))) @property def hosts(self): """ Gets the name of the hosts accessed through/by ZAP """ - return next(self.zap._request(self.zap.base + 'core/view/hosts/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/hosts/'))) @property def sites(self): """ Gets the sites accessed through/by ZAP (scheme and domain) """ - return next(self.zap._request(self.zap.base + 'core/view/sites/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/sites/'))) @property def urls(self): """ Gets the URLs accessed through/by ZAP """ - return next(self.zap._request(self.zap.base + 'core/view/urls/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/urls/'))) def message(self, id): """ Gets the HTTP message with the given ID. Returns the ID, request/response headers and bodies, cookies and note. """ - return next(self.zap._request(self.zap.base + 'core/view/message/', {'id' : id}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/message/', {'id': id}))) def messages(self, baseurl=None, start=None, count=None): """ @@ -90,7 +93,7 @@ def messages(self, baseurl=None, start=None, count=None): params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'core/view/messages/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/messages/', params))) def number_of_messages(self, baseurl=None): """ @@ -99,358 +102,358 @@ def number_of_messages(self, baseurl=None): params = {} if baseurl is not None: params['baseurl'] = baseurl - return next(self.zap._request(self.zap.base + 'core/view/numberOfMessages/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/numberOfMessages/', params))) @property def mode(self): """ Gets the mode """ - return next(self.zap._request(self.zap.base + 'core/view/mode/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/mode/'))) @property def version(self): """ Gets ZAP version """ - return next(self.zap._request(self.zap.base + 'core/view/version/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/version/'))) @property def excluded_from_proxy(self): """ Gets the regular expressions, applied to URLs, to exclude from the Proxy """ - return next(self.zap._request(self.zap.base + 'core/view/excludedFromProxy/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/excludedFromProxy/'))) @property def home_directory(self): - return next(self.zap._request(self.zap.base + 'core/view/homeDirectory/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/homeDirectory/'))) @property def session_location(self): """ Gets the location of the current session file """ - return next(self.zap._request(self.zap.base + 'core/view/sessionLocation/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/sessionLocation/'))) @property def proxy_chain_excluded_domains(self): """ 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. """ - return next(self.zap._request(self.zap.base + 'core/view/proxyChainExcludedDomains/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/proxyChainExcludedDomains/'))) @property def option_proxy_chain_skip_name(self): """ Use view proxyChainExcludedDomains instead. """ - return next(self.zap._request(self.zap.base + 'core/view/optionProxyChainSkipName/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyChainSkipName/'))) @property def option_proxy_excluded_domains(self): """ Use view proxyChainExcludedDomains instead. """ - return next(self.zap._request(self.zap.base + 'core/view/optionProxyExcludedDomains/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyExcludedDomains/'))) @property def option_proxy_excluded_domains_enabled(self): """ Use view proxyChainExcludedDomains instead. """ - return next(self.zap._request(self.zap.base + 'core/view/optionProxyExcludedDomainsEnabled/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyExcludedDomainsEnabled/'))) @property def option_default_user_agent(self): - return next(self.zap._request(self.zap.base + 'core/view/optionDefaultUserAgent/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionDefaultUserAgent/'))) @property def option_dns_ttl_successful_queries(self): """ Gets the TTL (in seconds) of successful DNS queries. """ - return next(self.zap._request(self.zap.base + 'core/view/optionDnsTtlSuccessfulQueries/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionDnsTtlSuccessfulQueries/'))) @property def option_http_state(self): - return next(self.zap._request(self.zap.base + 'core/view/optionHttpState/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionHttpState/'))) @property def option_proxy_chain_name(self): - return next(self.zap._request(self.zap.base + 'core/view/optionProxyChainName/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyChainName/'))) @property def option_proxy_chain_password(self): - return next(self.zap._request(self.zap.base + 'core/view/optionProxyChainPassword/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyChainPassword/'))) @property def option_proxy_chain_port(self): - return next(self.zap._request(self.zap.base + 'core/view/optionProxyChainPort/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyChainPort/'))) @property def option_proxy_chain_realm(self): - return next(self.zap._request(self.zap.base + 'core/view/optionProxyChainRealm/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyChainRealm/'))) @property def option_proxy_chain_user_name(self): - return next(self.zap._request(self.zap.base + 'core/view/optionProxyChainUserName/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyChainUserName/'))) @property def option_timeout_in_secs(self): - return next(self.zap._request(self.zap.base + 'core/view/optionTimeoutInSecs/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionTimeoutInSecs/'))) @property def option_http_state_enabled(self): - return next(self.zap._request(self.zap.base + 'core/view/optionHttpStateEnabled/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionHttpStateEnabled/'))) @property def option_proxy_chain_prompt(self): - return next(self.zap._request(self.zap.base + 'core/view/optionProxyChainPrompt/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionProxyChainPrompt/'))) @property def option_single_cookie_request_header(self): - return next(self.zap._request(self.zap.base + 'core/view/optionSingleCookieRequestHeader/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionSingleCookieRequestHeader/'))) @property def option_use_proxy_chain(self): - return next(self.zap._request(self.zap.base + 'core/view/optionUseProxyChain/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionUseProxyChain/'))) @property def option_use_proxy_chain_auth(self): - return next(self.zap._request(self.zap.base + 'core/view/optionUseProxyChainAuth/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/optionUseProxyChainAuth/'))) def access_url(self, url, followredirects=None, apikey=''): """ 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'. """ - params = {'url' : url, 'apikey' : apikey} + params = {'url': url, 'apikey': apikey} if followredirects is not None: params['followRedirects'] = followredirects - return next(self.zap._request(self.zap.base + 'core/action/accessUrl/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/accessUrl/', params))) def shutdown(self, apikey=''): """ Shuts down ZAP """ - return next(self.zap._request(self.zap.base + 'core/action/shutdown/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/shutdown/', {'apikey': apikey}))) def new_session(self, name=None, overwrite=None, apikey=''): """ 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. """ - params = {'apikey' : apikey} + params = {'apikey': apikey} if name is not None: params['name'] = name if overwrite is not None: params['overwrite'] = overwrite - return next(self.zap._request(self.zap.base + 'core/action/newSession/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/newSession/', params))) def load_session(self, name, apikey=''): """ 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. """ - return next(self.zap._request(self.zap.base + 'core/action/loadSession/', {'name' : name, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/loadSession/', {'name': name, 'apikey': apikey}))) def save_session(self, name, overwrite=None, apikey=''): """ 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. """ - params = {'name' : name, 'apikey' : apikey} + params = {'name': name, 'apikey': apikey} if overwrite is not None: params['overwrite'] = overwrite - return next(self.zap._request(self.zap.base + 'core/action/saveSession/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/saveSession/', params))) def snapshot_session(self, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/snapshotSession/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/snapshotSession/', {'apikey': apikey}))) def clear_excluded_from_proxy(self, apikey=''): """ Clears the regexes of URLs excluded from the proxy. """ - return next(self.zap._request(self.zap.base + 'core/action/clearExcludedFromProxy/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/clearExcludedFromProxy/', {'apikey': apikey}))) def exclude_from_proxy(self, regex, apikey=''): """ Adds a regex of URLs that should be excluded from the proxy. """ - return next(self.zap._request(self.zap.base + 'core/action/excludeFromProxy/', {'regex' : regex, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/excludeFromProxy/', {'regex': regex, 'apikey': apikey}))) def set_home_directory(self, dir, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setHomeDirectory/', {'dir' : dir, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setHomeDirectory/', {'dir': dir, 'apikey': apikey}))) def set_mode(self, mode, apikey=''): """ Sets the mode, which may be one of [safe, protect, standard, attack] """ - return next(self.zap._request(self.zap.base + 'core/action/setMode/', {'mode' : mode, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setMode/', {'mode': mode, 'apikey': apikey}))) def generate_root_ca(self, apikey=''): """ Generates a new Root CA certificate for the Local Proxy. """ - return next(self.zap._request(self.zap.base + 'core/action/generateRootCA/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/generateRootCA/', {'apikey': apikey}))) def send_request(self, request, followredirects=None, apikey=''): """ 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. """ - params = {'request' : request, 'apikey' : apikey} + params = {'request': request, 'apikey': apikey} if followredirects is not None: params['followRedirects'] = followredirects - return next(self.zap._request(self.zap.base + 'core/action/sendRequest/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/sendRequest/', params))) def delete_all_alerts(self, apikey=''): """ Deletes all alerts of the current session. """ - return next(self.zap._request(self.zap.base + 'core/action/deleteAllAlerts/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/deleteAllAlerts/', {'apikey': apikey}))) def run_garbage_collection(self, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/runGarbageCollection/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/runGarbageCollection/', {'apikey': apikey}))) def delete_site_node(self, url, method=None, postdata=None, apikey=''): """ Deletes the site node found in the Sites Tree on the basis of the URL, HTTP method, and post data (if applicable and specified). """ - params = {'url' : url, 'apikey' : apikey} + params = {'url': url, 'apikey': apikey} if method is not None: params['method'] = method if postdata is not None: params['postData'] = postdata - return next(self.zap._request(self.zap.base + 'core/action/deleteSiteNode/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/deleteSiteNode/', params))) def add_proxy_chain_excluded_domain(self, value, isregex=None, isenabled=None, apikey=''): """ 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). """ - params = {'value' : value, 'apikey' : apikey} + params = {'value': value, 'apikey': apikey} if isregex is not None: params['isRegex'] = isregex if isenabled is not None: params['isEnabled'] = isenabled - return next(self.zap._request(self.zap.base + 'core/action/addProxyChainExcludedDomain/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/addProxyChainExcludedDomain/', params))) def modify_proxy_chain_excluded_domain(self, idx, value=None, isregex=None, isenabled=None, apikey=''): """ 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. """ - params = {'idx' : idx, 'apikey' : apikey} + params = {'idx': idx, 'apikey': apikey} if value is not None: params['value'] = value if isregex is not None: params['isRegex'] = isregex if isenabled is not None: params['isEnabled'] = isenabled - return next(self.zap._request(self.zap.base + 'core/action/modifyProxyChainExcludedDomain/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/modifyProxyChainExcludedDomain/', params))) def remove_proxy_chain_excluded_domain(self, idx, apikey=''): """ Removes a domain excluded from the outgoing proxy, with the given index. The index can be obtained with the view proxyChainExcludedDomains. """ - return next(self.zap._request(self.zap.base + 'core/action/removeProxyChainExcludedDomain/', {'idx' : idx, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/removeProxyChainExcludedDomain/', {'idx': idx, 'apikey': apikey}))) def enable_all_proxy_chain_excluded_domains(self, apikey=''): """ Enables all domains excluded from the outgoing proxy. """ - return next(self.zap._request(self.zap.base + 'core/action/enableAllProxyChainExcludedDomains/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/enableAllProxyChainExcludedDomains/', {'apikey': apikey}))) def disable_all_proxy_chain_excluded_domains(self, apikey=''): """ Disables all domains excluded from the outgoing proxy. """ - return next(self.zap._request(self.zap.base + 'core/action/disableAllProxyChainExcludedDomains/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/disableAllProxyChainExcludedDomains/', {'apikey': apikey}))) def set_option_default_user_agent(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionDefaultUserAgent/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionDefaultUserAgent/', {'String': string, 'apikey': apikey}))) def set_option_proxy_chain_name(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainName/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainName/', {'String': string, 'apikey': apikey}))) def set_option_proxy_chain_password(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainPassword/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainPassword/', {'String': string, 'apikey': apikey}))) def set_option_proxy_chain_realm(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainRealm/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainRealm/', {'String': string, 'apikey': apikey}))) def set_option_proxy_chain_skip_name(self, string, apikey=''): """ Use actions [add|modify|remove]ProxyChainExcludedDomain instead. """ - return next(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainSkipName/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainSkipName/', {'String': string, 'apikey': apikey}))) def set_option_proxy_chain_user_name(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainUserName/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainUserName/', {'String': string, 'apikey': apikey}))) def set_option_dns_ttl_successful_queries(self, integer, apikey=''): """ Sets the TTL (in seconds) of successful DNS queries (applies after ZAP restart). """ - return next(self.zap._request(self.zap.base + 'core/action/setOptionDnsTtlSuccessfulQueries/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionDnsTtlSuccessfulQueries/', {'Integer': integer, 'apikey': apikey}))) def set_option_http_state_enabled(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionHttpStateEnabled/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionHttpStateEnabled/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_proxy_chain_port(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainPort/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainPort/', {'Integer': integer, 'apikey': apikey}))) def set_option_proxy_chain_prompt(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainPrompt/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionProxyChainPrompt/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_single_cookie_request_header(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionSingleCookieRequestHeader/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionSingleCookieRequestHeader/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_timeout_in_secs(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionTimeoutInSecs/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionTimeoutInSecs/', {'Integer': integer, 'apikey': apikey}))) def set_option_use_proxy_chain(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionUseProxyChain/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionUseProxyChain/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_use_proxy_chain_auth(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'core/action/setOptionUseProxyChainAuth/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setOptionUseProxyChainAuth/', {'Boolean': boolean, 'apikey': apikey}))) def proxy_pac(self, apikey=''): - return (self.zap._request_other(self.zap.base_other + 'core/other/proxy.pac/', {'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'core/other/proxy.pac/', {'apikey': apikey})) def rootcert(self, apikey=''): """ Gets the Root CA certificate of the Local Proxy. """ - return (self.zap._request_other(self.zap.base_other + 'core/other/rootcert/', {'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'core/other/rootcert/', {'apikey': apikey})) def setproxy(self, proxy, apikey=''): - return (self.zap._request_other(self.zap.base_other + 'core/other/setproxy/', {'proxy' : proxy, 'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'core/other/setproxy/', {'proxy': proxy, 'apikey': apikey})) def xmlreport(self, apikey=''): """ Generates a report in XML format """ - return (self.zap._request_other(self.zap.base_other + 'core/other/xmlreport/', {'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'core/other/xmlreport/', {'apikey': apikey})) def htmlreport(self, apikey=''): """ Generates a report in HTML format """ - return (self.zap._request_other(self.zap.base_other + 'core/other/htmlreport/', {'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'core/other/htmlreport/', {'apikey': apikey})) def mdreport(self, apikey=''): """ Generates a report in Markdown format """ - return (self.zap._request_other(self.zap.base_other + 'core/other/mdreport/', {'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'core/other/mdreport/', {'apikey': apikey})) def message_har(self, id, apikey=''): """ Gets the message with the given ID in HAR format """ - return (self.zap._request_other(self.zap.base_other + 'core/other/messageHar/', {'id' : id, 'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'core/other/messageHar/', {'id': id, 'apikey': apikey})) def messages_har(self, baseurl=None, start=None, count=None, apikey=''): """ Gets the HTTP messages sent through/by ZAP, in HAR format, optionally filtered by URL and paginated with 'start' position and 'count' of messages """ - params = {'apikey' : apikey} + params = {'apikey': apikey} if baseurl is not None: params['baseurl'] = baseurl if start is not None: @@ -463,9 +466,7 @@ def send_har_request(self, request, followredirects=None, apikey=''): """ 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. """ - params = {'request' : request, 'apikey' : apikey} + params = {'request': request, 'apikey': apikey} if followredirects is not None: params['followRedirects'] = followredirects return (self.zap._request_other(self.zap.base_other + 'core/other/sendHarRequest/', params)) - - diff --git a/src/zapv2/forcedUser.py b/src/zapv2/forcedUser.py index bbffc5d..fd5fd94 100644 --- a/src/zapv2/forcedUser.py +++ b/src/zapv2/forcedUser.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class forcedUser(object): def __init__(self, zap): @@ -29,24 +32,22 @@ def is_forced_user_mode_enabled(self): """ Returns 'true' if 'forced user' mode is enabled, 'false' otherwise """ - return next(self.zap._request(self.zap.base + 'forcedUser/view/isForcedUserModeEnabled/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'forcedUser/view/isForcedUserModeEnabled/'))) def get_forced_user(self, contextid): """ Gets the user (ID) set as 'forced user' for the given context (ID) """ - return next(self.zap._request(self.zap.base + 'forcedUser/view/getForcedUser/', {'contextId' : contextid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'forcedUser/view/getForcedUser/', {'contextId': contextid}))) def set_forced_user(self, contextid, userid, apikey=''): """ Sets the user (ID) that should be used in 'forced user' mode for the given context (ID) """ - return next(self.zap._request(self.zap.base + 'forcedUser/action/setForcedUser/', {'contextId' : contextid, 'userId' : userid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'forcedUser/action/setForcedUser/', {'contextId': contextid, 'userId': userid, 'apikey': apikey}))) def set_forced_user_mode_enabled(self, boolean, apikey=''): """ Sets if 'forced user' mode should be enabled or not """ - return next(self.zap._request(self.zap.base + 'forcedUser/action/setForcedUserModeEnabled/', {'boolean' : boolean, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'forcedUser/action/setForcedUserModeEnabled/', {'boolean': boolean, 'apikey': apikey}))) diff --git a/src/zapv2/httpSessions.py b/src/zapv2/httpSessions.py index c2e919c..632b75b 100644 --- a/src/zapv2/httpSessions.py +++ b/src/zapv2/httpSessions.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class httpSessions(object): def __init__(self, zap): @@ -29,78 +32,76 @@ def sites(self): """ Gets all of the sites that have sessions. """ - return next(self.zap._request(self.zap.base + 'httpSessions/view/sites/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/view/sites/'))) def sessions(self, site, session=None): """ Gets the sessions for the given site. Optionally returning just the session with the given name. """ - params = {'site' : site} + params = {'site': site} if session is not None: params['session'] = session - return next(self.zap._request(self.zap.base + 'httpSessions/view/sessions/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/view/sessions/', params))) def active_session(self, site): """ Gets the name of the active session for the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/view/activeSession/', {'site' : site}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/view/activeSession/', {'site': site}))) def session_tokens(self, site): """ Gets the names of the session tokens for the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/view/sessionTokens/', {'site' : site}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/view/sessionTokens/', {'site': site}))) def create_empty_session(self, site, session=None, apikey=''): """ Creates an empty session for the given site. Optionally with the given name. """ - params = {'site' : site, 'apikey' : apikey} + params = {'site': site, 'apikey': apikey} if session is not None: params['session'] = session - return next(self.zap._request(self.zap.base + 'httpSessions/action/createEmptySession/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/action/createEmptySession/', params))) def remove_session(self, site, session, apikey=''): """ Removes the session from the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/action/removeSession/', {'site' : site, 'session' : session, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/action/removeSession/', {'site': site, 'session': session, 'apikey': apikey}))) def set_active_session(self, site, session, apikey=''): """ Sets the given session as active for the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/action/setActiveSession/', {'site' : site, 'session' : session, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/action/setActiveSession/', {'site': site, 'session': session, 'apikey': apikey}))) def unset_active_session(self, site, apikey=''): """ Unsets the active session of the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/action/unsetActiveSession/', {'site' : site, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/action/unsetActiveSession/', {'site': site, 'apikey': apikey}))) def add_session_token(self, site, sessiontoken, apikey=''): """ Adds the session token to the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/action/addSessionToken/', {'site' : site, 'sessionToken' : sessiontoken, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/action/addSessionToken/', {'site': site, 'sessionToken': sessiontoken, 'apikey': apikey}))) def remove_session_token(self, site, sessiontoken, apikey=''): """ Removes the session token from the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/action/removeSessionToken/', {'site' : site, 'sessionToken' : sessiontoken, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/action/removeSessionToken/', {'site': site, 'sessionToken': sessiontoken, 'apikey': apikey}))) def set_session_token_value(self, site, session, sessiontoken, tokenvalue, apikey=''): """ Sets the value of the session token of the given session for the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/action/setSessionTokenValue/', {'site' : site, 'session' : session, 'sessionToken' : sessiontoken, 'tokenValue' : tokenvalue, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/action/setSessionTokenValue/', {'site': site, 'session': session, 'sessionToken': sessiontoken, 'tokenValue': tokenvalue, 'apikey': apikey}))) def rename_session(self, site, oldsessionname, newsessionname, apikey=''): """ Renames the session of the given site. """ - return next(self.zap._request(self.zap.base + 'httpSessions/action/renameSession/', {'site' : site, 'oldSessionName' : oldsessionname, 'newSessionName' : newsessionname, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'httpSessions/action/renameSession/', {'site': site, 'oldSessionName': oldsessionname, 'newSessionName': newsessionname, 'apikey': apikey}))) diff --git a/src/zapv2/importLogFiles.py b/src/zapv2/importLogFiles.py index b8fc5e1..75be823 100644 --- a/src/zapv2/importLogFiles.py +++ b/src/zapv2/importLogFiles.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class importLogFiles(object): def __init__(self, zap): @@ -28,33 +31,31 @@ def import_zap_log_from_file(self, filepath, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'importLogFiles/action/ImportZAPLogFromFile/', {'FilePath' : filepath, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'importLogFiles/action/ImportZAPLogFromFile/', {'FilePath': filepath, 'apikey': apikey}))) def import_mod_security_log_from_file(self, filepath, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'importLogFiles/action/ImportModSecurityLogFromFile/', {'FilePath' : filepath, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'importLogFiles/action/ImportModSecurityLogFromFile/', {'FilePath': filepath, 'apikey': apikey}))) def import_zap_http_request_response_pair(self, httprequest, httpresponse, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'importLogFiles/action/ImportZAPHttpRequestResponsePair/', {'HTTPRequest' : httprequest, 'HTTPResponse' : httpresponse, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'importLogFiles/action/ImportZAPHttpRequestResponsePair/', {'HTTPRequest': httprequest, 'HTTPResponse': httpresponse, 'apikey': apikey}))) def post_mod_security_audit_event(self, auditeventstring=None, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - params = {'apikey' : apikey} + params = {'apikey': apikey} if auditeventstring is not None: params['AuditEventString'] = auditeventstring - return next(self.zap._request(self.zap.base + 'importLogFiles/action/PostModSecurityAuditEvent/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'importLogFiles/action/PostModSecurityAuditEvent/', params))) def other_post_mod_security_audit_event(self, auditeventstring, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return (self.zap._request_other(self.zap.base_other + 'importLogFiles/other/OtherPostModSecurityAuditEvent/', {'AuditEventString' : auditeventstring, 'apikey' : apikey})) - - + return (self.zap._request_other(self.zap.base_other + 'importLogFiles/other/OtherPostModSecurityAuditEvent/', {'AuditEventString': auditeventstring, 'apikey': apikey})) diff --git a/src/zapv2/openapi.py b/src/zapv2/openapi.py new file mode 100644 index 0000000..05dc40a --- /dev/null +++ b/src/zapv2/openapi.py @@ -0,0 +1,40 @@ +# 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. +""" +This file was automatically generated. +""" + +import six + + +class openapi(object): + + def __init__(self, zap): + self.zap = zap + + def import_file(self, file, apikey=''): + """ + This component is optional and therefore the API will only work if it is installed + """ + return six.next(six.itervalues(self.zap._request(self.zap.base + 'openapi/action/importFile/', {'file': file, 'apikey': apikey}))) + + def import_url(self, url, apikey=''): + """ + This component is optional and therefore the API will only work if it is installed + """ + return six.next(six.itervalues(self.zap._request(self.zap.base + 'openapi/action/importUrl/', {'url': url, 'apikey': apikey}))) diff --git a/src/zapv2/params.py b/src/zapv2/params.py index db44721..fbfe157 100644 --- a/src/zapv2/params.py +++ b/src/zapv2/params.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class params(object): def __init__(self, zap): @@ -31,6 +34,4 @@ def params(self, site=None): params = {} if site is not None: params['site'] = site - return next(self.zap._request(self.zap.base + 'params/view/params/', params).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'params/view/params/', params))) diff --git a/src/zapv2/pnh.py b/src/zapv2/pnh.py index c717881..8dd20ca 100644 --- a/src/zapv2/pnh.py +++ b/src/zapv2/pnh.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class pnh(object): def __init__(self, zap): @@ -28,48 +31,46 @@ def monitor(self, id, message, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'pnh/action/monitor/', {'id' : id, 'message' : message, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pnh/action/monitor/', {'id': id, 'message': message, 'apikey': apikey}))) def oracle(self, id, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'pnh/action/oracle/', {'id' : id, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pnh/action/oracle/', {'id': id, 'apikey': apikey}))) def start_monitoring(self, url, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'pnh/action/startMonitoring/', {'url' : url, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pnh/action/startMonitoring/', {'url': url, 'apikey': apikey}))) def stop_monitoring(self, id, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'pnh/action/stopMonitoring/', {'id' : id, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pnh/action/stopMonitoring/', {'id': id, 'apikey': apikey}))) def pnh(self, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return (self.zap._request_other(self.zap.base_other + 'pnh/other/pnh/', {'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'pnh/other/pnh/', {'apikey': apikey})) def manifest(self, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return (self.zap._request_other(self.zap.base_other + 'pnh/other/manifest/', {'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'pnh/other/manifest/', {'apikey': apikey})) def service(self, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return (self.zap._request_other(self.zap.base_other + 'pnh/other/service/', {'apikey' : apikey})) + return (self.zap._request_other(self.zap.base_other + 'pnh/other/service/', {'apikey': apikey})) def fx__pnh_xpi(self, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return (self.zap._request_other(self.zap.base_other + 'pnh/other/fx_pnh.xpi/', {'apikey' : apikey})) - - + return (self.zap._request_other(self.zap.base_other + 'pnh/other/fx_pnh.xpi/', {'apikey': apikey})) diff --git a/src/zapv2/pscan.py b/src/zapv2/pscan.py index 8b0224b..587c868 100644 --- a/src/zapv2/pscan.py +++ b/src/zapv2/pscan.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class pscan(object): def __init__(self, zap): @@ -29,62 +32,60 @@ def scan_only_in_scope(self): """ Tells whether or not the passive scan should be performed only on messages that are in scope. """ - return next(self.zap._request(self.zap.base + 'pscan/view/scanOnlyInScope/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/view/scanOnlyInScope/'))) @property def records_to_scan(self): """ The number of records the passive scanner still has to scan """ - return next(self.zap._request(self.zap.base + 'pscan/view/recordsToScan/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/view/recordsToScan/'))) @property def scanners(self): """ Lists all passive scanners with its ID, name, enabled state and alert threshold. """ - return next(self.zap._request(self.zap.base + 'pscan/view/scanners/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/view/scanners/'))) def set_enabled(self, enabled, apikey=''): """ Sets whether or not the passive scanning is enabled (Note: the enabled state is not persisted). """ - return next(self.zap._request(self.zap.base + 'pscan/action/setEnabled/', {'enabled' : enabled, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/action/setEnabled/', {'enabled': enabled, 'apikey': apikey}))) def set_scan_only_in_scope(self, onlyinscope, apikey=''): """ Sets whether or not the passive scan should be performed only on messages that are in scope. """ - return next(self.zap._request(self.zap.base + 'pscan/action/setScanOnlyInScope/', {'onlyInScope' : onlyinscope, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/action/setScanOnlyInScope/', {'onlyInScope': onlyinscope, 'apikey': apikey}))) def enable_all_scanners(self, apikey=''): """ Enables all passive scanners """ - return next(self.zap._request(self.zap.base + 'pscan/action/enableAllScanners/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/action/enableAllScanners/', {'apikey': apikey}))) def disable_all_scanners(self, apikey=''): """ Disables all passive scanners """ - return next(self.zap._request(self.zap.base + 'pscan/action/disableAllScanners/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/action/disableAllScanners/', {'apikey': apikey}))) def enable_scanners(self, ids, apikey=''): """ Enables all passive scanners with the given IDs (comma separated list of IDs) """ - return next(self.zap._request(self.zap.base + 'pscan/action/enableScanners/', {'ids' : ids, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/action/enableScanners/', {'ids': ids, 'apikey': apikey}))) def disable_scanners(self, ids, apikey=''): """ Disables all passive scanners with the given IDs (comma separated list of IDs) """ - return next(self.zap._request(self.zap.base + 'pscan/action/disableScanners/', {'ids' : ids, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/action/disableScanners/', {'ids': ids, 'apikey': apikey}))) def set_scanner_alert_threshold(self, id, alertthreshold, apikey=''): """ Sets the alert threshold of the passive scanner with the given ID, accepted values for alert threshold: OFF, DEFAULT, LOW, MEDIUM and HIGH """ - return next(self.zap._request(self.zap.base + 'pscan/action/setScannerAlertThreshold/', {'id' : id, 'alertThreshold' : alertthreshold, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'pscan/action/setScannerAlertThreshold/', {'id': id, 'alertThreshold': alertthreshold, 'apikey': apikey}))) diff --git a/src/zapv2/reveal.py b/src/zapv2/reveal.py index 0e14ccb..974cd51 100644 --- a/src/zapv2/reveal.py +++ b/src/zapv2/reveal.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class reveal(object): def __init__(self, zap): @@ -29,12 +32,10 @@ def reveal(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'reveal/view/reveal/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'reveal/view/reveal/'))) def set_reveal(self, reveal, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'reveal/action/setReveal/', {'reveal' : reveal, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'reveal/action/setReveal/', {'reveal': reveal, 'apikey': apikey}))) diff --git a/src/zapv2/script.py b/src/zapv2/script.py index 4b6934e..4d1169d 100644 --- a/src/zapv2/script.py +++ b/src/zapv2/script.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class script(object): def __init__(self, zap): @@ -29,46 +32,44 @@ def list_engines(self): """ Lists the script engines available """ - return next(self.zap._request(self.zap.base + 'script/view/listEngines/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/listEngines/'))) @property def list_scripts(self): """ Lists the scripts available, with its engine, name, description, type and error state. """ - return next(self.zap._request(self.zap.base + 'script/view/listScripts/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/view/listScripts/'))) def enable(self, scriptname, apikey=''): """ Enables the script with the given name """ - return next(self.zap._request(self.zap.base + 'script/action/enable/', {'scriptName' : scriptname, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/enable/', {'scriptName': scriptname, 'apikey': apikey}))) def disable(self, scriptname, apikey=''): """ Disables the script with the given name """ - return next(self.zap._request(self.zap.base + 'script/action/disable/', {'scriptName' : scriptname, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/disable/', {'scriptName': scriptname, 'apikey': apikey}))) def load(self, scriptname, scripttype, scriptengine, filename, scriptdescription=None, apikey=''): """ Loads a script into ZAP from the given local file, with the given name, type and engine, optionally with a description """ - params = {'scriptName' : scriptname, 'scriptType' : scripttype, 'scriptEngine' : scriptengine, 'fileName' : filename, 'apikey' : apikey} + params = {'scriptName': scriptname, 'scriptType': scripttype, 'scriptEngine': scriptengine, 'fileName': filename, 'apikey': apikey} if scriptdescription is not None: params['scriptDescription'] = scriptdescription - return next(self.zap._request(self.zap.base + 'script/action/load/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/load/', params))) def remove(self, scriptname, apikey=''): """ Removes the script with the given name """ - return next(self.zap._request(self.zap.base + 'script/action/remove/', {'scriptName' : scriptname, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/remove/', {'scriptName': scriptname, 'apikey': apikey}))) def run_stand_alone_script(self, scriptname, apikey=''): """ Runs the stand alone script with the give name """ - return next(self.zap._request(self.zap.base + 'script/action/runStandAloneScript/', {'scriptName' : scriptname, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'script/action/runStandAloneScript/', {'scriptName': scriptname, 'apikey': apikey}))) diff --git a/src/zapv2/search.py b/src/zapv2/search.py index 40424e1..5b8e427 100644 --- a/src/zapv2/search.py +++ b/src/zapv2/search.py @@ -19,93 +19,96 @@ This file was automatically generated. """ +import six + + class search(object): def __init__(self, zap): self.zap = zap def urls_by_url_regex(self, regex, baseurl=None, start=None, count=None): - params = {'regex' : regex} + params = {'regex': regex} if baseurl is not None: params['baseurl'] = baseurl if start is not None: params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'search/view/urlsByUrlRegex/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/urlsByUrlRegex/', params))) def urls_by_request_regex(self, regex, baseurl=None, start=None, count=None): - params = {'regex' : regex} + params = {'regex': regex} if baseurl is not None: params['baseurl'] = baseurl if start is not None: params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'search/view/urlsByRequestRegex/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/urlsByRequestRegex/', params))) def urls_by_response_regex(self, regex, baseurl=None, start=None, count=None): - params = {'regex' : regex} + params = {'regex': regex} if baseurl is not None: params['baseurl'] = baseurl if start is not None: params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'search/view/urlsByResponseRegex/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/urlsByResponseRegex/', params))) def urls_by_header_regex(self, regex, baseurl=None, start=None, count=None): - params = {'regex' : regex} + params = {'regex': regex} if baseurl is not None: params['baseurl'] = baseurl if start is not None: params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'search/view/urlsByHeaderRegex/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/urlsByHeaderRegex/', params))) def messages_by_url_regex(self, regex, baseurl=None, start=None, count=None): - params = {'regex' : regex} + params = {'regex': regex} if baseurl is not None: params['baseurl'] = baseurl if start is not None: params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'search/view/messagesByUrlRegex/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/messagesByUrlRegex/', params))) def messages_by_request_regex(self, regex, baseurl=None, start=None, count=None): - params = {'regex' : regex} + params = {'regex': regex} if baseurl is not None: params['baseurl'] = baseurl if start is not None: params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'search/view/messagesByRequestRegex/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/messagesByRequestRegex/', params))) def messages_by_response_regex(self, regex, baseurl=None, start=None, count=None): - params = {'regex' : regex} + params = {'regex': regex} if baseurl is not None: params['baseurl'] = baseurl if start is not None: params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'search/view/messagesByResponseRegex/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/messagesByResponseRegex/', params))) def messages_by_header_regex(self, regex, baseurl=None, start=None, count=None): - params = {'regex' : regex} + params = {'regex': regex} if baseurl is not None: params['baseurl'] = baseurl if start is not None: params['start'] = start if count is not None: params['count'] = count - return next(self.zap._request(self.zap.base + 'search/view/messagesByHeaderRegex/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/messagesByHeaderRegex/', params))) def har_by_url_regex(self, regex, baseurl=None, start=None, count=None, apikey=''): - params = {'regex' : regex, 'apikey' : apikey} + params = {'regex': regex, 'apikey': apikey} if baseurl is not None: params['baseurl'] = baseurl if start is not None: @@ -115,7 +118,7 @@ def har_by_url_regex(self, regex, baseurl=None, start=None, count=None, apikey=' return (self.zap._request_other(self.zap.base_other + 'search/other/harByUrlRegex/', params)) def har_by_request_regex(self, regex, baseurl=None, start=None, count=None, apikey=''): - params = {'regex' : regex, 'apikey' : apikey} + params = {'regex': regex, 'apikey': apikey} if baseurl is not None: params['baseurl'] = baseurl if start is not None: @@ -125,7 +128,7 @@ def har_by_request_regex(self, regex, baseurl=None, start=None, count=None, apik return (self.zap._request_other(self.zap.base_other + 'search/other/harByRequestRegex/', params)) def har_by_response_regex(self, regex, baseurl=None, start=None, count=None, apikey=''): - params = {'regex' : regex, 'apikey' : apikey} + params = {'regex': regex, 'apikey': apikey} if baseurl is not None: params['baseurl'] = baseurl if start is not None: @@ -135,7 +138,7 @@ def har_by_response_regex(self, regex, baseurl=None, start=None, count=None, api return (self.zap._request_other(self.zap.base_other + 'search/other/harByResponseRegex/', params)) def har_by_header_regex(self, regex, baseurl=None, start=None, count=None, apikey=''): - params = {'regex' : regex, 'apikey' : apikey} + params = {'regex': regex, 'apikey': apikey} if baseurl is not None: params['baseurl'] = baseurl if start is not None: @@ -143,5 +146,3 @@ def har_by_header_regex(self, regex, baseurl=None, start=None, count=None, apike if count is not None: params['count'] = count return (self.zap._request_other(self.zap.base_other + 'search/other/harByHeaderRegex/', params)) - - diff --git a/src/zapv2/selenium.py b/src/zapv2/selenium.py index 2f0a097..a7bbbb7 100644 --- a/src/zapv2/selenium.py +++ b/src/zapv2/selenium.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class selenium(object): def __init__(self, zap): @@ -29,64 +32,62 @@ def option_chrome_driver_path(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/view/optionChromeDriverPath/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/view/optionChromeDriverPath/'))) @property def option_firefox_binary_path(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/view/optionFirefoxBinaryPath/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/view/optionFirefoxBinaryPath/'))) @property def option_firefox_driver_path(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/view/optionFirefoxDriverPath/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/view/optionFirefoxDriverPath/'))) @property def option_ie_driver_path(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/view/optionIeDriverPath/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/view/optionIeDriverPath/'))) @property def option_phantom_js_binary_path(self): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/view/optionPhantomJsBinaryPath/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/view/optionPhantomJsBinaryPath/'))) def set_option_chrome_driver_path(self, string, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/action/setOptionChromeDriverPath/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/action/setOptionChromeDriverPath/', {'String': string, 'apikey': apikey}))) def set_option_firefox_binary_path(self, string, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/action/setOptionFirefoxBinaryPath/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/action/setOptionFirefoxBinaryPath/', {'String': string, 'apikey': apikey}))) def set_option_firefox_driver_path(self, string, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/action/setOptionFirefoxDriverPath/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/action/setOptionFirefoxDriverPath/', {'String': string, 'apikey': apikey}))) def set_option_ie_driver_path(self, string, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/action/setOptionIeDriverPath/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/action/setOptionIeDriverPath/', {'String': string, 'apikey': apikey}))) def set_option_phantom_js_binary_path(self, string, apikey=''): """ This component is optional and therefore the API will only work if it is installed """ - return next(self.zap._request(self.zap.base + 'selenium/action/setOptionPhantomJsBinaryPath/', {'String' : string, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/action/setOptionPhantomJsBinaryPath/', {'String': string, 'apikey': apikey}))) diff --git a/src/zapv2/sessionManagement.py b/src/zapv2/sessionManagement.py index 9263937..da32662 100644 --- a/src/zapv2/sessionManagement.py +++ b/src/zapv2/sessionManagement.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class sessionManagement(object): def __init__(self, zap): @@ -26,18 +29,16 @@ def __init__(self, zap): @property def get_supported_session_management_methods(self): - return next(self.zap._request(self.zap.base + 'sessionManagement/view/getSupportedSessionManagementMethods/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'sessionManagement/view/getSupportedSessionManagementMethods/'))) def get_session_management_method_config_params(self, methodname): - return next(self.zap._request(self.zap.base + 'sessionManagement/view/getSessionManagementMethodConfigParams/', {'methodName' : methodname}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'sessionManagement/view/getSessionManagementMethodConfigParams/', {'methodName': methodname}))) def get_session_management_method(self, contextid): - return next(self.zap._request(self.zap.base + 'sessionManagement/view/getSessionManagementMethod/', {'contextId' : contextid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'sessionManagement/view/getSessionManagementMethod/', {'contextId': contextid}))) def set_session_management_method(self, contextid, methodname, methodconfigparams=None, apikey=''): - params = {'contextId' : contextid, 'methodName' : methodname, 'apikey' : apikey} + params = {'contextId': contextid, 'methodName': methodname, 'apikey': apikey} if methodconfigparams is not None: params['methodConfigParams'] = methodconfigparams - return next(self.zap._request(self.zap.base + 'sessionManagement/action/setSessionManagementMethod/', params).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'sessionManagement/action/setSessionManagementMethod/', params))) diff --git a/src/zapv2/spider.py b/src/zapv2/spider.py index 61a28dd..b0fd080 100644 --- a/src/zapv2/spider.py +++ b/src/zapv2/spider.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class spider(object): def __init__(self, zap): @@ -28,151 +31,151 @@ def status(self, scanid=None): params = {} if scanid is not None: params['scanId'] = scanid - return next(self.zap._request(self.zap.base + 'spider/view/status/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/status/', params))) def results(self, scanid=None): params = {} if scanid is not None: params['scanId'] = scanid - return next(self.zap._request(self.zap.base + 'spider/view/results/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/results/', params))) def full_results(self, scanid): - return next(self.zap._request(self.zap.base + 'spider/view/fullResults/', {'scanId' : scanid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/fullResults/', {'scanId': scanid}))) @property def scans(self): - return next(self.zap._request(self.zap.base + 'spider/view/scans/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/scans/'))) @property def excluded_from_scan(self): """ Gets the regexes of URLs excluded from the spider scans. """ - return next(self.zap._request(self.zap.base + 'spider/view/excludedFromScan/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/excludedFromScan/'))) @property def all_urls(self): """ Returns a list of unique URLs from the history table based on HTTP messages added by the Spider. """ - return next(self.zap._request(self.zap.base + 'spider/view/allUrls/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/allUrls/'))) @property def domains_always_in_scope(self): """ 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. """ - return next(self.zap._request(self.zap.base + 'spider/view/domainsAlwaysInScope/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/domainsAlwaysInScope/'))) @property def option_domains_always_in_scope(self): """ Use view domainsAlwaysInScope instead. """ - return next(self.zap._request(self.zap.base + 'spider/view/optionDomainsAlwaysInScope/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionDomainsAlwaysInScope/'))) @property def option_domains_always_in_scope_enabled(self): """ Use view domainsAlwaysInScope instead. """ - return next(self.zap._request(self.zap.base + 'spider/view/optionDomainsAlwaysInScopeEnabled/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionDomainsAlwaysInScopeEnabled/'))) @property def option_handle_parameters(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionHandleParameters/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionHandleParameters/'))) @property def option_max_children(self): """ Gets the maximum number of child nodes (per node) that can be crawled, 0 means no limit. """ - return next(self.zap._request(self.zap.base + 'spider/view/optionMaxChildren/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionMaxChildren/'))) @property def option_max_depth(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionMaxDepth/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionMaxDepth/'))) @property def option_max_duration(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionMaxDuration/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionMaxDuration/'))) @property def option_max_scans_in_ui(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionMaxScansInUI/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionMaxScansInUI/'))) @property def option_request_wait_time(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionRequestWaitTime/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionRequestWaitTime/'))) @property def option_scope(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionScope/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionScope/'))) @property def option_scope_text(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionScopeText/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionScopeText/'))) @property def option_skip_url_string(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionSkipURLString/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionSkipURLString/'))) @property def option_thread_count(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionThreadCount/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionThreadCount/'))) @property def option_user_agent(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionUserAgent/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionUserAgent/'))) @property def option_handle_o_data_parameters_visited(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionHandleODataParametersVisited/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionHandleODataParametersVisited/'))) @property def option_parse_comments(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionParseComments/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionParseComments/'))) @property def option_parse_git(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionParseGit/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionParseGit/'))) @property def option_parse_robots_txt(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionParseRobotsTxt/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionParseRobotsTxt/'))) @property def option_parse_svn_entries(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionParseSVNEntries/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionParseSVNEntries/'))) @property def option_parse_sitemap_xml(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionParseSitemapXml/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionParseSitemapXml/'))) @property def option_post_form(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionPostForm/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionPostForm/'))) @property def option_process_form(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionProcessForm/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionProcessForm/'))) @property def option_send_referer_header(self): """ Gets whether or not the 'Referer' header should be sent while spidering. """ - return next(self.zap._request(self.zap.base + 'spider/view/optionSendRefererHeader/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionSendRefererHeader/'))) @property def option_show_advanced_dialog(self): - return next(self.zap._request(self.zap.base + 'spider/view/optionShowAdvancedDialog/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/view/optionShowAdvancedDialog/'))) def scan(self, url=None, maxchildren=None, recurse=None, contextname=None, subtreeonly=None, apikey=''): """ 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'). """ - params = {'apikey' : apikey} + params = {'apikey': apikey} if url is not None: params['url'] = url if maxchildren is not None: @@ -183,13 +186,13 @@ def scan(self, url=None, maxchildren=None, recurse=None, contextname=None, subtr params['contextName'] = contextname if subtreeonly is not None: params['subtreeOnly'] = subtreeonly - return next(self.zap._request(self.zap.base + 'spider/action/scan/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/scan/', params))) def scan_as_user(self, contextid, userid, url=None, maxchildren=None, recurse=None, subtreeonly=None, apikey=''): """ Runs the spider from the perspective of a User, obtained using the given Context ID and User ID. See 'scan' action for more details. """ - params = {'contextId' : contextid, 'userId' : userid, 'apikey' : apikey} + params = {'contextId': contextid, 'userId': userid, 'apikey': apikey} if url is not None: params['url'] = url if maxchildren is not None: @@ -198,156 +201,154 @@ def scan_as_user(self, contextid, userid, url=None, maxchildren=None, recurse=No params['recurse'] = recurse if subtreeonly is not None: params['subtreeOnly'] = subtreeonly - return next(self.zap._request(self.zap.base + 'spider/action/scanAsUser/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/scanAsUser/', params))) def pause(self, scanid, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/pause/', {'scanId' : scanid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/pause/', {'scanId': scanid, 'apikey': apikey}))) def resume(self, scanid, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/resume/', {'scanId' : scanid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/resume/', {'scanId': scanid, 'apikey': apikey}))) def stop(self, scanid=None, apikey=''): - params = {'apikey' : apikey} + params = {'apikey': apikey} if scanid is not None: params['scanId'] = scanid - return next(self.zap._request(self.zap.base + 'spider/action/stop/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/stop/', params))) def remove_scan(self, scanid, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/removeScan/', {'scanId' : scanid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/removeScan/', {'scanId': scanid, 'apikey': apikey}))) def pause_all_scans(self, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/pauseAllScans/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/pauseAllScans/', {'apikey': apikey}))) def resume_all_scans(self, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/resumeAllScans/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/resumeAllScans/', {'apikey': apikey}))) def stop_all_scans(self, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/stopAllScans/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/stopAllScans/', {'apikey': apikey}))) def remove_all_scans(self, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/removeAllScans/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/removeAllScans/', {'apikey': apikey}))) def clear_excluded_from_scan(self, apikey=''): """ Clears the regexes of URLs excluded from the spider scans. """ - return next(self.zap._request(self.zap.base + 'spider/action/clearExcludedFromScan/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/clearExcludedFromScan/', {'apikey': apikey}))) def exclude_from_scan(self, regex, apikey=''): """ Adds a regex of URLs that should be excluded from the spider scans. """ - return next(self.zap._request(self.zap.base + 'spider/action/excludeFromScan/', {'regex' : regex, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/excludeFromScan/', {'regex': regex, 'apikey': apikey}))) def add_domain_always_in_scope(self, value, isregex=None, isenabled=None, apikey=''): """ 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). """ - params = {'value' : value, 'apikey' : apikey} + params = {'value': value, 'apikey': apikey} if isregex is not None: params['isRegex'] = isregex if isenabled is not None: params['isEnabled'] = isenabled - return next(self.zap._request(self.zap.base + 'spider/action/addDomainAlwaysInScope/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/addDomainAlwaysInScope/', params))) def modify_domain_always_in_scope(self, idx, value=None, isregex=None, isenabled=None, apikey=''): """ 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. """ - params = {'idx' : idx, 'apikey' : apikey} + params = {'idx': idx, 'apikey': apikey} if value is not None: params['value'] = value if isregex is not None: params['isRegex'] = isregex if isenabled is not None: params['isEnabled'] = isenabled - return next(self.zap._request(self.zap.base + 'spider/action/modifyDomainAlwaysInScope/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/modifyDomainAlwaysInScope/', params))) def remove_domain_always_in_scope(self, idx, apikey=''): """ Removes a domain that's always in scope, with the given index. The index can be obtained with the view domainsAlwaysInScope. """ - return next(self.zap._request(self.zap.base + 'spider/action/removeDomainAlwaysInScope/', {'idx' : idx, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/removeDomainAlwaysInScope/', {'idx': idx, 'apikey': apikey}))) def enable_all_domains_always_in_scope(self, apikey=''): """ Enables all domains that are always in scope. """ - return next(self.zap._request(self.zap.base + 'spider/action/enableAllDomainsAlwaysInScope/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/enableAllDomainsAlwaysInScope/', {'apikey': apikey}))) def disable_all_domains_always_in_scope(self, apikey=''): """ Disables all domains that are always in scope. """ - return next(self.zap._request(self.zap.base + 'spider/action/disableAllDomainsAlwaysInScope/', {'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/disableAllDomainsAlwaysInScope/', {'apikey': apikey}))) def set_option_handle_parameters(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionHandleParameters/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionHandleParameters/', {'String': string, 'apikey': apikey}))) def set_option_scope_string(self, string, apikey=''): """ Use actions [add|modify|remove]DomainAlwaysInScope instead. """ - return next(self.zap._request(self.zap.base + 'spider/action/setOptionScopeString/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionScopeString/', {'String': string, 'apikey': apikey}))) def set_option_skip_url_string(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionSkipURLString/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionSkipURLString/', {'String': string, 'apikey': apikey}))) def set_option_user_agent(self, string, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionUserAgent/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionUserAgent/', {'String': string, 'apikey': apikey}))) def set_option_handle_o_data_parameters_visited(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionHandleODataParametersVisited/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionHandleODataParametersVisited/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_max_children(self, integer, apikey=''): """ Sets the maximum number of child nodes (per node) that can be crawled, 0 means no limit. """ - return next(self.zap._request(self.zap.base + 'spider/action/setOptionMaxChildren/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionMaxChildren/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_depth(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionMaxDepth/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionMaxDepth/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_duration(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionMaxDuration/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionMaxDuration/', {'Integer': integer, 'apikey': apikey}))) def set_option_max_scans_in_ui(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionMaxScansInUI/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionMaxScansInUI/', {'Integer': integer, 'apikey': apikey}))) def set_option_parse_comments(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionParseComments/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionParseComments/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_parse_git(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionParseGit/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionParseGit/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_parse_robots_txt(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionParseRobotsTxt/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionParseRobotsTxt/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_parse_svn_entries(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionParseSVNEntries/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionParseSVNEntries/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_parse_sitemap_xml(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionParseSitemapXml/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionParseSitemapXml/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_post_form(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionPostForm/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionPostForm/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_process_form(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionProcessForm/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionProcessForm/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_request_wait_time(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionRequestWaitTime/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionRequestWaitTime/', {'Integer': integer, 'apikey': apikey}))) def set_option_send_referer_header(self, boolean, apikey=''): """ Sets whether or not the 'Referer' header should be sent while spidering. """ - return next(self.zap._request(self.zap.base + 'spider/action/setOptionSendRefererHeader/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionSendRefererHeader/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_show_advanced_dialog(self, boolean, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionShowAdvancedDialog/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionShowAdvancedDialog/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_thread_count(self, integer, apikey=''): - return next(self.zap._request(self.zap.base + 'spider/action/setOptionThreadCount/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'spider/action/setOptionThreadCount/', {'Integer': integer, 'apikey': apikey}))) diff --git a/src/zapv2/stats.py b/src/zapv2/stats.py index 6b999fb..ed5b32f 100644 --- a/src/zapv2/stats.py +++ b/src/zapv2/stats.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class stats(object): def __init__(self, zap): @@ -31,7 +34,7 @@ def stats(self, keyprefix=None): params = {} if keyprefix is not None: params['keyPrefix'] = keyprefix - return next(self.zap._request(self.zap.base + 'stats/view/stats/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/view/stats/', params))) def all_sites_stats(self, keyprefix=None): """ @@ -40,83 +43,81 @@ def all_sites_stats(self, keyprefix=None): params = {} if keyprefix is not None: params['keyPrefix'] = keyprefix - return next(self.zap._request(self.zap.base + 'stats/view/allSitesStats/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/view/allSitesStats/', params))) def site_stats(self, site, keyprefix=None): """ Gets all of the global statistics, optionally filtered by a key prefix """ - params = {'site' : site} + params = {'site': site} if keyprefix is not None: params['keyPrefix'] = keyprefix - return next(self.zap._request(self.zap.base + 'stats/view/siteStats/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/view/siteStats/', params))) @property def option_statsd_host(self): """ Gets the Statsd service hostname """ - return next(self.zap._request(self.zap.base + 'stats/view/optionStatsdHost/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/view/optionStatsdHost/'))) @property def option_statsd_port(self): """ Gets the Statsd service port """ - return next(self.zap._request(self.zap.base + 'stats/view/optionStatsdPort/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/view/optionStatsdPort/'))) @property def option_statsd_prefix(self): """ Gets the prefix to be applied to all stats sent to the configured Statsd service """ - return next(self.zap._request(self.zap.base + 'stats/view/optionStatsdPrefix/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/view/optionStatsdPrefix/'))) @property def option_in_memory_enabled(self): """ Returns 'true' if in memory statistics are enabled, otherwise returns 'false' """ - return next(self.zap._request(self.zap.base + 'stats/view/optionInMemoryEnabled/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/view/optionInMemoryEnabled/'))) @property def option_statsd_enabled(self): """ Returns 'true' if a Statsd server has been correctly configured, otherwise returns 'false' """ - return next(self.zap._request(self.zap.base + 'stats/view/optionStatsdEnabled/').itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/view/optionStatsdEnabled/'))) def clear_stats(self, keyprefix=None, apikey=''): """ Clears all of the statistics """ - params = {'apikey' : apikey} + params = {'apikey': apikey} if keyprefix is not None: params['keyPrefix'] = keyprefix - return next(self.zap._request(self.zap.base + 'stats/action/clearStats/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/action/clearStats/', params))) def set_option_statsd_host(self, string, apikey=''): """ Sets the Statsd service hostname, supply an empty string to stop using a Statsd service """ - return next(self.zap._request(self.zap.base + 'stats/action/setOptionStatsdHost/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/action/setOptionStatsdHost/', {'String': string, 'apikey': apikey}))) def set_option_statsd_prefix(self, string, apikey=''): """ Sets the prefix to be applied to all stats sent to the configured Statsd service """ - return next(self.zap._request(self.zap.base + 'stats/action/setOptionStatsdPrefix/', {'String' : string, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/action/setOptionStatsdPrefix/', {'String': string, 'apikey': apikey}))) def set_option_in_memory_enabled(self, boolean, apikey=''): """ Sets whether in memory statistics are enabled """ - return next(self.zap._request(self.zap.base + 'stats/action/setOptionInMemoryEnabled/', {'Boolean' : boolean, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/action/setOptionInMemoryEnabled/', {'Boolean': boolean, 'apikey': apikey}))) def set_option_statsd_port(self, integer, apikey=''): """ Sets the Statsd service port """ - return next(self.zap._request(self.zap.base + 'stats/action/setOptionStatsdPort/', {'Integer' : integer, 'apikey' : apikey}).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'stats/action/setOptionStatsdPort/', {'Integer': integer, 'apikey': apikey}))) diff --git a/src/zapv2/users.py b/src/zapv2/users.py index a6f5d42..658fd53 100644 --- a/src/zapv2/users.py +++ b/src/zapv2/users.py @@ -19,6 +19,9 @@ This file was automatically generated. """ +import six + + class users(object): def __init__(self, zap): @@ -28,7 +31,7 @@ def users_list(self, contextid=None): params = {} if contextid is not None: params['contextId'] = contextid - return next(self.zap._request(self.zap.base + 'users/view/usersList/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/view/usersList/', params))) def get_user_by_id(self, contextid=None, userid=None): params = {} @@ -36,30 +39,28 @@ def get_user_by_id(self, contextid=None, userid=None): params['contextId'] = contextid if userid is not None: params['userId'] = userid - return next(self.zap._request(self.zap.base + 'users/view/getUserById/', params).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/view/getUserById/', params))) def get_authentication_credentials_config_params(self, contextid): - return next(self.zap._request(self.zap.base + 'users/view/getAuthenticationCredentialsConfigParams/', {'contextId' : contextid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/view/getAuthenticationCredentialsConfigParams/', {'contextId': contextid}))) def get_authentication_credentials(self, contextid, userid): - return next(self.zap._request(self.zap.base + 'users/view/getAuthenticationCredentials/', {'contextId' : contextid, 'userId' : userid}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/view/getAuthenticationCredentials/', {'contextId': contextid, 'userId': userid}))) def new_user(self, contextid, name, apikey=''): - return next(self.zap._request(self.zap.base + 'users/action/newUser/', {'contextId' : contextid, 'name' : name, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/action/newUser/', {'contextId': contextid, 'name': name, 'apikey': apikey}))) def remove_user(self, contextid, userid, apikey=''): - return next(self.zap._request(self.zap.base + 'users/action/removeUser/', {'contextId' : contextid, 'userId' : userid, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/action/removeUser/', {'contextId': contextid, 'userId': userid, 'apikey': apikey}))) def set_user_enabled(self, contextid, userid, enabled, apikey=''): - return next(self.zap._request(self.zap.base + 'users/action/setUserEnabled/', {'contextId' : contextid, 'userId' : userid, 'enabled' : enabled, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/action/setUserEnabled/', {'contextId': contextid, 'userId': userid, 'enabled': enabled, 'apikey': apikey}))) def set_user_name(self, contextid, userid, name, apikey=''): - return next(self.zap._request(self.zap.base + 'users/action/setUserName/', {'contextId' : contextid, 'userId' : userid, 'name' : name, 'apikey' : apikey}).itervalues()) + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/action/setUserName/', {'contextId': contextid, 'userId': userid, 'name': name, 'apikey': apikey}))) def set_authentication_credentials(self, contextid, userid, authcredentialsconfigparams=None, apikey=''): - params = {'contextId' : contextid, 'userId' : userid, 'apikey' : apikey} + params = {'contextId': contextid, 'userId': userid, 'apikey': apikey} if authcredentialsconfigparams is not None: params['authCredentialsConfigParams'] = authcredentialsconfigparams - return next(self.zap._request(self.zap.base + 'users/action/setAuthenticationCredentials/', params).itervalues()) - - + return six.next(six.itervalues(self.zap._request(self.zap.base + 'users/action/setAuthenticationCredentials/', params)))