pax_global_header00006660000000000000000000000064141312250040014502gustar00rootroot0000000000000052 comment=beb9a87664ee8ae6a332243449c78cd347debc5b python-gvm-21.10.0/000077500000000000000000000000001413122500400137535ustar00rootroot00000000000000python-gvm-21.10.0/.coveragerc000066400000000000000000000001521413122500400160720ustar00rootroot00000000000000# Configuration for coverage.py [run] branch = True omit = tests/* */__init__.py source = gvm python-gvm-21.10.0/.github/000077500000000000000000000000001413122500400153135ustar00rootroot00000000000000python-gvm-21.10.0/.github/CODEOWNERS000066400000000000000000000001101413122500400166760ustar00rootroot00000000000000# default reviewers * @greenbone/python-gvm-maintainers python-gvm-21.10.0/.github/ISSUE_TEMPLATE.md000066400000000000000000000016711413122500400200250ustar00rootroot00000000000000 ### Expected behavior ### Current behavior ### Steps to reproduce 1. 2. 3. ### GVM versions **gsa:** (gsad --version) **gvm:** (gvmd --version) **openvas-scanner:** (openvassd --version) **gvm-libs:** **gvm-tools:** (gvm-cli --version) ### Environment **Operating system:** **Installation method / source:** (packages, source installation) ### Logfiles ``` ```python-gvm-21.10.0/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000015141413122500400211150ustar00rootroot00000000000000**What**: **Why**: **How**: **Checklist**: - [ ] Tests - [ ] [CHANGELOG](https://github.com/greenbone/python-gvm/blob/main/CHANGELOG.md) Entry - [ ] Documentation python-gvm-21.10.0/.github/dependabot.yml000066400000000000000000000003231413122500400201410ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: pip directory: "/" schedule: interval: weekly time: "04:00" open-pull-requests-limit: 10 allow: - dependency-type: direct - dependency-type: indirect python-gvm-21.10.0/.github/workflows/000077500000000000000000000000001413122500400173505ustar00rootroot00000000000000python-gvm-21.10.0/.github/workflows/ci-python.yml000066400000000000000000000041011413122500400220010ustar00rootroot00000000000000name: Build and test Python package on: push: branches: [ main ] pull_request: branches: [ main ] jobs: linting: name: Linting runs-on: 'ubuntu-latest' strategy: matrix: python-version: - 3.7 - 3.8 - 3.9 steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install poetry and dependencies uses: greenbone/actions/poetry@v1 - name: Check with black, pylint and pontos.version uses: greenbone/actions/lint-python@v1 with: packages: gvm tests test: name: Run all tests runs-on: 'ubuntu-latest' strategy: matrix: python-version: - 3.7 - 3.8 - 3.9 steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install poetry and dependencies uses: greenbone/actions/poetry@v1 - name: Run unit tests run: poetry run python -m unittest codecov: name: Upload coverage to codecov.io needs: test runs-on: 'ubuntu-latest' steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: 3.8 - name: Install poetry and dependencies uses: greenbone/actions/poetry@v1 - name: Calculate and upload coverage to codecov.io uses: greenbone/actions/coverage-python@v1 build-docs: name: Build the documentation runs-on: 'ubuntu-latest' steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: 3.8 - name: Install poetry and dependencies uses: greenbone/actions/poetry@v1 - name: Build docs run: cd docs && poetry run make html python-gvm-21.10.0/.github/workflows/codeql-analysis-python.yml000066400000000000000000000013151413122500400245020ustar00rootroot00000000000000name: "CodeQL" on: push: branches: [ main ] pull_request: branches: [ main ] paths-ignore: - '**/*.md' - '**/*.txt' schedule: - cron: '30 5 * * 0' # 5:30h on Sundays jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'python' ] steps: - name: Checkout repository uses: actions/checkout@v2 - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 python-gvm-21.10.0/.github/workflows/deploy-pypi.yml000066400000000000000000000011511413122500400223440ustar00rootroot00000000000000name: Deploy on PyPI on: release: types: [created] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: 3.8 - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install --upgrade poetry python -m pip install --upgrade twine - name: Build and publish env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | poetry build twine upload dist/* python-gvm-21.10.0/.github/workflows/release-pontos-manually.yml000066400000000000000000000042141413122500400246540ustar00rootroot00000000000000name: Release Python package with pontos on: workflow_dispatch: inputs: branch: description: 'Branch' required: true default: 'main' jobs: build-and-release: env: GITHUB_USER: ${{ secrets.GREENBONE_BOT }} GITHUB_MAIL: ${{ secrets.GREENBONE_BOT_MAIL }} GITHUB_TOKEN: ${{ secrets.GREENBONE_BOT_TOKEN }} GPG_KEY: ${{ secrets.GPG_KEY }} GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} name: Build and release with pontos runs-on: 'ubuntu-latest' steps: - uses: actions/checkout@v2 with: # because we want the git log for conventional commits, we need to fetch deeper! fetch-depth: 0 persist-credentials: false branch: ${{ github.event.inputs.branch }} - name: Set up Python uses: actions/setup-python@v2 with: python-version: 3.8 - name: Install poetry and dependencies uses: greenbone/actions/poetry@v1 - name: Tell git who I am run: | git config --global user.name "${{ env.GITHUB_USER }}" git config --global user.email "${{ env.GITHUB_MAIL }}" git remote set-url origin \ https://${{ env.GITHUB_TOKEN }}@github.com/${{ github.repository }} - name: Prepare release with pontos run: | poetry run pontos-release prepare --calendar -CC echo "VERSION=$(poetry run pontos-version show)" >> $GITHUB_ENV - name: Release with pontos run: | poetry run pontos-release release -CC - name: Import key from secrets run: | echo -e "${{ env.GPG_KEY }}" >> tmp.file gpg \ --pinentry-mode loopback \ --passphrase ${{ env.GPG_PASSPHRASE }} \ --import tmp.file rm tmp.file - name: Sign with pontos-release sign run: | echo "Signing assets for ${{env.VERSION}}" poetry run pontos-release sign \ --signing-key ${{ env.GPG_FINGERPRINT }} \ --passphrase ${{ env.GPG_PASSPHRASE }} \ --release-version ${{ env.VERSION }} python-gvm-21.10.0/.github/workflows/release-pontos.yml000066400000000000000000000043071413122500400230370ustar00rootroot00000000000000name: Release Python package with pontos on: pull_request: types: [closed] jobs: build-and-release: env: GITHUB_USER: ${{ secrets.GREENBONE_BOT }} GITHUB_MAIL: ${{ secrets.GREENBONE_BOT_MAIL }} GITHUB_TOKEN: ${{ secrets.GREENBONE_BOT_TOKEN }} GPG_KEY: ${{ secrets.GPG_KEY }} GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} name: Build and release with pontos # If the label 'make release' is set. If PR is closed because of an merge if: contains( github.event.pull_request.labels.*.name, 'make release') && github.event.pull_request.merged == true runs-on: 'ubuntu-latest' steps: - uses: actions/checkout@v2 with: # because we want the git log for conventional commits, we need to fetch deeper! fetch-depth: 0 persist-credentials: false - name: Set up Python uses: actions/setup-python@v2 with: python-version: 3.8 - name: Install poetry and dependencies uses: greenbone/actions/poetry@v1 - name: Tell git who I am run: | git config --global user.name "${{ env.GITHUB_USER }}" git config --global user.email "${{ env.GITHUB_MAIL }}" git remote set-url origin \ https://${{ env.GITHUB_TOKEN }}@github.com/${{ github.repository }} - name: Prepare release with pontos run: | poetry run pontos-release prepare --calendar -CC echo "VERSION=$(poetry run pontos-version show)" >> $GITHUB_ENV - name: Release with pontos run: | poetry run pontos-release release -CC - name: Import key from secrets run: | echo -e "${{ env.GPG_KEY }}" >> tmp.file gpg \ --pinentry-mode loopback \ --passphrase ${{ env.GPG_PASSPHRASE }} \ --import tmp.file rm tmp.file - name: Sign with pontos-release sign run: | echo "Signing assets for ${{env.VERSION}}" poetry run pontos-release sign \ --signing-key ${{ env.GPG_FINGERPRINT }} \ --passphrase ${{ env.GPG_PASSPHRASE }} \ --release-version ${{ env.VERSION }} python-gvm-21.10.0/.gitignore000066400000000000000000000001561413122500400157450ustar00rootroot00000000000000__pycache__ *.pyc *.log .egg *.egg-info dist build _build .idea .vscode htmlcov .coverage .venv .rej .DS_Storepython-gvm-21.10.0/.pylintrc000066400000000000000000000350061413122500400156240ustar00rootroot00000000000000[MASTER] # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code extension-pkg-whitelist=lxml # Add files or directories to the blacklist. They should be base names, not # paths. ignore=CVS # Add files or directories matching the regex patterns to the blacklist. The # regex matches against base names, not paths. ignore-patterns=docs # Pickle collected data for later comparisons. persistent=yes # When enabled, pylint would attempt to guess common misconfiguration and emit # user-friendly hints instead of false-positive error messages suggestion-mode=yes # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. unsafe-load-any-extension=no [MESSAGES CONTROL] # Only show warnings with the listed confidence levels. Leave empty to show # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED confidence= # Disable the message, report, category or checker with the given id(s). You # can either give multiple identifiers separated by comma (,) or put this # option multiple times (only on the command line, not in the configuration # file where it should appear only once).You can also use "--disable=all" to # disable everything first and then reenable specific checks. For example, if # you want to run only the similarities checker, you can use "--disable=all # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" # bad-continuation is disabled because of a bug in pylint. # See https://github.com/ambv/black/issues/48 and https://github.com/PyCQA/pylint/issues/289 disable=len-as-condition, attribute-defined-outside-init, missing-docstring, bad-continuation, R #disable=print-statement, # parameter-unpacking, # unpacking-in-except, # old-raise-syntax, # backtick, # long-suffix, # old-ne-operator, # old-octal-literal, # import-star-module-level, # non-ascii-bytes-literal, # raw-checker-failed, # bad-inline-option, # locally-disabled, # locally-enabled, # file-ignored, # suppressed-message, # useless-suppression, # deprecated-pragma, # apply-builtin, # basestring-builtin, # buffer-builtin, # cmp-builtin, # coerce-builtin, # execfile-builtin, # file-builtin, # long-builtin, # raw_input-builtin, # reduce-builtin, # standarderror-builtin, # unicode-builtin, # xrange-builtin, # coerce-method, # delslice-method, # getslice-method, # setslice-method, # no-absolute-import, # old-division, # dict-iter-method, # dict-view-method, # next-method-called, # metaclass-assignment, # indexing-exception, # raising-string, # reload-builtin, # oct-method, # hex-method, # nonzero-method, # cmp-method, # input-builtin, # round-builtin, # intern-builtin, # unichr-builtin, # map-builtin-not-iterating, # zip-builtin-not-iterating, # range-builtin-not-iterating, # filter-builtin-not-iterating, # using-cmp-argument, # eq-without-hash, # div-method, # idiv-method, # rdiv-method, # exception-message-attribute, # invalid-str-codec, # sys-max-int, # bad-python3-import, # deprecated-string-function, # deprecated-str-translate-call, # deprecated-itertools-function, # deprecated-types-field, # next-method-defined, # dict-items-not-iterating, # dict-keys-not-iterating, # dict-values-not-iterating # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option # multiple time (only on the command line, not in the configuration file where # it should appear only once). See also the "--disable" option for examples. enable=c-extension-no-member [REPORTS] # Python expression which should return a note less than 10 (10 is the highest # note). You have access to the variables errors warning, statement which # respectively contain the number of errors / warnings messages and the total # number of statements analyzed. This is used by the global evaluation report # (RP0004). evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) # Template used to display messages. This is a python new-style format string # used to format the message information. See doc for all details #msg-template= # Set the output format. Available formats are text, parseable, colorized, json # and msvs (visual studio).You can also give a reporter class, eg # mypackage.mymodule.MyReporterClass. output-format=text # Tells whether to display a full report or only the messages reports=no # Deactivate the evaluation score. score=no [REFACTORING] # Maximum number of nested blocks for function / method body max-nested-blocks=5 # Complete name of functions that never returns. When checking for # inconsistent-return-statements if a never returning function is called then # it will be considered as an explicit return statement and no message will be # printed. never-returning-functions=optparse.Values,sys.exit [VARIABLES] # List of additional names supposed to be defined in builtins. Remember that # you should avoid to define new builtins when possible. additional-builtins= # Tells whether unused global variables should be treated as a violation. allow-global-unused-variables=yes # List of strings which can identify a callback function by name. A callback # name must start or end with one of those strings. callbacks=cb_, _cb # A regular expression matching the name of dummy variables (i.e. expectedly # not used). dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ # Argument names that match this expression will be ignored. Default to name # with leading underscore ignored-argument-names=_.*|^ignored_|^unused_ # Tells whether we should check for unused import in __init__ files. init-import=no # List of qualified module names which can have objects that can redefine # builtins. redefining-builtins-modules=six.moves,past.builtins,future.builtins [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. notes=FIXME, XXX, TODO [BASIC] # Regular expression which should only match correct argument names argument-rgx=[a-z_][a-z0-9_]{1,40}$ # Regular expression which should only match correct instance attribute names attr-rgx=[a-z_][a-z0-9_]{1,40}$ # Bad variable names which should always be refused, separated by a comma bad-names=foo, bar, baz, toto, tutu, tata # Regular expression matching correct class attribute names. class-attribute-rgx=([a-z_][a-z0-9_]{1,40})|([A-Z_][A-Z0-9_]{1,30})$ # Naming style matching correct class names class-naming-style=PascalCase # Naming style matching correct constant names const-naming-style=UPPER_CASE # Minimum line length for functions/classes that require docstrings, shorter # ones are exempt. docstring-min-length=3 # Regular expression which should only match correct function names function-rgx=[a-z_][a-z0-9_]+$ # Good variable names which should always be accepted, separated by a comma good-names=e, f, i, j, k, ex, Run, logger, _ # Include a hint for the correct naming format with invalid-name include-naming-hint=yes # Regular expression matching correct inline iteration names. inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ # Regular expression which should only match correct method names method-rgx=[a-z_][a-z0-9_]+$ # Regular expression which should only match correct module names module-rgx=([a-z]+)|(test_*)$ # Regular expression which should only match function or class names that do # not require a docstring. no-docstring-rgx=^_ # List of decorators that produce properties, such as abc.abstractproperty. Add # to this list to register other decorators that produce valid properties. property-classes=abc.abstractproperty # Regular expression which should only match correct variable names variable-rgx=[a-z_][a-z0-9_]+$ [SIMILARITIES] # Ignore comments when computing similarities. ignore-comments=yes # Ignore docstrings when computing similarities. ignore-docstrings=yes # Ignore imports when computing similarities. ignore-imports=no # Minimum lines number of a similarity. min-similarity-lines=4 [LOGGING] # Logging modules to check that the string format arguments are in logging # function parameter format logging-modules=logging [TYPECHECK] # List of decorators that produce context managers, such as # contextlib.contextmanager. Add to this list to register other decorators that # produce valid context managers. contextmanager-decorators=contextlib.contextmanager # List of members which are set dynamically and missed by pylint inference # system, and so shouldn't trigger E1101 when accessed. Python regular # expressions are accepted. generated-members=gmp, connection, assertRaises, assertWarns, assertTrue, assertFalse, assertEqual # Tells whether missing members accessed in mixin class should be ignored. A # mixin class is detected if its name ends with "mixin" (case insensitive). ignore-mixin-members=yes # This flag controls whether pylint should warn about no-member and similar # checks whenever an opaque object is returned when inferring. The inference # can return multiple potential results while evaluating a Python object, but # some branches might not be evaluated, which results in partial inference. In # that case, it might be useful to still emit no-member and other checks for # the rest of the inferred objects. ignore-on-opaque-inference=yes # List of class names for which member attributes should not be checked (useful # for classes with dynamically set attributes). This supports the use of # qualified names. ignored-classes=optparse.Values,thread._local,_thread._local # List of module names for which member attributes should not be checked # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. ignored-modules= # Show a hint with possible names when a member name was not found. The aspect # of finding the hint is based on edit distance. missing-member-hint=yes # The minimum edit distance a name should have in order to be considered a # similar match for a missing member name. missing-member-hint-distance=1 # The total number of similar names that should be taken in consideration when # showing a hint for a missing member. missing-member-max-choices=1 [FORMAT] # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. expected-line-ending-format=LF # Regexp for a line that is allowed to be longer than the limit. ignore-long-lines=^\s*(# )??$ # Number of spaces of indent required inside a hanging or continued line. indent-after-paren=4 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 # tab). indent-string=' ' # Maximum number of characters on a single line. max-line-length=80 # Maximum number of lines in a module max-module-lines=1000 # List of optional constructs for which whitespace checking is disabled. `dict- # separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. # `trailing-comma` allows a space between comma and closing bracket: (a, ). # `empty-line` allows space-only lines. no-space-check=trailing-comma, dict-separator # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no # Allow the body of an if to be on the same line as the test if there is no # else. single-line-if-stmt=no [IMPORTS] # Allow wildcard imports from modules that define __all__. allow-wildcard-with-all=no # Analyse import fallback blocks. This can be used to support both Python 2 and # 3 compatible code, which means that the block might have code that exists # only in one or another interpreter, leading to false positives when analysed. analyse-fallback-blocks=no # Deprecated modules which should not be used, separated by a comma deprecated-modules=optparse,tkinter.tix # Create a graph of external dependencies in the given file (report RP0402 must # not be disabled) ext-import-graph= # Create a graph of every (i.e. internal and external) dependencies in the # given file (report RP0402 must not be disabled) import-graph= # Create a graph of internal dependencies in the given file (report RP0402 must # not be disabled) int-import-graph= # Force import order to recognize a module as part of the standard # compatibility libraries. known-standard-library= # Force import order to recognize a module as part of a third party library. known-third-party=enchant [DESIGN] # Maximum number of arguments for function / method max-args=15 # Maximum number of attributes for a class (see R0902). max-attributes=20 # Maximum number of boolean expressions in a if statement max-bool-expr=5 # Maximum number of branch for function / method body max-branches=12 # Maximum number of locals for function / method body max-locals=15 # Maximum number of parents for a class (see R0901). max-parents=7 # Maximum number of public methods for a class (see R0904). max-public-methods=30 # Maximum number of return / yield for function / method body max-returns=6 # Maximum number of statements in function / method body max-statements=50 # Minimum number of public methods for a class (see R0903). min-public-methods=0 [CLASSES] # List of method names used to declare (i.e. assign) instance attributes. defining-attr-methods=__init__, __new__, setUp # List of member names, which should be excluded from the protected access # warning. exclude-protected=_asdict, _fields, _replace, _source, _make # List of valid names for the first argument in a class method. valid-classmethod-first-arg=cls # List of valid names for the first argument in a metaclass class method. valid-metaclass-classmethod-first-arg=mcs [EXCEPTIONS] # Exceptions that will emit a warning when being caught. Defaults to # "Exception" overgeneral-exceptions=Exception python-gvm-21.10.0/.remarkrc000066400000000000000000000000721413122500400155610ustar00rootroot00000000000000{ "settings": { "listItemIndent": "1" } } python-gvm-21.10.0/CHANGELOG.md000066400000000000000000001153751413122500400156000ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Calendar Versioning](https://calver.org). ## [Unreleased] ### Added ### Changed * Switch to [`poetry-core`](https://github.com/python-poetry/poetry-core) as build backend ### Deprecated ### Removed ### Fixed [Unreleased]: https://github.com/greenbone/python-gvm/compare/v21.6.0...HEAD ## [21.6.0] - 2021-06-21 ### Changed * Changed API calls for SecInfo [#501](https://github.com/greenbone/python-gvm/pull/501): * `get_nvt_list()` -> `get_nvts()` * `get_cpe_list()` -> `get_cpes()` * `get_cve_list()` -> `get_cves()` * `get_cert_bund_advisory_list()` -> `get_cert_bund_advisories()` * `get_dnf_cert_advisory_list()` -> `get_dnf_cert_advisories()` * `get_oval_definition_list()` -> `get_oval_definitions()` ### Removed * Removed debug print statement in `check_command_status()` [#506](https://github.com/greenbone/python-gvm/pull/506) [21.6.0]: https://github.com/greenbone/python-gvm/compare/v21.5.2...v21.6.0 ## [21.5.2] - 2021-06-01 ### Added Add `import_policy` API call [#496](https://github.com/greenbone/python-gvm/pull/496) [21.5.2]: https://github.com/greenbone/python-gvm/compare/v21.5.1...v21.5.2 ## [21.5.1] - 2021-06-01 ### Changed * For SSH Connections: Reject unknown hosts, ask user if he wants to connect to unknown remote host and ask user if he wants to add the host to `known_hosts` [#486](https://github.com/greenbone/python-gvm/pull/486) ### Fixed * Export `HelpFormat` and `get_help_format_from_string()` [#495](https://github.com/greenbone/python-gvm/pull/495) [21.5.1]: https://github.com/greenbone/python-gvm/compare/v21.5.0...v21.5.1 ## [21.5.0] - 2021-05-25 **Dropped support for GMP v7, v8 and v9!** ### Added * Introduced new explicit API calls for SecInfo: `get_nvt()`, `get_nvt_list()`, `get_cpe()`, `get_cpe_list()`, `get_cve()`, `get_cve_list()`, `get_cert_bund_advisory()`, `get_cert_bund_advisory_list()`, `get_dnf_cert_advisory()`, `get_dnf_cert_advisory_list()`, `get_oval_definition()`, `get_oval_definition_list()`. [#456](https://github.com/greenbone/python-gvm/pull/456) ### Changed * Splitted up `get_preference(s)` into `get_nvt_preference(s)` and `get_scan_config_preference(s)`. [#473](https://github.com/greenbone/python-gvm/pull/473) * Improved and changed `help()`: Introduced `HelpFormat` Enum, changed `format` parameter to `help_format` using `HelpFormat`, changed `help_type` to `brief` and bool, as it only has two options (default and brief). [#473](https://github.com/greenbone/python-gvm/pull/473) * Changed `filter` to `filter_string` in getter functions. [#470](https://github.com/greenbone/python-gvm/pull/470) [#471](https://github.com/greenbone/python-gvm/pull/471) [#473](https://github.com/greenbone/python-gvm/pull/473) * API changes: `get_setting(s)` -> `get_user_setting(s)`, `modify_setting` -> `modify_user_setting`. [#472](https://github.com/greenbone/python-gvm/pull/472) * Changed all API calls for `_config` to `_scan_config` to match other Greenbone components. [#465](https://github.com/greenbone/python-gvm/pull/465) * Split up `get_asset(s)` into `get_host(s)` and `get_operating_system(s)`. [#459](https://github.com/greenbone/python-gvm/pull/459) * Split up `delete_asset` into `delete_host` and `delete_operating_system`. [#459](https://github.com/greenbone/python-gvm/pull/459) * Split up `modify_asset` into `modify_host` and `modify_operating_system`. [#459](https://github.com/greenbone/python-gvm/pull/459) * Deleted `AssetType`. It is not required anymore. [#459](https://github.com/greenbone/python-gvm/pull/458) * Changed the API calls `get_nvt()` and `get_nvts()` to `get_scan_config_nvt()` and `get_scan_config_nvts()`. [#456](https://github.com/greenbone/python-gvm/pull/456) * Splitted up the GmpMonolith class: * Detached the SystemReports API calls from the GMP class into a new `SystemReportsMixin`. [#473](https://github.com/greenbone/python-gvm/pull/473) * Detached the Help API calls from the GMP class into a new `HelpMixin`. [#473](https://github.com/greenbone/python-gvm/pull/473) * Detached the Trashcan API calls from the GMP class into a new `TrashcanMixin`. [#472](https://github.com/greenbone/python-gvm/pull/472) * Detached the Authentication API calls from the GMP class into a new `AuthenticationMixin`. [#472](https://github.com/greenbone/python-gvm/pull/472) * Detached the Version API calls from the GMP class into a new `VersionMixin`. [#472](https://github.com/greenbone/python-gvm/pull/472) * Detached the Preferences API calls from the GMP class into a new `PreferencesMixin`. [#471](https://github.com/greenbone/python-gvm/pull/471) * Detached the Settings API calls from the GMP class into a new `UserSettingsMixin`. [#471](https://github.com/greenbone/python-gvm/pull/471) * Detached the Groups API calls from the GMP class into a new `GroupsMixin`. [#471](https://github.com/greenbone/python-gvm/pull/471) * Detached the Vulnerabilities API calls from the GMP class into a new `VulnerabilitiesMixin`. [#471](https://github.com/greenbone/python-gvm/pull/471) * Detached the ReportFormats API calls from the GMP class into a new `ReportFormatsMixin`. [#470](https://github.com/greenbone/python-gvm/pull/470) * Detached the Roles API calls from the GMP class into a new `RolesMixin`. [#470](https://github.com/greenbone/python-gvm/pull/470) * Detached the Tickets API calls from the GMP class into a new `TicketsMixin`. [#470](https://github.com/greenbone/python-gvm/pull/470) * Detached the HostsOrdering Type from the GMP types class. [#469](https://github.com/greenbone/python-gvm/pull/469) * Detached the TicketStatus Type from the GMP types class. [#469](https://github.com/greenbone/python-gvm/pull/469) * Detached the Schedules API calls from the GMP class into a new `SchedulesMixin`. [#469](https://github.com/greenbone/python-gvm/pull/469) * Detached the Filters API calls from the GMP class into a new `FiltersMixin`. [#469](https://github.com/greenbone/python-gvm/pull/469) * Detached the Tags API calls from the GMP class into a new `TagsMixin`. [#468](https://github.com/greenbone/python-gvm/pull/468) * Detached the Feeds API calls from the GMP class into a new `FeedMixin`. [#468](https://github.com/greenbone/python-gvm/pull/468) [#472](https://github.com/greenbone/python-gvm/pull/472) * Detached the Aggregates API calls from the GMP class into a new `AggregatesMixin`. [#468](https://github.com/greenbone/python-gvm/pull/468) * Detached the EntityType from the GMP types class into a new `entites` file. [#467](https://github.com/greenbone/python-gvm/pull/467) * Detached the Users API calls from the GMP class into a new `UsersMixin`. [#467](https://github.com/greenbone/python-gvm/pull/467) * Detached the Permissions API calls from the GMP class into a new `PermissionsMixin`. [#467](https://github.com/greenbone/python-gvm/pull/467) * Detached the Scanner API calls from the GMP class into a new `ScannersMixin`. [#466](https://github.com/greenbone/python-gvm/pull/466) * Detached the Credential API calls from the GMP class into a new `CredentialsMixin`. [#466](https://github.com/greenbone/python-gvm/pull/466) * Detached Config and Policy calls from GMP class into new `ScanConfigsMixin` and `PoliciesMixin`. [#465](https://github.com/greenbone/python-gvm/pull/465) * Detached the Audit API calls from the GMP class into a new `AuditsMixin`. [#464](https://github.com/greenbone/python-gvm/pull/464) * Detached TLS-Certificates and assets into `TLSCertificatesMixin`, `HostsMixin` and `OperatingSystemsMixin`. [#459](https://github.com/greenbone/python-gvm/pull/458) * Detached the Alerts API calls from the GMP class into a new `AlertsMixin`. [#458](https://github.com/greenbone/python-gvm/pull/458) * Detached the Notes and Overrides API calls from the GMP class into a new `NotesMixin` and `OverridesMixin`. [#457](https://github.com/greenbone/python-gvm/pull/457) * Detached the `InfoType` from the GMP types class. [#456](https://github.com/greenbone/python-gvm/pull/456) * Detached the SecInfo (CPE, CVE, NVT, CERT-BUND, DNF-CERT, OVAL Definitions) calls from GMP class into new `SecInfoMixin`. [#456](https://github.com/greenbone/python-gvm/pull/456) * Detached the PortList and PortRange API calls from the GMP class into a new `PortListMixin`. [#446](https://github.com/greenbone/python-gvm/pull/446) * Detached the Target API calls from the GMP class into a new `TargetsMixin`. [#446](https://github.com/greenbone/python-gvm/pull/446) * Detached the `AliveTest` from the GMP types class. [#446](https://github.com/greenbone/python-gvm/pull/446) * Detached the `PortListType` from the GMP types class. [#446](https://github.com/greenbone/python-gvm/pull/446) * Detached the ReportFormatType from the GMP types class. [#445](https://github.com/greenbone/python-gvm/pull/445) * Detached the Report API calls from the GMP class into a new `ReportMixin`. [#445](https://github.com/greenbone/python-gvm/pull/445) * Detached the Task API calls from the GMP class into a new `TasksMixin`. [#443](https://github.com/greenbone/python-gvm/pull/443) * Moved helper functions from gmp to utils. The response XML will not be recovered by the parser anymore! [#442](https://github.com/greenbone/python-gvm/pull/442) ### Removed * Removed `sync_feed`, `sync_scap`, and `sync_cert` calls. [#472](https://github.com/greenbone/python-gvm/pull/472) * Removed `TimeUnit`. It was used for schedules before iCal and is not required anymore. [#469](https://github.com/greenbone/python-gvm/pull/469) * Removed `Gmpv214Mixin`. [#467](https://github.com/greenbone/python-gvm/pull/467) * Remove support of delete host/operating system by a report . [#459](https://github.com/greenbone/python-gvm/pull/459) * Remove deprecated `make_unique` parameter from `Targets`. [#446](https://github.com/greenbone/python-gvm/pull/446) * Removed deprecated `Agents` completely. [#441](https://github.com/greenbone/python-gvm/pull/441) * **Dropped support** for GMP v7, v8 and v9! The oldest usable GMP version is 20.8 [#436](https://github.com/greenbone/python-gvm/pull/436) [#437](https://github.com/greenbone/python-gvm/pull/437) [#438](https://github.com/greenbone/python-gvm/pull/438) [#439](https://github.com/greenbone/python-gvm/pull/439) [#444](https://github.com/greenbone/python-gvm/pull/444) [21.5.0]: https://github.com/greenbone/python-gvm/compare/v21.4.0...v21.5.0 ## [21.4.0] - 2021-04-26 ### Changed * `get_feed` can also be requested with `GVMD_DATA` for 20.08 and newer, added `GVMD_DATA` to the FeedType and updated API call [#434](https://github.com/greenbone/python-gvm/pull/434) [21.4.0]: https://github.com/greenbone/python-gvm/compare/v21.1.3...v21.4.0 ## [21.1.3] - 2021-01-27 ### Added * Added protocol version "next" and GMP 21.04 doc [#384](https://github.com/greenbone/python-gvm/pull/384) ### Fixed * Add missing ReportFormatType to GMP 21.04 [#385](https://github.com/greenbone/python-gvm/pull/385) [21.1.3]: https://github.com/greenbone/python-gvm/compare/v21.1.2...v21.1.3 ## [21.1.2] - 2021-01-27 ### Added * Added allow_simultaneous_ips param for targets [#380](https://github.com/greenbone/python-gvm/pull/380) ### Removed * dropped the GMP Scanner (4) from `ScannerTypes` for v21.4 [#383](https://github.com/greenbone/python-gvm/pull/383) ### Fixed * removing `timeout` from `get_nvt()` [#376](https://github.com/greenbone/python-gvm/pull/376) * Add `ReportFormatType` and `get_report_format_id_from_string` to `latest.py`, so it is usable with `import gvm.protcols.latest`[#381](https://github.com/greenbone/python-gvm/pull/381) * Fixing `import_report()` for v9 and v20.8 and newer, removed the `task_name` and `task_comment` parameters, that do not work anymore [#377](https://github.com/greenbone/python-gvm/pull/377) [21.1.2]: https://github.com/greenbone/python-gvm/compare/v21.1.1...v21.1.2 ## [21.1.1] - 2021-01-05 ### Fixed * Fixed release issues, through rerelease. [21.1.1]: https://github.com/greenbone/python-gvm/compare/v21.1.0...v21.1.1 ## [21.1.0] - 2021-01-05 ### Added * CI tests Python 3.9 now. [#367](https://github.com/greenbone/python-gvm/pull/367) ### Deprecated * Dropped Python 3.5 and Python 3.6 support. Python 3.7+ is required now. [#367](https://github.com/greenbone/python-gvm/pull/367) ### Fixed * Add missing types and functions to "latest" GMP [#369](https://github.com/greenbone/python-gvm/pull/369) [21.1.0]: https://github.com/greenbone/python-gvm/compare/v20.12.1...v21.1.0 ## [20.12.1] - 2020-12-16 ### Added * Added AUDIT and POLICY to EntityType enum [#353](https://github.com/greenbone/python-gvm/pull/353) ### Changed * Support "all" argument in modify_scan_config_set_family_selection [#368](https://github.com/greenbone/python-gvm/pull/368) * added the `audits` parameter to `get_policy` [#345](https://github.com/greenbone/python-gvm/pull/345) * Update get_aggregates params in GMP 9.0 and newer [#359](https://github.com/greenbone/python-gvm/pull/359) ### Fixed * added `get_info_list` to v20.08, so it works as expected with new `InfoType` [#362](https://github.com/greenbone/python-gvm/pull/362) [20.12.1]: https://github.com/greenbone/python-gvm/compare/v20.11.3...v20.12.1 ## [20.11.3] - 2020-11-26 ### Added * Adding parameters to `get_nvt command`, so it requests all details [#348](https://github.com/greenbone/python-gvm/pull/348) * Improved the `modify_user` function for gmpv7 and gmpv214. Added ability to change comment, groups and authentication method of user. Meaning of name parameter got changed for gmpv214 only. It is not intended for identifying a user anymore but for specifying the new name of the user [#347](https://github.com/greenbone/python-gvm/pull/347) * Adding `resume_audit`, `start_audit`, `stop_audit` to gmpv9 [#349](https://github.com/greenbone/python-gvm/pull/349) ### Changed * Implement tuple for `family` argument for `modify_config_set_family_selection` [#354](https://github.com/greenbone/python-gvm/pull/354) [20.11.3]: https://github.com/greenbone/python-gvm/compare/v20.11.2...HEAD ## [20.11.2] - 2020-11-17 ### Added * Added the `delete_tls_certificate` function [#335](https://github.com/greenbone/python-gvm/pull/335) [20.11.2]: https://github.com/greenbone/python-gvm/compare/v20.11.1...HEAD ## [20.11.1] - 2020-11-16 ### Added * Added the `modify_audit` function [#332](https://github.com/greenbone/python-gvm/pull/332) * Added the `modify_policy_set_nvt_preference` function [#332](https://github.com/greenbone/python-gvm/pull/332) * Added the `modify_policy_set_name` function [#332](https://github.com/greenbone/python-gvm/pull/332) * Added the `modify_policy_set_comment` function [#332](https://github.com/greenbone/python-gvm/pull/332) * Added the `modify_policy_set_scanner_preference` function [#332](https://github.com/greenbone/python-gvm/pull/332) * Added the `modify_policy_set_nvt_selection` function [#332](https://github.com/greenbone/python-gvm/pull/332) * Added the `modify_policy_set_family_selection` function [#332](https://github.com/greenbone/python-gvm/pull/332) ### Changed * Moved tests for `SeverityLevel` Enum and `get_severity_level_from_string()` [#327](https://github.com/greenbone/python-gvm/pull/327) * In `get_report()` the `details` parameter is `True` on default now. [#333](https://github.com/greenbone/python-gvm/pull/333) [20.11.1]: https://github.com/greenbone/python-gvm/compare/v20.11.0...HEAD ## [20.11.0] - 2020-11-03 ### Added * Added `clone_report_format()` and `import_report_format()` [#309](https://github.com/greenbone/python-gvm/pull/309) * Added the `get_x_from_string()` functions to `latest` [#308](https://github.com/greenbone/python-gvm/pull/308) * Added the `ReportFormatType` that can be used instead of a report_format_id [#311](https://github.com/greenbone/python-gvm/pull/311) * Added tests for constructor of SSHConnection, TLSConnection, UnixSocketConnection and GvmConnection [#321](https://github.com/greenbone/python-gvm/pull/321) ### Fixed * Corrected `seconds_active` parameter to `days_active` for notes and overrides. [#307](https://github.com/greenbone/python-gvm/pull/307) * Fixed SSHConnection throws TypeError if port is None [#321](https://github.com/greenbone/python-gvm/pull/321) * Fixed GvmConnection timeout set to None if None is passed [#321](https://github.com/greenbone/python-gvm/pull/321) * Fixed TLSConnection values set to None instead of default values when None is passed for these values [#321](https://github.com/greenbone/python-gvm/pull/321) * Fixed UnixSocketConnection values set to None instead of default when None is passed for these values [#321](https://github.com/greenbone/python-gvm/pull/321) [20.11.0]: https://github.com/greenbone/python-gvm/compare/v20.9.1...HEAD ## [20.9.1] - 2020-09-25 ### Added * Added `modify_config_set_name`. [#295](https://github.com/greenbone/python-gvm/pull/295) * Added logic to accept the new AlertEvents `TICKET_RECEIVED`, `ASSIGNED_TICKET_CHANGED` and `OWNED_TICKET_CHANGED` and the new Condition `SEVERITY_CHANGED`. [#297](https://github.com/greenbone/python-gvm/pull/297) * Added `create_config_from_osp_scanner`. [#298](https://github.com/greenbone/python-gvm/pull/298) ### Changed * Added the `details` parameter to `get_tls_certificate` and `get_tls_certificates`. [#293](https://github.com/greenbone/python-gvm/pull/293) * Added the `comment` parameter to `create_config`. [#294](https://github.com/greenbone/python-gvm/pull/294) ### Fixed * Fix ScannerType check for newer protocols. [#300](https://github.com/greenbone/python-gvm/pull/300) [20.9.1]: https://github.com/greenbone/python-gvm/compare/v20.9.0...HEAD ## [20.9.0] - 2020-09-17 ### Changed * Added the `tasks` parameter to `get_config()`. [#289](https://github.com/greenbone/python-gvm/pull/289) * Renamed `no_details` to `details` in `get_reports()` so it is uniform with all the other calls. [#290](https://github.com/greenbone/python-gvm/pull/290) ### Fixed - Force garbage clean up when disconnect. [#286](https://github.com/greenbone/python-gvm/pull/286) [20.9.0]: https://github.com/greenbone/python-gvm/compare/v20.8.1...HEAD ## [20.8.1] - 2020-09-01 ### Added * Added `AlertMethods`: Alemba vFire, Tippingpoint SMS [#275](https://github.com/greenbone/python-gvm/pull/275) * Added `AlertConditions`: Error, SeverityChanged [#275](https://github.com/greenbone/python-gvm/pull/275) * Added `AlertEvents`: Assigned ticket changed, Owned ticket changed, Ticket received [#275](https://github.com/greenbone/python-gvm/pull/275) ### Changed * `pretty_print()` has a new argument that can optionally handle a file. The output is redirected to this file. default is `sys.stdout`, as it is for build-in `print()` [#277](https://github.com/greenbone/python-gvm/pull/277) ### Fixed * `ARP_PING` is now a field of `AliveTypes`, the old `APR_PING` name is still available. [#281](https://github.com/greenbone/python-gvm/pull/281) * `modify_task` adds `` if alert_ids array is empty. [#285](https://github.com/greenbone/python-gvm/pull/285) [20.8.1]: https://github.com/greenbone/python-gvm/compare/v20.8.0...HEAD ## [20.8.0] - 2020-08-19 ### Added * Added support for GMP 20.08 [#254](https://github.com/greenbone/python-gvm/pull/254) ### Changed * Refactored Gmp classes into mixins [#254](https://github.com/greenbone/python-gvm/pull/254) ### Fixed * Require method and condition arguments for modify_alert with an event [#267](https://github.com/greenbone/python-gvm/pull/267) * Add SEVERITY_AT_LEAST to get_alert_condition_from_string [#268](https://github.com/greenbone/python-gvm/pull/268) [20.8.0]: https://github.com/greenbone/python-gvm/compare/v1.6.0...v20.8.0 ## [1.6.0] - 2020-06-10 ### Added * Extend AliveTest and ScannerType enums. [#235](https://github.com/greenbone/python-gvm/pull/235) ### Fixed * Fix python-gvm v8/v9 type checks. [#244](https://github.com/greenbone/python-gvm/pull/244) [1.6.0]: https://github.com/greenbone/python-gvm/compare/v1.5.0...v1.6.0 ## [1.5.0] - 2020-05-12 ### Added * Add full support for audits and policies. Add `get_policy`, `get_policies`, `clone_policy`, `delete_policy`, `get_audit`, `get_audits`, `clone_audit` and `delete_audit` methods to GMPv9 class. Also do not return policies for config requests and audits for task requests [#223](https://github.com/greenbone/python-gvm/pull/223) ### Changed * If it isn't possible to connect to a Unix Domain Socket a GvmError is raised now [#207](https://github.com/greenbone/python-gvm/pull/207) ### Removed * Dropped version handling code from python-gvm and replaced it with using pontos.version [#213](https://github.com/greenbone/python-gvm/pull/213) [1.5.0]: https://github.com/greenbone/python-gvm/compare/v1.4.0...v1.5.0 ## [1.4.0] ### Added * Added an API and CLI utilities for the version handling in python-gvm [#198](https://github.com/greenbone/python-gvm/pull/198) ### Changed * Replaced `pipenv` with `poetry` for dependency management. `poetry install` works a bit different then `pipenv install`. It installs dev packages by default and also python-gvm in editable mode. This means after running `poetry install` gvm will directly be importable in the virtual python environment. [#197](https://github.com/greenbone/python-gvm/pull/197) * Update error classes to always have meaningful `__str__` and `__repr__` method. This allows for easier error printing [#199](https://github.com/greenbone/python-gvm/pull/199) [1.4.0]: https://github.com/greenbone/python-gvm/compare/v1.3.0...v1.4.0 ## [1.3.0] ### Added * Added `GvmServerError`, `GvmClientError`, `GvmResponseError` and `InvalidArgumentType` error type classes [#192](https://github.com/greenbone/python-gvm/pull/192) ### Changed * Refactored the `InvalidArgument` and `RequiredArgument` errors in the gmp classes [#192](https://github.com/greenbone/python-gvm/pull/192) * Refactored the status response errors in case of a failure in the communication with the server in `transform.py` [#192](https://github.com/greenbone/python-gvm/pull/192) [1.3.0]: https://github.com/greenbone/python-gvm/compare/v1.2.0...v1.3.0 ## [1.2.0] ### Added * Added DEFAULT_SSH_PORT and DEFAULT_HOSTNAME constants to `gmp.connection` [#185](https://github.com/greenbone/python-gvm/pull/185) * Added `determine_remote_gmp_version` and `determine_supported_gmp` methods to `gmp.protocols.gmp` module [#186](https://github.com/greenbone/python-gvm/pull/186) ### Fixed * Added a workaround that fixes the `exclude_hosts`-bug in the method `modify_target`. See [#187](https://github.com/greenbone/python-gvm/issues/187) for more details [#188](https://github.com/greenbone/python-gvm/pull/188) * Fixed value of `EntityType.AGENT` enum [#190](https://github.com/greenbone/python-gvm/pull/190) [1.2.0]: https://github.com/greenbone/python-gvm/compare/v1.1.0...v1.2.0 ## [1.1.0] - 2019-11-22 ### Added * Added ignore_pagination and details arguments for get_report [#163](https://github.com/greenbone/python-gvm/pull/163) * Introduced Gmpv9 for [GMP 9](https://docs.greenbone.net/API/GMP/gmp-9.0.html) support [#157](https://github.com/greenbone/python-gvm/pull/157), [#165](https://github.com/greenbone/python-gvm/pull/165), [#166](https://github.com/greenbone/python-gvm/pull/166) * Added new `create_audit` method, to create a task with the `usage_type` `audit` [#157](https://github.com/greenbone/python-gvm/pull/157) * Added new `create_policy` method, to create a config with the `usage_type` `policy` [#157](https://github.com/greenbone/python-gvm/pull/157) * Added the new methods `create_tls_certificate`, `modify_tls_certificate` and `clone_tls_certificate` to create, modify and copy TLS certificates [#157](https://github.com/greenbone/python-gvm/pull/157) * Added the new method `get_tls_certificates`, to request TLS certificates from the server [#157](https://github.com/greenbone/python-gvm/pull/157) * Added the new method `get_tls_certificate`, to request a single TLS certificate from the server [#166](https://github.com/greenbone/python-gvm/pull/166) ### Changed * Use Gmpv9 in gvm.protocols.latest module [#165](https://github.com/greenbone/python-gvm/pull/165) * Added type `TLS_CERTIFICATE` to `EntityType` and `FilterType` [#157](https://github.com/greenbone/python-gvm/pull/157) * Changed the `DEFAULT_UNIX_SOCKET_PATH` [#119](https://github.com/greenbone/python-gvm/pull/162) * ospv1.py: Don't half shutdown the TLS socket. [#180](https://github.com/greenbone/python-gvm/pull/180) ### Deprecated * Mark make_unique argument of create_target Gmpv8 as deprecated and ignore it. It is already ignored by gvmd with GMP 8 [#156](https://github.com/greenbone/python-gvm/pull/156) [1.1.0]: https://github.com/greenbone/python-gvm/compare/v1.0.0...v1.1.0 ## [1.0.0] - 2019-09-18 ### Changed * Return version tuple from get_protocol_version methods [#154](https://github.com/greenbone/python-gvm/pull/154) ### Fixed * Fixed `create_tag` and `modify_tag` `resource_type` argument to expect an EntityType in `Gmp8` [#150](https://github.com/greenbone/python-gvm/pull/150) * Re-added `SMB` as an allowed `AlertMethod` for SecInfo events [#145](https://github.com/greenbone/python-gvm/pull/145) [1.0.0]: https://github.com/greenbone/python-gvm/compare/v1.0.0.beta3...v1.0.0 ## [1.0.0.beta3] - 2019-07-30 ### Added * Added preferences argument to `create_task` method [#89](https://github.com/greenbone/python-gvm/pull/89) * Added validation of alive_tests argument to `create_target` method [#88](https://github.com/greenbone/python-gvm/pull/88) * Added ssh_credential_port argument to `modify_target` [#88](https://github.com/greenbone/python-gvm/pull/88) * Split getting a single preference by name from `get_preferences` method into `get_preference` [#85](https://github.com/greenbone/python-gvm/pull/85) * Added resource_type argument to `get_aggregates` method [#107](https://github.com/greenbone/python-gvm/pull/107) * Added an explicit `create_container_task` method [#108](https://github.com/greenbone/python-gvm/pull/108) * Added Gmpv8 version of create_tag with resource_filter parameter and plural resource_ids parameter [#115](https://github.com/greenbone/python-gvm/pull/115) * Added Gmpv8 version of modify_tag with resource_action parameter, resource_filter parameter, plural resource_ids parameter [#115](https://github.com/greenbone/python-gvm/pull/115) * Added no_details argument to `get_reports` method [#129](https://github.com/greenbone/python-gvm/pull/129) * Added `get_vulnerabilities` method [#132](https://github.com/greenbone/python-gvm/pull/132) * Added `get_ticket`, `get_tickets`, `create_ticket`, `clone_ticket`, `modify_ticket` and `delete_ticket` APIs to GMPv8 [#132](https://github.com/greenbone/python-gvm/pull/132) * Added filter types for `host`, `operating system`, `ticket` and `vulnerability` [#133](https://github.com/greenbone/python-gvm/pull/133) * Added a `password only` credential type [#133](https://github.com/greenbone/python-gvm/pull/133) * Added [type hints](https://docs.python.org/3/library/typing.html) for Gmpv8 [#136](https://github.com/greenbone/python-gvm/pull/136) * Added dynamic selection of the Gmp class depending on the GMP version supported by the remote manager daemon [#141](https://github.com/greenbone/python-gvm/pull/141) * Added all types as types property to the Gmp classes (e.g gmp.types.EntityType.TASK) [#143](https://github.com/greenbone/python-gvm/pull/143) ### Changed * Renamed `create_asset` method to `create_host` and dropped asset_type argument. It is only possible to create host assets. [#77](https://github.com/greenbone/python-gvm/pull/77) * Require either setting_id or name for `modify_setting` not both arguments [#87](https://github.com/greenbone/python-gvm/pull/87) * Allow empty string as value argument for `modify_setting` [#87](https://github.com/greenbone/python-gvm/pull/87) * Require either user_id or name for `modify_user` not both arguments [#87](https://github.com/greenbone/python-gvm/pull/87) * Updated argument types for `create_note`, `create_override`, `modify_note` and `modify_override` [#87](https://github.com/greenbone/python-gvm/pull/87) * The arguments threat (and new_threat) for `create_note`, `modify_note`, `create_override` and `modify_override` must be one of 'High', 'Medium', 'Low', 'Alarm', 'Log' or 'Debug' now [#87](https://github.com/greenbone/python-gvm/pull/87) * Allow to pass either user_id or name to `delete_user` [#88](https://github.com/greenbone/python-gvm/pull/88) * Don't require inheritor_id or inheritor_name for `delete_user` * Don't require ca_pub for `create_scanner` [#88](https://github.com/greenbone/python-gvm/pull/88) * Change port argument for `create_scanner` to be an integer [#88](https://github.com/greenbone/python-gvm/pull/88) * Refactor `modify_scanner` method: Adjust argument types corresponding to `create_scanner` and only require scanner_id [#88](https://github.com/greenbone/python-gvm/pull/88) * Updated and improved validation of `create_schedule` and `modify_schedule` arguments [#89](https://github.com/greenbone/python-gvm/pull/89) * Refactor `modify_task` to use same arguments as `create_task` [#89](https://github.com/greenbone/python-gvm/pull/89) * Aligned ALIVE_TESTS declaration with list from GSA [#93](https://github.com/greenbone/python-gvm/pull/93) * Address DeprecationWarning regarding `collections` module [#99](https://github.com/greenbone/python-gvm/pull/99) * Forbid *'0'* as target_id value for `create_task` method and move creating a container task into an own method [#108](https://github.com/greenbone/python-gvm/pull/108) * Refresh the dependencies specified via the Pipfile.lock file to their latest versions [#113](https://github.com/greenbone/python-gvm/pull/113), [#131](https://github.com/greenbone/python-gvm/pull/131) * Make resource_id optional when creating tags (Gmpv7) [#124](https://github.com/greenbone/python-gvm/pull/124) * Allow creating tags without resource (Gmpv8) [#125](https://github.com/greenbone/python-gvm/pull/125) * Adapt modify_tag validation to actual implementation (Gmpv8) [#127](https://github.com/greenbone/python-gvm/pull/127) * Use Gmpv8 as latest Gmp version [#132](https://github.com/greenbone/python-gvm/pull/132) * Dropped the `make_unique` arguments from `create_filter` and `create_target` methods in Gmpv8 [#133](https://github.com/greenbone/python-gvm/pull/133) * Introduced Enum classes for authentication and privacy algorithms of SNMP credentials [#133](https://github.com/greenbone/python-gvm/pull/133) * Extended `InvalidArgument` and `RequiredArgument` errors to allow passing argument and function name as keyword parameter [#134](https://github.com/greenbone/python-gvm/pull/134) * Renamed `modify_target` and `create_target` argument `alive_tests` to `alive_test` [#139](https://github.com/greenbone/python-gvm/pull/139) * Use [enum](https://docs.python.org/3/library/enum.html) AliveTests for `alive_test` arguments [#136](https://github.com/greenbone/python-gvm/pull/136) [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `AlertCondition`, `AlertEvent` and `AlertMethod` enums for `create_alert` and `modify_alert` methods [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `AssetType` enum for `get_asset` and `get_assets` method [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `CredentialFormat` enum for `get_credential` method [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `CredentialType` enum for `create_credential` and `modify_credential` methods [#132](https://github.com/greenbone/python-gvm/pull/132) [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `EntityType` enum for `create_permission`, `create_tag`, `get_aggregates`, `modify_permission` and `modify_tag` methods [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `FeedType` enum for `get_feed` method [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `FilterType` enum for `create_filter` and `modify_filter` method [#133](https://github.com/greenbone/python-gvm/pull/133) [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `HostsOrdering` enum for `create_task` and `modify_task` method [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `InfoType` enum for `get_info` and `get_info_list` methods [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `PermissionSubjectType` enum for `create_permission` and `modify_permission` methods [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `PortRangeType` enum for `create_port_range` method [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `ScannerType` enum for `create_scanner` and `modify_scanner` methods [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `SnmpAuthAlgorithm` and `SnmpPrivacyAlgorithm` enums for `create_credential` and `modify_credential` methods [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `SeverityLevel` enum for `create_note`, `create_override`, `modify_note` and `modify_override` methods [#139](https://github.com/greenbone/python-gvm/pull/139) * Use new `TimeUnit` enum for `create_schedule` and `modify_schedule` methods [#139](https://github.com/greenbone/python-gvm/pull/139) * Update `create_schedule` and `modify_schedule` in `Gmpv8` to use [iCalendar](https://tools.ietf.org/html/rfc5545) based data for schedules [#140](https://github.com/greenbone/python-gvm/pull/140) ### Removed * Removed the format parameter from `get_credentials` method [#85](https://github.com/greenbone/python-gvm/pull/85) * Removed the task_id and nvt_oid parameters from `get_notes` and `get_overrides` methods [#85](https://github.com/greenbone/python-gvm/pull/85) * Removed sources argument from `modify_user` method [#87](https://github.com/greenbone/python-gvm/pull/87) * Removed `modify_report` method [#87](https://github.com/greenbone/python-gvm/pull/87) * Removed unused comment argument from `create_note` and `create_override` [#87](https://github.com/greenbone/python-gvm/pull/87) * Removed hosts_ordering argument from `modify_target` [#88](https://github.com/greenbone/python-gvm/pull/88) * Excluded tests from installation [#119](https://github.com/greenbone/python-gvm/pull/119) * Removed `credential_type` argument from `modify_credential` [#139](https://github.com/greenbone/python-gvm/pull/139) ### Fixed * Fixed generating XML for `get_credentials` command [#74](https://github.com/greenbone/python-gvm/pull/74) * Fixed generating XML for `get_settings` command [#80](https://github.com/greenbone/python-gvm/pull/80) * Fixed generating XML for `get_nvts` command [#84](https://github.com/greenbone/python-gvm/pull/84) * Fixed wrong order of key and value for condition_data, event_data and method_data dict parameters of `modify_alert` method [#85](https://github.com/greenbone/python-gvm/pull/85) * Fixed sending resource id in `modify_tag` [#88](https://github.com/greenbone/python-gvm/pull/88) * Ensure `modify_setting` value is send as Base64-encoded [#98](https://github.com/greenbone/python-gvm/pull/98) ### Deprecated * `modify_config` is marked as deprecated and will be removed in future. One of the more specific `modify_config_set_` method should be used instead [#87](https://github.com/greenbone/python-gvm/pull/87) [1.0.0.beta3]: https://github.com/greenbone/python-gvm/compare/v1.0.0.beta2...v1.0.0.beta3 ## [1.0.0.beta2] - 2018-12-04 ### Added * Added new `trigger_alert` method for triggering an alert method on a specific report. * Added `import_config` method to import a scan config from xml. * Added helper function to validate xml input `gvm.xml.validate_xml_string` * Add `finish_send` method to connections. The method allows to indicate to the server sending data is finished and no additional data has to be received. ### Changed * `help` method `type` argument got renamed to `help_type` * `help` method `help_type` argument will be checked for invalid values * `create_credential` requires a credential_type argument now. * Optional arguments are required to be passed as keyword arguments. * `get_report` method `format_id` argument got renamed to `report_format_id` * Check if scanner_type is one of '1' (OSP Scanner) or '2' (OpenVAS Scanner) in `create_scanner` method. * `pretty_print` accepts a xml string as input too * Optional arguments for connection class constructors must be passed as keyword arguments. * It's possible to wait indefinitely by deactivating the timeouts via passing None as timeout argument to the connection class constructors now. ### Fixed * Fix: Don't close the connection after each send/read command sequence automatically. This fixes sending more then one privileged gmp command after authentication. * Fixed generating XML for help command * Fixed wrong order of key and value for condition_data, event_data and method_data dict parameters of `create_alert` method. * Fixed `get_reports` sending the wrong protocol command * Fixed `create_permission` method * Fixed `get_config` sending the correct protocol command. * Don't crash if huge content is returned in a xml response. This fixes e.g. `get_reports` for bigger report data. ### Removed * Removed `format_id` argument from get_reports * Removed `alert_id` argument from `get_reports` * Removed unused `read_timeout` argument from `UnixSocketConnection` ## [1.0.0.beta1] - 2018-11-13 python-gvm was a part of [gvm-tools](https://github.com/greenbone/gvm-tools) prior gvm-tools version 2.0. It got extracted from gvm-tools and completely overhauled. Some notable changes are: * The package name changed from *gmp* to *gvm*. * The type of connection is passed to a more generic Gmp class instead of having to select the connection when creating the gmp object. * Support for different protocols and versions has been added. Currently supported protocols are OSP v1 and GMP v7. * Full API documentation is available at https://python-gvm.readthedocs.io/en/latest/. * Possible arguments to protocol methods are documented. * Arguments should be passed as keywords ### Gmp API changes * `create_report` has been renamed to `import_report`. * Requesting single entities has been extracted from the list commands e.g. `get_task(task_id)` instead of `get_tasks(task_id=task_id)`. * `get_info` requests a single info entity. * `get_info_list` requests a list of info entities. * `filt_id` argument is called `filter_id` at all Gmp methods. * `report_filter` argument for `get_reports` got renamed to `filter`. `report_filt_id` is `filter_id` now. * `create_schedule` `start_time` and `end_time` arguments got split into several parameters. * Plural arguments like `hosts`, `users`, ... always require a list now. * `create_alert` `event`, `condition` and `method` arguments got revised and split. * Boolean parameters expect True and False and not 1, 0, '1' or '0' now. * `get_assets` type parameter got renamed to `asset_type` * Copying an entity via the `copy` argument has been removed and extracted to own `clone` methods e.g. `clone_task`. [1.0.0.beta2]: https://github.com/greenbone/python-gvm/compare/v1.0.0.beta1...v1.0.0.beta2 [1.0.0.beta1]: https://github.com/greenbone/python-gvm/releases/tag/v1.0.0.beta1 python-gvm-21.10.0/LICENSE000066400000000000000000001045051413122500400147650ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. {one line to give the program's name and a brief idea of what it does.} Copyright (C) {year} {name of author} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: {project} Copyright (C) {year} {fullname} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . python-gvm-21.10.0/README.md000066400000000000000000000111351413122500400152330ustar00rootroot00000000000000![Greenbone Logo](https://www.greenbone.net/wp-content/uploads/gb_logo_resilience_horizontal.png) # Greenbone Vulnerability Management Python Library [![GitHub releases](https://img.shields.io/github/release-pre/greenbone/python-gvm.svg)](https://github.com/greenbone/python-gvm/releases) [![PyPI release](https://img.shields.io/pypi/v/python-gvm.svg)](https://pypi.org/project/python-gvm/) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/greenbone/python-gvm/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/greenbone/python-gvm/?branch=main) [![code test coverage](https://codecov.io/gh/greenbone/python-gvm/branch/main/graph/badge.svg)](https://codecov.io/gh/greenbone/python-gvm) [![Build and test](https://github.com/greenbone/python-gvm/actions/workflows/ci-python.yml/badge.svg)](https://github.com/greenbone/python-gvm/actions/workflows/ci-python.yml) The Greenbone Vulnerability Management Python API library (**python-gvm**) is a collection of APIs that help with remote controlling a Greenbone Security Manager (GSM) appliance and its underlying Greenbone Vulnerability Manager (GVM). The library essentially abstracts accessing the communication protocols Greenbone Management Protocol (GMP) and Open Scanner Protocol (OSP). ## Table of Contents - [Documentation](#documentation) - [Installation](#installation) - [Requirements](#requirements) - [Install using pip](#install-using-pip) - [Example](#example) - [Support](#support) - [Maintainer](#maintainer) - [Contributing](#contributing) - [License](#license) ## Documentation The documentation for python-gvm can be found at [https://python-gvm.readthedocs.io/](https://python-gvm.readthedocs.io/en/latest/). Please always take a look at the documentation for further details. This **README** just gives you a short overview. ## Installation ### Version Please consider to always use the **newest** version of `gvm-tools` and `python-gvm`. We freqently update this projects to add features and keep them free from bugs. This is why installing `python-gvm` using pip is recommended. **To use `python-gvm` with an old GMP version (7, 8, 9) you must use a release version** **that is `<21.05`. In the `21.05` release the support of these versions have been dropped.** ### Requirements Python 3.7 and later is supported. ### Install using pip pip 19.0 or later is required. You can install the latest stable release of python-gvm from the Python Package Index using [pip](https://pip.pypa.io/): python3 -m pip install --user python-gvm ## Example ```python3 from gvm.connections import UnixSocketConnection from gvm.protocols.gmp import Gmp from gvm.transforms import EtreeTransform from gvm.xml import pretty_print connection = UnixSocketConnection() transform = EtreeTransform() with Gmp(connection, transform=transform) as gmp: # Retrieve GMP version supported by the remote daemon version = gmp.get_version() # Prints the XML in beautiful form pretty_print(version) # Login gmp.authenticate('foo', 'bar') # Retrieve all tasks tasks = gmp.get_tasks() # Get names of tasks task_names = tasks.xpath('task/name/text()') pretty_print(task_names) ``` ## Support For any question on the usage of python-gvm please use the [Greenbone Community Portal](https://community.greenbone.net/c/gmp). If you found a problem with the software, please [create an issue](https://github.com/greenbone/gvm-tools/issues) on GitHub. ## Maintainer This project is maintained by [Greenbone Networks GmbH](https://www.greenbone.net/). ## Contributing Your contributions are highly appreciated. Please [create a pull request](https://github.com/greenbone/python-gvm/pulls) on GitHub. For bigger changes, please discuss it first in the [issues](https://github.com/greenbone/python-gvm/issues). For development you should use [poetry](https://python-poetry.org) to keep you python packages separated in different environments. First install poetry via pip python3 -m pip install --user poetry Afterwards run poetry install in the checkout directory of python-gvm (the directory containing the `pyproject.toml` file) to install all dependencies including the packages only required for development. The python-gvm repository uses [autohooks](https://github.com/greenbone/autohooks) to apply linting and auto formatting via git hooks. Please ensure the git hooks are active. $ poetry install $ poetry run autohooks activate --force ## License Copyright (C) 2017-2021 [Greenbone Networks GmbH](https://www.greenbone.net/) Licensed under the [GNU General Public License v3.0 or later](LICENSE). python-gvm-21.10.0/RELEASE.md000066400000000000000000000100741413122500400153570ustar00rootroot00000000000000# Release instructions Before creating a new release please do a careful consideration about the version number for the new release. We are following [Calendar Versioning](https://calver.org) and [PEP440](https://www.python.org/dev/peps/pep-0440/). ## Preparing the Required Python Packages * Install development dependencies ```sh poetry install ``` * Install twine for pypi package uploads ```sh python3 -m pip install --user --upgrade twine ``` ## Configuring the Access to the Python Package Index (PyPI) *Note:* This is only necessary for users performing the release process for the first time. * Create an account at [Test PyPI](https://packaging.python.org/guides/using-testpypi/). * Create an account at [PyPI](https://pypi.org/). * Create a pypi configuration file `~/.pypirc` with the following content (Note: `` must be replaced): ```ini [distutils] index-servers = pypi testpypi [pypi] username = [testpypi] repository = https://test.pypi.org/legacy/ username = ``` ## Create a GitHub Token for uploading the release files This step is only necessary if the token has to be created for the first time or if it has been lost. * Open Github Settings at https://github.com/settings/tokens * Create a new token * Copy token and store it carefully * Export token and GitHub user name in your current shell ```sh export GITHUB_TOKEN= export GITHUB_USER= ``` ## Prepare testing the to be released version * Fetch upstream changes ```sh git remote add upstream git@github.com:greenbone/python-gvm.git git fetch upstream git rebase update/main ``` * Get the current version number ```sh poetry run python -m pontos.version show ``` * Update the version number to some dev version e.g. ```sh poetry run python -m pontos.version update 20.8.2dev1 ``` ## Uploading to the PyPI Test Instance * Create a source and wheel distribution: ```sh rm -rf dist build python_gvm.egg-info poetry build ``` * Upload the archives in `dist` to [Test PyPI](https://test.pypi.org/): ```sh twine upload -r testpypi dist/* ``` * Check if the package is available at . ## Testing the Uploaded Package * Create a test directory: ```sh mkdir python-gvm-install-test cd python-gvm-install-test python3 -m venv test-env source test-env/bin/activate pip install -U pip # ensure the environment uses a recent version of pip pip install --pre -I --extra-index-url https://test.pypi.org/simple/ python-gvm ``` * Check install version with a Python script: ```sh python3 -c "from gvm import __version__; print(__version__)" ``` * Remove test environment: ```sh deactivate cd .. rm -rf python-gvm-install-test ``` ## Prepare the Release * Run pontos-release prepare ```sh poetry run pontos-release --project python-gvm --space greenbone prepare --release-version --next-version --git-signing-key ``` * Check git log and tag ``` git log -p # is the changelog correct? # does the version look right? # does the tag point to the correct commit? ``` * If something did go wrong delete the tag, revert the commits and remove the temporary file for the release changelog ``` git tag -d v git reset --hard rm .release.txt.md ``` ## Create the Release * Run pontos-release release ```sh poetry run pontos-release --project python-gvm --space greenbone release --release-version --git-remote-name upstream ## Uploading to the 'real' PyPI * Uploading to PyPI is done automatically after creating a release via GitHub Actions * Check if new version is available at . ## Check the Release * Check the Github release: See https://github.com/greenbone/python-gvm/releases ## Sign tar and zipball * May run pontos-release sign ```sh poetry run pontos-release --project python-gvm --space greenbone sign --release-version ``` python-gvm-21.10.0/changelog.toml000066400000000000000000000003461413122500400166020ustar00rootroot00000000000000commit_types = [ { message = "^add", group = "Added"}, { message = "^remove", group = "Removed"}, { message = "^change", group = "Changed"}, { message = "^fix", group = "Bug Fixes"}, ] changelog_dir = "changelog" python-gvm-21.10.0/changelog/000077500000000000000000000000001413122500400157025ustar00rootroot00000000000000python-gvm-21.10.0/changelog/v21.10.0.md000066400000000000000000000025331413122500400172140ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. ## [21.10.0] - 2021-10-12 ## Added * ng the missing changelog.toml file for [557ac8d](https://github.com/greenbone/python-gvm/commit/557ac8d) * Adding the `types` attribute back to the `Gmp` classes [#568] [d04aea4](https://github.com/greenbone/python-gvm/commit/d04aea4) * ng the Gmp.types attribute back to the Class [aa1dbcd](https://github.com/greenbone/python-gvm/commit/aa1dbcd) * ntry about the change ot the PEP 517 build backend implementation [d362b38](https://github.com/greenbone/python-gvm/commit/d362b38) * ncoding to open calls in tests [e22f171](https://github.com/greenbone/python-gvm/commit/e22f171) * hangelog entry [2dff7fe](https://github.com/greenbone/python-gvm/commit/2dff7fe) ## Changed * Removing all `get_entity_type_from_string()` methods and replace them by `EntityType.from_string()` classmethods [#573] [b6dec3d](https://github.com/greenbone/python-gvm/commit/b6dec3d) * Use encoding for open and read_text [f758bd3](https://github.com/greenbone/python-gvm/commit/f758bd3) ## Bug Fixes * ome typos in protocol gmpv208 [edba56b](https://github.com/greenbone/python-gvm/commit/edba56b) * ng pylint by disable [71d7b55](https://github.com/greenbone/python-gvm/commit/71d7b55) [21.10.0]: https://github.com/greenbone/python-gvm/compare/21.6.1.dev1...21.10.0python-gvm-21.10.0/docs/000077500000000000000000000000001413122500400147035ustar00rootroot00000000000000python-gvm-21.10.0/docs/Makefile000066400000000000000000000011421413122500400163410ustar00rootroot00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = -W # treat warnings as errors SPHINXBUILD = sphinx-build SOURCEDIR = . BUILDDIR = build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) python-gvm-21.10.0/docs/_static/000077500000000000000000000000001413122500400163315ustar00rootroot00000000000000python-gvm-21.10.0/docs/_static/custom.css000066400000000000000000000002021413122500400203470ustar00rootroot00000000000000div.sphinxsidebarwrapper p.description { font-size: 12px; } #contents.toc { background-color: #ffffff; border: none; } python-gvm-21.10.0/docs/_static/greenbone.png000066400000000000000000000243261413122500400210120ustar00rootroot00000000000000‰PNG  IHDRG7ãKiTXtXML:com.adobe.xmp I®: IDATxœíwxÕÚÀ³- HBï$!4AP¨ˆrÙ$VTDÀxQ,èUQŠ ¥(×( ‚ ¢‚‚‹@P Ø)†$´©¾ef¾?ff³Iv“M²› ßþžgždgΜ~ÞyÏ{²,ÓPׯu›îøéÇŸc\={àÞÇßoÐEšõÜ™²,›2žþËù/Ï/·4d¤ºGHä=»Š«ø¬W׫~d@nݤGÞ‘CõoèLô_þËU¹Cç^ ùžàà àªAqÛN8s™ó3=ÀÔ8’³ù‡Âºõ¸dß¾=ã"ž~üø©; )lty¹çÛ*ÿžçæø‘:?¼U ¼»#Šˆþ×úMq±%ªÞcêÇŸ:Ó€ÂFj™væ`‹Ö={Ñ<¢'¿ýþÒ‡ÇOY¬=ÍÏ+0BsìÜ5¯Ž…Œ€c‡¯h¸8ûñã§¶4˜°ùã·£ÍãeW´aä#½xgåk|°âÓ±¹d4mÜ1œ1˜™A÷*½¬{ÿ7dÅ;«'4T¼ýøñS;LØO;Õ@ÆDÿ!'€VŒ›ðÀÛ#o½ÿ(iÝ`#Ǧ'ö]£NÌ~iÁ @@CÅÝ?5ÇÐPû+- 0ÔˆÄNêAâ²s@a£Ï¾^u3@TVØå\,’ƒQfØS]ØðâqNœû­ý¬ç^}ò…9S_i¨ø{ƒèˆÈ(`$UáÒHU/€d HHIOK®ÏxþÓ‰Žˆt5„2=%=m~½GæLv£Ž´hÑÁÈY‹‘ø{¡MÏÞåÜ4k@©(£ ϦçŠx;=ÌxuîâçÖõq/¹ 8Ì&q”4¨¿ãÔkšêö§zŒª?^£Á„Mnvnc€fm ”Š:¬’À¸W›a7a­M”JÊÿo×sÛô@ œ"NMž8õ©úyÝˆŽˆŒA2kéEž£ãÇO½Ñ`ÂÆfõdD@'€Q/Ū‹PZv2`—õ€ÑBQ 4DâÚûcñ’wß™rîlÖ%õûÚlÂëà¿ åçoIƒ Ñnׄ 3ˆè™ug*` ¨q8MìX¥2³’Ö|ŸÆö@!÷Œxà†ˆ-™Fõ‚&ÁÍåÇÏßš3[¬6@tx!¿eé˜ÿ3m";ðÜ·CxäªhÒ¼Á: ìŽ÷¬²@˜NdÀ-Ù·áIßÿÒ³¯>?sîÔÙ ””šà®ë”Œbô ?ÿXL³±Ú,ÍÞ|±€9ñ‡xÛ¬ÝÜ”ÃÛ/Ù³:AD¢ü@ÒÒ34ØqïÅ—§Íš9ãÕ¹õûš9×ZMß‚F óã§^h(Í&àÐï]°wóQž~7žW“c eËÆ4z\Ñ›¤G’e„ /[$Ñ6 úöØÅSÌš7í™NíÓîŸtÏÅ:ÃØ]Ã^ž’žVg£otD¤6Z¥‘’ž_ÁÍH F½@éžÍ¯àFŽ×FÇ*Æ;e8>9%=m¹‡qóŠŸ.ÒHJzšPÁM8eÓ œÓ¹>%=-•Z§úY1ï’QʯZÕmd±bä©~%£äÁújüòy>ø¢4ˆ°{û#/+:ÔzàˆëyäÙPt‚ž³–`ŽÏçèþ}\68”"ÑŽ(Û*h72`Ô‰´èÆ™´S4nÒ™‚ücŒpòÛ£ÇÝ‘Öɪw‹H}eðuTŽèˆÈ‰(ö"WFsNÙ0|U8Ò¡VúQîæýøÂOwTV0/:"r~JzÚt½LUÄ<\—cJBtDä$w N×2”†ëŽp'ÿˆŽˆL&Õf>U]óÁ—eVïݨÛ]´æ‹·§3Œg^ ¥XjÆñ™3%§ÉÈ-àòkѲIç,”J’ºþ»<®L"ñD_ƾq#gvØ…õ—¯P«¯­D©óy¶¡TvWš•såØF͇㣀mj£t…/ü,GtDdœª±y2`šª¥xB Jü=q¿Ì•¿N£U ·a{šjXÞÊŸ•Y½ KAqó6B·Ÿ¿Ú¹fò¬#5¬1’^t‚Œ’ÓäÚõtìªcüªë¸ajÏçeÉEçBЀ¢Ý¨DÿtNñ×\ M·KùvÇgÃw&}}}¥«¸,\Ï>æ.\gÔ/“ǻڗÛç~ºa°ϧxÚ<9¬èÞÕ½úÈ-¬:僯ˬ^„ÍÆ¶Å6 9s¶ƒ¥ÏÚŸÇÐ9"€s 8Ur†\›&AF’¡mg;ÖF2%’PuAé^å—”P`×óè+Êü›Ç&Íx¦’U/DGDN‹Žˆ”+^¾îªâ%S6œ® :W `:Ð9%=MPmWö„_5_øéŠšîqTS÷©(v­éêåîãçlpWµšªò ©SŒÂõdÍU[ñoäƒOËÌçÂæñžŸ5|ÌuÛ.vµáëÍWm)eÿùlrlEè™`\.E¢N±Érµ‘TµG'C¦ÅHdd}ãñKÊ®k÷îÞw¯Òô7Ck,ñjeé—’ž¯^yª:íJ(ÍOIO›ïlLTÿŸä&ç†æu?= §F4ŵ`ðôËŸ‡b7霒ž6]÷ü”ô´~¸nhP¾»küš_ᢄÝåAM5ZåC}”™O…M܀៾ùÞœçÇξ•é3ƒù!'Ã…e‰ UÈxú‰v…1@™]bÀ. œ±2饼>où°º§àïScq7´î®2»t_ÅÈ™s%ó…ŸU¡ G£Pý¬rT§æW1Êâî¾scuw—šQ#P56uÉŸ—™¯„>ºq߉û7Žzá³Û‰‰;Ͼó2FA$P'£ê"b °‰2Û8´ȶØiÙ$Ÿ®×ÆðÙ¦M#hÀI‹#\~éÝ 'µ{Ð~ºÅÓ¡Woá¡àvÙx«™Oåê™Ç¦Žùàó2ózc”D©™ÉÐú‘ü®ï%ßMvéYJ¤Ft°„±véúŒ”o' Ên,¿R* DÆppCKšµ—e(‘Š9SÒˆûžêŌɟy|î#/¿ñì›^JÚ?—•¹ŠÑŠªfAûÒÏ¿ánþ÷–Ÿ¾ÄçeæUa“–’Ñ#ªK»hÑ6ì³Äœ,. @4Ò'¬9Þ}€³'~çŠ;ãi`!ß®'ß®WaÖ"¬BQGç«$žþ¶r Xd»,pÎb¡W„·á•7Ÿ{eæü©_Ó½™ÎZ’€‹~|tDdTm'›ù˜m5p›çá h_øéÇ·Ô¸ÌÁµ"áµnÔO{ÅDui÷³±ktØI×kÕ“^\B·Fz^~ô8gOüÀ⇳è…B~Ø¡£ #Õ"< º@IV~™b±I*¦ßÀAC®ú‘·Òè#þ KÜ /6?ýø–*ËÌ+ÂfïÎßôxɾÖ.5}¾árr¬aüžŸET°• K9øÝweŽóN’ºí[æmgíÌB R"!¡lGÑH/ÑÄ ¤— ÑKêdt2%’D¶Uä†{”-D÷$oøÞÒ5÷{#uÄzYÛy M*Š¡´suÓëØO¯S…½ÂYCõÖ¾CûþE—Y»Q‡~Më}ÕàÞß·éßK÷îÊ®œ±´àXáIé­”fG°qùGj@mX¾ü5®¾¦]»G3þîÇYùÉ›ìê7„·ˆ\°ë« GB‘ŒáI8ú‹ž 2¦`phÒV¦Ys §K¡ïåVnp _½û5ë>ÞxÓøǬ¬kZ눻®ÒD*¬Oªg\vï¨ÛâP_øy1áîá\ÆÉ¸˜9WE¸Ê³ú²[ù¼Ìê$lΞΎº¤OÔÎÐ^Ý KWöàTiéE'8kµbnfä³. lćvÓµ{Yá½ßàëOþÇ–erõ-— à~\”!X/ÓÄ òÛç£äì1.›så˜K0OÈÇ" ¹1˜¯Þ…ã©§ÚÔ%^Â]E©[„NwNT'ˆM¤ö;úyJUB°¶•Ì~^L¸›hçœ6wy‡‹5Wx­Ìj+l ¡Bd"MÚ}úe ùöd”f“e³ÑÔ £G“¶l,ÁVx‚½cyüé]z"‰Š.c\k5ÐÂ$r攎%ãBÑIdz–]{Òåêtb¤c¤HÖ©–ܽÈ`Í+y””¤PÄñÀמּþ‡Æ~X9”ze>UO+¯÷ã…ÕYÄóq=U=ÊÍýŠ”«„¾ð³ph•Ñ‘ž¸/×ȪɃy(«¯«ó³Úí&¼E}”Y­„M϶¿Í'ýÒUßÄ"‡“QšO¶õ¤.6 ­Œ*Q‡u&%=mºjŸÑvRÓºOÉ(†ºŠ}_ŸW:µ¢MRUim‡6W¶#mW9í=·‡æùÂO_’ž¯ÚN´ø´ÿ¡ò.u Nñ­v×;yàì¿–Ú„šŸ 6sÚ—e&Ȳgë”¶nÚ{ýÐkâÆý‹ÉSÂ9^ÒŽÌÒãäÚJ ÖÉXd¶z‚ì<1x)¿ýü'½úô(çÏÃ÷NåÕ ÐuŠdÖG\°ë*-]3ˆlÿTÏöÅÊgÒªxZt+i@ŽDM "‹Ì!û_÷[w½„‡ßkE€¾5A†æh˜ÍýC‘uü×mº{ØÈ›>ñ(üøñãuAÜôú¡ñk›÷ìÎCO†qº´…¶rm¥éd‡q7X_ÊÁ¤ÇK±— ç¾;eô­2¨×MBï¬^@X¯n¼¸&‚µ T)Rœ?kS5'4RÂ*¹_K%IǨ—ZØ¢Ìèf2êÒKäÛ³‘±!@©dB'(ö¡Ù/-|hîaøñã§xÔÐ#~”¶üïêÞäÚc“ld[sÊm×)ÉÊ4EyŠèiÙµ'­® f§}7Drš[‰¼¥×ÜÚŒn=D EÅ¢€Þ… ‘dm©EÍ‚hƒ©ê8‰Í[JÌØAÂêv-ßΉ?~'õÐMtê^Œ,¦EP(ï¾&q.ýOü±ý’èö1RN%÷B;÷ãǨ¶5oæâI3f=ºtò·sÕ`¹öVd–œ ÇVD ®ì]» Mpæ&ìKÌäæGL$J$zǶVI HÔ9f»B[/µà_{€bîYG×+%òíU+bн§©Qä\®Ž¥ž¦äô[GòÀÂîœØcâ«%_Vzoä­ãÖ®ûrÕè*=÷ãÇG¸ëFU)l.äF†5m|¸ûàÓÜEȰt¤À–É©’LvØP3 2áF‘ våünWšKuH@s£HÒjHZ¶®W]ÁC¯p²´õFE”!Ü(adÖÍùeËÎjÞ8°ÿç—÷ë½§æ±õãÇ3µ²Ùü«ÿÐ%`4=ûFg²¬-°IEdZrлØXÛÊSrmzD¹v‚F‹TžMOü½2ícúrtÏ$n Ì z´B\/Ày»Ž<»ž‰³dz^uu¹çC'Ü·î¥]·>ŽØ¿½he|eŸüøñã-Ü ›7ç½ûÀÏǾ»ñ¡…C›H®%‹¤tU|ˆ²ñ˜9Ê$Áolã×ý‚t•­s…ÅösÆbäÊÑ¡Žû¡mº0tB ç?ã2ÇýÝ»övòvüøñS†;aÓúñ_oy/bãeòì­(±_à‚½˜§Ñ'_Gì¼]O§f6®ü× ÒvÈ47ٱʂG DÔѾw)MÚt ]×pr­öäÚiÝãÍZ+÷FƒèƒdøñãGÅåhÔÍƒïž 4š±ä2òìFdÙN¶% ™ú9ûEë*µ1Ù9~:Œ};”•:„Ó.HÏYËyŠD±Ü°»;dÀ “iJþô‚ã,ª\›…àVÁ䜅Áƒ¯>î«ô<ºýº;!@©¯Âðãç" جrõ°’°ùiï/þ·ó“âÇÅÒ<¸„sÖ¦äXNR Ú ÒùV§Ñ„L¨^¢‘Adï¦&|>w a hÏDJ¥PZ†pªø86—§eº¢I3Ÿ¬0¢À. „tˆyvFÿ{äwU½_GÆ7øÐ?~.à©°¹ÿ®É3!„ûþ®tŸÄ\²¬…øXЈ2èd "'3Œ,6‹3•µ›ÅJâÖ`®0—nl„=° gJÏT9„îL~Ž€+‡R*ŠXeæ¦dœx™núwåÕývû&e|ëC¿ýø¹˜øÞ݃rÂfË7;Ì¿ß}ÓÝ3†¢(íd–fº}ò&¢ !z™ ½Ä'ómüúõõ‰‰Ž­z—™OœÆŠ©kØí f¼Õ–"C8&«$º=¢WC–!õL ”«.+!£ÔD¿&E|4GY{µð͹ |˜< Ùú&à?åÁÏÿ »±¨–“!O=üüŒÍ¸íÎ`²¬¡äZN¨ ÔIµÚ”Ü$ P'¬—Xñd>¿~­ÆG˜Jii>ÇÏþL¾”Ê®{€0~Ù¹›ÄM­LEé‚°Ws$Œ^PŽò•ó‹ ¼77€3§NøfÃî¾}üÊ¡·ÅoòQòüøñ£âÐlvlÝ3ð÷“»oýüP!˜|Û2N•}LÏ¥×Ht¸]^Pô@˜Qdõ‹ŽïKÆD;þ8¼“ènÊBÛ•ËÖòÁªµ#€ lû$…Ø›»Д"±QÆõ² L/qp› È`ÏIìùBywÍðÍk7¬ïÝùñãÇa3ýñ%°9ÃF4æx ˆÒyv½[ÄÑíû8s9÷½ލ£ZM¢&H@+“¤µzþܶáØñ}´ïØ€ù³1ý…ÇœÞPV¹§ÿöÇsúÐ,LO°>óv zãRÚñ.?}©ì·Ó»ÛÕ¿†„4²üxà—Þ/>÷ÔÜçgO™íµÄøñã§Jti)]~<´í®á“û#¡§ÀzŠÓYptû/œH>È篔ÒHï½Î”(C3£È‘dÛ–(;ñ½ûÎ;A°éeß™>ݯE–ed9—iϬü¹§˜`½Å±‚»"ÊVî âä/ ¢ýù_ï¾ñ‡äoˆò™¿ ñã§~Ñ<ýÈóã¸kl3Ž €Ä¡Í`q8ü}óQòE=F/Ìe5(ÛF¼ÿ˜²{PÿëyàÁ±åÜ]¸P@ߘ>Ž{£¢ŒåeZÐ :tH.¢ddt¬yA˜›>½ÈТPçDøñã§FaÛÖ£¯Ý‘,K:Hù1§¼ËFÁ˜[e(C#½r Ük÷g£µÿ…o¾ìp³aÝ&Þo-¿Ù@‹MÏ$@§Ó!àzÑ—„¢5}<ÏÅ<þð³óÇÜ\·˜× ³96eÓhç]ÏòÔ+9))qTCÅ­:ÌæØu(ñ^ž””è³3®ÌæX­vM¯*³9vêiII‰uîכͱQʦⶖy(;óMOJJôúÉ®òÕ]Úê« |‰aáKËoÏ7•tú÷“‘üUxRIÄ$düª›Ð]hß«WŽ äJ»êÕe ‰ Ä[å“sô7žxä9®¸ª/_~¾…;îêx§‘Œw§ã÷–$ewDÏ,’(.†(+v ŸLüüõzE]üú’93ji/`6ÇFáúÌäpõòé~»jHHJJ¬Í–“1TÞóŸ„»2Ð6š3›c;'%%zûćšäëß¾ _~ñÕ¨Ûb29]j#H'c—á’ë;Þ6šÇ è™B»La G£$”Ѧ`½D€N™Gsüp+OØ‹d?À´'f1ïµçïÌ~Q9>§O÷køêÛ騩ãÙøÑ"qŽ.1ýé×ÏÂy{¥b©#N¢ ÍM"'SŒ¬Ÿ¹€¯¶®™P§òÎ'#L§òžÂ¾>¶D;“¨¶›§/G©ä푸^¤³ÓÿÚyNá({ñz;ý5É׿} ­ú¸.Œ”ÂRôª±Õ" Œz.™<›Ÿ㉠ÑfôédBô"IGZŠŽ“ûàÏ-™œKSfGµí˧WÒo@™=æ¾Ñ’üû )?*¿Í[ ÞcåÚÅ„´ëÂ3Ë£±Ê(°R Ú0²CÐäeêxgœÒýZøò¢i‘#Ö9—¼ÈßQ®IœÍæØ(ov9¼í_uTk¾Ù« j¯k5ÉWo׳96\õ×å‡N}äyK£3X íÒÑ6:âØ:BåvÅótö°fø ÐÉdäØü±…Ÿüó‡;²ÕåüwÑlny3'ŽŸâ‰GžcæOÑÖ)¾ôì3åü}lüs,Z9—Žýú2oE,¢‘{ l§nZ˜Dr³^þ PÊèÖL™1ùÕšfˆpd€Ù;1))ÑíQîìï«]³e¸¶¥&%%Æ« Åùp±efsì2Pìfs¬vº£ÖpÞí~RRâz5ìcêóåII‰“Ô{šma¹zMCÕàÌæØ<`TRRb‚ú{SZ£Õì!“\Uf5ž#p³9ç°«Â…mÌëv7ö·d5ŽËU7®Ê'UÏzµ +åkaº*ƒpÊò½b¾:ÒëTw:Sv¢g”ú¬\Ø®ìWfsl*J}ÐÒVmú]¡ Sö|}‚}Ýf k§Wf¦XpÿY–ܶŸìòh¡ë¤û¦•CêÙA3yâ :Et`æPM(¯¿º”æLqøÛ7j‹VÎÅ<>žE«:Ph¡HjFž5ƒ|»¢Õ´0Šd¤ëxíöŸ€ln2"aÍúåc]D³¡p>ºt™Ù›k6Ç®3›c'j_˜Z°Eµw~_kзŒ97°<ÊŽÞ€²cd*Õ¬3›c=9¬l$ð廊á”?N6N½¢*¸‰Ò +22!¨1ÑÉöäµl£|¾háüTÓ¼VžFra€’gËœâèª|´²ñ––´ŽÊ†íªÒûJÞ:»Ÿ¨~tPÿ.s?LJ¨鯄îÊÁý¿çôNŸ2RËÅ–¢¬lãùÛN=Kÿ½•óGÑ¥U?6|ú ¥%%dŠGYºr!Íš7åûû™Û† LÛÁS+GòØã9mé@‰HVi*™–|L:™6&;‡÷›x{L"Ïuƒ‡'mNZQíº§~¹GQÖÈÚ1­°kˆ&¦'%% ®¦j¸Ó“’mÓ“’;k÷TÍ©³ó»”·Yxrp8Š0Wß×¾l΂ª3дB8š;Wa$;ù×”2;Suù¤UôT-]@?§xV›Ïfs¬¬]” Âõš–æ&Œ¦”ÙR´çU•OOºT?ZÞMwÊW­î»Kït5¾MîiÂE‹{ЯBœçWpS]ú+axò™‰›ßùpÁËŸÍÏä‰EM)r:Î$”ý~OÖñé3JyLýÏLæ¿ñ¢ÃÍçŸ~ÃØ»¡„åÞ½ëö‰¼·æ ‚ƒƒÊÝ¿Å<†o¶DH·n,ÿdFŽ´âìR>Ù–L΋"az‰f&‘Äزd 7ÆŽÚö¿„O¯«Aôë µ²vV¿ q”©¾á(ZDçªùÉ(zšêgʺǧ;ª_¾‰j0n©0lï* 1j8¿òPùð3pjÜII‰yfsleÈU…ö|½S^:ǧ6Zd*åÁ­†GMsuîVhåƒR> ^´?9ç…» +¦w~…®yE?µ2Y^Ũ¥§é¯„!º[ôσbnÜ´;yóÍ|]–mÕ{<êdddV>£ì=õðø)åÍ|–·–½\î>ݯåÝ÷ß ÿ——»¿í;¸î曀âÆßÀ“O†s¢XäTI6é,Å’„(C;“A€U3¬ú†36ø:IDATn÷Ü1aÝGŸ-¿“‹µ%ÓTRPPMŽ=…¢Fk_¸8pØKÊUª*ÐT}Ÿ¡64WÃþ5ÁS¥Vѧ¹Qç=ÄšfŽ’?Q(]IN÷« CûÂ;—ÏHÊìY©(vªºùë€\‚j~¬°³í¯:7Õ¥¿€w?|cVž›oþpê^ÜK¨Áλ®Z£uŸ6¯ÐaÏú÷.æày+ç,°©›§é$šEþ:bà½IGÀv€©¿ôßù¯¿ðTÕ±½øHJJLpª$5úêª_•~ª¶ Ù]´¿óÌæXO´MÐT4zsó"gaÖT3;O^ógã§'hGÃ:3ß“9FΚ‡Ù»ž2lÅ®«0’QÏq¯P>Ú±»š6»ŒòÝÕº¢ßëŒGé­@žÏûª2ý®0t¿¤ë¾ç¦Î5çÕg_xyÄ1f~Ù‰p£DžÍ½À‘PfçåëØõ~­/û0Or6+>\Ì'«7rç˜anc¼éËm v7C§Ëc˜ÿþeØÄ\~ȱqÞnÁ((›j5ÑK˜t2_,•Ù»º¬ ­ýpã„»Ç[Qe¶40j…sÕp¾W±²Ä¨#1(ÆR—¨w=°^uL}äªÂĨÚTª+u^ÕB܆å´‘¥¸jÂq^5Mší¡’ðTí]©jÃJPýÖ´m4FÆ­) (Â&ÜlŽsÒJãPÊkºsƒVãZµ|´QœT*hÝR!mq¾—€"\4A^Ûô&£vñÍæXGWVM—6^£ô;ãXõ={þ33þë’õ_½?âÙxÓÖw§M¸•\›«,”³ãH(Ûq†í,{E®îu%=/UÎõÞû}2»wía×ŽÝ |…ÛÀÇŒx>Wlp·?v÷O4r$?ƒc%vpìØÂ(r¾Pà͇Ïr!õíšõÌÙõãÿ®‹ìÜñ@õyØàTוДõõª·“çF¨¸Ã¹aj~NT¯C¢Vq&VyIÅ{#&Îñ8æôU¶ w*ºöÕtnhëT¿:«Ï5íîXÅ®EMíb4OÍ.¦……2âSñµåÀ¤jʧ*Ó]Ú\ÅM+¿i(yVÎM-ì€ZÚÂmü[Ò5ô(ý®QŽNii´ÓÄ ¬—ÑK47Š43ÚùîËþÚõ#‡R÷òâ³Ê´–À /{µJAӻ뵪 iÉìuû€ÄÞÜ󤔨1 2&ŒIPF›þ< gÁ ÉAsSìI§²oÿ74P6÷¡bÁk÷ãæšŒ¢¬ÂiB¨•í9Ú¶³F¤©¶£*T²Š~:‡µÞé^‚–×f©ª_>瑸T”‘~.œOWÃvN—#^ÚWTýâN¯àF»¯ QçgÉ(ùW›Éiš`Y! -ž©ªÛ§ß®Êg=n£“ÿ•Òæ†Q”ÍH¯szÝä_¹tÕ ý•py"æœçÎ~~ÎÓÏ)¿‚¸|D ]® &( d»À¹¿$~Øpœ‚´£ê-€,¾Kú‘k‡ p› #þE÷žƒ€LzÄ ouÁ*žçà…RŠ%;Á:e6p˜Aí6-Ùÿ±6›XÏÒE+Ÿœ4ùÞ×ÝàÇëøb6©Ÿšåëß© j|ünNNn—±#\¼yÇz·CÉ­­o/zåé'[–´õû¡±×zÍ8M›¶Í*¹hÜS,ýà¿Ü7{ Ão·s´ ˆ”be}“IP kn²“}AÏò‡NQpüýûÄþ±mÇÆ[CÃ×ÛÔu?~üÔœZõ •™õÎ[«îÚµ}ÏࣇŽEXJ¬—\Þ5åž{G­àÁÑk€"'çíôB«ý™mÞ\¸‚wÞÌÙ3™¼¿âc-_Ñ4¢ÿÝh&XÈà·| Ù6›cï™&z¥«öÝ×6ÏÓ´±P–.zsʤÉÿ~ÍáÇßRkaSSNŸÎéÙ¾}Ä/PXi ½‘SG1üîb2-"ÇŠE첌QPö¶ijÉ-6ðöÃ'(üKéž1ñ³Õë—Mr½I?~üøŒz6Ÿ®ùrÌ]c‡­Ö~¸1Ž{f6F ‡ÔbY @i¤—il±J:ÖÌ+äè¦}\Ùçú}ë¿^1¡}‡ö¿z=r~üøñ)õ*lxCÂÌÿþ_t .åhaE¢Ž`½¢ÍHÀɳ:6¾~ެï wÄ5ûWo|{JïËzíòI¤üøñãsê]ØÄ–”´çë!Ñ£ûмe‹È…\éG‹~:‰º¥„-þÊ;>_üþüW»vë|Qí=ãÇŸšÓ ÂÜçÖ5;ýúúFt*hÒ¨Q‘QÐÙ ìr‡®íSÆ=4vã¤ÇÇ|AŽ=ýøñó·Å°ù?/Ë+ýæ°IEND®B`‚python-gvm-21.10.0/docs/_templates/000077500000000000000000000000001413122500400170405ustar00rootroot00000000000000python-gvm-21.10.0/docs/_templates/sidebarlogo.html000066400000000000000000000005041413122500400222170ustar00rootroot00000000000000

{{ project }}

Remote Control of Your Greenbone Vulnerability Manager (GVM)

python-gvm-21.10.0/docs/api/000077500000000000000000000000001413122500400154545ustar00rootroot00000000000000python-gvm-21.10.0/docs/api/api.rst000066400000000000000000000007311413122500400167600ustar00rootroot00000000000000.. _api: Developer Interface =================== This part of the documentation covers all public interfaces of python-gvm. The API consists of the main module containing version information, connection classes for establishing a communication to a remote server, protocol modules to talk the communication languages, possible raised errors, additional utilities and xml helpers. .. toctree:: main connections transforms protocols errors other python-gvm-21.10.0/docs/api/connections.rst000066400000000000000000000005601413122500400205310ustar00rootroot00000000000000.. _connections: Connections ----------- .. automodule:: gvm.connections .. autoclass:: GvmConnection :members: .. autoclass:: SSHConnection :members: :inherited-members: .. autoclass:: TLSConnection :members: :inherited-members: .. autoclass:: UnixSocketConnection :members: :inherited-members: .. autoclass:: DebugConnection :members: python-gvm-21.10.0/docs/api/errors.rst000066400000000000000000000001051413122500400175160ustar00rootroot00000000000000.. _errors: Errors ====== .. automodule:: gvm.errors :members: python-gvm-21.10.0/docs/api/gmp.rst000066400000000000000000000002541413122500400167720ustar00rootroot00000000000000.. _gmp: .. avoid TOCtree warning by marking this file as orphan :orphan: GMP ^^^ .. automodule:: gvm.protocols.gmp Protocol -------- .. autoclass:: Gmp :members: python-gvm-21.10.0/docs/api/gmpv208.rst000066400000000000000000000031461413122500400174150ustar00rootroot00000000000000.. _gmpv208: GMP v20.8 ^^^^^^^^^ .. automodule:: gvm.protocols.gmpv208 Enums ----- .. autoclass:: AlertCondition :members: :undoc-members: :noindex: .. autoclass:: AlertEvent :members: :undoc-members: :noindex: .. autoclass:: AlertMethod :members: :undoc-members: :noindex: .. autoclass:: AliveTest :members: :undoc-members: :noindex: .. autoclass:: CredentialFormat :members: :undoc-members: :noindex: .. autoclass:: CredentialType :members: :undoc-members: :noindex: .. autoclass:: EntityType :members: :undoc-members: :noindex: .. autoclass:: FeedType :members: :undoc-members: :noindex: .. autoclass:: FilterType :members: :undoc-members: :noindex: .. autoclass:: HelpFormat :members: :undoc-members: :noindex: .. autoclass:: HostsOrdering :members: :undoc-members: :noindex: .. autoclass:: InfoType :members: :undoc-members: :noindex: .. autoclass:: PermissionSubjectType :members: :undoc-members: :noindex: .. autoclass:: ScannerType :members: :undoc-members: :noindex: .. autoclass:: PortRangeType :members: :undoc-members: :noindex: .. autoclass:: SeverityLevel :members: :undoc-members: :noindex: .. autoclass:: SnmpAuthAlgorithm :members: :undoc-members: :noindex: .. autoclass:: SnmpPrivacyAlgorithm :members: :undoc-members: :noindex: .. autoclass:: TicketStatus :members: :undoc-members: :noindex: Protocol -------- .. autoclass:: Gmp :members: :inherited-members: python-gvm-21.10.0/docs/api/gmpv214.rst000066400000000000000000000025341413122500400174120ustar00rootroot00000000000000.. _gmpv214: GMP v21.4 ^^^^^^^^^ .. automodule:: gvm.protocols.gmpv214 Enums ----- .. autoclass:: AlertCondition :members: :undoc-members: .. autoclass:: AlertEvent :members: :undoc-members: .. autoclass:: AlertMethod :members: :undoc-members: .. autoclass:: AliveTest :members: :undoc-members: .. autoclass:: CredentialFormat :members: :undoc-members: .. autoclass:: CredentialType :members: :undoc-members: .. autoclass:: EntityType :members: :undoc-members: .. autoclass:: FeedType :members: :undoc-members: .. autoclass:: FilterType :members: :undoc-members: .. autoclass:: HostsOrdering :members: :undoc-members: .. autoclass:: HelpFormat :members: :undoc-members: .. autoclass:: InfoType :members: :undoc-members: .. autoclass:: PermissionSubjectType :members: :undoc-members: .. autoclass:: ScannerType :members: :undoc-members: .. autoclass:: PortRangeType :members: :undoc-members: .. autoclass:: SeverityLevel :members: :undoc-members: .. autoclass:: SnmpAuthAlgorithm :members: :undoc-members: .. autoclass:: SnmpPrivacyAlgorithm :members: :undoc-members: .. autoclass:: TicketStatus :members: :undoc-members: Protocol -------- .. autoclass:: Gmp :members: :inherited-members: python-gvm-21.10.0/docs/api/main.rst000066400000000000000000000001441413122500400171310ustar00rootroot00000000000000.. _main: Main ==== .. automodule:: gvm .. autodata:: __version__ .. autofunction:: get_version python-gvm-21.10.0/docs/api/ospv1.rst000066400000000000000000000001711413122500400172550ustar00rootroot00000000000000.. _ospv1: OSP v1 ^^^^^^ .. automodule:: gvm.protocols.ospv1 .. autoclass:: Osp :members: :inherited-members: python-gvm-21.10.0/docs/api/other.rst000066400000000000000000000001451413122500400173270ustar00rootroot00000000000000Utils ----- .. automodule:: gvm.utils :members: XML --- .. automodule:: gvm.xml :members: python-gvm-21.10.0/docs/api/protocols.rst000066400000000000000000000006311413122500400202320ustar00rootroot00000000000000.. _protocols: Protocols --------- .. automodule:: gvm.protocols .. toctree:: :maxdepth: 2 gmpv208 gmpv214 ospv1 Dynamic ^^^^^^^ To dynamically use the supported GMP version of the manager daemon see :mod:`gvm.protocols.gmp` for details. "latest" protocols ^^^^^^^^^^^^^^^^^^ .. automodule:: gvm.protocols.latest "next" protocols ^^^^^^^^^^^^^^^^ .. automodule:: gvm.protocols.next python-gvm-21.10.0/docs/api/transforms.rst000066400000000000000000000001251413122500400204020ustar00rootroot00000000000000.. _transforms: Transforms ========== .. automodule:: gvm.transforms :members: python-gvm-21.10.0/docs/conf.py000066400000000000000000000134061413122500400162060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # pylint: disable=invalid-name,redefined-builtin,wrong-import-position import os import sys sys.path.insert(0, os.path.abspath('..')) import gvm # -- Project information ----------------------------------------------------- project = 'python-gvm' copyright = '2018 - 2021, Greenbone Networks GmbH' author = 'Greenbone Networks GmbH' # The short X.Y version version = f'{gvm.__version__[0]}.{gvm.__version__[1]}' # The full version, including alpha/beta/rc tags release = gvm.get_version() # -- General configuration --------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.githubpages', 'sphinx.ext.napoleon', 'sphinx_autodoc_typehints', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ['build'] # The name of the Pygments (syntax highlighting) style to use. pygments_style = None # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'alabaster' html_favicon = 'favicon.gif' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # html_theme_options = { 'github_user': 'greenbone', 'github_repo': 'python-gvm', 'github_banner': True, 'show_powered_by': False, } # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # The default sidebars (for documents that don't match any pattern) are # defined by theme itself. Builtin themes are using these templates by # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', # 'searchbox.html']``. # # html_sidebars = {} html_sidebars = { '**': [ 'sidebarlogo.html', 'localtoc.html', 'relations.html', 'searchbox.html', ] } html_show_sourcelink = False # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = project + '-doc' # -- Options for LaTeX output ------------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ( master_doc, project + '.tex', project + ' Documentation', 'Greenbone Networks GmbH', 'manual', ) ] # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [(master_doc, project, project + ' Documentation', [author], 1)] # -- Options for Texinfo output ---------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( master_doc, project, project + ' Documentation', author, project, 'One line description of project.', 'Miscellaneous', ) ] # -- Options for Epub output ------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project # The unique identifier of the text. This can be a ISBN number # or the project homepage. # # epub_identifier = '' # A unique identification for the text. # # epub_uid = '' # A list of files that should not be packed into the epub file. epub_exclude_files = ['search.html'] # -- Extension configuration ------------------------------------------------- python-gvm-21.10.0/docs/favicon.gif000066400000000000000000000011151413122500400170150ustar00rootroot00000000000000GIF89aÆh#26D$8F'8K$OUGM\8Ef(Lj"Qc>Lu&Pw%Vu*Wu+Rv4Z}&hnb\~.\€)[‚#Z…V‡#lpea6^‚;m|_k‡C_’+e1f’4hš!k–/|„ss’Fk"„viŸ$fŸ2h¤w‘Uƒƒƒi¦l¥{j|•Z…Š~k¦6ƒ‘nsª!z¡AŒŒŒo±o³ ~›dq±nµ …˜lŠ“|o¹r¸ s¯;p¾u²5rµ0q¿q¿qÀrÀªSrÀ’–vº#sÂv¿ €®X‰§p˜˜˜°YyÂuÆ v¾;wÆ~¾;yÃ0›¢””¬sŸ Ÿ’²c–®t|Ë «~Õ€Ó!Ô2‹ÊZÈ^„Û*‹ÚJ···¸¸¸º»¹¶Æ¥¼Á´®Ó‹çéç% % % % % % % % % % % % % % % % % % % % % % % % !þCreated with The GIMP!ù ,‘€‚ƒ„…†‚cg*‡†="Œ„ Za’J$XN’I?AAHF4‡]>VA9 †L[e0D 5„f\A26¥¥ƒ`G¥¥(_AM&‚^:Ï/8'-BƒQ!@A3E1YO%.„+`_. To clone the public repository run:: git clone git://github.com/greenbone/python-gvm Once there is a copy of the source, it can be embedded it the own application as follows:: pip install -e /path/to/python-gvm .. _pip: https://pip.pypa.io/en/stable/ .. _pipenv: https://pipenv.readthedocs.io/en/latest/ .. _poetry: https://python-poetry.org/ python-gvm-21.10.0/docs/requirements.txt000066400000000000000000000000711413122500400201650ustar00rootroot00000000000000lxml paramiko defusedxml sphinx sphinx-autodoc-typehints python-gvm-21.10.0/docs/usage.rst000066400000000000000000000257651413122500400165600ustar00rootroot00000000000000.. _usage: Usage ===== .. contents:: :local: :class: toc :backlinks: none Introduction ------------ To communicate with a remote server via one of the :ref:`GVM protocols ` it is required to decide which transport protocol should be used for the :ref:`connection `. Currently two protocols – namely :py:class:`GMP ` and :py:class:`OSP ` – and three connection types – namely :py:class:`TLS `, :py:class:`SSH ` and :py:class:`Unix domain socket ` – are available. Using GMP --------- The **Greenbone Management Protocol (GMP)** is the protocol implemented by the `Greenbone Vulnerability Manager Daemon – gvmd `_. It is also used by the `Greenbone Security Assistant Daemon `_ to request all of its information from **gvmd**. Making a Simple Request ^^^^^^^^^^^^^^^^^^^^^^^ To create a request, a :ref:`connection ` type has to be chosen. The decision depends on the location and configuration of the remote **gvmd** server. For local communication :py:class:`Unix domain socket ` fits best. The simplest command is to request the **GMP** version used by the remote **gvmd**. Step by Step """""""""""" The following shows the process of a simple request in more detail. 1. Import the necessary classes: .. code-block:: python from gvm.connections import UnixSocketConnection from gvm.protocols.gmp import Gmp 2. Specify the path to the Unix domain socket in the file system: .. note:: If **gvmd** is provided by a package of the distribution, it should be ``/var/run/gvmd.sock``. If **gvmd** was built from source and did not set a prefix, the default path can be used by setting ``path = None``. .. code-block:: python path = '/var/run/gvmd.sock' 3. Create a connection and a gmp object: .. code-block:: python connection = UnixSocketConnection(path=path) 4. Establish a connection to be able to make a request on **gvmd**. To automatically connect and disconnect, a Python `with statement `_ should be used. .. note:: By default all request methods of the :py:class:`gmp ` object return the response as UTF-8 encoded string. 5. Obtain the protocol version of the **gvmd** by printing the response of the unprivileged command ``*get_version*``: .. code-block:: python with Gmp(connection=connection) as gmp: print(gmp.get_version()) Full Example """""""""""" .. code-block:: python from gvm.connections import UnixSocketConnection from gvm.protocols.gmp import Gmp # path to unix socket path = '/var/run/gvmd.sock' connection = UnixSocketConnection(path=path) # using the with statement to automatically connect and disconnect to gvmd with Gmp(connection=connection) as gmp: # get the response message returned as a utf-8 encoded string response = gmp.get_version() # print the response message print(response) On success the response will look as follows: .. code-block:: xml 9.0 Privileged Request ^^^^^^^^^^^^^^^^^^ Most requests to **gvmd** require permissions to access data. Therefore it is required to authenticate against **gvmd**. Step by Step """""""""""" 1. Import the necessary classes: .. code-block:: python from gvm.connections import UnixSocketConnection from gvm.protocols.gmp import Gmp 2. Create a connection: .. code-block:: python path = '/var/run/gvmd.sock' connection = UnixSocketConnection(path=path) 3. In this case, an `Etree Element`_ should be obtained from the response to be able to extract specific information. To do so, pass a :py:mod:`transform ` to the :py:class:`Gmp ` constructor. Additionally, a :py:class:`GvmError ` should be raised if the status of the response was not *ok*. Therefore choose a :py:class:`EtreeCheckCommandTransform `: .. code-block:: python from gvm.transforms import EtreeCheckCommandTransform transform = EtreeCheckCommandTransform() .. note:: By choosing a :py:class:`EtreeCheckCommandTransform ` it is ensured that calling a privileged command always fails, e.g. calling .. code-block:: python with Gmp(connection=connection, transform=transform) as gmp: gmp.get_task() without being authenticated will throw an error now. 5. Set a user name and a password for authentication: .. code-block:: python username = 'foo' password = 'bar' 6. Create a connection, do the authentication, request all tasks with 'weekly' in their name and list their full names: .. code-block:: python from gvm.errors import GvmError try: with Gmp(connection=connection, transform=transform) as gmp: gmp.authenticate(username, password) tasks = gmp.get_tasks(filter_string='name~weekly') for task in tasks.xpath('task'): print(task.find('name').text) except GvmError as e: print('An error occurred', e) .. _Etree Element: https://docs.python.org/3/library/xml.etree.elementtree.html#element-objects Full Example """""""""""" .. code-block:: python import sys from gvm.connections import UnixSocketConnection from gvm.errors import GvmError from gvm.protocols.gmp import Gmp from gvm.transforms import EtreeCheckCommandTransform path = '/var/run/gvmd.sock' connection = UnixSocketConnection(path=path) transform = EtreeCheckCommandTransform() username = 'foo' password = 'bar' try: tasks = [] with Gmp(connection=connection, transform=transform) as gmp: gmp.authenticate(username, password) tasks = gmp.get_tasks(filter_string='name~weekly') for task in tasks.xpath('task'): print(task.find('name').text) except GvmError as e: print('An error occurred', e, file=sys.stderr) Using OSP --------- The **Open Scanner Protocol (OSP)** is a communication protocol implemented by a base class for scanner wrappers `Open Scanner Protocol Daemon – ospd `_. **OSP** creates a unified interface for different security scanners and makes their control flow and scan results consistently available under the `Greenbone Vulnerability Manager Daemon – gvmd `_. In many ways, **OSP** is similar to **Greenbone Management Protocol (GMP)**: XML-based, stateless and with a non-permanent connection. Making a Simple Request ^^^^^^^^^^^^^^^^^^^^^^^ To create a request you have to choose a :ref:`connection ` type. The decision depends on the location and configuration of the remote **ospd-wrapper** server. For local communication :py:class:`Unix domain socket ` fits best, but also a :py:class:`secure TLS connection ` is possible. The simplest command is to request the server version. Step by Step """""""""""" 1. Import the necessary classes: .. code-block:: python from gvm.connections import UnixSocketConnection from gvm.protocols.latest import Osp 2. The path to the Unix domain socket in the file system is given during the start of the ospd-wrapper. Specify the path to the Unix domain socket in the file system: .. code-block:: python path = '/tmp/ospd-wrapper.sock' 3. Create a connection and an osp object: .. code-block:: python connection = UnixSocketConnection(path=path) osp = Osp(connection=connection) 4. Establish a connection to be able to make a request on **ospd-wrapper**. To automatically connect and disconnect, a Python `with statement `_ should be used. .. note:: By default all request methods of the :py:class:`osp ` object return the response as UTF-8 encoded string. 5. Obtain the **OSP** protocol version, the **ospd** base implementation class and the **ospd-wrapper** server version by printing the response of the command ``get_version``: .. code-block:: python with osp: print(osp.get_version()) Full Example """""""""""" .. code-block:: python from gvm.connections import UnixSocketConnection from gvm.protocols.latest import Osp # path to unix socket path = '/var/run/ospd-wrapper.sock' connection = UnixSocketConnection(path=path) osp = Osp(connection=connection) # using the with statement to automatically connect and disconnect to ospd with osp: # get the response message returned as a utf-8 encoded string response = osp.get_version() # print the response message print(response) On success the response will look as follows: .. code-block:: xml OSP1.2OSPd1.4b1some-wrapperWrapper 6.0beta+2 Debugging --------- Sometimes networking setups can be complex and hard to follow. Connections may be aborted randomly or an invalid command may have arrived at the server side. Because of this, it may be necessary to debug the connection handling and especially the protocol commands. **python-gvm** uses the `logging`_ package internally. To enable a simple debug output appended to a *debug.log* file the following code can be used: .. code-block:: python import logging logging.basicConfig(filename='debug.log', level=logging.DEBUG) With this simple addition it is already possible to debug ssh connection problems. But what if a response did not contain the expected data and it is important to know in detail which command has been send to the server? In this case it is necessary to wrap the actual connection in a :py:class:`DebugConnection ` class. Example using GMP: .. code-block:: python from gvm.connections import UnixSocketConnection, DebugConnection from gvm.protocols.gmp import Gmp path = '/var/run/gvmd.sock' socketconnection = UnixSocketConnection(path=path) connection = DebugConnection(socketconnection) with Gmp(connection=connection) as gmp: gmp.get_version() With this change the file *debug.log* will contain something as follows:: DEBUG:gvm.connections:Sending 14 characters. Data DEBUG:gvm.connections:Read 97 characters. Data 9.0 .. _logging: https://docs.python.org/3/library/logging.html python-gvm-21.10.0/gvm/000077500000000000000000000000001413122500400145445ustar00rootroot00000000000000python-gvm-21.10.0/gvm/__init__.py000066400000000000000000000021041413122500400166520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Main module of python-gvm. """ from .__version__ import __version__ def get_version() -> str: """Returns the version of python-gvm as a string in `PEP440`_ compliant format. Returns: Current version of python-gvm .. _PEP440: https://www.python.org/dev/peps/pep-0440 """ return __version__ python-gvm-21.10.0/gvm/__version__.py000066400000000000000000000001501413122500400173730ustar00rootroot00000000000000# pylint: disable=invalid-name # THIS IS AN AUTOGENERATED FILE. DO NOT TOUCH! __version__ = "21.10.0" python-gvm-21.10.0/gvm/connections.py000066400000000000000000000436211413122500400174460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Module for connections to GVM server daemons like gvmd and ospd. """ import base64 import hashlib import logging import socket as socketlib import ssl import sys import time from pathlib import Path from typing import Optional, Union import paramiko from lxml import etree from gvm.errors import GvmError logger = logging.getLogger(__name__) BUF_SIZE = 16 * 1024 DEFAULT_READ_TIMEOUT = 60 # in seconds DEFAULT_TIMEOUT = 60 # in seconds DEFAULT_GVM_PORT = 9390 DEFAULT_UNIX_SOCKET_PATH = "/var/run/gvmd.sock" DEFAULT_SSH_PORT = 22 DEFAULT_SSH_USERNAME = "gmp" DEFAULT_SSH_PASSWORD = "" DEFAULT_HOSTNAME = '127.0.0.1' DEFAULT_KNOWN_HOSTS_FILE = ".ssh/known_hosts" MAX_SSH_DATA_LENGTH = 4095 class XmlReader: """ Read a XML command until its closing element """ def _start_xml(self): self._first_element = None # act on start and end element events and # allow huge text data (for report content) self._parser = etree.XMLPullParser( events=("start", "end"), huge_tree=True ) def _is_end_xml(self): for action, obj in self._parser.read_events(): if not self._first_element and action in "start": self._first_element = obj.tag if ( self._first_element and action in "end" and str(self._first_element) == str(obj.tag) ): return True return False def _feed_xml(self, data): try: self._parser.feed(data) except etree.ParseError as e: raise GvmError( f"Cannot parse XML response. Response data read {data}", e, ) from None class GvmConnection(XmlReader): """ Base class for establishing a connection to a remote server daemon. Arguments: timeout: Timeout in seconds for the connection. None to wait indefinitely """ def __init__(self, timeout: Optional[int] = DEFAULT_TIMEOUT): self._socket = None self._timeout = timeout if timeout is not None else DEFAULT_TIMEOUT def _read(self) -> bytes: return self._socket.recv(BUF_SIZE) def connect(self): """Establish a connection to a remote server""" raise NotImplementedError def send(self, data: Union[bytes, str]) -> None: """Send data to the connected remote server Arguments: data: Data to be send to the server. Either utf-8 encoded string or bytes. """ if self._socket is None: raise GvmError("Socket is not connected") if isinstance(data, str): return self._socket.sendall(data.encode()) else: return self._socket.sendall(data) def read(self) -> str: """Read data from the remote server Returns: str: data as utf-8 encoded string """ response = "" self._start_xml() if self._timeout is not None: now = time.time() break_timeout = now + self._timeout while True: data = self._read() if not data: # Connection was closed by server raise GvmError("Remote closed the connection") self._feed_xml(data) response += data.decode("utf-8", errors="ignore") if self._is_end_xml(): break if self._timeout is not None: now = time.time() if now > break_timeout: raise GvmError("Timeout while reading the response") return response def disconnect(self): """Disconnect and close the connection to the remote server""" try: if self._socket is not None: self._socket.close() except OSError as e: logger.debug("Connection closing error: %s", e) def finish_send(self): """Indicate to the remote server you are done with sending data""" # shutdown socket for sending. only allow reading data afterwards self._socket.shutdown(socketlib.SHUT_WR) class SSHConnection(GvmConnection): """ SSH Class to connect, read and write from GVM via SSH Arguments: timeout: Timeout in seconds for the connection. hostname: DNS name or IP address of the remote server. Default is 127.0.0.1. port: Port of the remote SSH server. Default is port 22. username: Username to use for SSH login. Default is "gmp". password: Passwort to use for SSH login. Default is "". """ def __init__( self, *, timeout: Optional[int] = DEFAULT_TIMEOUT, hostname: Optional[str] = DEFAULT_HOSTNAME, port: Optional[int] = DEFAULT_SSH_PORT, username: Optional[str] = DEFAULT_SSH_USERNAME, password: Optional[str] = DEFAULT_SSH_PASSWORD, known_hosts_file: Optional[str] = None, ): super().__init__(timeout=timeout) self.hostname = hostname if hostname is not None else DEFAULT_HOSTNAME self.port = int(port) if port is not None else DEFAULT_SSH_PORT self.username = ( username if username is not None else DEFAULT_SSH_USERNAME ) self.password = ( password if password is not None else DEFAULT_SSH_PASSWORD ) self.known_hosts_file = ( Path(known_hosts_file) if known_hosts_file is not None else Path.home() / DEFAULT_KNOWN_HOSTS_FILE ) def _send_all(self, data) -> int: """Returns the sum of sent bytes if success""" sent_sum = 0 while data: sent = self._stdin.channel.send(data) if not sent: # Connection was closed by server raise GvmError("Remote closed the connection") sent_sum += sent data = data[sent:] return sent_sum def _ssh_authentication_input_loop( self, hostkeys: paramiko.HostKeys, key: paramiko.PKey ) -> None: # Ask user for permission to continue # let it look like openssh sha64_fingerprint = base64.b64encode( hashlib.sha256(base64.b64decode(key.get_base64())).digest() ).decode("utf-8")[:-1] key_type = key.get_name().replace('ssh-', '').upper() print( f"The authenticity of host '{self.hostname}' can't " "be established." ) print(f"{key_type} key fingerprint is {sha64_fingerprint}.") print('Are you sure you want to continue connecting (yes/no)? ', end='') add = input() while True: if add == 'yes': hostkeys.add(self.hostname, key.get_name(), key) # ask user if the key should be added permanently print( f'Do you want to add {self.hostname} ' 'to known_hosts (yes/no)? ', end='', ) save = input() while True: if save == 'yes': try: hostkeys.save(filename=self.known_hosts_file) except OSError as e: raise GvmError( 'Something went wrong with writing ' f'the known_hosts file: {e}' ) from None logger.info( "Warning: Permanently added '%s' (%s) to " "the list of known hosts.", self.hostname, key_type, ) break elif save == 'no': logger.info( "Warning: Host '%s' (%s) not added to " "the list of known hosts.", self.hostname, key_type, ) break else: print("Please type 'yes' or 'no': ", end='') save = input() break elif add == 'no': return sys.exit( 'User denied key. Host key verification failed.' ) else: print("Please type 'yes' or 'no': ", end='') add = input() def _get_remote_host_key(self): """Get the remote host key for ssh connection""" try: tmp_socket = socketlib.socket() tmp_socket.connect((self.hostname, 22)) except OSError as e: raise GvmError( "Couldn't establish a connection to fetch the" f" remote server key: {e}" ) from None trans = paramiko.transport.Transport(tmp_socket) try: trans.start_client() except paramiko.SSHException as e: raise GvmError( f"Couldn't fetch the remote server key: {e}" ) from None key = trans.get_remote_server_key() try: trans.close() except paramiko.SSHException as e: raise GvmError( f"Couldn't close the connection to the remote server key: {e}" ) from None return key def _ssh_authentication(self) -> None: """Search/add/save the servers key for the SSH authentication process""" # set to reject policy (avoid MITM attacks) self._socket.set_missing_host_key_policy(paramiko.RejectPolicy()) # openssh is posix, so this might only a posix approach # https://stackoverflow.com/q/32945533 try: # load the keys into paramiko and check if remote is in the list self._socket.load_host_keys(filename=self.known_hosts_file) except OSError as e: raise GvmError( 'Something went wrong with reading ' f'the known_hosts file: {e}' ) from None hostkeys = self._socket.get_host_keys() if not hostkeys.lookup(self.hostname): # Key not found, so connect to remote and fetch the key # with the paramiko Transport protocol key = self._get_remote_host_key() self._ssh_authentication_input_loop(hostkeys=hostkeys, key=key) def connect(self) -> None: """ Connect to the SSH server and authenticate to it """ self._socket = paramiko.SSHClient() self._ssh_authentication() try: self._socket.connect( hostname=self.hostname, username=self.username, password=self.password, timeout=self._timeout, port=int(self.port), allow_agent=False, look_for_keys=False, ) self._stdin, self._stdout, self._stderr = self._socket.exec_command( "", get_pty=False ) except ( paramiko.BadHostKeyException, paramiko.AuthenticationException, paramiko.SSHException, ConnectionError, ) as e: raise GvmError(f"SSH Connection failed: {e}") from None def _read(self) -> bytes: return self._stdout.channel.recv(BUF_SIZE) def send(self, data: Union[bytes, str]) -> int: return self._send_all(data) def finish_send(self): # shutdown socket for sending. only allow reading data afterwards self._stdout.channel.shutdown(socketlib.SHUT_WR) def disconnect(self) -> None: """Disconnect and close the connection to the remote server""" try: if self._socket is not None: self._socket.close() except OSError as e: logger.debug("Connection closing error: %s", e) raise e except AttributeError: logger.debug("Connection might already be closed. No socket found.") if self._socket: del self._socket, self._stdin, self._stdout, self._stderr class TLSConnection(GvmConnection): """ TLS class to connect, read and write from a remote GVM daemon via TLS secured socket. Arguments: timeout: Timeout in seconds for the connection. hostname: DNS name or IP address of the remote TLS server. port: Port for the TLS connection. Default is 9390. certfile: Path to PEM encoded certificate file. See `python certificates`_ for details. cafile: Path to PEM encoded CA file. See `python certificates`_ for details. keyfile: Path to PEM encoded private key. See `python certificates`_ for details. password: Password for the private key. If the password argument is not specified and a password is required it will be interactively prompt the user for a password. .. _python certificates: https://docs.python.org/3/library/ssl.html#certificates """ def __init__( self, *, certfile: Optional[str] = None, cafile: Optional[str] = None, keyfile: Optional[str] = None, hostname: Optional[str] = DEFAULT_HOSTNAME, port: Optional[int] = DEFAULT_GVM_PORT, password: Optional[str] = None, timeout: Optional[int] = DEFAULT_TIMEOUT, ): super().__init__(timeout=timeout) self.hostname = hostname if hostname is not None else DEFAULT_HOSTNAME self.port = port if port is not None else DEFAULT_GVM_PORT self.certfile = certfile self.cafile = cafile self.keyfile = keyfile self.password = password def _new_socket(self): transport_socket = socketlib.socket( socketlib.AF_INET, socketlib.SOCK_STREAM ) if self.certfile and self.cafile and self.keyfile: context = ssl.create_default_context( ssl.Purpose.SERVER_AUTH, cafile=self.cafile ) context.check_hostname = False context.load_cert_chain( certfile=self.certfile, keyfile=self.keyfile, password=self.password, ) sock = context.wrap_socket(transport_socket, server_side=False) else: context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) sock = context.wrap_socket(transport_socket) sock.settimeout(self._timeout) return sock def connect(self): self._socket = self._new_socket() self._socket.connect((self.hostname, int(self.port))) class UnixSocketConnection(GvmConnection): """ UNIX-Socket class to connect, read, write from a GVM server daemon via direct communicating UNIX-Socket Arguments: path: Path to the socket. Default is "/var/run/gvmd.sock". timeout: Timeout in seconds for the connection. Default is 60 seconds. """ def __init__( self, *, path: Optional[str] = DEFAULT_UNIX_SOCKET_PATH, timeout: Optional[int] = DEFAULT_TIMEOUT, ) -> None: super().__init__(timeout=timeout) self.path = path if path is not None else DEFAULT_UNIX_SOCKET_PATH def connect(self) -> None: """Connect to the UNIX socket""" self._socket = socketlib.socket( socketlib.AF_UNIX, socketlib.SOCK_STREAM ) self._socket.settimeout(self._timeout) try: self._socket.connect(self.path) except FileNotFoundError: raise GvmError(f"Socket {self.path} does not exist") from None except ConnectionError: raise GvmError(f"Could not connect to socket {self.path}") from None class DebugConnection: """Wrapper around a connection for debugging purposes Allows to debug the connection flow including send and read data. Internally it uses the python `logging`_ framework to create debug messages. Please take a look at `the logging tutorial `_ for further details. Usage example: .. code-block:: python import logging logging.basicConfig(level=logging.DEBUG) socketconnection = UnixSocketConnection(path='/var/run/gvm.sock') connection = DebugConnection(socketconnection) gmp = Gmp(connection=connection) Arguments: connection: GvmConnection to observe .. _logging: https://docs.python.org/3/library/logging.html """ def __init__(self, connection: GvmConnection): self._connection = connection def read(self) -> str: data = self._connection.read() logger.debug("Read %s characters. Data %s", len(data), data) self.last_read_data = data return data def send(self, data): self.last_send_data = data logger.debug("Sending %s characters. Data %s", len(data), data) return self._connection.send(data) def connect(self): logger.debug("Connecting") return self._connection.connect() def disconnect(self): logger.debug("Disconnecting") return self._connection.disconnect() def finish_send(self): logger.debug("Finish send") self._connection.finish_send() python-gvm-21.10.0/gvm/errors.py000066400000000000000000000127241413122500400164400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Module for GVM errors """ from typing import Optional class GvmError(Exception): """An exception for gvm errors Base class for all exceptions originating in python-gvm. """ def __init__(self, message: str, *args): super().__init__(message, *args) self.message = message def __repr__(self): return f'<{self.__class__.__name__} message="{self.message}">' def __str__(self): return self.message class GvmClientError(GvmError): """An exception for gvm client errors Base class for all exceptions originating in python-gvm. """ class GvmServerError(GvmError): """An exception for gvm server errors Derives from :py:class:`GvmError` Arguments: status: The HTTP response status message: Error message to be displayed. Takes precedence over argument and function """ def __init__(self, status: str = None, message: str = None): super().__init__(message, status) self.status = status def __str__(self): return f'Server Error {self.status}. {self.message}' def __repr__(self): return ( f'<{self.__class__.__name__} status="{self.status}"' f' message="{self.message}">' ) class GvmResponseError(GvmClientError): """An exception for gvm server errors Derives from :py:class:`GvmClientError` Arguments: status: The HTTP response status message: Error message to be displayed. Takes precedence over argument and function """ def __init__(self, status: str = None, message: str = None): super().__init__(message, status) self.status = status def __str__(self): return f'Response Error {self.status}. {self.message}' def __repr__(self): return ( f'<{self.__class__.__name__} status="{self.status}"' f' message="{self.message}">' ) class InvalidArgument(GvmError): """Raised if an invalid argument/parameter is passed Derives from :py:class:`GvmError` Arguments: message: Error message to be displayed. Takes precedence over argument and function argument: Optional name of the invalid argument function: Optional name of the called function """ def __init__( self, message: Optional[str] = None, *, argument: Optional[str] = None, function: Optional[str] = None, ): super().__init__(message, argument, function) self.argument = argument self.function = function def __str__(self): if self.message: return self.message if not self.function: return f"Invalid argument {self.argument}" if not self.argument: return f"Invalid argument for {self.function}" return f"Invalid argument {self.argument} for {self.function}" class InvalidArgumentType(GvmError): """Raised if a passed argument has an invalid type Derives from :py:class:`GvmError` Arguments: argument: Name of the invalid argument arg_type: The correct argument type function: Optional name of the called function """ def __init__( self, argument: str = None, arg_type: str = None, *, function: Optional[str] = None, ): # pylint: disable=super-init-not-called self.argument = argument self.function = function self.arg_type = arg_type def __str__(self): if self.function: return ( f"In {self.function} the argument {self.argument} " f"must be of type {self.arg_type}." ) return f"The argument {self.argument} must be of type {self.arg_type}." class RequiredArgument(GvmError): """Raised if a required argument/parameter is missing Derives from :py:class:`GvmError` Arguments: message: Error message to be displayed. Takes precedence over argument and function. argument: Optional name of the required argument. function: Optional name of the called function. """ def __init__( self, message: Optional[str] = None, *, argument: Optional[str] = None, function: Optional[str] = None, ): super().__init__(message, argument, function) self.argument = argument self.function = function def __str__(self): if self.message: return self.message if not self.function: return f"Required argument {self.argument}" if not self.argument: return f"Required argument missing for {self.function}" return f"{self.function} requires a {self.argument} argument" python-gvm-21.10.0/gvm/protocols/000077500000000000000000000000001413122500400165705ustar00rootroot00000000000000python-gvm-21.10.0/gvm/protocols/__init__.py000066400000000000000000000021531413122500400207020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Package for supported Greenbone Protocol versions. Currently `GMP version 20.08`_, `GMP version 21.04`_ and `OSP version 1`_ are supported. .. _GMP version 20.08: https://docs.greenbone.net/API/GMP/gmp-20.08.html .. _GMP version 21.04: https://docs.greenbone.net/API/GMP/gmp-21.04.html .. _OSP version 1: https://docs.greenbone.net/API/OSP/osp-1.2.html """ python-gvm-21.10.0/gvm/protocols/base.py000066400000000000000000000103401413122500400200520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Optional, Callable, Any from gvm.connections import GvmConnection class GvmProtocol: """Base class for different GVM protocols Attributes: connection: Connection to use to talk with the remote daemon. See :mod:`gvm.connections` for possible connection types. transform: Optional transform `callable`_ to convert response data. After each request the callable gets passed the plain response data which can be used to check the data and/or conversion into different representations like a xml dom. See :mod:`gvm.transforms` for existing transforms. """ def __init__( self, connection: GvmConnection, *, transform: Optional[Callable[[str], Any]] = None, ): self._connection = connection self._connected = False self._transform_callable = transform def __enter__(self): self.connect() return self def __exit__(self, exc_type, exc_value, traceback): self.disconnect() def _read(self): """Read a command response from gvmd Returns: str: Response from server. """ return self._connection.read() def _send(self, data): """Send a command to the server Arguments: data (str): Data to be send over the connection to the server """ self.connect() self._connection.send(data) def _transform(self, data): transform = self._transform_callable if transform is None: return data return transform(data) def _send_xml_command(self, xmlcmd): """Send a xml command to the remote server Arguments: xmlcmd (gvm.xml.XmlCommand): XmlCommand instance to send """ return self.send_command(xmlcmd.to_string()) def is_connected(self) -> bool: """Status of the current connection Returns: True if a connection to the remote server has been established. """ return self._connected def connect(self): """Initiates a protocol connection Normally connect is not called directly. Either it is called automatically when sending a protocol command or when using a `with statement`_. .. _with statement: https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers """ if not self.is_connected(): self._connection.connect() self._connected = True def disconnect(self): """Disconnect the connection Ends and closes the connection. """ if self.is_connected(): self._connection.disconnect() self._connected = False def send_command(self, cmd: str) -> Any: """Send a command to the remote server If the class is not connected to the server yet the connection will be established automatically. Arguments: cmd (str): Command as string to be send over the connection to the server. Returns: any: The actual returned type depends on the set transform. Per default - if no transform is set explicitly - the response is returned as string. """ try: self._send(cmd) response = self._read() except Exception as e: self.disconnect() raise e return self._transform(response) python-gvm-21.10.0/gvm/protocols/gmp.py000066400000000000000000000075761413122500400177440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Module for communication with gvmd """ from typing import Any, Optional, Callable, Union from gvm.errors import GvmError from gvm.protocols.base import GvmProtocol, GvmConnection from gvm.protocols.gmpv208 import Gmp as Gmpv208 from gvm.protocols.gmpv214 import Gmp as Gmpv214 from gvm.transforms import EtreeCheckCommandTransform from gvm.xml import XmlCommand SUPPORTED_GMP_VERSIONS = Union[Gmpv208, Gmpv214] # pylint: disable=invalid-name class Gmp(GvmProtocol): """Dynamically select supported GMP protocol of the remote manager daemon. Must be used as a `Context Manager `_ Example: .. code-block:: python from gvm.protocols.gmp import Gmp with Gmp(connection) as gmp: # gmp can be an instance of gvm.protocols.gmpv208.Gmp, # gvm.protocols.gmpv214.Gmp depending # on the supported GMP version of the remote manager daemon resp = gmp.get_tasks() Attributes: connection: Connection to use to talk with the remote daemon. See :mod:`gvm.connections` for possible connection types. transform: Optional transform `callable`_ to convert response data. After each request the callable gets passed the plain response data which can be used to check the data and/or conversion into different representations like a xml dom. See :mod:`gvm.transforms` for existing transforms. .. _callable: https://docs.python.org/3/library/functions.html#callable """ def __init__( self, connection: GvmConnection, *, transform: Optional[Callable[[str], Any]] = None, ): super().__init__(connection, transform=EtreeCheckCommandTransform()) self._gmp_transform = transform def determine_remote_gmp_version(self) -> str: """Determine the supported GMP version of the remote daemon""" self.connect() resp = self._send_xml_command(XmlCommand("get_version")) self.disconnect() version_el = resp.find('version') if version_el is None: raise GvmError( 'Invalid response from manager daemon while requesting the ' 'version information.' ) return version_el.text def determine_supported_gmp(self) -> SUPPORTED_GMP_VERSIONS: """Determine supported GMP version of the remote daemon and return a corresponding Gmp class instance """ version = self.determine_remote_gmp_version() major_version = int(version.split('.')[0]) if major_version == 20: gmp_class = Gmpv208 elif major_version == 21: gmp_class = Gmpv214 else: raise GvmError( 'Remote manager daemon uses an unsupported version of GMP. ' f'The GMP version was {version}.' ) return gmp_class(self._connection, transform=self._gmp_transform) def __enter__(self): gmp = self.determine_supported_gmp() gmp.connect() return gmp python-gvm-21.10.0/gvm/protocols/gmpv208/000077500000000000000000000000001413122500400177735ustar00rootroot00000000000000python-gvm-21.10.0/gvm/protocols/gmpv208/__init__.py000066400000000000000000000146671413122500400221220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # pylint: disable=too-many-lines,redefined-builtin """ Module for communication with gvmd in `Greenbone Management Protocol version 20.08`_ .. _Greenbone Management Protocol version 20.08: https://docs.greenbone.net/API/GMP/gmp-20.08.html """ import logging from typing import Any, Callable, Optional from gvm.protocols.base import GvmProtocol from gvm.protocols.gmpv208.entities.alerts import ( AlertCondition, AlertEvent, AlertMethod, AlertsMixin, ) from gvm.protocols.gmpv208.entities.audits import AuditsMixin from gvm.protocols.gmpv208.entities.credentials import ( CredentialFormat, CredentialsMixin, CredentialType, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, ) from gvm.protocols.gmpv208.entities.entities import ( EntityType, ) from gvm.protocols.gmpv208.entities.filter import ( FiltersMixin, FilterType, ) from gvm.protocols.gmpv208.entities.groups import GroupsMixin from gvm.protocols.gmpv208.entities.hosts import ( HostsMixin, HostsOrdering, ) from gvm.protocols.gmpv208.entities.permissions import ( PermissionsMixin, PermissionSubjectType, ) from gvm.protocols.gmpv208.entities.port_lists import ( PortListMixin, PortRangeType, ) from gvm.protocols.gmpv208.entities.reports import ReportsMixin from gvm.protocols.gmpv208.entities.notes import NotesMixin from gvm.protocols.gmpv208.entities.operating_systems import ( OperatingSystemsMixin, ) from gvm.protocols.gmpv208.entities.overrides import OverridesMixin from gvm.protocols.gmpv208.entities.policies import PoliciesMixin from gvm.protocols.gmpv208.entities.results import ResultsMixin from gvm.protocols.gmpv208.entities.report_formats import ( ReportFormatType, ReportFormatsMixin, ) from gvm.protocols.gmpv208.entities.roles import RolesMixin from gvm.protocols.gmpv208.entities.scan_configs import ScanConfigsMixin from gvm.protocols.gmpv208.entities.scanners import ( ScannersMixin, ScannerType, ) from gvm.protocols.gmpv208.entities.schedules import SchedulesMixin from gvm.protocols.gmpv208.entities.secinfo import ( InfoType, SecInfoMixin, ) from gvm.protocols.gmpv208.entities.severity import ( SeverityLevel, ) from gvm.protocols.gmpv208.entities.tags import TagsMixin from gvm.protocols.gmpv208.entities.targets import ( AliveTest, TargetsMixin, ) from gvm.protocols.gmpv208.entities.tasks import TasksMixin from gvm.protocols.gmpv208.entities.tickets import ( TicketsMixin, TicketStatus, ) from gvm.protocols.gmpv208.entities.tls_certificates import TLSCertificateMixin from gvm.protocols.gmpv208.entities.users import ( UserAuthType, UsersMixin, ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin from gvm.protocols.gmpv208.system.aggregates import ( AggregatesMixin, AggregateStatistic, SortOrder, ) from gvm.protocols.gmpv208.system.authentication import AuthenticationMixin from gvm.protocols.gmpv208.system.feed import ( FeedType, FeedMixin, ) from gvm.protocols.gmpv208.system.help import ( HelpFormat, HelpMixin, ) from gvm.protocols.gmpv208.system.system_reports import SystemReportsMixin from gvm.protocols.gmpv208.system.trashcan import TrashcanMixin from gvm.protocols.gmpv208.system.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.system.version import VersionMixin from gvm.connections import GvmConnection logger = logging.getLogger(__name__) _TYPE_FIELDS = [ AggregateStatistic, AlertCondition, AlertEvent, AlertMethod, AliveTest, CredentialFormat, CredentialType, EntityType, FeedType, FilterType, HostsOrdering, InfoType, HelpFormat, PortRangeType, PermissionSubjectType, ReportFormatType, ScannerType, SeverityLevel, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, SortOrder, TicketStatus, UserAuthType, ] class Gmp( GvmProtocol, AggregatesMixin, AlertsMixin, AuditsMixin, AuthenticationMixin, CredentialsMixin, FeedMixin, FiltersMixin, GroupsMixin, HelpMixin, HostsMixin, NotesMixin, OperatingSystemsMixin, OverridesMixin, PermissionsMixin, PoliciesMixin, PortListMixin, ReportFormatsMixin, ReportsMixin, ResultsMixin, RolesMixin, TagsMixin, TargetsMixin, TasksMixin, TicketsMixin, TLSCertificateMixin, TrashcanMixin, ScanConfigsMixin, ScannersMixin, SchedulesMixin, SecInfoMixin, SystemReportsMixin, UserSettingsMixin, UsersMixin, VersionMixin, VulnerabilitiesMixin, ): """Python interface for Greenbone Management Protocol This class implements the `Greenbone Management Protocol version 20.08`_ Arguments: connection: Connection to use to talk with the gvmd daemon. See :mod:`gvm.connections` for possible connection types. transform: Optional transform `callable`_ to convert response data. After each request the callable gets passed the plain response data which can be used to check the data and/or conversion into different representations like a xml dom. See :mod:`gvm.transforms` for existing transforms. .. _Greenbone Management Protocol version 20.08: https://docs.greenbone.net/API/GMP/gmp-20.08.html .. _callable: https://docs.python.org/3/library/functions.html#callable """ def __init__( self, connection: GvmConnection, *, transform: Optional[Callable[[str], Any]] = None, ): self.types = {} for t in _TYPE_FIELDS: self.types[t.__name__] = t super().__init__(connection, transform=transform) # Is authenticated on gvmd self._authenticated = False python-gvm-21.10.0/gvm/protocols/gmpv208/entities/000077500000000000000000000000001413122500400216175ustar00rootroot00000000000000python-gvm-21.10.0/gvm/protocols/gmpv208/entities/__init__.py000066400000000000000000000013571413122500400237360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/gvm/protocols/gmpv208/entities/alerts.py000066400000000000000000000464071413122500400234760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional, Union from gvm.protocols.gmpv208.entities.report_formats import ( ReportFormatType, ) # if I use latest, I get circular import :/ from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class AlertEvent(Enum): """Enum for alert event types""" TASK_RUN_STATUS_CHANGED = 'Task run status changed' UPDATED_SECINFO_ARRIVED = 'Updated SecInfo arrived' NEW_SECINFO_ARRIVED = 'New SecInfo arrived' TICKET_RECEIVED = 'Ticket received' ASSIGNED_TICKET_CHANGED = 'Assigned ticket changed' OWNED_TICKET_CHANGED = 'Owned ticket changed' @classmethod def from_string( cls, alert_event: Optional[str], ) -> Optional["AlertEvent"]: """Convert an alert event string into a AlertEvent instance""" if not alert_event: return None try: return cls[alert_event.replace(' ', '_').upper()] except KeyError: raise InvalidArgument( argument='alert_event', function=cls.from_string.__name__, ) from None class AlertCondition(Enum): """Enum for alert condition types""" ALWAYS = 'Always' ERROR = 'Error' SEVERITY_AT_LEAST = 'Severity at least' SEVERITY_CHANGED = 'Severity changed' FILTER_COUNT_CHANGED = 'Filter count changed' FILTER_COUNT_AT_LEAST = 'Filter count at least' @classmethod def from_string( cls, alert_condition: Optional[str] ) -> Optional["AlertCondition"]: """Convert an alert condition string into a AlertCondition instance""" if not alert_condition: return None try: return cls[alert_condition.replace(' ', '_').upper()] except KeyError: raise InvalidArgument( argument='alert_condition', function=cls.from_string.__name__, ) from None class AlertMethod(Enum): """Enum for alert method type""" SCP = "SCP" SEND = "Send" SMB = "SMB" SNMP = "SNMP" SYSLOG = "Syslog" EMAIL = "Email" START_TASK = "Start Task" HTTP_GET = "HTTP Get" SOURCEFIRE_CONNECTOR = "Sourcefire Connector" VERINICE_CONNECTOR = "verinice Connector" TIPPINGPOINT_SMS = "TippingPoint SMS" ALEMBA_VFIRE = "Alemba vFire" @classmethod def from_string( cls, alert_method: Optional[str], ) -> Optional["AlertMethod"]: """Convert an alert method string into a AlertCondition instance""" if not alert_method: return None try: return cls[alert_method.replace(' ', '_').upper()] except KeyError: raise InvalidArgument( argument='alert_method', function=cls.from_string.__name__, ) from None def _check_event( event: AlertEvent, condition: AlertCondition, method: AlertMethod ): if event == AlertEvent.TASK_RUN_STATUS_CHANGED: if not condition: raise RequiredArgument( f"condition is required for event {event.name}" ) if not method: raise RequiredArgument(f"method is required for event {event.name}") if condition not in ( AlertCondition.ALWAYS, AlertCondition.FILTER_COUNT_CHANGED, AlertCondition.FILTER_COUNT_AT_LEAST, AlertCondition.SEVERITY_AT_LEAST, AlertCondition.SEVERITY_CHANGED, ): raise InvalidArgument( f"Invalid condition {condition.name} for event {event.name}" ) elif event in ( AlertEvent.NEW_SECINFO_ARRIVED, AlertEvent.UPDATED_SECINFO_ARRIVED, ): if not condition: raise RequiredArgument( f"condition is required for event {event.name}" ) if not method: raise RequiredArgument(f"method is required for event {event.name}") if condition != AlertCondition.ALWAYS: raise InvalidArgument( f"Invalid condition {condition.name} for event {event.name}" ) if method not in ( AlertMethod.SCP, AlertMethod.SEND, AlertMethod.SMB, AlertMethod.SNMP, AlertMethod.SYSLOG, AlertMethod.EMAIL, ): raise InvalidArgument( f"Invalid method {method.name} for event {event.name}" ) elif event in ( AlertEvent.TICKET_RECEIVED, AlertEvent.OWNED_TICKET_CHANGED, AlertEvent.ASSIGNED_TICKET_CHANGED, ): if not condition: raise RequiredArgument( f"condition is required for event {event.name}" ) if not method: raise RequiredArgument(f"method is required for event {event.name}") if condition != AlertCondition.ALWAYS: raise InvalidArgument( f"Invalid condition {condition.name} for event {event.name}" ) if method not in ( AlertMethod.EMAIL, AlertMethod.START_TASK, AlertMethod.SYSLOG, ): raise InvalidArgument( f"Invalid method {method.name} for event {event.name}" ) class AlertsMixin: def clone_alert(self, alert_id: str) -> Any: """Clone an existing alert Arguments: alert_id: UUID of an existing alert to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not alert_id: raise RequiredArgument( function=self.clone_alert.__name__, argument='alert_id' ) cmd = XmlCommand("create_alert") cmd.add_element("copy", alert_id) return self._send_xml_command(cmd) def create_alert( self, name: str, condition: AlertCondition, event: AlertEvent, method: AlertMethod, *, method_data: Optional[dict] = None, event_data: Optional[dict] = None, condition_data: Optional[dict] = None, filter_id: Optional[int] = None, comment: Optional[str] = None, ) -> Any: """Create a new alert Arguments: name: Name of the new Alert condition: The condition that must be satisfied for the alert to occur; if the event is either 'Updated SecInfo arrived' or 'New SecInfo arrived', condition must be 'Always'. Otherwise, condition can also be on of 'Severity at least', 'Filter count changed' or 'Filter count at least'. event: The event that must happen for the alert to occur, one of 'Task run status changed', 'Updated SecInfo arrived' or 'New SecInfo arrived' method: The method by which the user is alerted, one of 'SCP', 'Send', 'SMB', 'SNMP', 'Syslog' or 'Email'; if the event is neither 'Updated SecInfo arrived' nor 'New SecInfo arrived', method can also be one of 'Start Task', 'HTTP Get', 'Sourcefire Connector' or 'verinice Connector'. condition_data: Data that defines the condition event_data: Data that defines the event method_data: Data that defines the method filter_id: Filter to apply when executing alert comment: Comment for the alert Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_alert.__name__, argument='name' ) if not condition: raise RequiredArgument( function=self.create_alert.__name__, argument='condition' ) if not event: raise RequiredArgument( function=self.create_alert.__name__, argument='event' ) if not method: raise RequiredArgument( function=self.create_alert.__name__, argument='method' ) if not isinstance(condition, AlertCondition): raise InvalidArgumentType( function=self.create_alert.__name__, argument='condition', arg_type=AlertCondition.__name__, ) if not isinstance(event, AlertEvent): raise InvalidArgumentType( function=self.create_alert.__name__, argument='even', arg_type=AlertEvent.__name__, ) if not isinstance(method, AlertMethod): raise InvalidArgumentType( function=self.create_alert.__name__, argument='method', arg_type=AlertMethod.__name__, ) _check_event(event, condition, method) cmd = XmlCommand("create_alert") cmd.add_element("name", name) conditions = cmd.add_element("condition", condition.value) if condition_data is not None: for key, value in condition_data.items(): _data = conditions.add_element("data", value) _data.add_element("name", key) events = cmd.add_element("event", event.value) if event_data is not None: for key, value in event_data.items(): _data = events.add_element("data", value) _data.add_element("name", key) methods = cmd.add_element("method", method.value) if method_data is not None: for key, value in method_data.items(): _data = methods.add_element("data", value) _data.add_element("name", key) if filter_id: cmd.add_element("filter", attrs={"id": filter_id}) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) def delete_alert( self, alert_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing alert Arguments: alert_id: UUID of the alert to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not alert_id: raise RequiredArgument( function=self.delete_alert.__name__, argument='alert_id' ) cmd = XmlCommand("delete_alert") cmd.set_attribute("alert_id", alert_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_alerts( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> Any: """Request a list of alerts Arguments: filter: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: True to request the alerts in the trashcan tasks: Whether to include the tasks using the alerts Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_alerts") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return self._send_xml_command(cmd) def get_alert(self, alert_id: str, *, tasks: Optional[bool] = None) -> Any: """Request a single alert Arguments: alert_id: UUID of an existing alert Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_alerts") if not alert_id: raise RequiredArgument( function=self.get_alert.__name__, argument='alert_id' ) cmd.set_attribute("alert_id", alert_id) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return self._send_xml_command(cmd) def modify_alert( self, alert_id: str, *, name: Optional[str] = None, comment: Optional[str] = None, filter_id: Optional[str] = None, event: Optional[AlertEvent] = None, event_data: Optional[dict] = None, condition: Optional[AlertCondition] = None, condition_data: Optional[dict] = None, method: Optional[AlertMethod] = None, method_data: Optional[dict] = None, ) -> Any: """Modifies an existing alert. Arguments: alert_id: UUID of the alert to be modified. name: Name of the Alert. condition: The condition that must be satisfied for the alert to occur. If the event is either 'Updated SecInfo arrived' or 'New SecInfo arrived', condition must be 'Always'. Otherwise, condition can also be on of 'Severity at least', 'Filter count changed' or 'Filter count at least'. condition_data: Data that defines the condition event: The event that must happen for the alert to occur, one of 'Task run status changed', 'Updated SecInfo arrived' or 'New SecInfo arrived' event_data: Data that defines the event method: The method by which the user is alerted, one of 'SCP', 'Send', 'SMB', 'SNMP', 'Syslog' or 'Email'; if the event is neither 'Updated SecInfo arrived' nor 'New SecInfo arrived', method can also be one of 'Start Task', 'HTTP Get', 'Sourcefire Connector' or 'verinice Connector'. method_data: Data that defines the method filter_id: Filter to apply when executing alert comment: Comment for the alert Returns: The response. See :py:meth:`send_command` for details. """ if not alert_id: raise RequiredArgument( function=self.modify_alert.__name__, argument='alert_id' ) cmd = XmlCommand("modify_alert") cmd.set_attribute("alert_id", str(alert_id)) if name: cmd.add_element("name", name) if comment: cmd.add_element("comment", comment) if filter_id: cmd.add_element("filter", attrs={"id": filter_id}) if condition: if not isinstance(condition, AlertCondition): raise InvalidArgumentType( function=self.modify_alert.__name__, argument='condition', arg_type=AlertCondition.__name__, ) conditions = cmd.add_element("condition", condition.value) if condition_data is not None: for key, value in condition_data.items(): _data = conditions.add_element("data", value) _data.add_element("name", key) if method: if not isinstance(method, AlertMethod): raise InvalidArgumentType( function=self.modify_alert.__name__, argument='method', arg_type=AlertMethod.__name__, ) methods = cmd.add_element("method", method.value) if method_data is not None: for key, value in method_data.items(): _data = methods.add_element("data", value) _data.add_element("name", key) if event: if not isinstance(event, AlertEvent): raise InvalidArgumentType( function=self.modify_alert.__name__, argument='event', arg_type=AlertEvent.__name__, ) _check_event(event, condition, method) events = cmd.add_element("event", event.value) if event_data is not None: for key, value in event_data.items(): _data = events.add_element("data", value) _data.add_element("name", key) return self._send_xml_command(cmd) def test_alert(self, alert_id: str) -> Any: """Run an alert Invoke a test run of an alert Arguments: alert_id: UUID of the alert to be tested Returns: The response. See :py:meth:`send_command` for details. """ if not alert_id: raise InvalidArgument("test_alert requires an alert_id argument") cmd = XmlCommand("test_alert") cmd.set_attribute("alert_id", alert_id) return self._send_xml_command(cmd) def trigger_alert( self, alert_id: str, report_id: str, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, report_format_id: Optional[Union[str, ReportFormatType]] = None, delta_report_id: Optional[str] = None, ) -> Any: """Run an alert by ignoring its event and conditions The alert is triggered to run immediately with the provided filtered report by ignoring the even and condition settings. Arguments: alert_id: UUID of the alert to be run report_id: UUID of the report to be provided to the alert filter: Filter term to use to filter results in the report filter_id: UUID of filter to use to filter results in the report report_format_id: UUID of report format to use or ReportFormatType (enum) delta_report_id: UUID of an existing report to compare report to. Returns: The response. See :py:meth:`send_command` for details. """ if not alert_id: raise RequiredArgument( function=self.trigger_alert.__name__, argument='alert_id argument', ) if not report_id: raise RequiredArgument( function=self.trigger_alert.__name__, argument='report_id argument', ) cmd = XmlCommand("get_reports") cmd.set_attribute("report_id", report_id) cmd.set_attribute("alert_id", alert_id) add_filter(cmd, filter_string, filter_id) if report_format_id: if isinstance(report_format_id, ReportFormatType): report_format_id = report_format_id.value cmd.set_attribute("format_id", report_format_id) if delta_report_id: cmd.set_attribute("delta_report_id", delta_report_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/audits.py000066400000000000000000000367251413122500400234770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from collections.abc import Mapping from numbers import Integral from typing import Any, List, Optional from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.protocols.gmpv208.entities.hosts import HostsOrdering from gvm.utils import add_filter, is_list_like, to_bool, to_comma_list from gvm.xml import XmlCommand class AuditsMixin: def clone_audit(self, audit_id: str) -> Any: """Clone an existing audit Arguments: audit_id: UUID of existing audit to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not audit_id: raise RequiredArgument( function=self.clone_audit.__name__, argument='audit_id' ) cmd = XmlCommand("create_task") cmd.add_element("copy", audit_id) return self._send_xml_command(cmd) def create_audit( self, name: str, policy_id: str, target_id: str, scanner_id: str, *, alterable: Optional[bool] = None, hosts_ordering: Optional[HostsOrdering] = None, schedule_id: Optional[str] = None, alert_ids: Optional[List[str]] = None, comment: Optional[str] = None, schedule_periods: Optional[int] = None, observers: Optional[List[str]] = None, preferences: Optional[dict] = None, ) -> Any: """Create a new audit task Arguments: name: Name of the new audit policy_id: UUID of policy to use by the audit target_id: UUID of target to be scanned scanner_id: UUID of scanner to use for scanning the target comment: Comment for the audit alterable: Whether the task should be alterable alert_ids: List of UUIDs for alerts to be applied to the audit hosts_ordering: The order hosts are scanned in schedule_id: UUID of a schedule when the audit should be run. schedule_periods: A limit to the number of times the audit will be scheduled, or 0 for no limit observers: List of names or ids of users which should be allowed to observe this audit preferences: Name/Value pairs of scanner preferences. Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_audit.__name__, argument='name' ) if not policy_id: raise RequiredArgument( function=self.create_audit.__name__, argument='policy_id' ) if not target_id: raise RequiredArgument( function=self.create_audit.__name__, argument='target_id' ) if not scanner_id: raise RequiredArgument( function=self.create_audit.__name__, argument='scanner_id' ) # don't allow to create a container task with create_task if target_id == '0': raise InvalidArgument( function=self.create_audit.__name__, argument='target_id' ) cmd = XmlCommand("create_task") cmd.add_element("name", name) cmd.add_element("usage_type", "audit") cmd.add_element("config", attrs={"id": policy_id}) cmd.add_element("target", attrs={"id": target_id}) cmd.add_element("scanner", attrs={"id": scanner_id}) if comment: cmd.add_element("comment", comment) if alterable is not None: cmd.add_element("alterable", to_bool(alterable)) if hosts_ordering: if not isinstance(hosts_ordering, HostsOrdering): raise InvalidArgumentType( function=self.create_audit.__name__, argument='hosts_ordering', arg_type=HostsOrdering.__name__, ) cmd.add_element("hosts_ordering", hosts_ordering.value) if alert_ids is not None: if not is_list_like(alert_ids): raise InvalidArgumentType( function=self.modify_task.__name__, argument='alert_ids', arg_type='list', ) if not len(alert_ids) == 0: for alert in alert_ids: cmd.add_element("alert", attrs={"id": str(alert)}) if schedule_id: cmd.add_element("schedule", attrs={"id": schedule_id}) if schedule_periods is not None: if ( not isinstance(schedule_periods, Integral) or schedule_periods < 0 ): raise InvalidArgument( "schedule_periods must be an integer greater or equal " "than 0" ) cmd.add_element("schedule_periods", str(schedule_periods)) if observers is not None: if not is_list_like(observers): raise InvalidArgumentType( function=self.create_audit.__name__, argument='observers', arg_type='list', ) # gvmd splits by comma and space # gvmd tries to lookup each value as user name and afterwards as # user id. So both user name and user id are possible cmd.add_element("observers", to_comma_list(observers)) if preferences is not None: if not isinstance(preferences, Mapping): raise InvalidArgumentType( function=self.create_audit.__name__, argument='preferences', arg_type=Mapping.__name__, ) _xmlprefs = cmd.add_element("preferences") for pref_name, pref_value in preferences.items(): _xmlpref = _xmlprefs.add_element("preference") _xmlpref.add_element("scanner_name", pref_name) _xmlpref.add_element("value", str(pref_value)) return self._send_xml_command(cmd) def delete_audit( self, audit_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing audit Arguments: audit_id: UUID of the audit to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not audit_id: raise RequiredArgument( function=self.delete_audit.__name__, argument='audit_id' ) cmd = XmlCommand("delete_task") cmd.set_attribute("task_id", audit_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_audits( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, details: Optional[bool] = None, schedules_only: Optional[bool] = None, ) -> Any: """Request a list of audits Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan audits instead details: Whether to include full audit details schedules_only: Whether to only include id, name and schedule details Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_tasks") cmd.set_attribute("usage_type", "audit") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if details is not None: cmd.set_attribute("details", to_bool(details)) if schedules_only is not None: cmd.set_attribute("schedules_only", to_bool(schedules_only)) return self._send_xml_command(cmd) def get_audit(self, audit_id: str) -> Any: """Request a single audit Arguments: audit_id: UUID of an existing audit Returns: The response. See :py:meth:`send_command` for details. """ if not audit_id: raise RequiredArgument( function=self.get_task.__name__, argument='audit_id' ) cmd = XmlCommand("get_tasks") cmd.set_attribute("task_id", audit_id) cmd.set_attribute("usage_type", "audit") # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def modify_audit( self, audit_id: str, *, name: Optional[str] = None, policy_id: Optional[str] = None, target_id: Optional[str] = None, scanner_id: Optional[str] = None, alterable: Optional[bool] = None, hosts_ordering: Optional[HostsOrdering] = None, schedule_id: Optional[str] = None, schedule_periods: Optional[int] = None, comment: Optional[str] = None, alert_ids: Optional[List[str]] = None, observers: Optional[List[str]] = None, preferences: Optional[dict] = None, ) -> Any: """Modifies an existing task. Arguments: audit_id: UUID of audit to modify. name: The name of the audit. policy_id: UUID of policy to use by the audit target_id: UUID of target to be scanned scanner_id: UUID of scanner to use for scanning the target comment: The comment on the audit. alert_ids: List of UUIDs for alerts to be applied to the audit hosts_ordering: The order hosts are scanned in schedule_id: UUID of a schedule when the audit should be run. schedule_periods: A limit to the number of times the audit will be scheduled, or 0 for no limit. observers: List of names or ids of users which should be allowed to observe this audit preferences: Name/Value pairs of scanner preferences. Returns: The response. See :py:meth:`send_command` for details. """ if not audit_id: raise RequiredArgument( function=self.modify_task.__name__, argument='task_id argument' ) cmd = XmlCommand("modify_task") cmd.set_attribute("task_id", audit_id) if name: cmd.add_element("name", name) if comment: cmd.add_element("comment", comment) if policy_id: cmd.add_element("config", attrs={"id": policy_id}) if target_id: cmd.add_element("target", attrs={"id": target_id}) if alterable is not None: cmd.add_element("alterable", to_bool(alterable)) if hosts_ordering: if not isinstance(hosts_ordering, HostsOrdering): raise InvalidArgumentType( function=self.modify_task.__name__, argument='hosts_ordering', arg_type=HostsOrdering.__name__, ) cmd.add_element("hosts_ordering", hosts_ordering.value) if scanner_id: cmd.add_element("scanner", attrs={"id": scanner_id}) if schedule_id: cmd.add_element("schedule", attrs={"id": schedule_id}) if schedule_periods is not None: if ( not isinstance(schedule_periods, Integral) or schedule_periods < 0 ): raise InvalidArgument( "schedule_periods must be an integer greater or equal " "than 0" ) cmd.add_element("schedule_periods", str(schedule_periods)) if alert_ids is not None: if not is_list_like(alert_ids): raise InvalidArgumentType( function=self.modify_task.__name__, argument='alert_ids', arg_type='list', ) if len(alert_ids) == 0: cmd.add_element("alert", attrs={"id": "0"}) else: for alert in alert_ids: cmd.add_element("alert", attrs={"id": str(alert)}) if observers is not None: if not is_list_like(observers): raise InvalidArgumentType( function=self.modify_task.__name__, argument='observers', arg_type='list', ) cmd.add_element("observers", to_comma_list(observers)) if preferences is not None: if not isinstance(preferences, Mapping): raise InvalidArgumentType( function=self.modify_task.__name__, argument='preferences', arg_type=Mapping.__name__, ) _xmlprefs = cmd.add_element("preferences") for pref_name, pref_value in preferences.items(): _xmlpref = _xmlprefs.add_element("preference") _xmlpref.add_element("scanner_name", pref_name) _xmlpref.add_element("value", str(pref_value)) return self._send_xml_command(cmd) def resume_audit(self, audit_id: str) -> Any: """Resume an existing stopped audit Arguments: audit_id: UUID of the audit to be resumed Returns: The response. See :py:meth:`send_command` for details. """ if not audit_id: raise RequiredArgument( function=self.resume_audit.__name__, argument='audit_id' ) cmd = XmlCommand("resume_task") cmd.set_attribute("task_id", audit_id) return self._send_xml_command(cmd) def start_audit(self, audit_id: str) -> Any: """Start an existing audit Arguments: audit_id: UUID of the audit to be started Returns: The response. See :py:meth:`send_command` for details. """ if not audit_id: raise RequiredArgument( function=self.start_audit.__name__, argument='audit_id' ) cmd = XmlCommand("start_task") cmd.set_attribute("task_id", audit_id) return self._send_xml_command(cmd) def stop_audit(self, audit_id: str) -> Any: """Stop an existing running audit Arguments: audit_id: UUID of the audit to be stopped Returns: The response. See :py:meth:`send_command` for details. """ if not audit_id: raise RequiredArgument( function=self.stop_audit.__name__, argument='audit_id' ) cmd = XmlCommand("stop_task") cmd.set_attribute("task_id", audit_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/credentials.py000066400000000000000000000505611413122500400244750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class CredentialFormat(Enum): """Enum for credential format""" KEY = 'key' RPM = 'rpm' DEB = 'deb' EXE = 'exe' PEM = 'pem' @classmethod def from_string( cls, credential_format: Optional[str], ) -> Optional["CredentialFormat"]: if not credential_format: return None try: return cls[credential_format.upper()] except KeyError: raise InvalidArgument( argument='credential_format', function=cls.from_string.__name__, ) from None class CredentialType(Enum): """Enum for credential types""" CLIENT_CERTIFICATE = 'cc' SNMP = 'snmp' USERNAME_PASSWORD = 'up' USERNAME_SSH_KEY = 'usk' SMIME_CERTIFICATE = 'smime' PGP_ENCRYPTION_KEY = 'pgp' PASSWORD_ONLY = 'pw' @classmethod def from_string( cls, credential_type: Optional[str], ) -> Optional["CredentialType"]: """Convert a credential type string into a CredentialType instance""" if not credential_type: return None try: return cls[credential_type.upper()] except KeyError: raise InvalidArgument( argument='credential_type', function=cls.from_string.__name__, ) from None class SnmpAuthAlgorithm(Enum): """Enum for SNMP auth algorithm""" SHA1 = 'sha1' MD5 = 'md5' @classmethod def from_string( cls, algorithm: Optional[str], ) -> Optional["SnmpAuthAlgorithm"]: """Convert a SNMP auth algorithm string into a SnmpAuthAlgorithm instance""" if not algorithm: return None try: return cls[algorithm.upper()] except KeyError: raise InvalidArgument( argument='algorithm', function=cls.from_string.__name__, ) from None class SnmpPrivacyAlgorithm(Enum): """Enum for SNMP privacy algorithm""" AES = 'aes' DES = 'des' @classmethod def from_string( cls, algorithm: Optional[str], ) -> Optional["SnmpPrivacyAlgorithm"]: """Convert a SNMP privacy algorithm string into a SnmpPrivacyAlgorithm instance """ if not algorithm: return None try: return cls[algorithm.upper()] except KeyError: raise InvalidArgument( argument='algorithm', function=cls.from_string.__name__, ) from None class CredentialsMixin: def clone_credential(self, credential_id: str) -> Any: """Clone an existing credential Arguments: credential_id: UUID of an existing credential to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not credential_id: raise RequiredArgument( function=self.clone_credential.__name__, argument='credential_id', ) cmd = XmlCommand("create_credential") cmd.add_element("copy", credential_id) return self._send_xml_command(cmd) def create_credential( self, name: str, credential_type: CredentialType, *, comment: Optional[str] = None, allow_insecure: Optional[bool] = None, certificate: Optional[str] = None, key_phrase: Optional[str] = None, private_key: Optional[str] = None, login: Optional[str] = None, password: Optional[str] = None, auth_algorithm: Optional[SnmpAuthAlgorithm] = None, community: Optional[str] = None, privacy_algorithm: Optional[SnmpPrivacyAlgorithm] = None, privacy_password: Optional[str] = None, public_key: Optional[str] = None, ) -> Any: """Create a new credential Create a new credential e.g. to be used in the method of an alert. Currently the following credential types are supported: - Username + Password - Username + SSH-Key - Client Certificates - SNMPv1 or SNMPv2c protocol - S/MIME Certificate - OpenPGP Key - Password only Arguments: name: Name of the new credential credential_type: The credential type. comment: Comment for the credential allow_insecure: Whether to allow insecure use of the credential certificate: Certificate for the credential. Required for client-certificate and smime credential types. key_phrase: Key passphrase for the private key. Used for the username+ssh-key credential type. private_key: Private key to use for login. Required for usk credential type. Also used for the cc credential type. The supported key types (dsa, rsa, ecdsa, ...) and formats (PEM, PKC#12, OpenSSL, ...) depend on your installed GnuTLS version. login: Username for the credential. Required for username+password, username+ssh-key and snmp credential type. password: Password for the credential. Used for username+password and snmp credential types. community: The SNMP community auth_algorithm: The SNMP authentication algorithm. Required for snmp credential type. privacy_algorithm: The SNMP privacy algorithm privacy_password: The SNMP privacy password public_key: PGP public key in *armor* plain text format. Required for pgp credential type. Examples: Creating a Username + Password credential .. code-block:: python gmp.create_credential( name='UP Credential', credential_type=CredentialType.USERNAME_PASSWORD, login='foo', password='bar', ) Creating a Username + SSH Key credential .. code-block:: python with open('path/to/private-ssh-key') as f: key = f.read() gmp.create_credential( name='USK Credential', credential_type=CredentialType.USERNAME_SSH_KEY, login='foo', key_phrase='foobar', private_key=key, ) Creating a PGP credential .. note:: A compatible public pgp key file can be exported with GnuPG via :: $ gpg --armor --export alice@cyb.org > alice.asc .. code-block:: python with open('path/to/pgp.key.asc') as f: key = f.read() gmp.create_credential( name='PGP Credential', credential_type=CredentialType.PGP_ENCRYPTION_KEY, public_key=key, ) Creating a S/MIME credential .. code-block:: python with open('path/to/smime-cert') as f: cert = f.read() gmp.create_credential( name='SMIME Credential', credential_type=CredentialType.SMIME_CERTIFICATE, certificate=cert, ) Creating a Password-Only credential .. code-block:: python gmp.create_credential( name='Password-Only Credential', credential_type=CredentialType.PASSWORD_ONLY, password='foo', ) Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_credential.__name__, argument='name' ) if not isinstance(credential_type, CredentialType): raise InvalidArgumentType( function=self.create_credential.__name__, argument='credential_type', arg_type=CredentialType.__name__, ) cmd = XmlCommand("create_credential") cmd.add_element("name", name) cmd.add_element("type", credential_type.value) if comment: cmd.add_element("comment", comment) if allow_insecure is not None: cmd.add_element("allow_insecure", to_bool(allow_insecure)) if ( credential_type == CredentialType.CLIENT_CERTIFICATE or credential_type == CredentialType.SMIME_CERTIFICATE ): if not certificate: raise RequiredArgument( function=self.create_credential.__name__, argument='certificate', ) cmd.add_element("certificate", certificate) if ( credential_type == CredentialType.USERNAME_PASSWORD or credential_type == CredentialType.USERNAME_SSH_KEY or credential_type == CredentialType.SNMP ): if not login: raise RequiredArgument( function=self.create_credential.__name__, argument='login' ) cmd.add_element("login", login) if credential_type == CredentialType.PASSWORD_ONLY and not password: raise RequiredArgument( function=self.create_credential.__name__, argument='password' ) if ( credential_type == CredentialType.USERNAME_PASSWORD or credential_type == CredentialType.SNMP or credential_type == CredentialType.PASSWORD_ONLY ) and password: cmd.add_element("password", password) if credential_type == CredentialType.USERNAME_SSH_KEY: if not private_key: raise RequiredArgument( function=self.create_credential.__name__, argument='private_key', ) _xmlkey = cmd.add_element("key") _xmlkey.add_element("private", private_key) if key_phrase: _xmlkey.add_element("phrase", key_phrase) if credential_type == CredentialType.CLIENT_CERTIFICATE and private_key: _xmlkey = cmd.add_element("key") _xmlkey.add_element("private", private_key) if credential_type == CredentialType.SNMP: if not isinstance(auth_algorithm, SnmpAuthAlgorithm): raise InvalidArgumentType( function=self.create_credential.__name__, argument='auth_algorithm', arg_type=SnmpAuthAlgorithm.__name__, ) cmd.add_element("auth_algorithm", auth_algorithm.value) if community: cmd.add_element("community", community) if privacy_algorithm is not None or privacy_password: _xmlprivacy = cmd.add_element("privacy") if privacy_algorithm is not None: if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm): raise InvalidArgumentType( function=self.create_credential.__name__, argument='privacy_algorithm', arg_type=SnmpPrivacyAlgorithm.__name__, ) _xmlprivacy.add_element( "algorithm", privacy_algorithm.value ) if privacy_password: _xmlprivacy.add_element("password", privacy_password) if credential_type == CredentialType.PGP_ENCRYPTION_KEY: if not public_key: raise RequiredArgument( function=self.create_credential.__name__, argument='public_key', ) _xmlkey = cmd.add_element("key") _xmlkey.add_element("public", public_key) return self._send_xml_command(cmd) def delete_credential( self, credential_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing credential Arguments: credential_id: UUID of the credential to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not credential_id: raise RequiredArgument( function=self.delete_credential.__name__, argument='credential_id', ) cmd = XmlCommand("delete_credential") cmd.set_attribute("credential_id", credential_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_credentials( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, scanners: Optional[bool] = None, trash: Optional[bool] = None, targets: Optional[bool] = None, ) -> Any: """Request a list of credentials Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query scanners: Whether to include a list of scanners using the credentials trash: Whether to get the trashcan credentials instead targets: Whether to include a list of targets using the credentials Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_credentials") add_filter(cmd, filter_string, filter_id) if scanners is not None: cmd.set_attribute("scanners", to_bool(scanners)) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if targets is not None: cmd.set_attribute("targets", to_bool(targets)) return self._send_xml_command(cmd) def get_credential( self, credential_id: str, *, scanners: Optional[bool] = None, targets: Optional[bool] = None, credential_format: Optional[CredentialFormat] = None, ) -> Any: """Request a single credential Arguments: credential_id: UUID of an existing credential scanners: Whether to include a list of scanners using the credentials targets: Whether to include a list of targets using the credentials credential_format: One of "key", "rpm", "deb", "exe" or "pem" Returns: The response. See :py:meth:`send_command` for details. """ if not credential_id: raise RequiredArgument( function=self.get_credential.__name__, argument='credential_id' ) cmd = XmlCommand("get_credentials") cmd.set_attribute("credential_id", credential_id) if credential_format: if not isinstance(credential_format, CredentialFormat): raise InvalidArgumentType( function=self.get_credential.__name__, argument='credential_format', arg_type=CredentialFormat.__name__, ) cmd.set_attribute("format", credential_format.value) if scanners is not None: cmd.set_attribute("scanners", to_bool(scanners)) if targets is not None: cmd.set_attribute("targets", to_bool(targets)) return self._send_xml_command(cmd) def modify_credential( self, credential_id: str, *, name: Optional[str] = None, comment: Optional[str] = None, allow_insecure: Optional[bool] = None, certificate: Optional[str] = None, key_phrase: Optional[str] = None, private_key: Optional[str] = None, login: Optional[str] = None, password: Optional[str] = None, auth_algorithm: Optional[SnmpAuthAlgorithm] = None, community: Optional[str] = None, privacy_algorithm: Optional[SnmpPrivacyAlgorithm] = None, privacy_password: Optional[str] = None, public_key: Optional[str] = None, ) -> Any: """Modifies an existing credential. Arguments: credential_id: UUID of the credential name: Name of the credential comment: Comment for the credential allow_insecure: Whether to allow insecure use of the credential certificate: Certificate for the credential key_phrase: Key passphrase for the private key private_key: Private key to use for login login: Username for the credential password: Password for the credential auth_algorithm: The authentication algorithm for SNMP community: The SNMP community privacy_algorithm: The privacy algorithm for SNMP privacy_password: The SNMP privacy password public_key: PGP public key in *armor* plain text format Returns: The response. See :py:meth:`send_command` for details. """ if not credential_id: raise RequiredArgument( function=self.modify_credential.__name__, argument='credential_id', ) cmd = XmlCommand("modify_credential") cmd.set_attribute("credential_id", credential_id) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if allow_insecure is not None: cmd.add_element("allow_insecure", to_bool(allow_insecure)) if certificate: cmd.add_element("certificate", certificate) if key_phrase and private_key: _xmlkey = cmd.add_element("key") _xmlkey.add_element("phrase", key_phrase) _xmlkey.add_element("private", private_key) elif (not key_phrase and private_key) or ( key_phrase and not private_key ): raise RequiredArgument( function=self.modify_credential.__name__, argument='key_phrase and private_key', ) if login: cmd.add_element("login", login) if password: cmd.add_element("password", password) if auth_algorithm: if not isinstance(auth_algorithm, SnmpAuthAlgorithm): raise InvalidArgumentType( function=self.modify_credential.__name__, argument='auth_algorithm', arg_type=SnmpAuthAlgorithm.__name__, ) cmd.add_element("auth_algorithm", auth_algorithm.value) if community: cmd.add_element("community", community) if privacy_algorithm is not None or privacy_password is not None: _xmlprivacy = cmd.add_element("privacy") if privacy_algorithm is not None: if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm): raise InvalidArgumentType( function=self.modify_credential.__name__, argument='privacy_algorithm', arg_type=SnmpPrivacyAlgorithm.__name__, ) _xmlprivacy.add_element("algorithm", privacy_algorithm.value) if privacy_password is not None: _xmlprivacy.add_element("password", privacy_password) if public_key: _xmlkey = cmd.add_element("key") _xmlkey.add_element("public", public_key) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/entities.py000066400000000000000000000050311413122500400240140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Optional from gvm.errors import InvalidArgument class EntityType(Enum): """Enum for entity types""" ALERT = "alert" ASSET = "asset" AUDIT = "audit" CERT_BUND_ADV = "cert_bund_adv" CPE = "cpe" CREDENTIAL = "credential" CVE = "cve" DFN_CERT_ADV = "dfn_cert_adv" FILTER = "filter" GROUP = "group" HOST = "host" INFO = "info" NOTE = "note" NVT = "nvt" OPERATING_SYSTEM = "os" OVALDEF = "ovaldef" OVERRIDE = "override" PERMISSION = "permission" POLICY = "policy" PORT_LIST = "port_list" REPORT = "report" REPORT_FORMAT = "report_format" RESULT = "result" ROLE = "role" SCAN_CONFIG = "config" SCANNER = "scanner" SCHEDULE = "schedule" TAG = "tag" TARGET = "target" TASK = "task" TICKET = "ticket" TLS_CERTIFICATE = "tls_certificate" USER = "user" VULNERABILITY = "vuln" @classmethod def from_string( cls, entity_type: Optional[str], ) -> Optional["EntityType"]: """Convert a entity type string to an actual EntityType instance Arguments: entity_type: Entity type string to convert to a EntityType """ if not entity_type: return None if entity_type == 'vuln': return cls.VULNERABILITY if entity_type == 'os': return cls.OPERATING_SYSTEM if entity_type == 'config': return cls.SCAN_CONFIG if entity_type == 'tls_certificate': return cls.TLS_CERTIFICATE try: return cls[entity_type.upper()] except KeyError: raise InvalidArgument( argument='entity_type', function=cls.from_string.__name__, ) from None python-gvm-21.10.0/gvm/protocols/gmpv208/entities/filter.py000066400000000000000000000177371413122500400234750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class FilterType(Enum): """Enum for filter types""" ALERT = "alert" ASSET = "asset" SCAN_CONFIG = "config" CREDENTIAL = "credential" FILTER = "filter" GROUP = "group" HOST = "host" NOTE = "note" OPERATING_SYSTEM = "os" OVERRIDE = "override" PERMISSION = "permission" PORT_LIST = "port_list" REPORT = "report" REPORT_FORMAT = "report_format" RESULT = "result" ROLE = "role" SCHEDULE = "schedule" ALL_SECINFO = "secinfo" TAG = "tag" TARGET = "target" TASK = "task" TICKET = "ticket" TLS_CERTIFICATE = "tls_certificate" USER = "user" VULNERABILITY = "vuln" @classmethod def from_string( cls, filter_type: Optional[str], ) -> Optional["FilterType"]: """Convert a filter type string to an actual FilterType instance Arguments: filter_type (str): Filter type string to convert to a FilterType """ if not filter_type: return None if filter_type == 'vuln': return cls.VULNERABILITY if filter_type == 'os': return cls.OPERATING_SYSTEM if filter_type == 'config': return cls.SCAN_CONFIG if filter_type == 'secinfo': return cls.ALL_SECINFO try: return cls[filter_type.upper()] except KeyError: raise InvalidArgument( argument='filter_type', function=cls.from_string.__name__, ) from None class FiltersMixin: def clone_filter(self, filter_id: str) -> Any: """Clone an existing filter Arguments: filter_id: UUID of an existing filter to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not filter_id: raise RequiredArgument( function=self.clone_filter.__name__, argument='filter_id' ) cmd = XmlCommand("create_filter") cmd.add_element("copy", filter_id) return self._send_xml_command(cmd) def create_filter( self, name: str, *, filter_type: Optional[FilterType] = None, comment: Optional[str] = None, term: Optional[str] = None, ) -> Any: """Create a new filter Arguments: name: Name of the new filter filter_type: Filter for entity type comment: Comment for the filter term: Filter term e.g. 'name=foo' Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_filter.__name__, argument="name" ) cmd = XmlCommand("create_filter") _xmlname = cmd.add_element("name", name) if comment: cmd.add_element("comment", comment) if term: cmd.add_element("term", term) if filter_type: if not isinstance(filter_type, FilterType): raise InvalidArgumentType( function=self.create_filter.__name__, argument="filter_type", arg_type=FilterType.__name__, ) cmd.add_element("type", filter_type.value) return self._send_xml_command(cmd) def delete_filter( self, filter_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing filter Arguments: filter_id: UUID of the filter to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not filter_id: raise RequiredArgument( function=self.delete_filter.__name__, argument='filter_id' ) cmd = XmlCommand("delete_filter") cmd.set_attribute("filter_id", filter_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_filters( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, alerts: Optional[bool] = None, ) -> Any: """Request a list of filters Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan filters instead alerts: Whether to include list of alerts that use the filter. Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_filters") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if alerts is not None: cmd.set_attribute("alerts", to_bool(alerts)) return self._send_xml_command(cmd) def get_filter( self, filter_id: str, *, alerts: Optional[bool] = None ) -> Any: """Request a single filter Arguments: filter_id: UUID of an existing filter alerts: Whether to include list of alerts that use the filter. Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_filters") if not filter_id: raise RequiredArgument( function=self.get_filter.__name__, argument='filter_id' ) cmd.set_attribute("filter_id", filter_id) if alerts is not None: cmd.set_attribute("alerts", to_bool(alerts)) return self._send_xml_command(cmd) def modify_filter( self, filter_id: str, *, comment: Optional[str] = None, name: Optional[str] = None, term: Optional[str] = None, filter_type: Optional[FilterType] = None, ) -> Any: """Modifies an existing filter. Arguments: filter_id: UUID of the filter to be modified comment: Comment on filter. name: Name of filter. term: Filter term. filter_type: Resource type filter applies to. Returns: The response. See :py:meth:`send_command` for details. """ if not filter_id: raise RequiredArgument( function=self.modify_filter.__name__, argument='filter_id' ) cmd = XmlCommand("modify_filter") cmd.set_attribute("filter_id", filter_id) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if term: cmd.add_element("term", term) if filter_type: if not isinstance(filter_type, FilterType): raise InvalidArgumentType( function=self.modify_filter.__name__, argument='filter_type', arg_type=FilterType.__name__, ) cmd.add_element("type", filter_type.value) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/groups.py000066400000000000000000000126431413122500400235160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional from gvm.errors import RequiredArgument from gvm.utils import add_filter, to_bool, to_comma_list from gvm.xml import XmlCommand class GroupsMixin: def clone_group(self, group_id: str) -> Any: """Clone an existing group Arguments: group_id: UUID of an existing group to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not group_id: raise RequiredArgument( function=self.clone_group.__name__, argument='group_id' ) cmd = XmlCommand("create_group") cmd.add_element("copy", group_id) return self._send_xml_command(cmd) def create_group( self, name: str, *, comment: Optional[str] = None, special: Optional[bool] = False, users: Optional[List[str]] = None, ) -> Any: """Create a new group Arguments: name: Name of the new group comment: Comment for the group special: Create permission giving members full access to each other's entities users: List of user names to be in the group Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_group.__name__, argument='name' ) cmd = XmlCommand("create_group") cmd.add_element("name", name) if comment: cmd.add_element("comment", comment) if special: _xmlspecial = cmd.add_element("specials") _xmlspecial.add_element("full") if users: cmd.add_element("users", to_comma_list(users)) return self._send_xml_command(cmd) def delete_group( self, group_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing group Arguments: group_id: UUID of the group to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not group_id: raise RequiredArgument( function=self.delete_group.__name__, argument='group_id' ) cmd = XmlCommand("delete_group") cmd.set_attribute("group_id", group_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_groups( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, ) -> Any: """Request a list of groups Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan groups instead Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_groups") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return self._send_xml_command(cmd) def get_group(self, group_id: str) -> Any: """Request a single group Arguments: group_id: UUID of an existing group Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_groups") if not group_id: raise RequiredArgument( function=self.get_group.__name__, argument='group_id' ) cmd.set_attribute("group_id", group_id) return self._send_xml_command(cmd) def modify_group( self, group_id: str, *, comment: Optional[str] = None, name: Optional[str] = None, users: Optional[List[str]] = None, ) -> Any: """Modifies an existing group. Arguments: group_id: UUID of group to modify. comment: Comment on group. name: Name of group. users: List of user names to be in the group Returns: The response. See :py:meth:`send_command` for details. """ if not group_id: raise RequiredArgument( function=self.modify_group.__name__, argument='group_id' ) cmd = XmlCommand("modify_group") cmd.set_attribute("group_id", group_id) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if users: cmd.add_element("users", to_comma_list(users)) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/hosts.py000066400000000000000000000114271413122500400233360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import RequiredArgument, InvalidArgument from gvm.utils import add_filter from gvm.xml import XmlCommand class HostsOrdering(Enum): """Enum for host ordering during scans""" SEQUENTIAL = "sequential" RANDOM = "random" REVERSE = "reverse" @classmethod def from_string( cls, hosts_ordering: Optional[str], ) -> Optional["HostsOrdering"]: """Convert a hosts ordering string to an actual HostsOrdering instance Arguments: hosts_ordering: Host ordering string to convert to a HostsOrdering """ if not hosts_ordering: return None try: return cls[hosts_ordering.upper()] except KeyError: raise InvalidArgument( argument='hosts_ordering', function=cls.from_string.__name__, ) from None class HostsMixin: def create_host(self, name: str, *, comment: Optional[str] = None) -> Any: """Create a new host host Arguments: name: Name for the new host host comment: Comment for the new host host Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_host.__name__, argument='name' ) cmd = XmlCommand("create_asset") host = cmd.add_element("asset") host.add_element("type", "host") host.add_element("name", name) if comment: host.add_element("comment", comment) return self._send_xml_command(cmd) def delete_host(self, host_id: str) -> Any: """Deletes an existing host Arguments: host_id: UUID of the single host to delete. """ if not host_id: raise RequiredArgument( function=self.delete_host.__name__, argument='host_id', ) cmd = XmlCommand("delete_asset") cmd.set_attribute("asset_id", host_id) return self._send_xml_command(cmd) def get_hosts( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, ) -> Any: """Request a list of hosts Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_assets") cmd.set_attribute("type", "host") add_filter(cmd, filter_string, filter_id) return self._send_xml_command(cmd) def get_host(self, host_id: str) -> Any: """Request a single host Arguments: host_id: UUID of an existing host Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_assets") if not host_id: raise RequiredArgument( function=self.get_host.__name__, argument='host_id' ) cmd.set_attribute("asset_id", host_id) cmd.set_attribute("type", "host") return self._send_xml_command(cmd) def modify_host( self, host_id: str, *, comment: Optional[str] = None ) -> Any: """Modifies an existing host. Arguments: host_id: UUID of the host to be modified. comment: Comment for the host. Not passing a comment arguments clears the comment for this host. Returns: The response. See :py:meth:`send_command` for details. """ if not host_id: raise RequiredArgument( function=self.modify_host.__name__, argument='host_id' ) cmd = XmlCommand("modify_asset") cmd.set_attribute("asset_id", host_id) if not comment: comment = "" cmd.add_element("comment", comment) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/notes.py000066400000000000000000000204241413122500400233230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208.entities.severity import Severity, SeverityLevel from gvm.utils import add_filter, to_comma_list, to_bool from gvm.xml import XmlCommand class NotesMixin: def create_note( self, text: str, nvt_oid: str, *, days_active: Optional[int] = None, hosts: Optional[List[str]] = None, port: Optional[int] = None, result_id: Optional[str] = None, severity: Optional[Severity] = None, task_id: Optional[str] = None, threat: Optional[SeverityLevel] = None, ) -> Any: """Create a new note Arguments: text: Text of the new note nvt_id: OID of the nvt to which note applies days_active: Days note will be active. -1 on always, 0 off hosts: A list of hosts addresses port: Port to which the note applies result_id: UUID of a result to which note applies severity: Severity to which note applies task_id: UUID of task to which note applies threat: Severity level to which note applies. Will be converted to severity. Returns: The response. See :py:meth:`send_command` for details. """ if not text: raise RequiredArgument( function=self.create_note.__name__, argument='text' ) if not nvt_oid: raise RequiredArgument( function=self.create_note.__name__, argument='nvt_oid' ) cmd = XmlCommand("create_note") cmd.add_element("text", text) cmd.add_element("nvt", attrs={"oid": nvt_oid}) if days_active is not None: cmd.add_element("active", str(days_active)) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if port: cmd.add_element("port", str(port)) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity: cmd.add_element("severity", str(severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) if threat is not None: if not isinstance(threat, SeverityLevel): raise InvalidArgumentType( function="create_note", argument="threat", arg_type=SeverityLevel.__name__, ) cmd.add_element("threat", threat.value) return self._send_xml_command(cmd) def clone_note(self, note_id: str) -> Any: """Clone an existing note Arguments: note_id: UUID of an existing note to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not note_id: raise RequiredArgument( function=self.clone_note.__name__, argument='note_id' ) cmd = XmlCommand("create_note") cmd.add_element("copy", note_id) return self._send_xml_command(cmd) def delete_note( self, note_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing note Arguments: note_id: UUID of the note to be deleted. ultimate: Whether to remove entirely,or to the trashcan. """ if not note_id: raise RequiredArgument( function=self.delete_note.__name__, argument='note_id' ) cmd = XmlCommand("delete_note") cmd.set_attribute("note_id", note_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_notes( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, details: Optional[bool] = None, result: Optional[bool] = None, ) -> Any: """Request a list of notes Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query details: Add info about connected results and tasks result: Return the details of possible connected results. Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_notes") add_filter(cmd, filter_string, filter_id) if details is not None: cmd.set_attribute("details", to_bool(details)) if result is not None: cmd.set_attribute("result", to_bool(result)) return self._send_xml_command(cmd) def get_note(self, note_id: str) -> Any: """Request a single note Arguments: note_id: UUID of an existing note Returns: The response. See :py:meth:`send_command` for details. """ if not note_id: raise RequiredArgument( function=self.get_note.__name__, argument='note_id' ) cmd = XmlCommand("get_notes") cmd.set_attribute("note_id", note_id) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def modify_note( self, note_id: str, text: str, *, days_active: Optional[int] = None, hosts: Optional[List[str]] = None, port: Optional[int] = None, result_id: Optional[str] = None, severity: Optional[Severity] = None, task_id: Optional[str] = None, threat: Optional[SeverityLevel] = None, ) -> Any: """Modifies an existing note. Arguments: note_id: UUID of note to modify. text: The text of the note. days_active: Days note will be active. -1 on always, 0 off. hosts: A list of hosts addresses port: Port to which note applies. result_id: Result to which note applies. severity: Severity to which note applies. task_id: Task to which note applies. threat: Threat level to which note applies. Will be converted to severity. Returns: The response. See :py:meth:`send_command` for details. """ if not note_id: raise RequiredArgument( function=self.modify_note.__name__, argument='note_id' ) if not text: raise RequiredArgument( function=self.modify_note.__name__, argument='text' ) cmd = XmlCommand("modify_note") cmd.set_attribute("note_id", note_id) cmd.add_element("text", text) if days_active is not None: cmd.add_element("active", str(days_active)) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if port: cmd.add_element("port", str(port)) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity: cmd.add_element("severity", str(severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) if threat is not None: if not isinstance(threat, SeverityLevel): raise InvalidArgumentType( function=self.modify_note.__name__, argument='threat', arg_type=SeverityLevel.__name__, ) cmd.add_element("threat", threat.value) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/operating_systems.py000066400000000000000000000073041413122500400257540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, Optional from gvm.errors import RequiredArgument from gvm.utils import add_filter from gvm.xml import XmlCommand class OperatingSystemsMixin: def delete_operating_system( self, operating_system_id: str, ) -> Any: """Deletes an existing operating_system Arguments: operating_system_id: UUID of the single operating_system to delete. """ if not operating_system_id: raise RequiredArgument( function=self.delete_operating_system.__name__, argument='operating_system_id', ) cmd = XmlCommand("delete_asset") cmd.set_attribute("asset_id", operating_system_id) return self._send_xml_command(cmd) def get_operating_systems( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, ) -> Any: """Request a list of operating_systems Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_assets") cmd.set_attribute("type", "os") add_filter(cmd, filter_string, filter_id) return self._send_xml_command(cmd) def get_operating_system(self, operating_system_id: str) -> Any: """Request a single operating_system Arguments: operating_system_id: UUID of an existing operating_system Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_assets") if not operating_system_id: raise RequiredArgument( function=self.get_operating_system.__name__, argument='operating_system_id', ) cmd.set_attribute("asset_id", operating_system_id) cmd.set_attribute("type", "os") return self._send_xml_command(cmd) def modify_operating_system( self, operating_system_id: str, *, comment: Optional[str] = None ) -> Any: """Modifies an existing operating system. Arguments: operating_system_id: UUID of the operating_system to be modified. comment: Comment for the operating_system. Not passing a comment arguments clears the comment for this operating system. Returns: The response. See :py:meth:`send_command` for details. """ if not operating_system_id: raise RequiredArgument( function=self.modify_operating_system.__name__, argument='operating_system_id', ) cmd = XmlCommand("modify_asset") cmd.set_attribute("asset_id", operating_system_id) if not comment: comment = "" cmd.add_element("comment", comment) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/overrides.py000066400000000000000000000237101413122500400241760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208.entities.severity import Severity, SeverityLevel from gvm.utils import add_filter, to_comma_list, to_bool from gvm.xml import XmlCommand class OverridesMixin: def create_override( self, text: str, nvt_oid: str, *, days_active: Optional[int] = None, hosts: Optional[List[str]] = None, port: Optional[int] = None, result_id: Optional[str] = None, severity: Optional[Severity] = None, new_severity: Optional[Severity] = None, task_id: Optional[str] = None, threat: Optional[SeverityLevel] = None, new_threat: Optional[SeverityLevel] = None, ) -> Any: """Create a new override Arguments: text: Text of the new override nvt_id: OID of the nvt to which override applies days_active: Days override will be active. -1 on always, 0 off hosts: A list of host addresses port: Port to which the override applies result_id: UUID of a result to which override applies severity: Severity to which override applies new_severity: New severity for result task_id: UUID of task to which override applies threat: Severity level to which override applies. Will be converted to severity. new_threat: New severity level for results. Will be converted to new_severity. Returns: The response. See :py:meth:`send_command` for details. """ if not text: raise RequiredArgument( function=self.create_override.__name__, argument='text' ) if not nvt_oid: raise RequiredArgument( function=self.create_override.__name__, argument='nvt_oid' ) cmd = XmlCommand("create_override") cmd.add_element("text", text) cmd.add_element("nvt", attrs={"oid": nvt_oid}) if days_active is not None: cmd.add_element("active", str(days_active)) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if port: cmd.add_element("port", str(port)) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity: cmd.add_element("severity", str(severity)) if new_severity: cmd.add_element("new_severity", str(new_severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) if threat is not None: if not isinstance(threat, SeverityLevel): raise InvalidArgumentType( function=self.create_override.__name__, argument="threat", arg_type=SeverityLevel.__name__, ) cmd.add_element("threat", threat.value) if new_threat is not None: if not isinstance(new_threat, SeverityLevel): raise InvalidArgumentType( function=self.create_override.__name__, argument="new_threat", arg_type=SeverityLevel.__name__, ) cmd.add_element("new_threat", new_threat.value) return self._send_xml_command(cmd) def clone_override(self, override_id: str) -> Any: """Clone an existing override Arguments: override_id: UUID of an existing override to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not override_id: raise RequiredArgument( function=self.clone_override.__name__, argument='override_id' ) cmd = XmlCommand("create_override") cmd.add_element("copy", override_id) return self._send_xml_command(cmd) def delete_override( self, override_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing override Arguments: override_id: UUID of the override to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not override_id: raise RequiredArgument( function=self.delete_override.__name__, argument='override_id' ) cmd = XmlCommand("delete_override") cmd.set_attribute("override_id", override_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_overrides( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, details: Optional[bool] = None, result: Optional[bool] = None, ) -> Any: """Request a list of overrides Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query details: Whether to include full details result: Whether to include results using the override Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_overrides") add_filter(cmd, filter_string, filter_id) if details is not None: cmd.set_attribute("details", to_bool(details)) if result is not None: cmd.set_attribute("result", to_bool(result)) return self._send_xml_command(cmd) def get_override(self, override_id: str) -> Any: """Request a single override Arguments: override_id: UUID of an existing override Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_overrides") if not override_id: raise RequiredArgument( function=self.get_override.__name__, argument='override_id' ) cmd.set_attribute("override_id", override_id) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def modify_override( self, override_id: str, text: str, *, days_active: Optional[int] = None, hosts: Optional[List[str]] = None, port: Optional[int] = None, result_id: Optional[str] = None, severity: Optional[Severity] = None, new_severity: Optional[Severity] = None, task_id: Optional[str] = None, threat: Optional[SeverityLevel] = None, new_threat: Optional[SeverityLevel] = None, ) -> Any: """Modifies an existing override. Arguments: override_id: UUID of override to modify. text: The text of the override. days_active: Days override will be active. -1 on always, 0 off. hosts: A list of host addresses port: Port to which override applies. result_id: Result to which override applies. severity: Severity to which override applies. new_severity: New severity score for result. task_id: Task to which override applies. threat: Threat level to which override applies. Will be converted to severity. new_threat: New threat level for results. Will be converted to new_severity. Returns: The response. See :py:meth:`send_command` for details. """ if not override_id: raise RequiredArgument( function=self.modify_override.__name__, argument='override_id' ) if not text: raise RequiredArgument( function=self.modify_override.__name__, argument='text' ) cmd = XmlCommand("modify_override") cmd.set_attribute("override_id", override_id) cmd.add_element("text", text) if days_active is not None: cmd.add_element("active", str(days_active)) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if port: cmd.add_element("port", str(port)) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity: cmd.add_element("severity", str(severity)) if new_severity: cmd.add_element("new_severity", str(new_severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) if threat is not None: if not isinstance(threat, SeverityLevel): raise InvalidArgumentType( function=self.modify_override.__name__, argument='threat', arg_type=SeverityLevel.__name__, ) cmd.add_element("threat", threat.value) if new_threat is not None: if not isinstance(new_threat, SeverityLevel): raise InvalidArgumentType( function=self.modify_override.__name__, argument='new_threat', arg_type=SeverityLevel.__name__, ) cmd.add_element("new_threat", new_threat.value) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/permissions.py000066400000000000000000000251401413122500400245460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.protocols.gmpv208.entities.entities import EntityType from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class PermissionSubjectType(Enum): """Enum for permission subject type""" USER = 'user' GROUP = 'group' ROLE = 'role' @classmethod def from_string( cls, subject_type: Optional[str], ) -> Optional["PermissionSubjectType"]: """Convert a permission subject type string to an actual PermissionSubjectType instance Arguments: subject_type: Permission subject type string to convert to a PermissionSubjectType """ if not subject_type: return None try: return cls[subject_type.upper()] except KeyError: raise InvalidArgument( argument='subject_type', function=cls.from_string.__name__, ) from None class PermissionsMixin: def clone_permission(self, permission_id: str) -> Any: """Clone an existing permission Arguments: permission_id: UUID of an existing permission to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not permission_id: raise RequiredArgument( function=self.clone_permission.__name__, argument='permission_id', ) cmd = XmlCommand("create_permission") cmd.add_element("copy", permission_id) return self._send_xml_command(cmd) def create_permission( self, name: str, subject_id: str, subject_type: PermissionSubjectType, *, resource_id: Optional[str] = None, resource_type: Optional[EntityType] = None, comment: Optional[str] = None, ) -> Any: """Create a new permission Arguments: name: Name of the new permission subject_id: UUID of subject to whom the permission is granted subject_type: Type of the subject user, group or role comment: Comment for the permission resource_id: UUID of entity to which the permission applies resource_type: Type of the resource. For Super permissions user, group or role Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_permission.__name__, argument='name' ) if not subject_id: raise RequiredArgument( function=self.create_permission.__name__, argument='subject_id' ) if not isinstance(subject_type, PermissionSubjectType): raise InvalidArgumentType( function=self.create_permission.__name__, argument='subject_type', arg_type=PermissionSubjectType.__name__, ) cmd = XmlCommand("create_permission") cmd.add_element("name", name) _xmlsubject = cmd.add_element("subject", attrs={"id": subject_id}) _xmlsubject.add_element("type", subject_type.value) if comment: cmd.add_element("comment", comment) if resource_id or resource_type: if not resource_id: raise RequiredArgument( function=self.create_permission.__name__, argument='resource_id', ) if not resource_type: raise RequiredArgument( function=self.create_permission.__name__, argument='resource_type', ) if not isinstance(resource_type, EntityType): raise InvalidArgumentType( function=self.create_permission.__name__, argument='resource_type', arg_type=EntityType.__name__, ) _xmlresource = cmd.add_element( "resource", attrs={"id": resource_id} ) _actual_resource_type = resource_type if resource_type.value == EntityType.AUDIT.value: _actual_resource_type = EntityType.TASK elif resource_type.value == EntityType.POLICY.value: _actual_resource_type = EntityType.SCAN_CONFIG _xmlresource.add_element("type", _actual_resource_type.value) return self._send_xml_command(cmd) def delete_permission( self, permission_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing permission Arguments: permission_id: UUID of the permission to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not permission_id: raise RequiredArgument( function=self.delete_permission.__name__, argument='permission_id', ) cmd = XmlCommand("delete_permission") cmd.set_attribute("permission_id", permission_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_permissions( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, ) -> Any: """Request a list of permissions Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get permissions in the trashcan instead Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_permissions") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return self._send_xml_command(cmd) def get_permission(self, permission_id: str) -> Any: """Request a single permission Arguments: permission_id: UUID of an existing permission Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_permissions") if not permission_id: raise RequiredArgument( function=self.get_permission.__name__, argument='permission_id' ) cmd.set_attribute("permission_id", permission_id) return self._send_xml_command(cmd) def modify_permission( self, permission_id: str, *, comment: Optional[str] = None, name: Optional[str] = None, resource_id: Optional[str] = None, resource_type: Optional[EntityType] = None, subject_id: Optional[str] = None, subject_type: Optional[PermissionSubjectType] = None, ) -> Any: """Modifies an existing permission. Arguments: permission_id: UUID of permission to be modified. comment: The comment on the permission. name: Permission name, currently the name of a command. subject_id: UUID of subject to whom the permission is granted subject_type: Type of the subject user, group or role resource_id: UUID of entity to which the permission applies resource_type: Type of the resource. For Super permissions user, group or role Returns: The response. See :py:meth:`send_command` for details. """ if not permission_id: raise RequiredArgument( function=self.modify_permission.__name__, argument='permission_id', ) cmd = XmlCommand("modify_permission") cmd.set_attribute("permission_id", permission_id) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if resource_id or resource_type: if not resource_id: raise RequiredArgument( function=self.modify_permission.__name__, argument='resource_id', ) if not resource_type: raise RequiredArgument( function=self.modify_permission.__name__, argument='resource_type', ) if not isinstance(resource_type, EntityType): raise InvalidArgumentType( function=self.modify_permission.__name__, argument='resource_type', arg_type=EntityType.__name__, ) _xmlresource = cmd.add_element( "resource", attrs={"id": resource_id} ) _actual_resource_type = resource_type if resource_type.value == EntityType.AUDIT.value: _actual_resource_type = EntityType.TASK elif resource_type.value == EntityType.POLICY.value: _actual_resource_type = EntityType.SCAN_CONFIG _xmlresource.add_element("type", _actual_resource_type.value) if subject_id or subject_type: if not subject_id: raise RequiredArgument( function=self.modify_permission.__name__, argument='subject_id', ) if not isinstance(subject_type, PermissionSubjectType): raise InvalidArgumentType( function=self.modify_permission.__name__, argument='subject_type', arg_type=PermissionSubjectType.__name__, ) _xmlsubject = cmd.add_element("subject", attrs={"id": subject_id}) _xmlsubject.add_element("type", subject_type.value) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/policies.py000066400000000000000000000345031413122500400240050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional, Tuple from lxml.etree import XMLSyntaxError from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.utils import add_filter, to_base64, to_bool, is_list_like from gvm.xml import XmlCommand _EMPTY_POLICY_ID = '085569ce-73ed-11df-83c3-002264764cea' class PoliciesMixin: def clone_policy(self, policy_id: str) -> Any: """Clone a policy from an existing one Arguments: policy_id: UUID of the existing policy Returns: The response. See :py:meth:`send_command` for details. """ if not policy_id: raise RequiredArgument( function=self.clone_policy.__name__, argument='policy_id' ) cmd = XmlCommand("create_config") cmd.add_element("copy", policy_id) return self._send_xml_command(cmd) def create_policy( self, name: str, *, policy_id: str = None, comment: Optional[str] = None ) -> Any: """Create a new policy Arguments: name: Name of the new policy policy_id: UUID of an existing policy as base. By default the empty policy is used. comment: A comment on the policy Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("create_config") if policy_id is None: policy_id = _EMPTY_POLICY_ID if not name: raise RequiredArgument( function=self.create_policy.__name__, argument='name' ) if comment is not None: cmd.add_element("comment", comment) cmd.add_element("copy", policy_id) cmd.add_element("name", name) cmd.add_element("usage_type", "policy") return self._send_xml_command(cmd) def delete_policy( self, policy_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing policy Arguments: policy_id: UUID of the policy to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not policy_id: raise RequiredArgument( function=self.delete_policy.__name__, argument='policy_id' ) cmd = XmlCommand("delete_config") cmd.set_attribute("config_id", policy_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_policies( self, *, audits: Optional[bool] = None, filter_string: Optional[str] = None, filter_id: Optional[str] = None, details: Optional[bool] = None, families: Optional[bool] = None, preferences: Optional[bool] = None, trash: Optional[bool] = None, ) -> Any: """Request a list of policies Arguments: audits: Whether to get audits using the policy filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query details: Whether to get families, preferences, nvt selectors and tasks. families: Whether to include the families if no details are requested preferences: Whether to include the preferences if no details are requested trash: Whether to get the trashcan audits instead Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_configs") cmd.set_attribute("usage_type", "policy") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if details is not None: cmd.set_attribute("details", to_bool(details)) if families is not None: cmd.set_attribute("families", to_bool(families)) if preferences is not None: cmd.set_attribute("preferences", to_bool(preferences)) if audits is not None: cmd.set_attribute("tasks", to_bool(audits)) return self._send_xml_command(cmd) def get_policy( self, policy_id: str, *, audits: Optional[bool] = None ) -> Any: """Request a single policy Arguments: policy_id: UUID of an existing policy audits: Whether to get audits using this policy Returns: The response. See :py:meth:`send_command` for details. """ if not policy_id: raise RequiredArgument( function=self.get_policy.__name__, argument='policy_id' ) cmd = XmlCommand("get_configs") cmd.set_attribute("config_id", policy_id) cmd.set_attribute("usage_type", "policy") if audits is not None: cmd.set_attribute("tasks", to_bool(audits)) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def import_policy(self, policy: str) -> Any: """Import a policy from XML Arguments: policy: Policy XML as string to import. This XML must contain a :code:`` root element. Returns: The response. See :py:meth:`send_command` for details. """ if not policy: raise RequiredArgument( function=self.import_policy.__name__, argument='policy' ) cmd = XmlCommand("create_config") try: cmd.append_xml_str(policy) except XMLSyntaxError as e: raise InvalidArgument( function=self.import_policy.__name__, argument='policy' ) from e return self._send_xml_command(cmd) def modify_policy_set_nvt_preference( self, policy_id: str, name: str, nvt_oid: str, *, value: Optional[str] = None, ) -> Any: """Modifies the nvt preferences of an existing policy. Arguments: policy_id: UUID of policy to modify. name: Name for preference to change. nvt_oid: OID of the NVT associated with preference to modify value: New value for the preference. None to delete the preference and to use the default instead. """ if not policy_id: raise RequiredArgument( function=self.modify_policy_set_nvt_preference.__name__, argument='policy_id', ) if not nvt_oid: raise RequiredArgument( function=self.modify_policy_set_nvt_preference.__name__, argument='nvt_oid', ) if not name: raise RequiredArgument( function=self.modify_policy_set_nvt_preference.__name__, argument='name', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) _xmlpref = cmd.add_element("preference") _xmlpref.add_element("nvt", attrs={"oid": nvt_oid}) _xmlpref.add_element("name", name) if value: _xmlpref.add_element("value", to_base64(value)) return self._send_xml_command(cmd) def modify_policy_set_name(self, policy_id: str, name: str) -> Any: """Modifies the name of an existing policy Arguments: policy_id: UUID of policy to modify. name: New name for the policy. """ if not policy_id: raise RequiredArgument( function=self.modify_policy_set_name.__name__, argument='policy_id', ) if not name: raise RequiredArgument( function=self.modify_policy_set_name.__name__, argument='name', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) cmd.add_element("name", name) return self._send_xml_command(cmd) def modify_policy_set_comment( self, policy_id: str, comment: Optional[str] = None ) -> Any: """Modifies the comment of an existing policy Arguments: policy_id: UUID of policy to modify. comment: Comment to set on a policy. Default is an empty comment and the previous comment will be removed. """ if not policy_id: raise RequiredArgument( function=self.modify_policy_set_comment.__name__, argument='policy_id', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) if not comment: comment = "" cmd.add_element("comment", comment) return self._send_xml_command(cmd) def modify_policy_set_scanner_preference( self, policy_id: str, name: str, *, value: Optional[str] = None ) -> Any: """Modifies the scanner preferences of an existing policy Arguments: policy_id: UUID of policy to modify. name: Name of the scanner preference to change value: New value for the preference. None to delete the preference and to use the default instead. """ if not policy_id: raise RequiredArgument( function=(self.modify_policy_set_scanner_preference.__name__), argument='policy_id', ) if not name: raise RequiredArgument( function=(self.modify_policy_set_scanner_preference.__name__), argument='name argument', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) _xmlpref = cmd.add_element("preference") _xmlpref.add_element("name", name) if value: _xmlpref.add_element("value", to_base64(value)) return self._send_xml_command(cmd) def modify_policy_set_nvt_selection( self, policy_id: str, family: str, nvt_oids: List[str] ) -> Any: """Modifies the selected nvts of an existing policy The manager updates the given family in the policy to include only the given NVTs. Arguments: policy_id: UUID of policy to modify. family: Name of the NVT family to include NVTs from nvt_oids: List of NVTs to select for the family. """ if not policy_id: raise RequiredArgument( function=self.modify_policy_set_nvt_selection.__name__, argument='policy_id', ) if not family: raise RequiredArgument( function=self.modify_policy_set_nvt_selection.__name__, argument='family argument', ) if not is_list_like(nvt_oids): raise InvalidArgumentType( function=self.modify_policy_set_nvt_selection.__name__, argument='nvt_oids', arg_type='list', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) _xmlnvtsel = cmd.add_element("nvt_selection") _xmlnvtsel.add_element("family", family) for nvt in nvt_oids: _xmlnvtsel.add_element("nvt", attrs={"oid": nvt}) return self._send_xml_command(cmd) def modify_policy_set_family_selection( self, policy_id: str, families: List[Tuple[str, bool, bool]], *, auto_add_new_families: Optional[bool] = True, ) -> Any: """ Selected the NVTs of a policy at a family level. Arguments: policy_id: UUID of policy to modify. families: A list of tuples with the first entry being the name of the NVT family selected, second entry a boolean indicating whether new NVTs should be added to the family automatically, and third entry a boolean indicating whether all nvts from the family should be included. auto_add_new_families: Whether new families should be added to the policy automatically. Default: True. """ if not policy_id: raise RequiredArgument( function=self.modify_policy_set_family_selection.__name__, argument='policy_id', ) if not is_list_like(families): raise InvalidArgumentType( function=self.modify_policy_set_family_selection.__name__, argument='families', arg_type='list', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) _xmlfamsel = cmd.add_element("family_selection") _xmlfamsel.add_element("growing", to_bool(auto_add_new_families)) for family in families: _xmlfamily = _xmlfamsel.add_element("family") _xmlfamily.add_element("name", family[0]) if len(family) != 3: raise InvalidArgument( "Family must be a tuple of 3. (str, bool, bool)" ) if not isinstance(family[1], bool) or not isinstance( family[2], bool ): raise InvalidArgumentType( function=(self.modify_policy_set_family_selection.__name__), argument='families', arg_type='[tuple(str, bool, bool)]', ) _xmlfamily.add_element("all", to_bool(family[2])) _xmlfamily.add_element("growing", to_bool(family[1])) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/port_lists.py000066400000000000000000000217031413122500400243760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class PortRangeType(Enum): """Enum for port range type""" TCP = 'TCP' UDP = 'UDP' @classmethod def from_string( cls, port_range_type: Optional[str], ) -> Optional["PortRangeType"]: """Convert a port range type string to an actual PortRangeType instance Arguments: port_range_type: Port range type string to convert to a PortRangeType """ if not port_range_type: return None try: return cls[port_range_type.upper()] except KeyError: raise InvalidArgument( argument='port_range_type', function=cls.from_string.__name__, ) from None class PortListMixin: def clone_port_list(self, port_list_id: str) -> Any: """Clone an existing port list Arguments: port_list_id: UUID of an existing port list to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not port_list_id: raise RequiredArgument( function=self.clone_port_list.__name__, argument='port_list_id' ) cmd = XmlCommand("create_port_list") cmd.add_element("copy", port_list_id) return self._send_xml_command(cmd) def create_port_list( self, name: str, port_range: str, *, comment: Optional[str] = None ) -> Any: """Create a new port list Arguments: name: Name of the new port list port_range: Port list ranges e.g. `"T: 1-1234"` for tcp port 1 - 1234 comment: Comment for the port list Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_port_list.__name__, argument='name' ) if not port_range: raise RequiredArgument( function=self.create_port_list.__name__, argument='port_range' ) cmd = XmlCommand("create_port_list") cmd.add_element("name", name) cmd.add_element("port_range", port_range) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) def create_port_range( self, port_list_id: str, start: int, end: int, port_range_type: PortRangeType, *, comment: Optional[str] = None, ) -> Any: """Create new port range Arguments: port_list_id: UUID of the port list to which to add the range start: The first port in the range end: The last port in the range port_range_type: The type of the ports: TCP, UDP, ... comment: Comment for the port range Returns: The response. See :py:meth:`send_command` for details. """ if not port_list_id: raise RequiredArgument( function=self.create_port_range.__name__, argument='port_list_id', ) if not port_range_type: raise RequiredArgument( function=self.create_port_range.__name__, argument='port_range_type', ) if not start: raise RequiredArgument( function=self.create_port_range.__name__, argument='start' ) if not end: raise RequiredArgument( function=self.create_port_range.__name__, argument='end' ) if not isinstance(port_range_type, PortRangeType): raise InvalidArgumentType( function=self.create_port_range.__name__, argument='port_range_type', arg_type=PortRangeType.__name__, ) cmd = XmlCommand("create_port_range") cmd.add_element("port_list", attrs={"id": port_list_id}) cmd.add_element("start", str(start)) cmd.add_element("end", str(end)) cmd.add_element("type", port_range_type.value) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) def delete_port_list( self, port_list_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing port list Arguments: port_list_id: UUID of the port list to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not port_list_id: raise RequiredArgument( function=self.delete_port_list.__name__, argument='port_list_id' ) cmd = XmlCommand("delete_port_list") cmd.set_attribute("port_list_id", port_list_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def delete_port_range(self, port_range_id: str) -> Any: """Deletes an existing port range Arguments: port_range_id: UUID of the port range to be deleted. """ if not port_range_id: raise RequiredArgument( function=self.delete_port_range.__name__, argument='port_range_id', ) cmd = XmlCommand("delete_port_range") cmd.set_attribute("port_range_id", port_range_id) return self._send_xml_command(cmd) def get_port_lists( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, details: Optional[bool] = None, targets: Optional[bool] = None, trash: Optional[bool] = None, ) -> Any: """Request a list of port lists Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query details: Whether to include full port list details targets: Whether to include targets using this port list trash: Whether to get port lists in the trashcan instead Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_port_lists") add_filter(cmd, filter_string, filter_id) if details is not None: cmd.set_attribute("details", to_bool(details)) if targets is not None: cmd.set_attribute("targets", to_bool(targets)) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return self._send_xml_command(cmd) def get_port_list(self, port_list_id: str): """Request a single port list Arguments: port_list_id: UUID of an existing port list Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_port_lists") if not port_list_id: raise RequiredArgument( function=self.get_port_list.__name__, argument='port_list_id' ) cmd.set_attribute("port_list_id", port_list_id) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def modify_port_list( self, port_list_id: str, *, comment: Optional[str] = None, name: Optional[str] = None, ) -> Any: """Modifies an existing port list. Arguments: port_list_id: UUID of port list to modify. name: Name of port list. comment: Comment on port list. Returns: The response. See :py:meth:`send_command` for details. """ if not port_list_id: raise RequiredArgument( function=self.modify_port_list.__name__, argument='port_list_id' ) cmd = XmlCommand("modify_port_list") cmd.set_attribute("port_list_id", port_list_id) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/report_formats.py000066400000000000000000000246241413122500400252470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional, Union from lxml.etree import XMLSyntaxError from gvm.errors import InvalidArgument, RequiredArgument from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class ReportFormatType(Enum): """Enum for builtin report formats""" ANONYMOUS_XML = '5057e5cc-b825-11e4-9d0e-28d24461215b' ARF = '910200ca-dc05-11e1-954f-406186ea4fc5' CPE = '5ceff8ba-1f62-11e1-ab9f-406186ea4fc5' CSV_HOSTS = '9087b18c-626c-11e3-8892-406186ea4fc5"' CSV_RESULTS = 'c1645568-627a-11e3-a660-406186ea4fc5' GCR_PDF = 'dc51a40a-c022-11e9-b02d-3f7ca5bdcb11' GSR_HTML = 'ffa123c9-a2d2-409e-bbbb-a6c1385dbeaa' GSR_PDF = '35ba7077-dc85-42ef-87c9-b0eda7e903b6' GXCR_PDF = 'f0d348de-c022-11e9-bc4c-4bf1d5e1a8ca' GXR_PDF = 'ebbc7f34-8ae5-11e1-b07b-001f29eadec8' ITG = '77bd6c4a-1f62-11e1-abf0-406186ea4fc5' LATEX = 'a684c02c-b531-11e1-bdc2-406186ea4fc5' NBE = '9ca6fe72-1f62-11e1-9e7c-406186ea4fc5' PDF = 'c402cc3e-b531-11e1-9163-406186ea4fc5' SVG = '9e5e5deb-879e-4ecc-8be6-a71cd0875cdd' TXT = 'a3810a62-1f62-11e1-9219-406186ea4fc5' VERINICE_ISM = 'c15ad349-bd8d-457a-880a-c7056532ee15' VERINICE_ITG = '50c9950a-f326-11e4-800c-28d24461215b' XML = 'a994b278-1f62-11e1-96ac-406186ea4fc5' @classmethod def from_string( cls, report_format: Optional[str], ) -> Optional["ReportFormatType"]: """Convert an report format name into a ReportFormatType instance""" if not report_format: return None try: return cls[report_format.replace(' ', '_').upper()] except KeyError: raise InvalidArgument( argument='report_format', function=cls.from_string.__name__, ) from KeyError class ReportFormatsMixin: def clone_report_format( self, report_format_id: Union[str, ReportFormatType] ) -> Any: """Clone a report format from an existing one Arguments: report_format_id: UUID of the existing report format or ReportFormatType (enum) Returns: The response. See :py:meth:`send_command` for details. """ if not report_format_id: raise RequiredArgument( function=self.clone_report_format.__name__, argument='report_format_id', ) cmd = XmlCommand("create_report_format") if isinstance(report_format_id, ReportFormatType): report_format_id = report_format_id.value cmd.add_element("copy", report_format_id) return self._send_xml_command(cmd) def delete_report_format( self, report_format_id: Optional[Union[str, ReportFormatType]] = None, *, ultimate: Optional[bool] = False, ) -> Any: """Deletes an existing report format Arguments: report_format_id: UUID of the report format to be deleted. or ReportFormatType (enum) ultimate: Whether to remove entirely, or to the trashcan. """ if not report_format_id: raise RequiredArgument( function=self.delete_report_format.__name__, argument='report_format_id', ) cmd = XmlCommand("delete_report_format") if isinstance(report_format_id, ReportFormatType): report_format_id = report_format_id.value cmd.set_attribute("report_format_id", report_format_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_report_formats( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, alerts: Optional[bool] = None, params: Optional[bool] = None, details: Optional[bool] = None, ) -> Any: """Request a list of report formats Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan report formats instead alerts: Whether to include alerts that use the report format params: Whether to include report format parameters details: Include report format file, signature and parameters Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_report_formats") add_filter(cmd, filter_string, filter_id) if details is not None: cmd.set_attribute("details", to_bool(details)) if alerts is not None: cmd.set_attribute("alerts", to_bool(alerts)) if params is not None: cmd.set_attribute("params", to_bool(params)) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return self._send_xml_command(cmd) def get_report_format( self, report_format_id: Union[str, ReportFormatType] ) -> Any: """Request a single report format Arguments: report_format_id: UUID of an existing report format or ReportFormatType (enum) Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_report_formats") if not report_format_id: raise RequiredArgument( function=self.get_report_format.__name__, argument='report_format_id', ) if isinstance(report_format_id, ReportFormatType): report_format_id = report_format_id.value cmd.set_attribute("report_format_id", report_format_id) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def import_report_format(self, report_format: str) -> Any: """Import a report format from XML Arguments: report_format: Report format XML as string to import. This XML must contain a :code:`` root element. Returns: The response. See :py:meth:`send_command` for details. """ if not report_format: raise RequiredArgument( function=self.import_report_format.__name__, argument='report_format', ) cmd = XmlCommand("create_report_format") try: cmd.append_xml_str(report_format) except XMLSyntaxError as e: raise InvalidArgument( function=self.import_report_format.__name__, argument='report_format', ) from e return self._send_xml_command(cmd) def modify_report_format( self, report_format_id: Optional[Union[str, ReportFormatType]] = None, *, active: Optional[bool] = None, name: Optional[str] = None, summary: Optional[str] = None, param_name: Optional[str] = None, param_value: Optional[str] = None, ) -> Any: """Modifies an existing report format. Arguments: report_format_id: UUID of report format to modify or ReportFormatType (enum) active: Whether the report format is active. name: The name of the report format. summary: A summary of the report format. param_name: The name of the param. param_value: The value of the param. Returns: The response. See :py:meth:`send_command` for details. """ if not report_format_id: raise RequiredArgument( function=self.modify_report_format.__name__, argument='report_format_id ', ) cmd = XmlCommand("modify_report_format") if isinstance(report_format_id, ReportFormatType): report_format_id = report_format_id.value cmd.set_attribute("report_format_id", report_format_id) if active is not None: cmd.add_element("active", to_bool(active)) if name: cmd.add_element("name", name) if summary: cmd.add_element("summary", summary) if param_name: _xmlparam = cmd.add_element("param") _xmlparam.add_element("name", param_name) if param_value is not None: _xmlparam.add_element("value", param_value) return self._send_xml_command(cmd) def verify_report_format( self, report_format_id: Union[str, ReportFormatType] ) -> Any: """Verify an existing report format Verifies the trust level of an existing report format. It will be checked whether the signature of the report format currently matches the report format. This includes the script and files used to generate reports of this format. It is *not* verified if the report format works as expected by the user. Arguments: report_format_id: UUID of the report format to be verified or ReportFormatType (enum) Returns: The response. See :py:meth:`send_command` for details. """ if not report_format_id: raise RequiredArgument( function=self.verify_report_format.__name__, argument='report_format_id', ) cmd = XmlCommand("verify_report_format") if isinstance(report_format_id, ReportFormatType): report_format_id = report_format_id.value cmd.set_attribute("report_format_id", report_format_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/reports.py000066400000000000000000000142331413122500400236720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, Optional, Union from lxml.etree import XMLSyntaxError from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmpv208.entities.report_formats import ( ReportFormatType, ) # if I use latest, I get circular import :/ from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class ReportsMixin: def delete_report(self, report_id: str) -> Any: """Deletes an existing report Arguments: report_id: UUID of the report to be deleted. """ if not report_id: raise RequiredArgument( function=self.delete_report.__name__, argument='report_id' ) cmd = XmlCommand("delete_report") cmd.set_attribute("report_id", report_id) return self._send_xml_command(cmd) def get_report( self, report_id: str, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, delta_report_id: Optional[str] = None, report_format_id: Optional[Union[str, ReportFormatType]] = None, ignore_pagination: Optional[bool] = None, details: Optional[bool] = True, ) -> Any: """Request a single report Arguments: report_id: UUID of an existing report filter_string: Filter term to use to filter results in the report filter_id: UUID of filter to use to filter results in the report delta_report_id: UUID of an existing report to compare report to. report_format_id: UUID of report format to use or ReportFormatType (enum) ignore_pagination: Whether to ignore the filter terms "first" and "rows". details: Request additional report information details defaults to True Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_reports") if not report_id: raise RequiredArgument( function=self.get_report.__name__, argument='report_id' ) cmd.set_attribute("report_id", report_id) add_filter(cmd, filter_string, filter_id) if delta_report_id: cmd.set_attribute("delta_report_id", delta_report_id) if report_format_id: if isinstance(report_format_id, ReportFormatType): report_format_id = report_format_id.value cmd.set_attribute("format_id", report_format_id) if ignore_pagination is not None: cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination)) cmd.set_attribute("details", to_bool(details)) return self._send_xml_command(cmd) def get_reports( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, note_details: Optional[bool] = None, override_details: Optional[bool] = None, details: Optional[bool] = None, ) -> Any: """Request a list of reports Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query note_details: If notes are included, whether to include note details override_details: If overrides are included, whether to include override details details: Whether to exclude results Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_reports") if filter_string: cmd.set_attribute("report_filter", filter_string) if filter_id: cmd.set_attribute("report_filt_id", filter_id) if note_details is not None: cmd.set_attribute("note_details", to_bool(note_details)) if override_details is not None: cmd.set_attribute("override_details", to_bool(override_details)) if details is not None: cmd.set_attribute("details", to_bool(details)) cmd.set_attribute("ignore_pagination", "1") return self._send_xml_command(cmd) def import_report( self, report: str, *, task_id: Optional[str] = None, in_assets: Optional[bool] = None, ) -> Any: """Import a Report from XML Arguments: report: Report XML as string to import. This XML must contain a :code:`` root element. task_id: UUID of task to import report to in_asset: Whether to create or update assets using the report Returns: The response. See :py:meth:`send_command` for details. """ if not report: raise RequiredArgument( function=self.import_report.__name__, argument='report' ) cmd = XmlCommand("create_report") if task_id: cmd.add_element("task", attrs={"id": task_id}) else: raise RequiredArgument( function=self.import_report.__name__, argument='task_id' ) if in_assets is not None: cmd.add_element("in_assets", to_bool(in_assets)) try: cmd.append_xml_str(report) except XMLSyntaxError as e: raise InvalidArgument( f"Invalid xml passed as report to import_report {e}" ) from None return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/results.py000066400000000000000000000057021413122500400236760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, Optional from gvm.errors import RequiredArgument from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class ResultsMixin: def get_result(self, result_id: str) -> Any: """Request a single result Arguments: result_id: UUID of an existing result Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_results") if not result_id: raise RequiredArgument( function=self.get_result.__name__, argument='result_id' ) cmd.set_attribute("result_id", result_id) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def get_results( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, task_id: Optional[str] = None, note_details: Optional[bool] = None, override_details: Optional[bool] = None, details: Optional[bool] = None, ) -> Any: """Request a list of results Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query task_id: UUID of task for note and override handling note_details: If notes are included, whether to include note details override_details: If overrides are included, whether to include override details details: Whether to include additional details of the results Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_results") add_filter(cmd, filter_string, filter_id) if task_id: cmd.set_attribute("task_id", task_id) if details is not None: cmd.set_attribute("details", to_bool(details)) if note_details is not None: cmd.set_attribute("note_details", to_bool(note_details)) if override_details is not None: cmd.set_attribute("override_details", to_bool(override_details)) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/roles.py000066400000000000000000000121231413122500400233140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional from gvm.errors import RequiredArgument from gvm.utils import add_filter, to_bool, to_comma_list from gvm.xml import XmlCommand class RolesMixin: def clone_role(self, role_id: str) -> Any: """Clone an existing role Arguments: role_id: UUID of an existing role to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not role_id: raise RequiredArgument( function=self.clone_role.__name__, argument='role_id' ) cmd = XmlCommand("create_role") cmd.add_element("copy", role_id) return self._send_xml_command(cmd) def create_role( self, name: str, *, comment: Optional[str] = None, users: Optional[List[str]] = None, ) -> Any: """Create a new role Arguments: name: Name of the role comment: Comment for the role users: List of user names to add to the role Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_role.__name__, argument='name' ) cmd = XmlCommand("create_role") cmd.add_element("name", name) if comment: cmd.add_element("comment", comment) if users: cmd.add_element("users", to_comma_list(users)) return self._send_xml_command(cmd) def delete_role( self, role_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing role Arguments: role_id: UUID of the role to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not role_id: raise RequiredArgument( function=self.delete_role.__name__, argument='role_id' ) cmd = XmlCommand("delete_role") cmd.set_attribute("role_id", role_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_roles( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, ) -> Any: """Request a list of roles Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan roles instead Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_roles") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return self._send_xml_command(cmd) def get_role(self, role_id: str) -> Any: """Request a single role Arguments: role_id: UUID of an existing role Returns: The response. See :py:meth:`send_command` for details. """ if not role_id: raise RequiredArgument( function=self.get_role.__name__, argument='role_id' ) cmd = XmlCommand("get_roles") cmd.set_attribute("role_id", role_id) return self._send_xml_command(cmd) def modify_role( self, role_id: str, *, comment: Optional[str] = None, name: Optional[str] = None, users: Optional[List[str]] = None, ) -> Any: """Modifies an existing role. Arguments: role_id: UUID of role to modify. comment: Name of role. name: Comment on role. users: List of user names. Returns: The response. See :py:meth:`send_command` for details. """ if not role_id: raise RequiredArgument( function=self.modify_role.__name__, argument='role_id argument' ) cmd = XmlCommand("modify_role") cmd.set_attribute("role_id", role_id) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if users: cmd.add_element("users", to_comma_list(users)) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/scan_configs.py000066400000000000000000000517721413122500400246410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional, Tuple from lxml.etree import XMLSyntaxError from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.utils import add_filter, deprecation, is_list_like, to_base64, to_bool from gvm.xml import XmlCommand class ScanConfigsMixin: def clone_scan_config(self, config_id: str) -> Any: """Clone a scan config from an existing one Arguments: config_id: UUID of the existing scan config Returns: The response. See :py:meth:`send_command` for details. """ if not config_id: raise RequiredArgument( function=self.clone_scan_config.__name__, argument='config_id' ) cmd = XmlCommand("create_config") cmd.add_element("copy", config_id) return self._send_xml_command(cmd) def create_scan_config( self, config_id: str, name: str, *, comment: Optional[str] = None ) -> Any: """Create a new scan config Arguments: config_id: UUID of the existing scan config name: Name of the new scan config comment: A comment on the config Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_scan_config.__name__, argument='name' ) if not config_id: raise RequiredArgument( function=self.create_scan_config.__name__, argument='config_id' ) cmd = XmlCommand("create_config") if comment is not None: cmd.add_element("comment", comment) cmd.add_element("copy", config_id) cmd.add_element("name", name) cmd.add_element("usage_type", "scan") return self._send_xml_command(cmd) def create_scan_config_from_osp_scanner( self, scanner_id: str, name: str, *, comment: Optional[str] = None ) -> Any: """Create a new scan config from an ospd scanner. Create config by retrieving the expected preferences from the given scanner via OSP. Arguments: scanner_id: UUID of an OSP scanner to get config data from name: Name of the new scan config comment: A comment on the config Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_scan_config_from_osp_scanner.__name__, argument='name', ) if not scanner_id: raise RequiredArgument( function=self.create_scan_config_from_osp_scanner.__name__, argument='scanner_id', ) cmd = XmlCommand("create_config") if comment is not None: cmd.add_element("comment", comment) cmd.add_element("scanner", scanner_id) cmd.add_element("name", name) cmd.add_element("usage_type", "scan") return self._send_xml_command(cmd) def delete_scan_config( self, config_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing config Arguments: config_id: UUID of the config to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not config_id: raise RequiredArgument( function=self.delete_scan_config.__name__, argument='config_id' ) cmd = XmlCommand("delete_config") cmd.set_attribute("config_id", config_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_scan_configs( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, details: Optional[bool] = None, families: Optional[bool] = None, preferences: Optional[bool] = None, tasks: Optional[bool] = None, ) -> Any: """Request a list of scan configs Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan scan configs instead details: Whether to get config families, preferences, nvt selectors and tasks. families: Whether to include the families if no details are requested preferences: Whether to include the preferences if no details are requested tasks: Whether to get tasks using this config Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_configs") cmd.set_attribute("usage_type", "scan") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if details is not None: cmd.set_attribute("details", to_bool(details)) if families is not None: cmd.set_attribute("families", to_bool(families)) if preferences is not None: cmd.set_attribute("preferences", to_bool(preferences)) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return self._send_xml_command(cmd) def get_scan_config( self, config_id: str, *, tasks: Optional[bool] = None ) -> Any: """Request a single scan config Arguments: config_id: UUID of an existing scan config tasks: Whether to get tasks using this config Returns: The response. See :py:meth:`send_command` for details. """ if not config_id: raise RequiredArgument( function=self.get_scan_config.__name__, argument='config_id' ) cmd = XmlCommand("get_configs") cmd.set_attribute("config_id", config_id) cmd.set_attribute("usage_type", "scan") if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def get_scan_config_preferences( self, *, nvt_oid: Optional[str] = None, config_id: Optional[str] = None ) -> Any: """Request a list of scan_config preferences When the command includes a config_id attribute, the preference element includes the preference name, type and value, and the NVT to which the preference applies. If the command includes a config_id and an nvt_oid, the preferences for the given nvt in the config will be shown. Arguments: nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_preferences") if nvt_oid: cmd.set_attribute("nvt_oid", nvt_oid) if config_id: cmd.set_attribute("config_id", config_id) return self._send_xml_command(cmd) def get_scan_config_preference( self, name: str, *, nvt_oid: Optional[str] = None, config_id: Optional[str] = None, ) -> Any: """Request a nvt preference Arguments: name: name of a particular preference nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_preferences") if not name: raise RequiredArgument( function=self.get_scan_config_preference.__name__, argument='name', ) cmd.set_attribute("preference", name) if nvt_oid: cmd.set_attribute("nvt_oid", nvt_oid) if config_id: cmd.set_attribute("config_id", config_id) return self._send_xml_command(cmd) def import_scan_config(self, config: str) -> Any: """Import a scan config from XML Arguments: config: Scan Config XML as string to import. This XML must contain a :code:`` root element. Returns: The response. See :py:meth:`send_command` for details. """ if not config: raise RequiredArgument( function=self.import_scan_config.__name__, argument='config' ) cmd = XmlCommand("create_config") try: cmd.append_xml_str(config) except XMLSyntaxError as e: raise InvalidArgument( function=self.import_scan_config.__name__, argument='config' ) from e return self._send_xml_command(cmd) def modify_scan_config_set_nvt_preference( self, config_id: str, name: str, nvt_oid: str, *, value: Optional[str] = None, ) -> Any: """Modifies the nvt preferences of an existing scan config. Arguments: config_id: UUID of scan config to modify. name: Name for nvt preference to change. nvt_oid: OID of the NVT associated with preference to modify value: New value for the preference. None to delete the preference and to use the default instead. """ if not config_id: raise RequiredArgument( function=self.modify_scan_config_set_nvt_preference.__name__, argument='config_id', ) if not nvt_oid: raise RequiredArgument( function=self.modify_scan_config_set_nvt_preference.__name__, argument='nvt_oid', ) if not name: raise RequiredArgument( function=self.modify_scan_config_set_nvt_preference.__name__, argument='name', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) _xmlpref = cmd.add_element("preference") _xmlpref.add_element("nvt", attrs={"oid": nvt_oid}) _xmlpref.add_element("name", name) if value: _xmlpref.add_element("value", to_base64(value)) return self._send_xml_command(cmd) def modify_scan_config_set_name(self, config_id: str, name: str) -> Any: """Modifies the name of an existing scan config Arguments: config_id: UUID of scan config to modify. name: New name for the config. """ if not config_id: raise RequiredArgument( function=self.modify_scan_config_set_name.__name__, argument='config_id', ) if not name: raise RequiredArgument( function=self.modify_scan_config_set_name.__name__, argument='name', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) cmd.add_element("name", name) return self._send_xml_command(cmd) def modify_scan_config_set_comment( self, config_id: str, *, comment: Optional[str] = None ) -> Any: """Modifies the comment of an existing scan config Arguments: config_id: UUID of scan config to modify. comment: Comment to set on a config. Default is an empty comment and the previous comment will be removed. """ if not config_id: raise RequiredArgument( function=self.modify_scan_config_set_comment.__name__, argument='config_id argument', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) if not comment: comment = "" cmd.add_element("comment", comment) return self._send_xml_command(cmd) def modify_scan_config_set_scanner_preference( self, config_id: str, name: str, *, value: Optional[str] = None ) -> Any: """Modifies the scanner preferences of an existing scan config Arguments: config_id: UUID of scan config to modify. name: Name of the scanner preference to change value: New value for the preference. None to delete the preference and to use the default instead. """ if not config_id: raise RequiredArgument( function=( self.modify_scan_config_set_scanner_preference.__name__ ), argument='config_id', ) if not name: raise RequiredArgument( function=( self.modify_scan_config_set_scanner_preference.__name__ ), argument='name argument', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) _xmlpref = cmd.add_element("preference") _xmlpref.add_element("name", name) if value: _xmlpref.add_element("value", to_base64(value)) return self._send_xml_command(cmd) def modify_scan_config_set_nvt_selection( self, config_id: str, family: str, nvt_oids: List[str] ) -> Any: """Modifies the selected nvts of an existing scan config The manager updates the given family in the config to include only the given NVTs. Arguments: config_id: UUID of scan config to modify. family: Name of the NVT family to include NVTs from nvt_oids: List of NVTs to select for the family. """ if not config_id: raise RequiredArgument( function=self.modify_scan_config_set_nvt_selection.__name__, argument='config_id', ) if not family: raise RequiredArgument( function=self.modify_scan_config_set_nvt_selection.__name__, argument='family argument', ) if not is_list_like(nvt_oids): raise InvalidArgumentType( function=self.modify_scan_config_set_nvt_selection.__name__, argument='nvt_oids', arg_type='list', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) _xmlnvtsel = cmd.add_element("nvt_selection") _xmlnvtsel.add_element("family", family) for nvt in nvt_oids: _xmlnvtsel.add_element("nvt", attrs={"oid": nvt}) return self._send_xml_command(cmd) def modify_scan_config_set_family_selection( self, config_id: str, families: List[Tuple[str, bool, bool]], *, auto_add_new_families: Optional[bool] = True, ) -> Any: """ Selected the NVTs of a scan config at a family level. Arguments: config_id: UUID of scan config to modify. families: A list of tuples (str, bool, bool): str: the name of the NVT family selected, bool: add new NVTs to the family automatically, bool: include all NVTs from the family auto_add_new_families: Whether new families should be added to the scan config automatically. Default: True. """ if not config_id: raise RequiredArgument( function=self.modify_scan_config_set_family_selection.__name__, argument='config_id', ) if not is_list_like(families): raise InvalidArgumentType( function=self.modify_scan_config_set_family_selection.__name__, argument='families', arg_type='list', ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) _xmlfamsel = cmd.add_element("family_selection") _xmlfamsel.add_element("growing", to_bool(auto_add_new_families)) for family in families: _xmlfamily = _xmlfamsel.add_element("family") _xmlfamily.add_element("name", family[0]) if len(family) != 3: raise InvalidArgument( "Family must be a tuple of 3. (str, bool, bool)" ) if not isinstance(family[1], bool) or not isinstance( family[2], bool ): raise InvalidArgumentType( function=( self.modify_scan_config_set_family_selection.__name__ ), argument='families', arg_type='[tuple(str, bool, bool)]', ) _xmlfamily.add_element("all", to_bool(family[2])) _xmlfamily.add_element("growing", to_bool(family[1])) return self._send_xml_command(cmd) def modify_scan_config( self, config_id: str, selection: Optional[str] = None, **kwargs ) -> Any: """Modifies an existing scan config. DEPRECATED. Please use *modify_scan_config_set_* methods instead. modify_config has four modes to operate depending on the selection. Arguments: config_id: UUID of scan config to modify. selection: one of 'scan_pref', 'nvt_pref', 'nvt_selection' or 'family_selection' name: New name for preference. value: New value for preference. nvt_oids: List of NVTs associated with preference to modify. family: Name of family to modify. Returns: The response. See :py:meth:`send_command` for details. """ if not config_id: raise RequiredArgument( function=self.modify_scan_config.__name__, argument='config_id argument', ) if selection is None: deprecation( "Using modify_config to update the comment of a scan config is" "deprecated. Please use modify_scan_config_set_comment instead." ) return self.modify_scan_config_set_comment( config_id, comment=kwargs.get("comment") ) if selection not in ( "nvt_pref", "scan_pref", "family_selection", "nvt_selection", ): raise InvalidArgument( "selection must be one of nvt_pref, " "scan_pref, family_selection or " "nvt_selection" ) if selection == "nvt_pref": deprecation( "Using modify_scan_config to update a nvt preference of a scan " "config is deprecated. Please use " "modify_scan_config_set_nvt_preference instead." ) return self.modify_scan_config_set_nvt_preference( config_id, **kwargs ) if selection == "scan_pref": deprecation( "Using modify_scan_config to update a scanner preference of a " "scan config is deprecated. Please use " "modify_scan_config_set_scanner_preference instead." ) return self.modify_scan_config_set_scanner_preference( config_id, **kwargs ) if selection == "nvt_selection": deprecation( "Using modify_scan_config to update a nvt selection of a " "scan config is deprecated. Please use " "modify_scan_config_set_nvt_selection instead." ) return self.modify_scan_config_set_nvt_selection( config_id, **kwargs ) deprecation( "Using modify_scan_config to update a family selection of a " "scan config is deprecated. Please use " "modify_scan_config_set_family_selection instead." ) return self.modify_scan_config_set_family_selection(config_id, **kwargs) def sync_scan_config(self) -> Any: """Request an OSP config synchronization with scanner Returns: The response. See :py:meth:`send_command` for details. """ return self._send_xml_command(XmlCommand("sync_config")) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/scanners.py000066400000000000000000000241421413122500400240100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class ScannerType(Enum): """Enum for scanner type""" OSP_SCANNER_TYPE = "1" OPENVAS_SCANNER_TYPE = "2" CVE_SCANNER_TYPE = "3" GMP_SCANNER_TYPE = "4" # formerly slave scanner GREENBONE_SENSOR_SCANNER_TYPE = "5" @classmethod def from_string( cls, scanner_type: Optional[str], ) -> Optional["ScannerType"]: """Convert a scanner type string to an actual ScannerType instance Arguments: scanner_type: Scanner type string to convert to a ScannerType """ if not scanner_type: return None scanner_type = scanner_type.lower() if scanner_type == cls.OSP_SCANNER_TYPE.value or scanner_type == 'osp': return cls.OSP_SCANNER_TYPE if ( scanner_type == cls.OPENVAS_SCANNER_TYPE.value or scanner_type == 'openvas' ): return cls.OPENVAS_SCANNER_TYPE if scanner_type == cls.CVE_SCANNER_TYPE.value or scanner_type == 'cve': return cls.CVE_SCANNER_TYPE if scanner_type == cls.GMP_SCANNER_TYPE.value or scanner_type == 'gmp': return cls.GMP_SCANNER_TYPE if ( scanner_type == cls.GREENBONE_SENSOR_SCANNER_TYPE.value or scanner_type == 'greenbone' ): return cls.GREENBONE_SENSOR_SCANNER_TYPE raise InvalidArgument( argument='scanner_type', function=cls.from_string.__name__ ) class ScannersMixin: def clone_scanner(self, scanner_id: str) -> Any: """Clone an existing scanner Arguments: scanner_id: UUID of an existing scanner to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not scanner_id: raise RequiredArgument( function=self.clone_scanner.__name__, argument='scanner_id' ) cmd = XmlCommand("create_scanner") cmd.add_element("copy", scanner_id) return self._send_xml_command(cmd) def create_scanner( self, name: str, host: str, port: int, scanner_type: ScannerType, credential_id: str, *, ca_pub: Optional[str] = None, comment: Optional[str] = None, ) -> Any: """Create a new scanner Arguments: name: Name of the scanner host: The host of the scanner port: The port of the scanner scanner_type: Type of the scanner. credential_id: UUID of client certificate credential for the scanner ca_pub: Certificate of CA to verify scanner certificate comment: Comment for the scanner Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_scanner.__name__, argument='name' ) if not host: raise RequiredArgument( function=self.create_scanner.__name__, argument='host' ) if not port: raise RequiredArgument( function=self.create_scanner.__name__, argument='port' ) if not scanner_type: raise RequiredArgument( function=self.create_scanner.__name__, argument='scanner_type' ) if not credential_id: raise RequiredArgument( function=self.create_scanner.__name__, argument='credential_id' ) if not isinstance(scanner_type, ScannerType): raise InvalidArgumentType( function=self.create_scanner.__name__, argument='scanner_type', arg_type=ScannerType.__name__, ) cmd = XmlCommand("create_scanner") cmd.add_element("name", name) cmd.add_element("host", host) cmd.add_element("port", str(port)) cmd.add_element("type", scanner_type.value) if ca_pub: cmd.add_element("ca_pub", ca_pub) cmd.add_element("credential", attrs={"id": str(credential_id)}) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) def delete_scanner( self, scanner_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing scanner Arguments: scanner_id: UUID of the scanner to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not scanner_id: raise RequiredArgument( function=self.delete_scanner.__name__, argument='scanner_id' ) cmd = XmlCommand("delete_scanner") cmd.set_attribute("scanner_id", scanner_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_scanners( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, details: Optional[bool] = None, ) -> Any: """Request a list of scanners Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan scanners instead details: Whether to include extra details like tasks using this scanner Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_scanners") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if details is not None: cmd.set_attribute("details", to_bool(details)) return self._send_xml_command(cmd) def get_scanner(self, scanner_id: str) -> Any: """Request a single scanner Arguments: scanner_id: UUID of an existing scanner Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_scanners") if not scanner_id: raise RequiredArgument( function=self.get_scanner.__name__, argument='scanner_id' ) cmd.set_attribute("scanner_id", scanner_id) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def modify_scanner( self, scanner_id: str, *, scanner_type: Optional[ScannerType] = None, host: Optional[str] = None, port: Optional[int] = None, comment: Optional[str] = None, name: Optional[str] = None, ca_pub: Optional[str] = None, credential_id: Optional[str] = None, ) -> Any: """Modifies an existing scanner. Arguments: scanner_id: UUID of scanner to modify. scanner_type: New type of the Scanner. host: Host of the scanner. port: Port of the scanner. comment: Comment on scanner. name: Name of scanner. ca_pub: Certificate of CA to verify scanner's certificate. credential_id: UUID of the client certificate credential for the Scanner. Returns: The response. See :py:meth:`send_command` for details. """ if not scanner_id: raise RequiredArgument( function=self.modify_scanner.__name__, argument='scanner_id argument', ) cmd = XmlCommand("modify_scanner") cmd.set_attribute("scanner_id", scanner_id) if scanner_type is not None: if not isinstance(scanner_type, ScannerType): raise InvalidArgumentType( function=self.modify_scanner.__name__, argument='scanner_type', arg_type=ScannerType.__name__, ) cmd.add_element("type", scanner_type.value) if host: cmd.add_element("host", host) if port: cmd.add_element("port", str(port)) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if ca_pub: cmd.add_element("ca_pub", ca_pub) if credential_id: cmd.add_element("credential", attrs={"id": str(credential_id)}) return self._send_xml_command(cmd) def verify_scanner(self, scanner_id: str) -> Any: """Verify an existing scanner Verifies if it is possible to connect to an existing scanner. It is *not* verified if the scanner works as expected by the user. Arguments: scanner_id: UUID of the scanner to be verified Returns: The response. See :py:meth:`send_command` for details. """ if not scanner_id: raise RequiredArgument( function=self.verify_scanner.__name__, argument='scanner_id' ) cmd = XmlCommand("verify_scanner") cmd.set_attribute("scanner_id", scanner_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/schedules.py000066400000000000000000000172541413122500400241610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, Optional from gvm.errors import RequiredArgument from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class SchedulesMixin: def clone_schedule(self, schedule_id: str) -> Any: """Clone an existing schedule Arguments: schedule_id: UUID of an existing schedule to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not schedule_id: raise RequiredArgument( function=self.clone_schedule.__name__, argument='schedule_id' ) cmd = XmlCommand("create_schedule") cmd.add_element("copy", schedule_id) return self._send_xml_command(cmd) def create_schedule( self, name: str, icalendar: str, timezone: str, *, comment: Optional[str] = None, ) -> Any: """Create a new schedule based in `iCalendar`_ data. Example: Requires https://pypi.org/project/icalendar/ .. code-block:: python import pytz from datetime import datetime from icalendar import Calendar, Event cal = Calendar() cal.add('prodid', '-//Foo Bar//') cal.add('version', '2.0') event = Event() event.add('dtstamp', datetime.now(tz=pytz.UTC)) event.add('dtstart', datetime(2020, 1, 1, tzinfo=pytz.utc)) cal.add_component(event) gmp.create_schedule( name="My Schedule", icalendar=cal.to_ical(), timezone='UTC' ) Arguments: name: Name of the new schedule icalendar: `iCalendar`_ (RFC 5545) based data. timezone: Timezone to use for the icalender events e.g Europe/Berlin. If the datetime values in the icalendar data are missing timezone information this timezone gets applied. Otherwise the datetime values from the icalendar data are displayed in this timezone comment: Comment on schedule. Returns: The response. See :py:meth:`send_command` for details. .. _iCalendar: https://tools.ietf.org/html/rfc5545 """ if not name: raise RequiredArgument( function=self.create_schedule.__name__, argument='name' ) if not icalendar: raise RequiredArgument( function=self.create_schedule.__name__, argument='icalendar' ) if not timezone: raise RequiredArgument( function=self.create_schedule.__name__, argument='timezone' ) cmd = XmlCommand("create_schedule") cmd.add_element("name", name) cmd.add_element("icalendar", icalendar) cmd.add_element("timezone", timezone) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) def delete_schedule( self, schedule_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing schedule Arguments: schedule_id: UUID of the schedule to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not schedule_id: raise RequiredArgument( function=self.delete_schedule.__name__, argument='schedule_id' ) cmd = XmlCommand("delete_schedule") cmd.set_attribute("schedule_id", schedule_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_schedules( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> Any: """Request a list of schedules Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan schedules instead tasks: Whether to include tasks using the schedules Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_schedules") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return self._send_xml_command(cmd) def get_schedule( self, schedule_id: str, *, tasks: Optional[bool] = None ) -> Any: """Request a single schedule Arguments: schedule_id: UUID of an existing schedule tasks: Whether to include tasks using the schedules Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_schedules") if not schedule_id: raise RequiredArgument( function=self.get_schedule.__name__, argument='schedule_id' ) cmd.set_attribute("schedule_id", schedule_id) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return self._send_xml_command(cmd) def modify_schedule( self, schedule_id: str, *, name: Optional[str] = None, icalendar: Optional[str] = None, timezone: Optional[str] = None, comment: Optional[str] = None, ) -> Any: """Modifies an existing schedule Arguments: schedule_id: UUID of the schedule to be modified name: Name of the schedule icalendar: `iCalendar`_ (RFC 5545) based data. timezone: Timezone to use for the icalender events e.g Europe/Berlin. If the datetime values in the icalendar data are missing timezone information this timezone gets applied. Otherwise the datetime values from the icalendar data are displayed in this timezone comment: Comment on schedule. Returns: The response. See :py:meth:`send_command` for details. .. _iCalendar: https://tools.ietf.org/html/rfc5545 """ if not schedule_id: raise RequiredArgument( function=self.modify_schedule.__name__, argument='schedule_id' ) cmd = XmlCommand("modify_schedule") cmd.set_attribute("schedule_id", schedule_id) if name: cmd.add_element("name", name) if icalendar: cmd.add_element("icalendar", icalendar) if timezone: cmd.add_element("timezone", timezone) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/secinfo.py000066400000000000000000000376551413122500400236370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class InfoType(Enum): """Enum for info types""" CERT_BUND_ADV = "CERT_BUND_ADV" CPE = "CPE" CVE = "CVE" DFN_CERT_ADV = "DFN_CERT_ADV" OVALDEF = "OVALDEF" NVT = "NVT" @classmethod def from_string(cls, info_type: Optional[str]) -> Optional["InfoType"]: """Convert a info type string to an actual InfoType instance Arguments: info_type: Info type string to convert to a InfoType """ if not info_type: return None try: return cls[info_type.upper()] except KeyError: raise InvalidArgument( argument='info_type', function=cls.from_string.__name__ ) from None class SecInfoMixin: def get_nvt_families(self, *, sort_order: Optional[str] = None): """Request a list of nvt families Arguments: sort_order: Sort order Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_nvt_families") if sort_order: cmd.set_attribute("sort_order", sort_order) return self._send_xml_command(cmd) def get_scan_config_nvts( self, *, details: Optional[bool] = None, preferences: Optional[bool] = None, preference_count: Optional[bool] = None, timeout: Optional[bool] = None, config_id: Optional[str] = None, preferences_config_id: Optional[str] = None, family: Optional[str] = None, sort_order: Optional[str] = None, sort_field: Optional[str] = None, ): """Request a list of nvts Arguments: details: Whether to include full details preferences: Whether to include nvt preferences preference_count: Whether to include preference count timeout: Whether to include the special timeout preference config_id: UUID of scan config to which to limit the NVT listing preferences_config_id: UUID of scan config to use for preference values family: Family to which to limit NVT listing sort_order: Sort order sort_field: Sort field Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_nvts") if details is not None: cmd.set_attribute("details", to_bool(details)) if preferences is not None: cmd.set_attribute("preferences", to_bool(preferences)) if preference_count is not None: cmd.set_attribute("preference_count", to_bool(preference_count)) if timeout is not None: cmd.set_attribute("timeout", to_bool(timeout)) if config_id: cmd.set_attribute("config_id", config_id) if preferences_config_id: cmd.set_attribute("preferences_config_id", preferences_config_id) if family: cmd.set_attribute("family", family) if sort_order: cmd.set_attribute("sort_order", sort_order) if sort_field: cmd.set_attribute("sort_field", sort_field) return self._send_xml_command(cmd) def get_scan_config_nvt(self, nvt_oid: str): """Request a single nvt Arguments: nvt_oid: OID of an existing nvt Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_nvts") if not nvt_oid: raise RequiredArgument( function=self.get_scan_config_nvt.__name__, argument='nvt_oid' ) cmd.set_attribute("nvt_oid", nvt_oid) # for single entity always request all details cmd.set_attribute("details", "1") cmd.set_attribute("preferences", "1") cmd.set_attribute("preference_count", "1") return self._send_xml_command(cmd) def get_cves( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Any: """Request a list of CVEs Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query name: Name or identifier of the requested information details: Whether to include information about references to this information Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info_list( info_type=InfoType.CVE, filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) def get_cpes( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Any: """Request a list of CPEs Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query name: Name or identifier of the requested information details: Whether to include information about references to this information Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info_list( info_type=InfoType.CPE, filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) def get_nvts( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Any: """Request a list of NVTs Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query name: Name or identifier of the requested information details: Whether to include information about references to this information Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info_list( info_type=InfoType.NVT, filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) def get_dfn_cert_advisories( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Any: """Request a list of DFN-CERT Advisories Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query name: Name or identifier of the requested information details: Whether to include information about references to this information Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info_list( info_type=InfoType.DFN_CERT_ADV, filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) def get_cert_bund_advisories( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Any: """Request a list of CERT-BUND Advisories Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query name: Name or identifier of the requested information details: Whether to include information about references to this information Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info_list( info_type=InfoType.CERT_BUND_ADV, filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) def get_oval_definitions( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Any: """Request a list of OVAL definitions Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query name: Name or identifier of the requested information details: Whether to include information about references to this information Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info_list( info_type=InfoType.OVALDEF, filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) def get_info_list( self, info_type: InfoType, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Any: """Request a list of security information Arguments: info_type: Type must be either CERT_BUND_ADV, CPE, CVE, DFN_CERT_ADV, OVALDEF, NVT or ALLINFO filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query name: Name or identifier of the requested information details: Whether to include information about references to this information Returns: The response. See :py:meth:`send_command` for details. """ if not info_type: raise RequiredArgument( function=self.get_info_list.__name__, argument='info_type' ) if not isinstance(info_type, InfoType): raise InvalidArgumentType( function=self.get_info_list.__name__, argument='info_type', arg_type=InfoType.__name__, ) cmd = XmlCommand("get_info") cmd.set_attribute("type", info_type.value) add_filter(cmd, filter_string, filter_id) if name: cmd.set_attribute("name", name) if details is not None: cmd.set_attribute("details", to_bool(details)) return self._send_xml_command(cmd) def get_cve(self, cve_id: str) -> Any: """Request a single CVE Arguments: cve_id: ID of an existing CVE Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info(cve_id, InfoType.CVE) def get_cpe(self, cpe_id: str) -> Any: """Request a single CPE Arguments: cpe_id: ID of an existing CPE Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info(cpe_id, InfoType.CPE) def get_nvt(self, nvt_id: str) -> Any: """Request a single NVT Arguments: nvt_id: ID of an existing NVT Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info(nvt_id, InfoType.NVT) def get_dfn_cert_advisory(self, cert_id: str) -> Any: """Request a single DFN-CERT Advisory Arguments: cert_id: ID of an existing DFN-CERT Advisory Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info(cert_id, InfoType.DFN_CERT_ADV) def get_cert_bund_advisory(self, cert_id: str) -> Any: """Request a single CERT-BUND Advisory Arguments: cert_id: ID of an existing CERT-BUND Advisory Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info(cert_id, InfoType.CERT_BUND_ADV) def get_oval_definition(self, oval_id: str) -> Any: """Request a single Oval definition Arguments: oval_id: ID of an existing Oval definition Returns: The response. See :py:meth:`send_command` for details. """ return self.get_info(oval_id, InfoType.OVALDEF) def get_info(self, info_id: str, info_type: InfoType) -> Any: """Request a single secinfo Arguments: info_id: ID of an existing secinfo info_type: Type must be either CERT_BUND_ADV, CPE, CVE, DFN_CERT_ADV, OVALDEF, NVT Returns: The response. See :py:meth:`send_command` for details. """ if not info_type: raise RequiredArgument( function=self.get_info.__name__, argument='info_type' ) if not isinstance(info_type, InfoType): raise InvalidArgumentType( function=self.get_info.__name__, argument='info_type', arg_type=InfoType.__name__, ) if not info_id: raise RequiredArgument( function=self.get_info.__name__, argument='info_id' ) cmd = XmlCommand("get_info") cmd.set_attribute("info_id", info_id) cmd.set_attribute("type", info_type.value) # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def get_nvt_preferences( self, *, nvt_oid: Optional[str] = None, ) -> Any: """Request a list of preferences The preference element includes just the name and value, with the NVT and type built into the name. Arguments: nvt_oid: OID of nvt Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_preferences") if nvt_oid: cmd.set_attribute("nvt_oid", nvt_oid) return self._send_xml_command(cmd) def get_nvt_preference( self, name: str, *, nvt_oid: Optional[str] = None, ) -> Any: """Request a nvt preference Arguments: name: name of a particular preference nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_preferences") if not name: raise RequiredArgument( function=self.get_nvt_preference.__name__, argument='name' ) cmd.set_attribute("preference", name) if nvt_oid: cmd.set_attribute("nvt_oid", nvt_oid) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/severity.py000066400000000000000000000030271413122500400240450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from numbers import Real from typing import Optional from gvm.errors import InvalidArgument Severity = Real class SeverityLevel(Enum): """Enum for severity levels""" HIGH = "High" MEDIUM = "Medium" LOW = "Low" LOG = "Log" ALARM = "Alarm" DEBUG = "Debug" @classmethod def from_string( cls, severity_level: Optional[str], ) -> Optional["SeverityLevel"]: """Convert a severity level string into a SeverityLevel instance""" if not severity_level: return None try: return cls[severity_level.upper()] except KeyError: raise InvalidArgument( argument='severity_level', function=cls.from_string.__name__, ) from None python-gvm-21.10.0/gvm/protocols/gmpv208/entities/tags.py000066400000000000000000000232071413122500400231330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.protocols.gmpv208.entities.entities import EntityType from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class TagsMixin: def clone_tag(self, tag_id: str) -> Any: """Clone an existing tag Arguments: tag_id: UUID of an existing tag to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not tag_id: raise RequiredArgument( function=self.clone_tag.__name__, argument='tag_id' ) cmd = XmlCommand("create_tag") cmd.add_element("copy", tag_id) return self._send_xml_command(cmd) def create_tag( self, name: str, resource_type: EntityType, *, resource_filter: Optional[str] = None, resource_ids: Optional[List[str]] = None, value: Optional[str] = None, comment: Optional[str] = None, active: Optional[bool] = None, ) -> Any: """Create a tag. Arguments: name: Name of the tag. A full tag name consisting of namespace and predicate e.g. `foo:bar`. resource_type: Entity type the tag is to be attached to. resource_filter: Filter term to select resources the tag is to be attached to. Only one of resource_filter or resource_ids can be provided. resource_ids: IDs of the resources the tag is to be attached to. Only one of resource_filter or resource_ids can be provided. value: Value associated with the tag. comment: Comment for the tag. active: Whether the tag should be active. Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_tag.__name__, argument='name' ) if resource_filter and resource_ids: raise InvalidArgument( "create_tag accepts either resource_filter or resource_ids " "argument", function=self.create_tag.__name__, ) if not resource_type: raise RequiredArgument( function=self.create_tag.__name__, argument='resource_type' ) if not isinstance(resource_type, EntityType): raise InvalidArgumentType( function=self.create_tag.__name__, argument='resource_type', arg_type=EntityType.__name__, ) cmd = XmlCommand('create_tag') cmd.add_element('name', name) _xmlresources = cmd.add_element("resources") if resource_filter is not None: _xmlresources.set_attribute("filter", resource_filter) for resource_id in resource_ids or []: _xmlresources.add_element( "resource", attrs={"id": str(resource_id)} ) _actual_resource_type = resource_type if resource_type.value == EntityType.AUDIT.value: _actual_resource_type = EntityType.TASK elif resource_type.value == EntityType.POLICY.value: _actual_resource_type = EntityType.SCAN_CONFIG _xmlresources.add_element("type", _actual_resource_type.value) if comment: cmd.add_element("comment", comment) if value: cmd.add_element("value", value) if active is not None: if active: cmd.add_element("active", "1") else: cmd.add_element("active", "0") return self._send_xml_command(cmd) def delete_tag( self, tag_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing tag Arguments: tag_id: UUID of the tag to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not tag_id: raise RequiredArgument( function=self.delete_tag.__name__, argument='tag_id' ) cmd = XmlCommand("delete_tag") cmd.set_attribute("tag_id", tag_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_tags( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, names_only: Optional[bool] = None, ) -> Any: """Request a list of tags Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get tags from the trashcan instead names_only: Whether to get only distinct tag names Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_tags") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if names_only is not None: cmd.set_attribute("names_only", to_bool(names_only)) return self._send_xml_command(cmd) def get_tag(self, tag_id: str) -> Any: """Request a single tag Arguments: tag_id: UUID of an existing tag Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_tags") if not tag_id: raise RequiredArgument( function=self.get_tag.__name__, argument='tag_id' ) cmd.set_attribute("tag_id", tag_id) return self._send_xml_command(cmd) def modify_tag( self, tag_id: str, *, comment: Optional[str] = None, name: Optional[str] = None, value=None, active=None, resource_action: Optional[str] = None, resource_type: Optional[EntityType] = None, resource_filter: Optional[str] = None, resource_ids: Optional[List[str]] = None, ) -> Any: """Modifies an existing tag. Arguments: tag_id: UUID of the tag. comment: Comment to add to the tag. name: Name of the tag. value: Value of the tag. active: Whether the tag is active. resource_action: Whether to add or remove resources instead of overwriting. One of '', 'add', 'set' or 'remove'. resource_type: Type of the resources to which to attach the tag. Required if resource_filter is set. resource_filter: Filter term to select resources the tag is to be attached to. resource_ids: IDs of the resources to which to attach the tag. Returns: The response. See :py:meth:`send_command` for details. """ if not tag_id: raise RequiredArgument( function=self.modify_tag.__name__, argument='tag_id' ) cmd = XmlCommand("modify_tag") cmd.set_attribute("tag_id", str(tag_id)) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if value: cmd.add_element("value", value) if active is not None: cmd.add_element("active", to_bool(active)) if resource_action or resource_filter or resource_ids or resource_type: if resource_filter and not resource_type: raise RequiredArgument( function=self.modify_tag.__name__, argument='resource_type' ) _xmlresources = cmd.add_element("resources") if resource_action is not None: _xmlresources.set_attribute("action", resource_action) if resource_filter is not None: _xmlresources.set_attribute("filter", resource_filter) for resource_id in resource_ids or []: _xmlresources.add_element( "resource", attrs={"id": str(resource_id)} ) if resource_type is not None: if not isinstance(resource_type, EntityType): raise InvalidArgumentType( function=self.modify_tag.__name__, argument="resource_type", arg_type=EntityType.__name__, ) _actual_resource_type = resource_type if resource_type.value == EntityType.AUDIT.value: _actual_resource_type = EntityType.TASK elif resource_type.value == EntityType.POLICY.value: _actual_resource_type = EntityType.SCAN_CONFIG _xmlresources.add_element("type", _actual_resource_type.value) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/targets.py000066400000000000000000000321111413122500400236400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, List, Optional from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.utils import add_filter, to_bool, to_comma_list from gvm.xml import XmlCommand class AliveTest(Enum): """Enum for choosing an alive test""" SCAN_CONFIG_DEFAULT = 'Scan Config Default' ICMP_PING = 'ICMP Ping' TCP_ACK_SERVICE_PING = 'TCP-ACK Service Ping' TCP_SYN_SERVICE_PING = 'TCP-SYN Service Ping' ARP_PING = 'ARP Ping' APR_PING = 'ARP Ping' # Alias for ARP_PING ICMP_AND_TCP_ACK_SERVICE_PING = 'ICMP & TCP-ACK Service Ping' ICMP_AND_ARP_PING = 'ICMP & ARP Ping' TCP_ACK_SERVICE_AND_ARP_PING = 'TCP-ACK Service & ARP Ping' ICMP_TCP_ACK_SERVICE_AND_ARP_PING = ( # pylint: disable=invalid-name 'ICMP, TCP-ACK Service & ARP Ping' ) CONSIDER_ALIVE = 'Consider Alive' @classmethod def from_string( cls, alive_test: Optional[str], ) -> Optional["AliveTest"]: """Convert an alive test string into a AliveTest instance""" if not alive_test: return None alive_test = alive_test.lower() try: return cls[ alive_test.replace(',', '') .replace(' ', '_') .replace('-', '_') .replace('&', 'and') .upper() ] except KeyError: raise InvalidArgument( argument='alive_test', function=cls.from_string.__name__, ) from None class TargetsMixin: def clone_target(self, target_id: str) -> Any: """Clone an existing target Arguments: target_id: UUID of an existing target to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not target_id: raise RequiredArgument( function=self.clone_target.__name__, argument='target_id' ) cmd = XmlCommand("create_target") cmd.add_element("copy", target_id) return self._send_xml_command(cmd) def create_target( self, name: str, *, asset_hosts_filter: Optional[str] = None, hosts: Optional[List[str]] = None, comment: Optional[str] = None, exclude_hosts: Optional[List[str]] = None, ssh_credential_id: Optional[str] = None, ssh_credential_port: Optional[int] = None, smb_credential_id: Optional[str] = None, esxi_credential_id: Optional[str] = None, snmp_credential_id: Optional[str] = None, alive_test: Optional[AliveTest] = None, reverse_lookup_only: Optional[bool] = None, reverse_lookup_unify: Optional[bool] = None, port_range: Optional[str] = None, port_list_id: Optional[str] = None, ) -> Any: """Create a new target Arguments: name: Name of the target asset_hosts_filter: Filter to select target host from assets hosts hosts: List of hosts addresses to scan exclude_hosts: List of hosts addresses to exclude from scan comment: Comment for the target ssh_credential_id: UUID of a ssh credential to use on target ssh_credential_port: The port to use for ssh credential smb_credential_id: UUID of a smb credential to use on target snmp_credential_id: UUID of a snmp credential to use on target esxi_credential_id: UUID of a esxi credential to use on target alive_test: Which alive test to use reverse_lookup_only: Whether to scan only hosts that have names reverse_lookup_unify: Whether to scan only one IP when multiple IPs have the same name. port_range: Port range for the target port_list_id: UUID of the port list to use on target Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("create_target") cmd.add_element("name", name) if not name: raise RequiredArgument( function=self.create_target.__name__, argument='name' ) if asset_hosts_filter: cmd.add_element( "asset_hosts", attrs={"filter": str(asset_hosts_filter)} ) elif hosts: cmd.add_element("hosts", to_comma_list(hosts)) else: raise RequiredArgument( function=self.create_target.__name__, argument='hosts or asset_hosts_filter', ) if comment: cmd.add_element("comment", comment) if exclude_hosts: cmd.add_element("exclude_hosts", to_comma_list(exclude_hosts)) if ssh_credential_id: _xmlssh = cmd.add_element( "ssh_credential", attrs={"id": ssh_credential_id} ) if ssh_credential_port: _xmlssh.add_element("port", str(ssh_credential_port)) if smb_credential_id: cmd.add_element("smb_credential", attrs={"id": smb_credential_id}) if esxi_credential_id: cmd.add_element("esxi_credential", attrs={"id": esxi_credential_id}) if snmp_credential_id: cmd.add_element("snmp_credential", attrs={"id": snmp_credential_id}) if alive_test: if not isinstance(alive_test, AliveTest): raise InvalidArgumentType( function=self.create_target.__name__, argument='alive_test', arg_type=AliveTest.__name__, ) cmd.add_element("alive_tests", alive_test.value) if reverse_lookup_only is not None: cmd.add_element("reverse_lookup_only", to_bool(reverse_lookup_only)) if reverse_lookup_unify is not None: cmd.add_element( "reverse_lookup_unify", to_bool(reverse_lookup_unify) ) # since 20.08 one of port_range or port_list_id is required! if not port_range and not port_list_id: raise RequiredArgument( function=self.create_target.__name__, argument='port_range or port_list_id', ) if port_range: cmd.add_element("port_range", port_range) if port_list_id: cmd.add_element("port_list", attrs={"id": port_list_id}) return self._send_xml_command(cmd) def delete_target( self, target_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing target Arguments: target_id: UUID of the target to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not target_id: raise RequiredArgument( function=self.delete_target.__name__, argument='target_id' ) cmd = XmlCommand("delete_target") cmd.set_attribute("target_id", target_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_target( self, target_id: str, *, tasks: Optional[bool] = None ) -> Any: """Request a single target Arguments: target_id: UUID of an existing target tasks: Whether to include list of tasks that use the target Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_targets") if not target_id: raise RequiredArgument( function=self.get_target.__name__, argument='target_id' ) cmd.set_attribute("target_id", target_id) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return self._send_xml_command(cmd) def get_targets( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> Any: """Request a list of targets Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan targets instead tasks: Whether to include list of tasks that use the target Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_targets") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return self._send_xml_command(cmd) def modify_target( self, target_id: str, *, name: Optional[str] = None, comment: Optional[str] = None, hosts: Optional[List[str]] = None, exclude_hosts: Optional[List[str]] = None, ssh_credential_id: Optional[str] = None, ssh_credential_port: Optional[bool] = None, smb_credential_id: Optional[str] = None, esxi_credential_id: Optional[str] = None, snmp_credential_id: Optional[str] = None, alive_test: Optional[AliveTest] = None, reverse_lookup_only: Optional[bool] = None, reverse_lookup_unify: Optional[bool] = None, port_list_id: Optional[str] = None, ) -> Any: """Modifies an existing target. Arguments: target_id: ID of target to modify. comment: Comment on target. name: Name of target. hosts: List of target hosts. exclude_hosts: A list of hosts to exclude. ssh_credential_id: UUID of SSH credential to use on target. ssh_credential_port: The port to use for ssh credential smb_credential_id: UUID of SMB credential to use on target. esxi_credential_id: UUID of ESXi credential to use on target. snmp_credential_id: UUID of SNMP credential to use on target. port_list_id: UUID of port list describing ports to scan. alive_test: Which alive tests to use. reverse_lookup_only: Whether to scan only hosts that have names. reverse_lookup_unify: Whether to scan only one IP when multiple IPs have the same name. Returns: The response. See :py:meth:`send_command` for details. """ if not target_id: raise RequiredArgument( function=self.modify_target.__name__, argument='target_id' ) cmd = XmlCommand("modify_target") cmd.set_attribute("target_id", target_id) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if exclude_hosts is None: exclude_hosts = [''] if exclude_hosts: cmd.add_element("exclude_hosts", to_comma_list(exclude_hosts)) if alive_test: if not isinstance(alive_test, AliveTest): raise InvalidArgumentType( function=self.modify_target.__name__, argument='alive_test', arg_type=AliveTest.__name__, ) cmd.add_element("alive_tests", alive_test.value) if ssh_credential_id: _xmlssh = cmd.add_element( "ssh_credential", attrs={"id": ssh_credential_id} ) if ssh_credential_port: _xmlssh.add_element("port", str(ssh_credential_port)) if smb_credential_id: cmd.add_element("smb_credential", attrs={"id": smb_credential_id}) if esxi_credential_id: cmd.add_element("esxi_credential", attrs={"id": esxi_credential_id}) if snmp_credential_id: cmd.add_element("snmp_credential", attrs={"id": snmp_credential_id}) if reverse_lookup_only is not None: cmd.add_element("reverse_lookup_only", to_bool(reverse_lookup_only)) if reverse_lookup_unify is not None: cmd.add_element( "reverse_lookup_unify", to_bool(reverse_lookup_unify) ) if port_list_id: cmd.add_element("port_list", attrs={"id": port_list_id}) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/tasks.py000066400000000000000000000416661413122500400233330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from collections.abc import Mapping from numbers import Integral from typing import Any, List, Optional from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.protocols.gmpv208.entities.hosts import HostsOrdering from gvm.utils import add_filter, is_list_like, to_bool, to_comma_list from gvm.xml import XmlCommand class TasksMixin: def clone_task(self, task_id: str) -> Any: """Clone an existing task Arguments: task_id: UUID of existing task to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not task_id: raise RequiredArgument( function=self.clone_task.__name__, argument='task_id' ) cmd = XmlCommand("create_task") cmd.add_element("copy", task_id) return self._send_xml_command(cmd) def create_container_task( self, name: str, *, comment: Optional[str] = None ) -> Any: """Create a new container task A container task is a "meta" task to import and view reports from other systems. Arguments: name: Name of the task comment: Comment for the task Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_container_task.__name__, argument='name' ) cmd = XmlCommand("create_task") cmd.add_element("name", name) cmd.add_element("target", attrs={"id": "0"}) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) def create_task( self, name: str, config_id: str, target_id: str, scanner_id: str, *, alterable: Optional[bool] = None, hosts_ordering: Optional[HostsOrdering] = None, schedule_id: Optional[str] = None, alert_ids: Optional[List[str]] = None, comment: Optional[str] = None, schedule_periods: Optional[int] = None, observers: Optional[List[str]] = None, preferences: Optional[dict] = None, ) -> Any: """Create a new scan task Arguments: name: Name of the new task config_id: UUID of config to use by the task target_id: UUID of target to be scanned scanner_id: UUID of scanner to use for scanning the target comment: Comment for the task alterable: Whether the task should be alterable alert_ids: List of UUIDs for alerts to be applied to the task hosts_ordering: The order hosts are scanned in schedule_id: UUID of a schedule when the task should be run. schedule_periods: A limit to the number of times the task will be scheduled, or 0 for no limit observers: List of names or ids of users which should be allowed to observe this task preferences: Name/Value pairs of scanner preferences. Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_task.__name__, argument='name' ) if not config_id: raise RequiredArgument( function=self.create_task.__name__, argument='config_id' ) if not target_id: raise RequiredArgument( function=self.create_task.__name__, argument='target_id' ) if not scanner_id: raise RequiredArgument( function=self.create_task.__name__, argument='scanner_id' ) # don't allow to create a container task with create_task if target_id == '0': raise InvalidArgument( function=self.create_task.__name__, argument='target_id' ) cmd = XmlCommand("create_task") cmd.add_element("name", name) cmd.add_element("usage_type", "scan") cmd.add_element("config", attrs={"id": config_id}) cmd.add_element("target", attrs={"id": target_id}) cmd.add_element("scanner", attrs={"id": scanner_id}) if comment: cmd.add_element("comment", comment) if alterable is not None: cmd.add_element("alterable", to_bool(alterable)) if hosts_ordering: if not isinstance(hosts_ordering, HostsOrdering): raise InvalidArgumentType( function=self.create_task.__name__, argument='hosts_ordering', arg_type=HostsOrdering.__name__, ) cmd.add_element("hosts_ordering", hosts_ordering.value) if alert_ids is not None: if not is_list_like(alert_ids): raise InvalidArgumentType( function=self.modify_task.__name__, argument='alert_ids', arg_type='list', ) if not len(alert_ids) == 0: for alert in alert_ids: cmd.add_element("alert", attrs={"id": str(alert)}) if schedule_id: cmd.add_element("schedule", attrs={"id": schedule_id}) if schedule_periods is not None: if ( not isinstance(schedule_periods, Integral) or schedule_periods < 0 ): raise InvalidArgument( "schedule_periods must be an integer greater or equal " "than 0" ) cmd.add_element("schedule_periods", str(schedule_periods)) if observers is not None: if not is_list_like(observers): raise InvalidArgumentType( function=self.create_task.__name__, argument='observers', arg_type='list', ) # gvmd splits by comma and space # gvmd tries to lookup each value as user name and afterwards as # user id. So both user name and user id are possible cmd.add_element("observers", to_comma_list(observers)) if preferences is not None: if not isinstance(preferences, Mapping): raise InvalidArgumentType( function=self.create_task.__name__, argument='preferences', arg_type=Mapping.__name__, ) _xmlprefs = cmd.add_element("preferences") for pref_name, pref_value in preferences.items(): _xmlpref = _xmlprefs.add_element("preference") _xmlpref.add_element("scanner_name", pref_name) _xmlpref.add_element("value", str(pref_value)) return self._send_xml_command(cmd) def delete_task( self, task_id: str, *, ultimate: Optional[bool] = False ) -> Any: """Deletes an existing task Arguments: task_id: UUID of the task to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not task_id: raise RequiredArgument( function=self.delete_task.__name__, argument='task_id' ) cmd = XmlCommand("delete_task") cmd.set_attribute("task_id", task_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_tasks( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, details: Optional[bool] = None, schedules_only: Optional[bool] = None, ) -> Any: """Request a list of tasks Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: Whether to get the trashcan tasks instead details: Whether to include full task details schedules_only: Whether to only include id, name and schedule details Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_tasks") cmd.set_attribute("usage_type", "scan") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) if details is not None: cmd.set_attribute("details", to_bool(details)) if schedules_only is not None: cmd.set_attribute("schedules_only", to_bool(schedules_only)) return self._send_xml_command(cmd) def get_task(self, task_id: str) -> Any: """Request a single task Arguments: task_id: UUID of an existing task Returns: The response. See :py:meth:`send_command` for details. """ if not task_id: raise RequiredArgument( function=self.get_task.__name__, argument='task_id' ) cmd = XmlCommand("get_tasks") cmd.set_attribute("task_id", task_id) cmd.set_attribute("usage_type", "scan") # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def modify_task( self, task_id: str, *, name: Optional[str] = None, config_id: Optional[str] = None, target_id: Optional[str] = None, scanner_id: Optional[str] = None, alterable: Optional[bool] = None, hosts_ordering: Optional[HostsOrdering] = None, schedule_id: Optional[str] = None, schedule_periods: Optional[int] = None, comment: Optional[str] = None, alert_ids: Optional[List[str]] = None, observers: Optional[List[str]] = None, preferences: Optional[dict] = None, ) -> Any: """Modifies an existing task. Arguments: task_id: UUID of task to modify. name: The name of the task. config_id: UUID of scan config to use by the task target_id: UUID of target to be scanned scanner_id: UUID of scanner to use for scanning the target comment: The comment on the task. alert_ids: List of UUIDs for alerts to be applied to the task hosts_ordering: The order hosts are scanned in schedule_id: UUID of a schedule when the task should be run. schedule_periods: A limit to the number of times the task will be scheduled, or 0 for no limit. observers: List of names or ids of users which should be allowed to observe this task preferences: Name/Value pairs of scanner preferences. Returns: The response. See :py:meth:`send_command` for details. """ if not task_id: raise RequiredArgument( function=self.modify_task.__name__, argument='task_id argument' ) cmd = XmlCommand("modify_task") cmd.set_attribute("task_id", task_id) if name: cmd.add_element("name", name) if comment: cmd.add_element("comment", comment) if config_id: cmd.add_element("config", attrs={"id": config_id}) if target_id: cmd.add_element("target", attrs={"id": target_id}) if alterable is not None: cmd.add_element("alterable", to_bool(alterable)) if hosts_ordering: if not isinstance(hosts_ordering, HostsOrdering): raise InvalidArgumentType( function=self.modify_task.__name__, argument='hosts_ordering', arg_type=HostsOrdering.__name__, ) cmd.add_element("hosts_ordering", hosts_ordering.value) if scanner_id: cmd.add_element("scanner", attrs={"id": scanner_id}) if schedule_id: cmd.add_element("schedule", attrs={"id": schedule_id}) if schedule_periods is not None: if ( not isinstance(schedule_periods, Integral) or schedule_periods < 0 ): raise InvalidArgument( "schedule_periods must be an integer greater or equal " "than 0" ) cmd.add_element("schedule_periods", str(schedule_periods)) if alert_ids is not None: if not is_list_like(alert_ids): raise InvalidArgumentType( function=self.modify_task.__name__, argument='alert_ids', arg_type='list', ) if len(alert_ids) == 0: cmd.add_element("alert", attrs={"id": "0"}) else: for alert in alert_ids: cmd.add_element("alert", attrs={"id": str(alert)}) if observers is not None: if not is_list_like(observers): raise InvalidArgumentType( function=self.modify_task.__name__, argument='observers', arg_type='list', ) cmd.add_element("observers", to_comma_list(observers)) if preferences is not None: if not isinstance(preferences, Mapping): raise InvalidArgumentType( function=self.modify_task.__name__, argument='preferences', arg_type=Mapping.__name__, ) _xmlprefs = cmd.add_element("preferences") for pref_name, pref_value in preferences.items(): _xmlpref = _xmlprefs.add_element("preference") _xmlpref.add_element("scanner_name", pref_name) _xmlpref.add_element("value", str(pref_value)) return self._send_xml_command(cmd) def move_task(self, task_id: str, *, slave_id: Optional[str] = None) -> Any: """Move an existing task to another GMP slave scanner or the master Arguments: task_id: UUID of the task to be moved slave_id: UUID of slave to reassign the task to, empty for master. Returns: The response. See :py:meth:`send_command` for details. """ if not task_id: raise RequiredArgument( function=self.move_task.__name__, argument='task_id' ) cmd = XmlCommand("move_task") cmd.set_attribute("task_id", task_id) if slave_id is not None: cmd.set_attribute("slave_id", slave_id) return self._send_xml_command(cmd) def start_task(self, task_id: str) -> Any: """Start an existing task Arguments: task_id: UUID of the task to be started Returns: The response. See :py:meth:`send_command` for details. """ if not task_id: raise RequiredArgument( function=self.start_task.__name__, argument='task_id' ) cmd = XmlCommand("start_task") cmd.set_attribute("task_id", task_id) return self._send_xml_command(cmd) def resume_task(self, task_id: str) -> Any: """Resume an existing stopped task Arguments: task_id: UUID of the task to be resumed Returns: The response. See :py:meth:`send_command` for details. """ if not task_id: raise RequiredArgument( function=self.resume_task.__name__, argument='task_id' ) cmd = XmlCommand("resume_task") cmd.set_attribute("task_id", task_id) return self._send_xml_command(cmd) def stop_task(self, task_id: str) -> Any: """Stop an existing running task Arguments: task_id: UUID of the task to be stopped Returns: The response. See :py:meth:`send_command` for details. """ if not task_id: raise RequiredArgument( function=self.stop_task.__name__, argument='task_id' ) cmd = XmlCommand("stop_task") cmd.set_attribute("task_id", task_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/tickets.py000066400000000000000000000166151413122500400236500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class TicketStatus(Enum): """Enum for ticket status""" OPEN = 'Open' FIXED = 'Fixed' CLOSED = 'Closed' @classmethod def from_string( cls, ticket_status: Optional[str], ) -> Optional["TicketStatus"]: """Convert a ticket status string into a TicketStatus instance""" if not ticket_status: return None try: return cls[ticket_status.upper()] except KeyError: raise InvalidArgument( argument='ticket_status', function=cls.from_string.__name__, ) from None class TicketsMixin: def clone_ticket(self, ticket_id: str) -> Any: """Clone an existing ticket Arguments: ticket_id: UUID of an existing ticket to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not ticket_id: raise RequiredArgument( function=self.clone_ticket.__name__, argument='ticket_id' ) cmd = XmlCommand("create_ticket") _copy = cmd.add_element("copy", ticket_id) return self._send_xml_command(cmd) def create_ticket( self, *, result_id: str, assigned_to_user_id: str, note: str, comment: Optional[str] = None, ) -> Any: """Create a new ticket Arguments: result_id: UUID of the result the ticket applies to assigned_to_user_id: UUID of a user the ticket should be assigned to note: A note about opening the ticket comment: Comment for the ticket Returns: The response. See :py:meth:`send_command` for details. """ if not result_id: raise RequiredArgument( function=self.create_ticket.__name__, argument='result_id' ) if not assigned_to_user_id: raise RequiredArgument( function=self.create_ticket.__name__, argument='assigned_to_user_id', ) if not note: raise RequiredArgument( function=self.create_ticket.__name__, argument='note' ) cmd = XmlCommand("create_ticket") _result = cmd.add_element("result") _result.set_attribute("id", result_id) _assigned = cmd.add_element("assigned_to") _user = _assigned.add_element("user") _user.set_attribute("id", assigned_to_user_id) _note = cmd.add_element("open_note", note) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) def delete_ticket( self, ticket_id: str, *, ultimate: Optional[bool] = False ): """Deletes an existing ticket Arguments: ticket_id: UUID of the ticket to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ if not ticket_id: raise RequiredArgument( function=self.delete_ticket.__name__, argument='ticket_id' ) cmd = XmlCommand("delete_ticket") cmd.set_attribute("ticket_id", ticket_id) cmd.set_attribute("ultimate", to_bool(ultimate)) return self._send_xml_command(cmd) def get_tickets( self, *, trash: Optional[bool] = None, filter_string: Optional[str] = None, filter_id: Optional[str] = None, ) -> Any: """Request a list of tickets Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query trash: True to request the tickets in the trashcan Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_tickets") add_filter(cmd, filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return self._send_xml_command(cmd) def get_ticket(self, ticket_id: str) -> Any: """Request a single ticket Arguments: ticket_id: UUID of an existing ticket Returns: The response. See :py:meth:`send_command` for details. """ if not ticket_id: raise RequiredArgument( function=self.get_ticket.__name__, argument='ticket_id' ) cmd = XmlCommand("get_tickets") cmd.set_attribute("ticket_id", ticket_id) return self._send_xml_command(cmd) def modify_ticket( self, ticket_id: str, *, status: Optional[TicketStatus] = None, note: Optional[str] = None, assigned_to_user_id: Optional[str] = None, comment: Optional[str] = None, ) -> Any: """Modify a single ticket Arguments: ticket_id: UUID of an existing ticket status: New status for the ticket note: Note for the status change. Required if status is set. assigned_to_user_id: UUID of the user the ticket should be assigned to comment: Comment for the ticket Returns: The response. See :py:meth:`send_command` for details. """ if not ticket_id: raise RequiredArgument( function=self.modify_ticket.__name__, argument='ticket_id' ) if status and not note: raise RequiredArgument( function=self.modify_ticket.__name__, argument='note' ) if note and not status: raise RequiredArgument( function=self.modify_ticket.__name__, argument='status' ) cmd = XmlCommand("modify_ticket") cmd.set_attribute("ticket_id", ticket_id) if assigned_to_user_id: _assigned = cmd.add_element("assigned_to") _user = _assigned.add_element("user") _user.set_attribute("id", assigned_to_user_id) if status: if not isinstance(status, TicketStatus): raise InvalidArgumentType( function=self.modify_ticket.__name__, argument='status', arg_type=TicketStatus.__name__, ) cmd.add_element('status', status.value) cmd.add_element(f'{status.name.lower()}_note', note) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/tls_certificates.py000066400000000000000000000150721413122500400255250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, Optional from gvm.errors import RequiredArgument from gvm.utils import add_filter, to_bool from gvm.xml import XmlCommand class TLSCertificateMixin: def clone_tls_certificate(self, tls_certificate_id: str) -> Any: """Modifies an existing TLS certificate. Arguments: tls_certificate_id: The UUID of an existing TLS certificate Returns: The response. See :py:meth:`send_command` for details. """ if not tls_certificate_id: raise RequiredArgument( function=self.clone_tls_certificate.__name__, argument='tls_certificate_id', ) cmd = XmlCommand("create_tls_certificate") cmd.add_element("copy", tls_certificate_id) return self._send_xml_command(cmd) def create_tls_certificate( self, name: str, certificate: str, *, comment: Optional[str] = None, trust: Optional[bool] = None, ) -> Any: """Create a new TLS certificate Arguments: name: Name of the TLS certificate, defaulting to the MD5 fingerprint. certificate: The Base64 encoded certificate data (x.509 DER or PEM). comment: Comment for the TLS certificate. trust: Whether the certificate is trusted. Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_tls_certificate.__name__, argument='name' ) if not certificate: raise RequiredArgument( function=self.create_tls_certificate.__name__, argument='certificate', ) cmd = XmlCommand("create_tls_certificate") if comment: cmd.add_element("comment", comment) cmd.add_element("name", name) cmd.add_element("certificate", certificate) if trust: cmd.add_element("trust", to_bool(trust)) return self._send_xml_command(cmd) def delete_tls_certificate(self, tls_certificate_id: str) -> Any: """Deletes an existing tls certificate Arguments: tls_certificate_id: UUID of the tls certificate to be deleted. """ if not tls_certificate_id: raise RequiredArgument( function=self.delete_tls_certificate.__name__, argument='tls_certificate_id', ) cmd = XmlCommand("delete_tls_certificate") cmd.set_attribute("tls_certificate_id", tls_certificate_id) return self._send_xml_command(cmd) def get_tls_certificates( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, include_certificate_data: Optional[bool] = None, details: Optional[bool] = None, ) -> Any: """Request a list of TLS certificates Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query include_certificate_data: Whether to include the certificate data in the response details: Whether to include additional details of the tls certificates Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_tls_certificates") add_filter(cmd, filter_string, filter_id) if details is not None: cmd.set_attribute("details", to_bool(details)) if include_certificate_data is not None: cmd.set_attribute( "include_certificate_data", to_bool(include_certificate_data) ) return self._send_xml_command(cmd) def get_tls_certificate(self, tls_certificate_id: str) -> Any: """Request a single TLS certificate Arguments: tls_certificate_id: UUID of an existing TLS certificate Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_tls_certificates") if not tls_certificate_id: raise RequiredArgument( function=self.get_tls_certificate.__name__, argument='tls_certificate_id', ) cmd.set_attribute("tls_certificate_id", tls_certificate_id) # for single tls certificate always request cert data cmd.set_attribute("include_certificate_data", "1") # for single entity always request all details cmd.set_attribute("details", "1") return self._send_xml_command(cmd) def modify_tls_certificate( self, tls_certificate_id: str, *, name: Optional[str] = None, comment: Optional[str] = None, trust: Optional[bool] = None, ) -> Any: """Modifies an existing TLS certificate. Arguments: tls_certificate_id: UUID of the TLS certificate to be modified. name: Name of the TLS certificate, defaulting to the MD5 fingerprint comment: Comment for the TLS certificate. trust: Whether the certificate is trusted. Returns: The response. See :py:meth:`send_command` for details. """ if not tls_certificate_id: raise RequiredArgument( function=self.modify_tls_certificate.__name__, argument='tls_certificate_id', ) cmd = XmlCommand("modify_tls_certificate") cmd.set_attribute("tls_certificate_id", str(tls_certificate_id)) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if trust: cmd.add_element("trust", to_bool(trust)) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/users.py000066400000000000000000000234761413122500400233460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, List, Optional from gvm.errors import RequiredArgument, InvalidArgument from gvm.utils import add_filter, to_comma_list, to_bool from gvm.xml import XmlCommand class UserAuthType(Enum): """Enum for Sources allowed for authentication for the user""" FILE = 'file' LDAP_CONNECT = 'ldap_connect' RADIUS_CONNECT = 'radius_connect' @classmethod def from_string( cls, user_auth_type: Optional[str], ) -> Optional["UserAuthType"]: """Convert a user auth type string into a UserAuthType instance""" if not user_auth_type: return None try: return cls[user_auth_type.upper()] except KeyError: raise InvalidArgument( argument='user_auth_type', function=cls.from_string.__name__, ) from None class UsersMixin: def clone_user(self, user_id: str) -> Any: """Clone an existing user Arguments: user_id: UUID of existing user to clone from Returns: The response. See :py:meth:`send_command` for details. """ if not user_id: raise RequiredArgument( function=self.clone_user.__name__, argument='user_id' ) cmd = XmlCommand("create_user") cmd.add_element("copy", user_id) return self._send_xml_command(cmd) def create_user( self, name: str, *, password: Optional[str] = None, hosts: Optional[List[str]] = None, hosts_allow: Optional[bool] = False, ifaces: Optional[List[str]] = None, ifaces_allow: Optional[bool] = False, role_ids: Optional[List[str]] = None, ) -> Any: """Create a new user Arguments: name: Name of the user password: Password of the user hosts: A list of host addresses (IPs, DNS names) hosts_allow: If True allow only access to passed hosts otherwise deny access. Default is False for deny hosts. ifaces: A list of interface names ifaces_allow: If True allow only access to passed interfaces otherwise deny access. Default is False for deny interfaces. role_ids: A list of role UUIDs for the user Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_user.__name__, argument='name' ) cmd = XmlCommand("create_user") cmd.add_element("name", name) if password: cmd.add_element("password", password) if hosts: cmd.add_element( "hosts", to_comma_list(hosts), attrs={"allow": to_bool(hosts_allow)}, ) if ifaces: cmd.add_element( "ifaces", to_comma_list(ifaces), attrs={"allow": to_bool(ifaces_allow)}, ) if role_ids: for role in role_ids: cmd.add_element("role", attrs={"id": role}) return self._send_xml_command(cmd) def delete_user( self, user_id: str = None, *, name: Optional[str] = None, inheritor_id: Optional[str] = None, inheritor_name: Optional[str] = None, ) -> Any: """Deletes an existing user Either user_id or name must be passed. Arguments: user_id: UUID of the task to be deleted. name: The name of the user to be deleted. inheritor_id: The ID of the inheriting user or "self". Overrides inheritor_name. inheritor_name: The name of the inheriting user. """ if not user_id and not name: raise RequiredArgument( function=self.delete_user.__name__, argument='user_id or name' ) cmd = XmlCommand("delete_user") if user_id: cmd.set_attribute("user_id", user_id) if name: cmd.set_attribute("name", name) if inheritor_id: cmd.set_attribute("inheritor_id", inheritor_id) if inheritor_name: cmd.set_attribute("inheritor_name", inheritor_name) return self._send_xml_command(cmd) def get_users( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, ) -> Any: """Request a list of users Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_users") add_filter(cmd, filter_string, filter_id) return self._send_xml_command(cmd) def get_user(self, user_id: str) -> Any: """Request a single user Arguments: user_id: UUID of an existing user Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_users") if not user_id: raise RequiredArgument( function=self.get_user.__name__, argument='user_id' ) cmd.set_attribute("user_id", user_id) return self._send_xml_command(cmd) def modify_user( self, user_id: str = None, name: str = None, *, new_name: Optional[str] = None, comment: Optional[str] = None, password: Optional[str] = None, auth_source: Optional[UserAuthType] = None, role_ids: Optional[List[str]] = None, hosts: Optional[List[str]] = None, hosts_allow: Optional[bool] = False, ifaces: Optional[List[str]] = None, ifaces_allow: Optional[bool] = False, group_ids: Optional[List[str]] = None, ) -> Any: """Modifies an existing user. Most of the fields need to be supplied for changing a single field even if no change is wanted for those. Else empty values are inserted for the missing fields instead. Arguments: user_id: UUID of the user to be modified. Overrides name element argument. name: The name of the user to be modified. Either user_id or name must be passed. new_name: The new name for the user. comment: Comment on the user. password: The password for the user. auth_source: Source allowed for authentication for this user. roles_id: List of roles UUIDs for the user. hosts: User access rules: List of hosts. hosts_allow: Defines how the hosts list is to be interpreted. If False (default) the list is treated as a deny list. All hosts are allowed by default except those provided by the hosts parameter. If True the list is treated as a allow list. All hosts are denied by default except those provided by the hosts parameter. ifaces: User access rules: List of ifaces. ifaces_allow: Defines how the ifaces list is to be interpreted. If False (default) the list is treated as a deny list. All ifaces are allowed by default except those provided by the ifaces parameter. If True the list is treated as a allow list. All ifaces are denied by default except those provided by the ifaces parameter. group_ids: List of group UUIDs for the user. Returns: The response. See :py:meth:`send_command` for details. """ if not user_id and not name: raise RequiredArgument( function=self.modify_user.__name__, argument='user_id or name' ) cmd = XmlCommand("modify_user") if user_id: cmd.set_attribute("user_id", user_id) else: cmd.add_element("name", name) if new_name: cmd.add_element("new_name", new_name) if role_ids: for role in role_ids: cmd.add_element("role", attrs={"id": role}) if hosts: cmd.add_element( "hosts", to_comma_list(hosts), attrs={"allow": to_bool(hosts_allow)}, ) if ifaces: cmd.add_element( "ifaces", to_comma_list(ifaces), attrs={"allow": to_bool(ifaces_allow)}, ) if comment: cmd.add_element("comment", comment) if password: cmd.add_element("password", password) if auth_source: _xmlauthsrc = cmd.add_element("sources") _xmlauthsrc.add_element("source", auth_source.value) if group_ids: _xmlgroups = cmd.add_element("groups") for group_id in group_ids: _xmlgroups.add_element("group", attrs={"id": group_id}) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/entities/vulnerabilities.py000066400000000000000000000040731413122500400253760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, Optional from gvm.errors import RequiredArgument from gvm.utils import add_filter from gvm.xml import XmlCommand class VulnerabilitiesMixin: def get_vulnerabilities( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, ) -> Any: """Request a list of vulnerabilities Arguments: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_vulns") add_filter(cmd, filter_string, filter_id) return self._send_xml_command(cmd) def get_vulnerability(self, vulnerability_id: str) -> Any: """Request a single vulnerability Arguments: vulnerability_id: ID of an existing vulnerability Returns: The response. See :py:meth:`send_command` for details. """ if not vulnerability_id: raise RequiredArgument( function=self.get_vulnerability.__name__, argument='vulnerability_id', ) cmd = XmlCommand("get_vulns") cmd.set_attribute("vuln_id", vulnerability_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/system/000077500000000000000000000000001413122500400213175ustar00rootroot00000000000000python-gvm-21.10.0/gvm/protocols/gmpv208/system/__init__.py000066400000000000000000000013571413122500400234360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/gvm/protocols/gmpv208/system/aggregates.py000066400000000000000000000225321413122500400240060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.protocols.gmpv208.entities.entities import ( EntityType, ) # if I use latest, I get circular import :/ from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.utils import add_filter from gvm.xml import XmlCommand class AggregateStatistic(Enum): """Enum for aggregate statistic types""" COUNT = "count" # Number of items C_COUNT = "c_count" # Cumulative number of items C_SUM = "c_sum" # Cumulative sum of values MAX = "max" # Maximum value MEAN = "mean" # Arithmetic mean of values MIN = "min" # Minimum value SUM = "sum" # Sum of values TEXT = "text" # Text column value VALUE = "value" # Group or subgroup column value @classmethod def from_string( cls, aggregate_statistic: Optional[str], ) -> Optional["AggregateStatistic"]: """ Convert a aggregate statistic string to an actual AggregateStatistic instance. Arguments: aggregate_statistic: Aggregate statistic string to convert to a AggregateStatistic """ if not aggregate_statistic: return None try: return cls[aggregate_statistic.upper()] except KeyError: raise InvalidArgument( argument='aggregate_statistic', function=cls.from_string.__name__, ) from None class SortOrder(Enum): """Enum for sort order""" ASCENDING = "ascending" DESCENDING = "descending" @classmethod def from_string( cls, sort_order: Optional[str], ) -> Optional["SortOrder"]: """ Convert a sort order string to an actual SortOrder instance. Arguments: sort_order: Sort order string to convert to a SortOrder """ if not sort_order: return None try: return cls[sort_order.upper()] except KeyError: raise InvalidArgument( argument='sort_order', function=cls.from_string.__name__ ) from None class AggregatesMixin: def get_aggregates( self, resource_type: EntityType, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, sort_criteria: Optional[list] = None, data_columns: Optional[list] = None, group_column: Optional[str] = None, subgroup_column: Optional[str] = None, text_columns: Optional[list] = None, first_group: Optional[int] = None, max_groups: Optional[int] = None, mode: Optional[int] = None, **kwargs, ) -> Any: """Request aggregated information on a resource / entity type Additional arguments can be set via the kwargs parameter for backward compatibility with older versions of python-gvm, but are not validated. Arguments: resource_type: The entity type to gather data from filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query sort_criteria: List of sort criteria (dicts that can contain a field, stat and order) data_columns: List of fields to aggregate data from group_column: The field to group the entities by subgroup_column: The field to further group the entities inside groups by text_columns: List of simple text columns which no statistics are calculated for first_group: The index of the first aggregate group to return max_groups: The maximum number of aggregate groups to return, -1 for all mode: Special mode for aggregation Returns: The response. See :py:meth:`send_command` for details. """ if not resource_type: raise RequiredArgument( function=self.get_aggregates.__name__, argument='resource_type' ) if not isinstance(resource_type, EntityType): raise InvalidArgumentType( function=self.get_aggregates.__name__, argument='resource_type', arg_type=EntityType.__name__, ) cmd = XmlCommand('get_aggregates') _actual_resource_type = resource_type if resource_type.value == EntityType.AUDIT.value: _actual_resource_type = EntityType.TASK cmd.set_attribute('usage_type', 'audit') elif resource_type.value == EntityType.POLICY.value: _actual_resource_type = EntityType.SCAN_CONFIG cmd.set_attribute('usage_type', 'policy') elif resource_type.value == EntityType.SCAN_CONFIG.value: cmd.set_attribute('usage_type', 'scan') elif resource_type.value == EntityType.TASK.value: cmd.set_attribute('usage_type', 'scan') cmd.set_attribute('type', _actual_resource_type.value) add_filter(cmd, filter_string, filter_id) if first_group is not None: if not isinstance(first_group, int): raise InvalidArgumentType( function=self.get_aggregates.__name__, argument='first_group', arg_type=int.__name__, ) cmd.set_attribute('first_group', str(first_group)) if max_groups is not None: if not isinstance(max_groups, int): raise InvalidArgumentType( function=self.get_aggregates.__name__, argument='max_groups', arg_type=int.__name__, ) cmd.set_attribute('max_groups', str(max_groups)) if sort_criteria is not None: if not isinstance(sort_criteria, list): raise InvalidArgumentType( function=self.get_aggregates.__name__, argument='sort_criteria', arg_type=list.__name__, ) for sort in sort_criteria: if not isinstance(sort, dict): raise InvalidArgumentType( function=self.get_aggregates.__name__, argument='sort_criteria', ) sort_elem = cmd.add_element('sort') if sort.get('field'): sort_elem.set_attribute('field', sort.get('field')) if sort.get('stat'): if isinstance(sort['stat'], AggregateStatistic): sort_elem.set_attribute('stat', sort['stat'].value) else: stat = AggregateStatistic.from_string(sort['stat']) sort_elem.set_attribute('stat', stat.value) if sort.get('order'): if isinstance(sort['order'], SortOrder): sort_elem.set_attribute('order', sort['order'].value) else: so = SortOrder.from_string(sort['order']) sort_elem.set_attribute('order', so.value) if data_columns is not None: if not isinstance(data_columns, list): raise InvalidArgumentType( function=self.get_aggregates.__name__, argument='data_columns', arg_type=list.__name__, ) for column in data_columns: cmd.add_element('data_column', column) if group_column is not None: cmd.set_attribute('group_column', group_column) if subgroup_column is not None: if not group_column: raise RequiredArgument( f'{self.get_aggregates.__name__} requires a group_column' ' argument if subgroup_column is given', function=self.get_aggregates.__name__, argument='subgroup_column', ) cmd.set_attribute('subgroup_column', subgroup_column) if text_columns is not None: if not isinstance(text_columns, list): raise InvalidArgumentType( function=self.get_aggregates.__name__, argument='text_columns', arg_type=list.__name__, ) for column in text_columns: cmd.add_element('text_column', column) if mode is not None: cmd.set_attribute('mode', mode) # Add additional keyword args as attributes for backward compatibility. cmd.set_attributes(kwargs) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/system/authentication.py000066400000000000000000000072701413122500400247160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any from gvm.errors import RequiredArgument from gvm.utils import check_command_status from gvm.xml import XmlCommand class AuthenticationMixin: def is_authenticated(self) -> bool: """Checks if the user is authenticated If the user is authenticated privileged GMP commands like get_tasks may be send to gvmd. Returns: bool: True if an authenticated connection to gvmd has been established. """ return self._authenticated def authenticate(self, username: str, password: str) -> Any: """Authenticate to gvmd. The generated authenticate command will be send to server. Afterwards the response is read, transformed and returned. Arguments: username: Username password: Password Returns: Transformed response from server. """ cmd = XmlCommand("authenticate") if not username: raise RequiredArgument( function=self.authenticate.__name__, argument='username' ) if not password: raise RequiredArgument( function=self.authenticate.__name__, argument='password' ) credentials = cmd.add_element("credentials") credentials.add_element("username", username) credentials.add_element("password", password) self._send(cmd.to_string()) response = self._read() if check_command_status(response): self._authenticated = True return self._transform(response) def describe_auth(self) -> Any: """Describe authentication methods Returns a list of all used authentication methods if such a list is available. Returns: The response. See :py:meth:`send_command` for details. """ return self._send_xml_command(XmlCommand("describe_auth")) def modify_auth(self, group_name: str, auth_conf_settings: dict) -> Any: """Modifies an existing auth. Arguments: group_name: Name of the group to be modified. auth_conf_settings: The new auth config. Returns: The response. See :py:meth:`send_command` for details. """ if not group_name: raise RequiredArgument( function=self.modify_auth.__name__, argument='group_name' ) if not auth_conf_settings: raise RequiredArgument( function=self.modify_auth.__name__, argument='auth_conf_settings', ) cmd = XmlCommand("modify_auth") _xmlgroup = cmd.add_element("group", attrs={"name": str(group_name)}) for key, value in auth_conf_settings.items(): _xmlauthconf = _xmlgroup.add_element("auth_conf_setting") _xmlauthconf.add_element("key", key) _xmlauthconf.add_element("value", value) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/system/feed.py000066400000000000000000000047261413122500400226050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.xml import XmlCommand class FeedType(Enum): """Enum for feed types""" NVT = "NVT" CERT = "CERT" SCAP = "SCAP" GVMD_DATA = "GVMD_DATA" @classmethod def from_string(cls, feed_type: Optional[str]) -> Optional["FeedType"]: """Convert a feed type string into a FeedType instance""" if not feed_type: return None try: return cls[feed_type.upper()] except KeyError: raise InvalidArgument( argument='feed_type', function=cls.from_string.__name__ ) from None class FeedMixin: def get_feeds(self) -> Any: """Request the list of feeds Returns: The response. See :py:meth:`send_command` for details. """ return self._send_xml_command(XmlCommand("get_feeds")) def get_feed(self, feed_type: Optional[FeedType]) -> Any: """Request a single feed Arguments: feed_type: Type of single feed to get: NVT, CERT or SCAP Returns: The response. See :py:meth:`send_command` for details. """ if not feed_type: raise RequiredArgument( function=self.get_feed.__name__, argument='feed_type' ) if not isinstance(feed_type, FeedType): raise InvalidArgumentType( function=self.get_feed.__name__, argument='feed_type', arg_type=FeedType.__name__, ) cmd = XmlCommand("get_feeds") cmd.set_attribute("type", feed_type.value) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/system/help.py000066400000000000000000000050201413122500400226160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import InvalidArgument, InvalidArgumentType from gvm.xml import XmlCommand class HelpFormat(Enum): """Enum for the help format""" HTML = "html" RNC = "rnc" TEXT = "text" XML = "xml" @classmethod def from_string( cls, sort_order: Optional[str], ) -> Optional["HelpFormat"]: """ Convert a sort order string to an actual SortOrder instance. Arguments: sort_order: Sort order string to convert to a SortOrder """ if not sort_order: return None try: return cls[sort_order.upper()] except KeyError: raise InvalidArgument( argument='sort_order', function=cls.from_string.__name__ ) from None class HelpMixin: def help( self, *, help_format: Optional[HelpFormat] = None, brief: Optional[bool] = None, ) -> Any: """Get the help text Arguments: help_format: Format of of the help: "html", "rnc", "text" or "xml brief: If True help is brief Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("help") help_type = "" if brief: help_type = "brief" cmd.set_attribute("type", help_type) if help_format: if not isinstance(help_format, HelpFormat): raise InvalidArgumentType( function=self.help.__name__, argument='feed_type', arg_type=HelpFormat.__name__, ) cmd.set_attribute("format", help_format.value) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/system/system_reports.py000066400000000000000000000052711413122500400250000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # pylint: disable=arguments-differ, redefined-builtin, too-many-lines from numbers import Integral from typing import Any, Optional from gvm.errors import InvalidArgument from gvm.utils import to_bool from gvm.xml import XmlCommand class SystemReportsMixin: def get_system_reports( self, *, name: Optional[str] = None, duration: Optional[int] = None, start_time: Optional[str] = None, end_time: Optional[str] = None, brief: Optional[bool] = None, slave_id: Optional[str] = None, ) -> Any: """Request a list of system reports Arguments: name: A string describing the required system report duration: The number of seconds into the past that the system report should include start_time: The start of the time interval the system report should include in ISO time format end_time: The end of the time interval the system report should include in ISO time format brief: Whether to include the actual system reports slave_id: UUID of GMP scanner from which to get the system reports Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_system_reports") if name: cmd.set_attribute("name", name) if duration is not None: if not isinstance(duration, Integral): raise InvalidArgument("duration needs to be an integer number") cmd.set_attribute("duration", str(duration)) if start_time: cmd.set_attribute("start_time", str(start_time)) if end_time: cmd.set_attribute("end_time", str(end_time)) if brief is not None: cmd.set_attribute("brief", to_bool(brief)) if slave_id: cmd.set_attribute("slave_id", slave_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/system/trashcan.py000066400000000000000000000034141413122500400234760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any from gvm.errors import RequiredArgument from gvm.xml import XmlCommand class TrashcanMixin: def empty_trashcan(self) -> Any: """Empty the trashcan Remove all entities from the trashcan. **Attention:** this command can not be reverted Returns: The response. See :py:meth:`send_command` for details. """ return self._send_xml_command(XmlCommand("empty_trashcan")) def restore_from_trashcan(self, entity_id: str) -> Any: """Restore an entity from the trashcan Arguments: entity_id: ID of the entity to be restored from the trashcan Returns: The response. See :py:meth:`send_command` for details. """ if not entity_id: raise RequiredArgument( function=self.restore_from_trashcan.__name__, argument='entity_id', ) cmd = XmlCommand("restore") cmd.set_attribute("id", entity_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/system/user_settings.py000066400000000000000000000061131413122500400245700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, Optional from gvm.errors import RequiredArgument from gvm.utils import to_base64 from gvm.xml import XmlCommand class UserSettingsMixin: def get_user_settings(self, *, filter_string: Optional[str] = None) -> Any: """Request a list of user settings Arguments: filter_string: Filter term to use for the query Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_settings") if filter_string: cmd.set_attribute("filter", filter_string) return self._send_xml_command(cmd) def get_user_setting(self, setting_id: str) -> Any: """Request a single user setting Arguments: setting_id: UUID of an existing setting Returns: The response. See :py:meth:`send_command` for details. """ cmd = XmlCommand("get_settings") if not setting_id: raise RequiredArgument( function=self.get_user_setting.__name__, argument='setting_id' ) cmd.set_attribute("setting_id", setting_id) return self._send_xml_command(cmd) def modify_user_setting( self, setting_id: Optional[str] = None, name: Optional[str] = None, value: Optional[str] = None, ) -> Any: """Modifies an existing user setting. Arguments: setting_id: UUID of the setting to be changed. name: The name of the setting. Either setting_id or name must be passed. value: The value of the setting. Returns: The response. See :py:meth:`send_command` for details. """ if not setting_id and not name: raise RequiredArgument( function=self.modify_user_setting.__name__, argument='setting_id or name argument', ) if value is None: raise RequiredArgument( function=self.modify_user_setting.__name__, argument='value argument', ) cmd = XmlCommand("modify_setting") if setting_id: cmd.set_attribute("setting_id", setting_id) else: cmd.add_element("name", name) cmd.add_element("value", to_base64(value)) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv208/system/version.py000066400000000000000000000026611413122500400233630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any from gvm.xml import XmlCommand PROTOCOL_VERSION = (20, 8) class VersionMixin: def get_version(self) -> Any: """Get the Greenbone Vulnerability Manager Protocol version used by the remote gvmd. Returns: The response. See :py:meth:`send_command` for details. """ return self._send_xml_command(XmlCommand("get_version")) @staticmethod def get_protocol_version() -> tuple: """Determine the Greenbone Management Protocol (gmp) version used by python-gvm version. Returns: tuple: Implemented version of the Greenbone Management Protocol """ return PROTOCOL_VERSION python-gvm-21.10.0/gvm/protocols/gmpv214/000077500000000000000000000000001413122500400177705ustar00rootroot00000000000000python-gvm-21.10.0/gvm/protocols/gmpv214/__init__.py000066400000000000000000000132531413122500400221050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # pylint: disable=too-many-lines,redefined-builtin """ Module for communication with gvmd in `Greenbone Management Protocol version 21.04`_ .. _Greenbone Management Protocol version 21.04: https://docs.greenbone.net/API/GMP/gmp-21.04.html """ import logging from typing import Any, Callable, Optional from gvm.protocols.base import GvmProtocol from gvm.protocols.gmpv208.entities.alerts import ( AlertCondition, AlertEvent, AlertMethod, AlertsMixin, ) from gvm.protocols.gmpv208.entities.audits import AuditsMixin from gvm.protocols.gmpv208.entities.credentials import ( CredentialFormat, CredentialsMixin, CredentialType, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, ) from gvm.protocols.gmpv208.entities.entities import ( EntityType, ) from gvm.protocols.gmpv208.entities.filter import ( FiltersMixin, FilterType, ) from gvm.protocols.gmpv208.entities.groups import GroupsMixin from gvm.protocols.gmpv208.entities.hosts import ( HostsMixin, HostsOrdering, ) from gvm.protocols.gmpv208.entities.operating_systems import ( OperatingSystemsMixin, ) from gvm.protocols.gmpv208.entities.permissions import ( PermissionsMixin, PermissionSubjectType, ) from gvm.protocols.gmpv208.entities.policies import PoliciesMixin from gvm.protocols.gmpv208.entities.port_lists import ( PortListMixin, PortRangeType, ) from gvm.protocols.gmpv208.entities.reports import ReportsMixin from gvm.protocols.gmpv208.entities.report_formats import ( ReportFormatType, ReportFormatsMixin, ) from gvm.protocols.gmpv208.entities.results import ResultsMixin from gvm.protocols.gmpv208.entities.roles import RolesMixin from gvm.protocols.gmpv208.entities.scan_configs import ScanConfigsMixin from gvm.protocols.gmpv208.entities.schedules import SchedulesMixin from gvm.protocols.gmpv208.entities.secinfo import ( InfoType, SecInfoMixin, ) from gvm.protocols.gmpv208.entities.severity import ( SeverityLevel, ) from gvm.protocols.gmpv208.entities.tags import TagsMixin from gvm.protocols.gmpv208.entities.tasks import TasksMixin from gvm.protocols.gmpv208.entities.tickets import ( TicketStatus, TicketsMixin, ) from gvm.protocols.gmpv208.entities.tls_certificates import TLSCertificateMixin from gvm.protocols.gmpv208.entities.users import ( UserAuthType, ) from gvm.protocols.gmpv208.entities.vulnerabilities import VulnerabilitiesMixin from gvm.protocols.gmpv208.system.aggregates import ( AggregatesMixin, AggregateStatistic, SortOrder, ) from gvm.protocols.gmpv208.system.authentication import AuthenticationMixin from gvm.protocols.gmpv208.system.feed import ( FeedType, FeedMixin, ) from gvm.protocols.gmpv208.system.help import ( HelpFormat, HelpMixin, ) from gvm.protocols.gmpv208.system.system_reports import SystemReportsMixin from gvm.protocols.gmpv208.system.user_settings import UserSettingsMixin from gvm.protocols.gmpv208.system.trashcan import TrashcanMixin # NEW IN 214 from gvm.protocols.gmpv214.entities.notes import NotesMixin from gvm.protocols.gmpv214.entities.overrides import OverridesMixin from gvm.protocols.gmpv214.entities.scanners import ( ScannerType, ScannersMixin, ) from gvm.protocols.gmpv214.entities.targets import ( AliveTest, TargetsMixin, ) from gvm.protocols.gmpv214.entities.users import UsersMixin from gvm.protocols.gmpv214.system.version import VersionMixin from gvm.connections import GvmConnection logger = logging.getLogger(__name__) _TYPE_FIELDS = [ AggregateStatistic, AlertCondition, AlertEvent, AlertMethod, AliveTest, CredentialFormat, CredentialType, EntityType, FeedType, FilterType, HostsOrdering, InfoType, HelpFormat, PortRangeType, PermissionSubjectType, ReportFormatType, ScannerType, SeverityLevel, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, SortOrder, TicketStatus, UserAuthType, ] class Gmp( GvmProtocol, AggregatesMixin, AlertsMixin, AuditsMixin, AuthenticationMixin, CredentialsMixin, FeedMixin, FiltersMixin, GroupsMixin, HelpMixin, HostsMixin, NotesMixin, OperatingSystemsMixin, OverridesMixin, PermissionsMixin, PoliciesMixin, PortListMixin, ReportFormatsMixin, ReportsMixin, ResultsMixin, RolesMixin, TagsMixin, TargetsMixin, TasksMixin, TicketsMixin, TLSCertificateMixin, TrashcanMixin, ScanConfigsMixin, ScannersMixin, SchedulesMixin, SecInfoMixin, SystemReportsMixin, UserSettingsMixin, UsersMixin, VersionMixin, VulnerabilitiesMixin, ): def __init__( self, connection: GvmConnection, *, transform: Optional[Callable[[str], Any]] = None, ): self.types = {} for t in _TYPE_FIELDS: self.types[t.__name__] = t super().__init__(connection, transform=transform) # Is authenticated on gvmd self._authenticated = False python-gvm-21.10.0/gvm/protocols/gmpv214/entities/000077500000000000000000000000001413122500400216145ustar00rootroot00000000000000python-gvm-21.10.0/gvm/protocols/gmpv214/entities/__init__.py000066400000000000000000000013571413122500400237330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/gvm/protocols/gmpv214/entities/notes.py000066400000000000000000000124271413122500400233240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional from gvm.errors import RequiredArgument from gvm.protocols.gmpv208.entities.notes import NotesMixin as Gmp208NotesMixin from gvm.protocols.gmpv208.entities.severity import Severity from gvm.utils import deprecation, to_comma_list from gvm.xml import XmlCommand class NotesMixin(Gmp208NotesMixin): def create_note( self, text: str, nvt_oid: str, *, days_active: Optional[int] = None, hosts: Optional[List[str]] = None, port: Optional[int] = None, result_id: Optional[str] = None, severity: Optional[Severity] = None, task_id: Optional[str] = None, threat: Any = None, ) -> Any: """Create a new note Arguments: text: Text of the new note nvt_id: OID of the nvt to which note applies days_active: Days note will be active. -1 on always, 0 off hosts: A list of hosts addresses port: Port to which the note applies result_id: UUID of a result to which note applies severity: Severity to which note applies task_id: UUID of task to which note applies threat: deprecated Returns: The response. See :py:meth:`send_command` for details. """ if not text: raise RequiredArgument( function=self.create_note.__name__, argument='text' ) if not nvt_oid: raise RequiredArgument( function=self.create_note.__name__, argument='nvt_oid' ) cmd = XmlCommand("create_note") cmd.add_element("text", text) cmd.add_element("nvt", attrs={"oid": nvt_oid}) if days_active is not None: cmd.add_element("active", str(days_active)) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if port: cmd.add_element("port", str(port)) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity: cmd.add_element("severity", str(severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) if threat is not None: major, minor = self.get_protocol_version() deprecation( "The threat parameter has been removed in GMP" f" version {major}{minor}" ) return self._send_xml_command(cmd) def modify_note( self, note_id: str, text: str, *, days_active: Optional[int] = None, hosts: Optional[List[str]] = None, port: Optional[int] = None, result_id: Optional[str] = None, severity: Optional[Severity] = None, task_id: Optional[str] = None, threat: Any = None, ) -> Any: """Modifies an existing note. Arguments: note_id: UUID of note to modify. text: The text of the note. days_active: Days note will be active. -1 on always, 0 off. hosts: A list of hosts addresses port: Port to which note applies. result_id: Result to which note applies. severity: Severity to which note applies. task_id: Task to which note applies. threat: deprecated Returns: The response. See :py:meth:`send_command` for details. """ if not note_id: raise RequiredArgument( function=self.modify_note.__name__, argument='note_id' ) if not text: raise RequiredArgument( function=self.modify_note.__name__, argument='text' ) cmd = XmlCommand("modify_note") cmd.set_attribute("note_id", note_id) cmd.add_element("text", text) if days_active is not None: cmd.add_element("active", str(days_active)) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if port: cmd.add_element("port", str(port)) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity: cmd.add_element("severity", str(severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) if threat is not None: major, minor = self.get_protocol_version() deprecation( "The threat parameter has been removed in GMP" f" version {major}{minor}" ) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv214/entities/overrides.py000066400000000000000000000146161413122500400242000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Any, List, Optional from gvm.errors import RequiredArgument from gvm.protocols.gmpv208.entities.overrides import ( OverridesMixin as Gmp208OverridesMixin, ) from gvm.protocols.gmpv208.entities.severity import Severity from gvm.utils import deprecation, to_comma_list from gvm.xml import XmlCommand class OverridesMixin(Gmp208OverridesMixin): def create_override( self, text: str, nvt_oid: str, *, days_active: Optional[int] = None, hosts: Optional[List[str]] = None, port: Optional[int] = None, result_id: Optional[str] = None, severity: Optional[Severity] = None, new_severity: Optional[Severity] = None, task_id: Optional[str] = None, threat: Any = None, new_threat: Any = None, ) -> Any: """Create a new override Arguments: text: Text of the new override nvt_id: OID of the nvt to which override applies days_active: Days override will be active. -1 on always, 0 off hosts: A list of host addresses port: Port to which the override applies result_id: UUID of a result to which override applies severity: Severity to which override applies new_severity: New severity for result task_id: UUID of task to which override applies threat: deprecated new_threat: deprecated Returns: The response. See :py:meth:`send_command` for details. """ if not text: raise RequiredArgument( function=self.create_override.__name__, argument='text' ) if not nvt_oid: raise RequiredArgument( function=self.create_override.__name__, argument='nvt_oid' ) cmd = XmlCommand("create_override") cmd.add_element("text", text) cmd.add_element("nvt", attrs={"oid": nvt_oid}) if days_active is not None: cmd.add_element("active", str(days_active)) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if port: cmd.add_element("port", str(port)) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity: cmd.add_element("severity", str(severity)) if new_severity: cmd.add_element("new_severity", str(new_severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) if threat is not None: major, minor = self.get_protocol_version() deprecation( "The threat parameter has been removed in GMP" f" version {major}{minor}" ) if new_threat is not None: major, minor = self.get_protocol_version() deprecation( "The new_threat parameter has been removed in GMP" f" version {major}{minor}" ) return self._send_xml_command(cmd) def modify_override( self, override_id: str, text: str, *, days_active: Optional[int] = None, hosts: Optional[List[str]] = None, port: Optional[int] = None, result_id: Optional[str] = None, severity: Optional[Severity] = None, new_severity: Optional[Severity] = None, task_id: Optional[str] = None, threat: Any = None, new_threat: Any = None, ) -> Any: """Modifies an existing override. Arguments: override_id: UUID of override to modify. text: The text of the override. days_active: Days override will be active. -1 on always, 0 off. hosts: A list of host addresses port: Port to which override applies. result_id: Result to which override applies. severity: Severity to which override applies. new_severity: New severity score for result. task_id: Task to which override applies. threat: deprecated new_threat: deprecated Returns: The response. See :py:meth:`send_command` for details. """ if not override_id: raise RequiredArgument( function=self.modify_override.__name__, argument='override_id' ) if not text: raise RequiredArgument( function=self.modify_override.__name__, argument='text' ) cmd = XmlCommand("modify_override") cmd.set_attribute("override_id", override_id) cmd.add_element("text", text) if days_active is not None: cmd.add_element("active", str(days_active)) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if port: cmd.add_element("port", str(port)) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity: cmd.add_element("severity", str(severity)) if new_severity: cmd.add_element("new_severity", str(new_severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) if threat is not None: major, minor = self.get_protocol_version() deprecation( "The threat parameter has been removed in GMP" f" version {major}{minor}" ) if new_threat is not None: major, minor = self.get_protocol_version() deprecation( "The new_threat parameter has been removed in GMP" f" version {major}{minor}" ) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv214/entities/scanners.py000066400000000000000000000151021413122500400240010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from enum import Enum from typing import Any, Optional from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.protocols.gmpv208.entities.scanners import ( ScannersMixin as Gmp208ScannersMixin, ) from gvm.xml import XmlCommand class ScannerType(Enum): """Enum for scanner type""" OSP_SCANNER_TYPE = "1" OPENVAS_SCANNER_TYPE = "2" CVE_SCANNER_TYPE = "3" GREENBONE_SENSOR_SCANNER_TYPE = "5" @classmethod def from_string( cls, scanner_type: Optional[str], ) -> Optional["ScannerType"]: """Convert a scanner type string to an actual ScannerType instance Arguments: scanner_type: Scanner type string to convert to a ScannerType """ if not scanner_type: return None scanner_type = scanner_type.lower() if scanner_type == cls.OSP_SCANNER_TYPE.value or scanner_type == 'osp': return cls.OSP_SCANNER_TYPE if ( scanner_type == cls.OPENVAS_SCANNER_TYPE.value or scanner_type == 'openvas' ): return cls.OPENVAS_SCANNER_TYPE if scanner_type == cls.CVE_SCANNER_TYPE.value or scanner_type == 'cve': return cls.CVE_SCANNER_TYPE if ( scanner_type == cls.GREENBONE_SENSOR_SCANNER_TYPE.value or scanner_type == 'greenbone' ): return cls.GREENBONE_SENSOR_SCANNER_TYPE raise InvalidArgument( argument='scanner_type', function=cls.from_string.__name__ ) class ScannersMixin(Gmp208ScannersMixin): # Override bc. of ScannerType (?) def create_scanner( self, name: str, host: str, port: int, scanner_type: ScannerType, credential_id: str, *, ca_pub: Optional[str] = None, comment: Optional[str] = None, ) -> Any: """Create a new scanner Arguments: name: Name of the scanner host: The host of the scanner port: The port of the scanner scanner_type: Type of the scanner. credential_id: UUID of client certificate credential for the scanner ca_pub: Certificate of CA to verify scanner certificate comment: Comment for the scanner Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_scanner.__name__, argument='name' ) if not host: raise RequiredArgument( function=self.create_scanner.__name__, argument='host' ) if not port: raise RequiredArgument( function=self.create_scanner.__name__, argument='port' ) if not scanner_type: raise RequiredArgument( function=self.create_scanner.__name__, argument='scanner_type' ) if not credential_id: raise RequiredArgument( function=self.create_scanner.__name__, argument='credential_id' ) if not isinstance(scanner_type, ScannerType): raise InvalidArgumentType( function=self.create_scanner.__name__, argument='scanner_type', arg_type=ScannerType.__name__, ) cmd = XmlCommand("create_scanner") cmd.add_element("name", name) cmd.add_element("host", host) cmd.add_element("port", str(port)) cmd.add_element("type", scanner_type.value) if ca_pub: cmd.add_element("ca_pub", ca_pub) cmd.add_element("credential", attrs={"id": str(credential_id)}) if comment: cmd.add_element("comment", comment) return self._send_xml_command(cmd) def modify_scanner( self, scanner_id: str, *, scanner_type: Optional[ScannerType] = None, host: Optional[str] = None, port: Optional[int] = None, comment: Optional[str] = None, name: Optional[str] = None, ca_pub: Optional[str] = None, credential_id: Optional[str] = None, ) -> Any: """Modifies an existing scanner. Arguments: scanner_id: UUID of scanner to modify. scanner_type: New type of the Scanner. host: Host of the scanner. port: Port of the scanner. comment: Comment on scanner. name: Name of scanner. ca_pub: Certificate of CA to verify scanner's certificate. credential_id: UUID of the client certificate credential for the Scanner. Returns: The response. See :py:meth:`send_command` for details. """ if not scanner_id: raise RequiredArgument( function=self.modify_scanner.__name__, argument='scanner_id argument', ) cmd = XmlCommand("modify_scanner") cmd.set_attribute("scanner_id", scanner_id) if scanner_type is not None: if not isinstance(scanner_type, ScannerType): raise InvalidArgumentType( function=self.modify_scanner.__name__, argument='scanner_type', arg_type=ScannerType.__name__, ) cmd.add_element("type", scanner_type.value) if host: cmd.add_element("host", host) if port: cmd.add_element("port", str(port)) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if ca_pub: cmd.add_element("ca_pub", ca_pub) if credential_id: cmd.add_element("credential", attrs={"id": str(credential_id)}) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv214/entities/targets.py000066400000000000000000000227241413122500400236460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # pylint: disable=arguments-differ, unused-import from typing import Any, List, Optional from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208.entities.targets import ( TargetsMixin as Gmp208TargetsMixin, AliveTest, ) from gvm.utils import to_bool, to_comma_list from gvm.xml import XmlCommand class TargetsMixin(Gmp208TargetsMixin): def create_target( self, name: str, *, asset_hosts_filter: Optional[str] = None, hosts: Optional[List[str]] = None, comment: Optional[str] = None, exclude_hosts: Optional[List[str]] = None, ssh_credential_id: Optional[str] = None, ssh_credential_port: Optional[int] = None, smb_credential_id: Optional[str] = None, esxi_credential_id: Optional[str] = None, snmp_credential_id: Optional[str] = None, alive_test: Optional[AliveTest] = None, allow_simultaneous_ips: Optional[bool] = None, reverse_lookup_only: Optional[bool] = None, reverse_lookup_unify: Optional[bool] = None, port_range: Optional[str] = None, port_list_id: Optional[str] = None, ) -> Any: """Create a new target Arguments: name: Name of the target asset_hosts_filter: Filter to select target host from assets hosts hosts: List of hosts addresses to scan exclude_hosts: List of hosts addresses to exclude from scan comment: Comment for the target ssh_credential_id: UUID of a ssh credential to use on target ssh_credential_port: The port to use for ssh credential smb_credential_id: UUID of a smb credential to use on target snmp_credential_id: UUID of a snmp credential to use on target esxi_credential_id: UUID of a esxi credential to use on target alive_test: Which alive test to use allow_simultaneous_ips: Whether to scan multiple IPs of the same host simultaneously reverse_lookup_only: Whether to scan only hosts that have names reverse_lookup_unify: Whether to scan only one IP when multiple IPs have the same name. port_range: Port range for the target port_list_id: UUID of the port list to use on target Returns: The response. See :py:meth:`send_command` for details. """ if not name: raise RequiredArgument( function=self.create_target.__name__, argument='name' ) cmd = XmlCommand("create_target") cmd.add_element("name", name) if asset_hosts_filter: cmd.add_element( "asset_hosts", attrs={"filter": str(asset_hosts_filter)} ) elif hosts: cmd.add_element("hosts", to_comma_list(hosts)) else: raise RequiredArgument( function=self.create_target.__name__, argument='hosts or asset_hosts_filter', ) if comment: cmd.add_element("comment", comment) if exclude_hosts: cmd.add_element("exclude_hosts", to_comma_list(exclude_hosts)) if ssh_credential_id: _xmlssh = cmd.add_element( "ssh_credential", attrs={"id": ssh_credential_id} ) if ssh_credential_port: _xmlssh.add_element("port", str(ssh_credential_port)) if smb_credential_id: cmd.add_element("smb_credential", attrs={"id": smb_credential_id}) if esxi_credential_id: cmd.add_element("esxi_credential", attrs={"id": esxi_credential_id}) if snmp_credential_id: cmd.add_element("snmp_credential", attrs={"id": snmp_credential_id}) if alive_test: if not isinstance(alive_test, AliveTest): raise InvalidArgumentType( function=self.create_target.__name__, argument='alive_test', arg_type=AliveTest.__name__, ) cmd.add_element("alive_tests", alive_test.value) if allow_simultaneous_ips is not None: cmd.add_element( "allow_simultaneous_ips", to_bool(allow_simultaneous_ips) ) if reverse_lookup_only is not None: cmd.add_element("reverse_lookup_only", to_bool(reverse_lookup_only)) if reverse_lookup_unify is not None: cmd.add_element( "reverse_lookup_unify", to_bool(reverse_lookup_unify) ) if port_range: cmd.add_element("port_range", port_range) if port_list_id: cmd.add_element("port_list", attrs={"id": port_list_id}) return self._send_xml_command(cmd) def modify_target( self, target_id: str, *, name: Optional[str] = None, comment: Optional[str] = None, hosts: Optional[List[str]] = None, exclude_hosts: Optional[List[str]] = None, ssh_credential_id: Optional[str] = None, ssh_credential_port: Optional[bool] = None, smb_credential_id: Optional[str] = None, esxi_credential_id: Optional[str] = None, snmp_credential_id: Optional[str] = None, alive_test: Optional[AliveTest] = None, allow_simultaneous_ips: Optional[bool] = None, reverse_lookup_only: Optional[bool] = None, reverse_lookup_unify: Optional[bool] = None, port_list_id: Optional[str] = None, ) -> Any: """Modifies an existing target. Arguments: target_id: ID of target to modify. comment: Comment on target. name: Name of target. hosts: List of target hosts. exclude_hosts: A list of hosts to exclude. ssh_credential_id: UUID of SSH credential to use on target. ssh_credential_port: The port to use for ssh credential smb_credential_id: UUID of SMB credential to use on target. esxi_credential_id: UUID of ESXi credential to use on target. snmp_credential_id: UUID of SNMP credential to use on target. port_list_id: UUID of port list describing ports to scan. alive_test: Which alive tests to use. allow_simultaneous_ips: Whether to scan multiple IPs of the same host simultaneously reverse_lookup_only: Whether to scan only hosts that have names. reverse_lookup_unify: Whether to scan only one IP when multiple IPs have the same name. Returns: The response. See :py:meth:`send_command` for details. """ if not target_id: raise RequiredArgument( function=self.modify_target.__name__, argument='target_id' ) cmd = XmlCommand("modify_target") cmd.set_attribute("target_id", target_id) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) if hosts: cmd.add_element("hosts", to_comma_list(hosts)) if exclude_hosts is None: exclude_hosts = [''] if exclude_hosts: cmd.add_element("exclude_hosts", to_comma_list(exclude_hosts)) if alive_test: if not isinstance(alive_test, AliveTest): raise InvalidArgumentType( function=self.modify_target.__name__, argument='alive_test', arg_type=AliveTest.__name__, ) cmd.add_element("alive_tests", alive_test.value) if ssh_credential_id: _xmlssh = cmd.add_element( "ssh_credential", attrs={"id": ssh_credential_id} ) if ssh_credential_port: _xmlssh.add_element("port", str(ssh_credential_port)) if smb_credential_id: cmd.add_element("smb_credential", attrs={"id": smb_credential_id}) if esxi_credential_id: cmd.add_element("esxi_credential", attrs={"id": esxi_credential_id}) if snmp_credential_id: cmd.add_element("snmp_credential", attrs={"id": snmp_credential_id}) if allow_simultaneous_ips is not None: cmd.add_element( "allow_simultaneous_ips", to_bool(allow_simultaneous_ips) ) if reverse_lookup_only is not None: cmd.add_element("reverse_lookup_only", to_bool(reverse_lookup_only)) if reverse_lookup_unify is not None: cmd.add_element( "reverse_lookup_unify", to_bool(reverse_lookup_unify) ) if port_list_id: cmd.add_element("port_list", attrs={"id": port_list_id}) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv214/entities/users.py000066400000000000000000000107531413122500400233350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # pylint: disable=arguments-differ, arguments-renamed from typing import Any, List, Optional from gvm.errors import RequiredArgument from gvm.protocols.gmpv208.entities.users import ( UsersMixin as Gmp208UsersMixin, UserAuthType, ) from gvm.utils import to_comma_list, to_bool from gvm.xml import XmlCommand class UsersMixin(Gmp208UsersMixin): def modify_user( self, user_id: str = None, *, name: Optional[str] = None, comment: Optional[str] = None, password: Optional[str] = None, auth_source: Optional[UserAuthType] = None, role_ids: Optional[List[str]] = None, hosts: Optional[List[str]] = None, hosts_allow: Optional[bool] = False, ifaces: Optional[List[str]] = None, ifaces_allow: Optional[bool] = False, group_ids: Optional[List[str]] = None, ) -> Any: """Modifies an existing user. Most of the fields need to be supplied for changing a single field even if no change is wanted for those. Else empty values are inserted for the missing fields instead. Arguments: user_id: UUID of the user to be modified. name: The new name for the user. comment: Comment on the user. password: The password for the user. auth_source: Source allowed for authentication for this user. roles_id: List of roles UUIDs for the user. hosts: User access rules: List of hosts. hosts_allow: Defines how the hosts list is to be interpreted. If False (default) the list is treated as a deny list. All hosts are allowed by default except those provided by the hosts parameter. If True the list is treated as a allow list. All hosts are denied by default except those provided by the hosts parameter. ifaces: User access rules: List of ifaces. ifaces_allow: Defines how the ifaces list is to be interpreted. If False (default) the list is treated as a deny list. All ifaces are allowed by default except those provided by the ifaces parameter. If True the list is treated as a allow list. All ifaces are denied by default except those provided by the ifaces parameter. group_ids: List of group UUIDs for the user. Returns: The response. See :py:meth:`send_command` for details. """ if not user_id: raise RequiredArgument( function=self.modify_user.__name__, argument='user_id' ) cmd = XmlCommand("modify_user") cmd.set_attribute("user_id", user_id) if name: cmd.add_element("new_name", name) if role_ids: for role in role_ids: cmd.add_element("role", attrs={"id": role}) if hosts: cmd.add_element( "hosts", to_comma_list(hosts), attrs={"allow": to_bool(hosts_allow)}, ) if ifaces: cmd.add_element( "ifaces", to_comma_list(ifaces), attrs={"allow": to_bool(ifaces_allow)}, ) if comment: cmd.add_element("comment", comment) if password: cmd.add_element("password", password) if auth_source: _xmlauthsrc = cmd.add_element("sources") _xmlauthsrc.add_element("source", auth_source.value) if group_ids: _xmlgroups = cmd.add_element("groups") for group_id in group_ids: _xmlgroups.add_element("group", attrs={"id": group_id}) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/protocols/gmpv214/system/000077500000000000000000000000001413122500400213145ustar00rootroot00000000000000python-gvm-21.10.0/gvm/protocols/gmpv214/system/__init__.py000066400000000000000000000013571413122500400234330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/gvm/protocols/gmpv214/system/version.py000066400000000000000000000023021413122500400233500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.protocols.gmpv208.system.version import ( VersionMixin as Gmp208VersionMixin, ) PROTOCOL_VERSION = (21, 4) class VersionMixin(Gmp208VersionMixin): @staticmethod def get_protocol_version() -> tuple: """Determine the Greenbone Management Protocol (gmp) version used by python-gvm version. Returns: tuple: Implemented version of the Greenbone Management Protocol """ return PROTOCOL_VERSION python-gvm-21.10.0/gvm/protocols/latest.py000066400000000000000000000044351413122500400204440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Latest supported stable protocols. This module exposes the latest supported protocols for the newest stable release branch of GVM. The provided Gmp class implements the latest `Greenbone Management Protocol`_. The provided Osp class implements the latest Open Scanner Protocol. For details about the possible supported protocol versions please take a look at :py:mod:`gvm.protocols`. Exports: - :py:class:`gvm.protocols.gmpv208.Gmp` - :py:class:`gvm.protocols.ospv1.Osp` .. _Greenbone Management Protocol: https://docs.greenbone.net/API/GMP/gmp.html """ from .gmpv208 import ( Gmp, AggregateStatistic, AlertCondition, AlertEvent, AlertMethod, AliveTest, CredentialFormat, CredentialType, EntityType, FeedType, FilterType, HelpFormat, HostsOrdering, InfoType, PermissionSubjectType, PortRangeType, ReportFormatType, ScannerType, SeverityLevel, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, SortOrder, TicketStatus, UserAuthType, ) from .ospv1 import Osp __all__ = [ "Gmp", "Osp", "AggregateStatistic", "AlertCondition", "AlertEvent", "AlertMethod", "AliveTest", "CredentialType", "CredentialFormat", "EntityType", "FeedType", "FilterType", "HelpFormat", "HostsOrdering", "InfoType", "PermissionSubjectType", "PortRangeType", "ReportFormatType", "ScannerType", "SeverityLevel", "SnmpAuthAlgorithm", "SnmpPrivacyAlgorithm", "SortOrder", "TicketStatus", "UserAuthType", ] python-gvm-21.10.0/gvm/protocols/next.py000066400000000000000000000044701413122500400201250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Latest supported protocols, including unstable ones. This module exposes the latest supported protocols of GVM including versions not yet released as stable. The provided Gmp class implements the latest `Greenbone Management Protocol`_. The provided Osp class implements the latest Open Scanner Protocol. For details about the possible supported protocol versions please take a look at :py:mod:`gvm.protocols`. Exports: - :py:class:`gvm.protocols.gmpv214.Gmp` - :py:class:`gvm.protocols.ospv1.Osp` .. _Greenbone Management Protocol: https://docs.greenbone.net/API/GMP/gmp.html """ from .gmpv214 import ( Gmp, AggregateStatistic, AlertCondition, AlertEvent, AlertMethod, AliveTest, CredentialFormat, CredentialType, EntityType, FeedType, FilterType, HelpFormat, HostsOrdering, InfoType, PermissionSubjectType, PortRangeType, ReportFormatType, ScannerType, SeverityLevel, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, SortOrder, TicketStatus, UserAuthType, ) from .ospv1 import Osp __all__ = [ "Gmp", "Osp", "AggregateStatistic", "AlertCondition", "AlertEvent", "AlertMethod", "AliveTest", "CredentialType", "CredentialFormat", "EntityType", "FeedType", "FilterType", "HelpFormat", "HostsOrdering", "InfoType", "PermissionSubjectType", "PortRangeType", "ReportFormatType", "ScannerType", "SeverityLevel", "SnmpAuthAlgorithm", "SnmpPrivacyAlgorithm", "SortOrder", "TicketStatus", "UserAuthType", ] python-gvm-21.10.0/gvm/protocols/ospv1.py000066400000000000000000000227151413122500400202210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Module for communication to a daemon speaking `Open Scanner Protocol version 1`_ .. _Open Scanner Protocol version 1: https://docs.greenbone.net/API/OSP/osp-20.08.html """ import logging from gvm.errors import RequiredArgument, InvalidArgument from gvm.xml import XmlCommand from .base import GvmProtocol logger = logging.getLogger(__name__) PROTOCOL_VERSION = (1, 2) def create_credentials_element(_xmlcredentials, credentials): """Generates an xml element with credentials.""" for service, credential in credentials.items(): cred_type = credential.get("type") serv_port = credential.get("port") username = credential.get("username") password = credential.get("password") _xmlcredential = _xmlcredentials.add_element("credential") _xmlcredential.set_attribute("type", cred_type) _xmlcredential.set_attribute("port", serv_port) _xmlcredential.set_attribute("service", service) _xmlcredential.add_element("username", username) _xmlcredential.add_element("password", password) return _xmlcredentials def create_vt_selection_element(_xmlvtselection, vt_selection): """Generates an xml element with a selection of Vulnerability tests.""" for vt_id, vt_values in vt_selection.items(): if vt_id != "vt_groups" and isinstance(vt_values, dict): _xmlvt = _xmlvtselection.add_element( "vt_single", attrs={"id": vt_id} ) if vt_values: for key, value in vt_values.items(): _xmlvt.add_element("vt_value", value, attrs={"id": key}) elif vt_id == "vt_groups" and isinstance(vt_values, list): for group in vt_values: _xmlvt = _xmlvtselection.add_element( "vt_group", attrs={"filter": group} ) else: raise InvalidArgument( f"It was not possible to add {vt_id} to the VTs selection." ) return _xmlvtselection class Osp(GvmProtocol): @staticmethod def get_protocol_version(): """Determine the Open Scanner Protocol version. Returns: tuple: Implemented version of the Open Scanner Protocol """ return PROTOCOL_VERSION def _read(self): # OSP is stateless. Therefore the connection is closed after each # response and we must reset the connection data = super()._read() self.disconnect() return data def get_version(self): """Get the version of the OSPD server which is connected to.""" cmd = XmlCommand("get_version") return self._send_xml_command(cmd) def help(self): """Get the help text.""" cmd = XmlCommand("help") return self._send_xml_command(cmd) def get_scans(self, scan_id=None, details=True, pop_results=False): """Get the stored scans. Arguments: scan_id (str, optional): UUID identifier for a scan. details (boolean, optional): Whether to get full scan reports. Default: True pop_results (boolean, optional) Whether to remove the fetched results. Default: False Returns: str: Response from server. """ cmd = XmlCommand("get_scans") if scan_id: cmd.set_attribute("scan_id", scan_id) if details: cmd.set_attribute("details", "1") else: cmd.set_attribute("details", "0") if pop_results: cmd.set_attribute("pop_results", "1") else: cmd.set_attribute("pop_results", "0") return self._send_xml_command(cmd) def delete_scan(self, scan_id=None): """Delete a finished scan. Arguments: scan_id (str): UUID identifier for a finished scan. Returns: str: Response from server. """ if not scan_id: raise ValueError("delete_scan requires a scan_id element") cmd = XmlCommand("delete_scan") cmd.set_attribute("scan_id", scan_id) return self._send_xml_command(cmd) def get_scanner_details(self): """Return scanner description and parameters.""" cmd = XmlCommand("get_scanner_details") return self._send_xml_command(cmd) def get_vts(self, vt_id=None): """Return information about vulnerability tests, if offered by scanner. Arguments: vt_id (str, optional): UUID identifier for a vulnerability test. Returns: str: Response from server. """ cmd = XmlCommand("get_vts") if vt_id: cmd.set_attribute("vt_id", vt_id) return self._send_xml_command(cmd) def start_scan( self, scan_id=None, parallel=1, target=None, ports=None, targets=None, scanner_params=None, vt_selection=None, ): """Start a new scan. Arguments: scan_id (str, optional): UUID identifier for a running scan. parallel (int, optional): Number of parallel scanned targets. Default 1. target (dict, optional): Deprecated. Please use targets instead. targets (list, optional): List of dictionaries. See example. ports (str, optional): Deprecated. Ports to use for target parameter. scanner_params: (dict, optional): Dictionary of scanner parameters. vt_selection: (dict, optional): Vulnerability tests to select. See example. Returns: str: Response from server. Examples: Scanner Parameters:: scanner_parameters = { 'scan_param1': 'scan_param1_value', 'scan_param2': 'scan_param2_value', } Targets:: targets = [{ 'hosts': 'localhost', 'ports': '80,43' }, { 'hosts': '192.168.0.0/24', 'ports': '22', }, { 'credentials': { 'smb': { 'password': 'pass', 'port': 'port', 'type': 'type', 'username': 'username', } } }] VT Selection:: vt_selection = { 'vt1': {}, 'vt2': {'value_id': 'value'}, 'vt_groups': ['family=debian', 'family=general'] } """ cmd = XmlCommand("start_scan") if scan_id: cmd.set_attribute("scan_id", scan_id) cmd.set_attribute("parallel", str(parallel)) # Add even if it is empty, since it is mandatory _xmlscanparams = cmd.add_element("scanner_params") if scanner_params: _xmlscanparams.set_attributes(scanner_params) if targets: _xmltargets = cmd.add_element("targets") for target in targets: _xmltarget = _xmltargets.add_element("target") hosts = target.get("hosts") ports = target.get("ports") credentials = target.get("credentials") _xmltarget.add_element("hosts", hosts) _xmltarget.add_element("ports", ports) if credentials: _xmlcredentials = _xmltarget.add_element("credentials") _xmlcredentials = create_credentials_element( _xmlcredentials, credentials ) # Check target as attribute for legacy mode compatibility. Deprecated. elif target: cmd.set_attribute("target", target) if ports: cmd.set_attribute("ports", ports) else: raise RequiredArgument( function=self.start_scan.__name__, argument='targets' ) if vt_selection: _xmlvtselection = cmd.add_element("vt_selection") _xmlvtselection = create_vt_selection_element( _xmlvtselection, vt_selection ) return self._send_xml_command(cmd) def stop_scan(self, scan_id): """Stop a currently running scan. Args: scan_id (str): UUID identifier for a running scan. Returns: str: Response from server. """ if not scan_id: raise RequiredArgument( function=self.stop_scan.__name__, argument='scan_id' ) cmd = XmlCommand("stop_scan") cmd.set_attribute("scan_id", scan_id) return self._send_xml_command(cmd) python-gvm-21.10.0/gvm/transforms.py000066400000000000000000000046141413122500400173210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Module for transforming responses """ from lxml import etree from .errors import GvmError, GvmServerError, GvmResponseError from .xml import create_parser class EtreeTransform: """ Transform a response into a lxml.etree root element """ def __init__(self): self._parser = create_parser() def _convert_response(self, response: str) -> etree.Element: return etree.XML(response, parser=self._parser) def __call__(self, response: str) -> etree.Element: return self._convert_response(response) def check_command_status(root: etree.Element): status = root.get("status") if status is None: raise GvmServerError("No status in response.", root) if status[0] == "4": raise GvmResponseError(status=status, message=root.get("status_text")) elif status[0] == "5": raise GvmServerError(status=status, message=root.get("status_text")) elif status[0] != "2": raise GvmError(f"Error in response. {root.get('status_text')}", root) class CheckCommandTransform(EtreeTransform): """ Check the response code of a response and raise GmpError if response was an error response """ def __call__(self, response: str) -> str: root = self._convert_response(response) check_command_status(root) return response class EtreeCheckCommandTransform(EtreeTransform): """ Transform a response into a lxml.etree root element and raise GmpError if response was an error response """ def __call__(self, response: str) -> etree.Element: root = self._convert_response(response) check_command_status(root) return root python-gvm-21.10.0/gvm/utils.py000066400000000000000000000043671413122500400162700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # pylint: disable=arguments-differ, redefined-builtin import base64 import warnings import logging from typing import Any, List from lxml import etree from gvm.xml import create_parser logger = logging.getLogger(__name__) def deprecation(message: str): warnings.warn(message, DeprecationWarning, stacklevel=2) def check_command_status(xml: str) -> bool: """Check gmp response Look into the gmp response and check for the status in the root element Arguments: xml: XML-Source Returns: True if valid, otherwise False """ if xml == 0 or xml is None: logger.error("XML Command is empty.") return False try: root = etree.XML(xml, parser=create_parser()) status = root.attrib["status"] return status is not None and status[0] == "2" except KeyError: print(logger) logger.error("Not received an status code within the response.") except etree.Error as e: logger.error("etree.XML(xml): %s", e) return False def to_bool(value: bool) -> str: return "1" if value else "0" def to_base64(value: str) -> bytes: return base64.b64encode(value.encode("utf-8")) def to_comma_list(value: List) -> str: return ",".join(value) def add_filter(cmd, filter_string, filter_id): if filter_string: cmd.set_attribute("filter", filter_string) if filter_id: cmd.set_attribute("filt_id", filter_id) def is_list_like(value: Any) -> bool: return isinstance(value, (list, tuple)) python-gvm-21.10.0/gvm/xml.py000066400000000000000000000106371413122500400157250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import sys from typing import List, Optional, Union from io import IOBase import defusedxml.lxml as secET from defusedxml import DefusedXmlException from lxml.etree import ( SubElement, XMLParser, Element, tostring as xmltostring, iselement as isxmlelement, LxmlError, ) from gvm.errors import GvmError, InvalidArgumentType def create_parser(): # huge_tree => disable security restrictions and support very deep trees and # very long text content (for get_reports) return XMLParser(encoding="utf-8", huge_tree=True) class XmlCommandElement: def __init__(self, element): self._element = element def add_element( self, name: str, text: Optional[str] = None, *, attrs: Optional[dict] = None, ): node = SubElement(self._element, name, attrib=attrs) node.text = text return XmlCommandElement(node) def set_attribute(self, name: str, value: str): self._element.set(name, value) def set_attributes(self, attrs: dict): """Set several attributes at once. Arguments: attrs (dict): Attributes to be set on the element """ for key, value in attrs.items(): self._element.set(key, value) def append_xml_str(self, xml_text: str): """Append a xml element in string format.""" node = secET.fromstring(xml_text) self._element.append(node) def to_string(self) -> str: return xmltostring(self._element).decode("utf-8") def __str__(self): return self.to_string() class XmlCommand(XmlCommandElement): def __init__(self, name): super().__init__(Element(name)) def pretty_print( xml: Union[str, List[Union[Element, str]], Element], file: IOBase = sys.stdout, ): """Prints beautiful XML-Code This function gets a string containing the xml, an object of List[lxml.etree.Element] or directly a lxml element. Print it with good readable format. Arguments: xml (str, List[lxml.etree.Element] or lxml.etree.Element): xml as string, List[lxml.etree.Element] or directly a lxml element. file: A IOBase type. Can be a File, StringIO, ... """ if not isinstance(file, IOBase): raise TypeError( f'Type needs to be from IOBase, not {type(file)}.' ) from None if isinstance(xml, list): for item in xml: if isxmlelement(item): file.write( xmltostring(item, pretty_print=True).decode( sys.getdefaultencoding() + '\n' ) ) else: file.write(item + '\n') elif isxmlelement(xml): file.write( xmltostring(xml, pretty_print=True).decode( sys.getdefaultencoding() + '\n' ) ) elif isinstance(xml, str): tree = secET.fromstring(xml) file.write( xmltostring(tree, pretty_print=True).decode( sys.getdefaultencoding() + '\n' ) ) else: raise InvalidArgumentType( function=pretty_print.__name__, argument='xml', arg_type='' ) def validate_xml_string(xml_string: str): """Checks if the passed string contains valid XML Raises a GvmError if the XML is invalid. Otherwise the function just returns. Arguments: xml_string: XML string to validate Raises: GvmError: The xml string did contain invalid XML """ try: secET.fromstring(xml_string) except (DefusedXmlException, LxmlError) as e: raise GvmError("Invalid XML", e) from e python-gvm-21.10.0/poetry.lock000066400000000000000000002360021413122500400161520ustar00rootroot00000000000000[[package]] name = "alabaster" version = "0.7.12" description = "A configurable sidebar-enabled Sphinx theme" category = "dev" optional = false python-versions = "*" [[package]] name = "appdirs" version = "1.4.4" description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "dev" optional = false python-versions = "*" [[package]] name = "astroid" version = "2.8.2" description = "An abstract syntax tree for Python with inference support." category = "dev" optional = false python-versions = "~=3.6" [package.dependencies] lazy-object-proxy = ">=1.4.0" typed-ast = {version = ">=1.4.0,<1.5", markers = "implementation_name == \"cpython\" and python_version < \"3.8\""} typing-extensions = {version = ">=3.10", markers = "python_version < \"3.10\""} wrapt = ">=1.11,<1.13" [[package]] name = "autohooks" version = "21.7.0" description = "Library for managing git hooks" category = "dev" optional = false python-versions = ">=3.7,<4.0" [package.dependencies] colorful = ">=0.5.4,<0.6.0" packaging = ">=20.3,<21.0" tomlkit = ">=0.5.11" [[package]] name = "autohooks-plugin-black" version = "21.7.1" description = "An autohooks plugin for python code formatting via black" category = "dev" optional = false python-versions = ">=3.6.2,<4.0" [package.dependencies] autohooks = ">=2.2.0" black = {version = ">=20.8b1,<=21.7b0", markers = "python_version >= \"3.6\" and python_version < \"4.0\""} [[package]] name = "autohooks-plugin-pylint" version = "21.6.0" description = "An autohooks plugin for python code linting via pylint" category = "dev" optional = false python-versions = ">=3.7,<4.0" [package.dependencies] autohooks = ">=2.2.0" pylint = ">=2.8.3,<3.0.0" [[package]] name = "babel" version = "2.9.1" description = "Internationalization utilities" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.dependencies] pytz = ">=2015.7" [[package]] name = "bcrypt" version = "3.2.0" description = "Modern password hashing for your software and your servers" category = "main" optional = false python-versions = ">=3.6" [package.dependencies] cffi = ">=1.1" six = ">=1.4.1" [package.extras] tests = ["pytest (>=3.2.1,!=3.3.0)"] typecheck = ["mypy"] [[package]] name = "black" version = "21.7b0" description = "The uncompromising code formatter." category = "dev" optional = false python-versions = ">=3.6.2" [package.dependencies] appdirs = "*" click = ">=7.1.2" mypy-extensions = ">=0.4.3" pathspec = ">=0.8.1,<1" regex = ">=2020.1.8" tomli = ">=0.2.6,<2.0.0" typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\""} typing-extensions = {version = ">=3.7.4", markers = "python_version < \"3.8\""} [package.extras] colorama = ["colorama (>=0.4.3)"] d = ["aiohttp (>=3.6.0)", "aiohttp-cors (>=0.4.0)"] python2 = ["typed-ast (>=1.4.2)"] uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "certifi" version = "2021.10.8" description = "Python package for providing Mozilla's CA Bundle." category = "dev" optional = false python-versions = "*" [[package]] name = "cffi" version = "1.14.6" description = "Foreign Function Interface for Python calling C code." category = "main" optional = false python-versions = "*" [package.dependencies] pycparser = "*" [[package]] name = "charset-normalizer" version = "2.0.6" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." category = "dev" optional = false python-versions = ">=3.5.0" [package.extras] unicode_backport = ["unicodedata2"] [[package]] name = "click" version = "8.0.3" description = "Composable command line interface toolkit" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "colorama" version = "0.4.4" description = "Cross-platform colored terminal text." category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "colorful" version = "0.5.4" description = "Terminal string styling done right, in Python." category = "dev" optional = false python-versions = "*" [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} [[package]] name = "coverage" version = "6.0.1" description = "Code coverage measurement for Python" category = "dev" optional = false python-versions = ">=3.6" [package.extras] toml = ["tomli"] [[package]] name = "cryptography" version = "35.0.0" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." category = "main" optional = false python-versions = ">=3.6" [package.dependencies] cffi = ">=1.12" [package.extras] docs = ["sphinx (>=1.6.5,!=1.8.0,!=3.1.0,!=3.1.1)", "sphinx-rtd-theme"] docstest = ["doc8", "pyenchant (>=1.6.11)", "twine (>=1.12.0)", "sphinxcontrib-spelling (>=4.0.1)"] pep8test = ["black", "flake8", "flake8-import-order", "pep8-naming"] sdist = ["setuptools_rust (>=0.11.4)"] ssh = ["bcrypt (>=3.1.5)"] test = ["pytest (>=6.2.0)", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"] [[package]] name = "defusedxml" version = "0.7.1" description = "XML bomb protection for Python stdlib modules" category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "docutils" version = "0.17.1" description = "Docutils -- Python Documentation Utilities" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "idna" version = "3.2" description = "Internationalized Domain Names in Applications (IDNA)" category = "dev" optional = false python-versions = ">=3.5" [[package]] name = "imagesize" version = "1.2.0" description = "Getting image size from png/jpeg/jpeg2000/gif file" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "importlib-metadata" version = "4.8.1" description = "Read metadata from Python packages" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] perf = ["ipython"] testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] [[package]] name = "isort" version = "5.9.3" description = "A Python utility / library to sort Python imports." category = "dev" optional = false python-versions = ">=3.6.1,<4.0" [package.extras] pipfile_deprecated_finder = ["pipreqs", "requirementslib"] requirements_deprecated_finder = ["pipreqs", "pip-api"] colors = ["colorama (>=0.4.3,<0.5.0)"] plugins = ["setuptools"] [[package]] name = "jinja2" version = "3.0.2" description = "A very fast and expressive template engine." category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] MarkupSafe = ">=2.0" [package.extras] i18n = ["Babel (>=2.7)"] [[package]] name = "lazy-object-proxy" version = "1.6.0" description = "A fast and thorough lazy object proxy." category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" [[package]] name = "lxml" version = "4.6.3" description = "Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API." category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, != 3.4.*" [package.extras] cssselect = ["cssselect (>=0.7)"] html5 = ["html5lib"] htmlsoup = ["beautifulsoup4"] source = ["Cython (>=0.29.7)"] [[package]] name = "markupsafe" version = "2.0.1" description = "Safely add untrusted strings to HTML/XML markup." category = "dev" optional = false python-versions = ">=3.6" [[package]] name = "mccabe" version = "0.6.1" description = "McCabe checker, plugin for flake8" category = "dev" optional = false python-versions = "*" [[package]] name = "mypy-extensions" version = "0.4.3" description = "Experimental type system extensions for programs checked with the mypy typechecker." category = "dev" optional = false python-versions = "*" [[package]] name = "packaging" version = "20.9" description = "Core utilities for Python packages" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.dependencies] pyparsing = ">=2.0.2" [[package]] name = "paramiko" version = "2.8.0" description = "SSH2 protocol library" category = "main" optional = false python-versions = "*" [package.dependencies] bcrypt = ">=3.1.3" cryptography = ">=2.5" pynacl = ">=1.0.1" [package.extras] all = ["pyasn1 (>=0.1.7)", "pynacl (>=1.0.1)", "bcrypt (>=3.1.3)", "invoke (>=1.3)", "gssapi (>=1.4.1)", "pywin32 (>=2.1.8)"] ed25519 = ["pynacl (>=1.0.1)", "bcrypt (>=3.1.3)"] gssapi = ["pyasn1 (>=0.1.7)", "gssapi (>=1.4.1)", "pywin32 (>=2.1.8)"] invoke = ["invoke (>=1.3)"] [[package]] name = "pathspec" version = "0.9.0" description = "Utility library for gitignore style pattern matching of file paths." category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [[package]] name = "platformdirs" version = "2.4.0" description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "dev" optional = false python-versions = ">=3.6" [package.extras] docs = ["Sphinx (>=4)", "furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)"] test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"] [[package]] name = "pontos" version = "21.10.2" description = "Common utilities and tools maintained by Greenbone Networks" category = "dev" optional = false python-versions = ">=3.7,<4.0" [package.dependencies] colorful = ">=0.5.4,<0.6.0" packaging = ">=20.3,<21.0" requests = ">=2.24.0,<3.0.0" tomlkit = ">=0.5.11" [[package]] name = "pycparser" version = "2.20" description = "C parser in Python" category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "pygments" version = "2.10.0" description = "Pygments is a syntax highlighting package written in Python." category = "dev" optional = false python-versions = ">=3.5" [[package]] name = "pylint" version = "2.11.1" description = "python code static checker" category = "dev" optional = false python-versions = "~=3.6" [package.dependencies] astroid = ">=2.8.0,<2.9" colorama = {version = "*", markers = "sys_platform == \"win32\""} isort = ">=4.2.5,<6" mccabe = ">=0.6,<0.7" platformdirs = ">=2.2.0" toml = ">=0.7.1" typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""} [[package]] name = "pynacl" version = "1.4.0" description = "Python binding to the Networking and Cryptography (NaCl) library" category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.dependencies] cffi = ">=1.4.1" six = "*" [package.extras] docs = ["sphinx (>=1.6.5)", "sphinx-rtd-theme"] tests = ["pytest (>=3.2.1,!=3.3.0)", "hypothesis (>=3.27.0)"] [[package]] name = "pyparsing" version = "2.4.7" description = "Python parsing module" category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "pytz" version = "2021.3" description = "World timezone definitions, modern and historical" category = "dev" optional = false python-versions = "*" [[package]] name = "regex" version = "2021.10.8" description = "Alternative regular expression module, to replace re." category = "dev" optional = false python-versions = "*" [[package]] name = "requests" version = "2.26.0" description = "Python HTTP for Humans." category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" [package.dependencies] certifi = ">=2017.4.17" charset-normalizer = {version = ">=2.0.0,<2.1.0", markers = "python_version >= \"3\""} idna = {version = ">=2.5,<4", markers = "python_version >= \"3\""} urllib3 = ">=1.21.1,<1.27" [package.extras] socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"] [[package]] name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "snowballstemmer" version = "2.1.0" description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." category = "dev" optional = false python-versions = "*" [[package]] name = "sphinx" version = "4.2.0" description = "Python documentation generator" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] alabaster = ">=0.7,<0.8" babel = ">=1.3" colorama = {version = ">=0.3.5", markers = "sys_platform == \"win32\""} docutils = ">=0.14,<0.18" imagesize = "*" Jinja2 = ">=2.3" packaging = "*" Pygments = ">=2.0" requests = ">=2.5.0" snowballstemmer = ">=1.1" sphinxcontrib-applehelp = "*" sphinxcontrib-devhelp = "*" sphinxcontrib-htmlhelp = ">=2.0.0" sphinxcontrib-jsmath = "*" sphinxcontrib-qthelp = "*" sphinxcontrib-serializinghtml = ">=1.1.5" [package.extras] docs = ["sphinxcontrib-websupport"] lint = ["flake8 (>=3.5.0)", "isort", "mypy (>=0.900)", "docutils-stubs", "types-typed-ast", "types-pkg-resources", "types-requests"] test = ["pytest", "pytest-cov", "html5lib", "cython", "typed-ast"] [[package]] name = "sphinx-autodoc-typehints" version = "1.12.0" description = "Type hints (PEP 484) support for the Sphinx autodoc extension" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] Sphinx = ">=3.0" [package.extras] test = ["pytest (>=3.1.0)", "typing-extensions (>=3.5)", "sphobjinv (>=2.0)", "Sphinx (>=3.2.0)", "dataclasses"] type_comments = ["typed-ast (>=1.4.0)"] [[package]] name = "sphinxcontrib-applehelp" version = "1.0.2" description = "sphinxcontrib-applehelp is a sphinx extension which outputs Apple help books" category = "dev" optional = false python-versions = ">=3.5" [package.extras] lint = ["flake8", "mypy", "docutils-stubs"] test = ["pytest"] [[package]] name = "sphinxcontrib-devhelp" version = "1.0.2" description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp document." category = "dev" optional = false python-versions = ">=3.5" [package.extras] lint = ["flake8", "mypy", "docutils-stubs"] test = ["pytest"] [[package]] name = "sphinxcontrib-htmlhelp" version = "2.0.0" description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" category = "dev" optional = false python-versions = ">=3.6" [package.extras] lint = ["flake8", "mypy", "docutils-stubs"] test = ["pytest", "html5lib"] [[package]] name = "sphinxcontrib-jsmath" version = "1.0.1" description = "A sphinx extension which renders display math in HTML via JavaScript" category = "dev" optional = false python-versions = ">=3.5" [package.extras] test = ["pytest", "flake8", "mypy"] [[package]] name = "sphinxcontrib-qthelp" version = "1.0.3" description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp document." category = "dev" optional = false python-versions = ">=3.5" [package.extras] lint = ["flake8", "mypy", "docutils-stubs"] test = ["pytest"] [[package]] name = "sphinxcontrib-serializinghtml" version = "1.1.5" description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)." category = "dev" optional = false python-versions = ">=3.5" [package.extras] lint = ["flake8", "mypy", "docutils-stubs"] test = ["pytest"] [[package]] name = "toml" version = "0.10.2" description = "Python Library for Tom's Obvious, Minimal Language" category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "tomli" version = "1.2.1" description = "A lil' TOML parser" category = "dev" optional = false python-versions = ">=3.6" [[package]] name = "tomlkit" version = "0.7.2" description = "Style preserving TOML library" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "typed-ast" version = "1.4.3" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false python-versions = "*" [[package]] name = "typing-extensions" version = "3.10.0.2" description = "Backported and Experimental Type Hints for Python 3.5+" category = "dev" optional = false python-versions = "*" [[package]] name = "urllib3" version = "1.26.7" description = "HTTP library with thread-safe connection pooling, file post, and more." category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" [package.extras] brotli = ["brotlipy (>=0.6.0)"] secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] [[package]] name = "wrapt" version = "1.12.1" description = "Module for decorators, wrappers and monkey patching." category = "dev" optional = false python-versions = "*" [[package]] name = "zipp" version = "3.6.0" description = "Backport of pathlib-compatible object wrapper for zip files" category = "dev" optional = false python-versions = ">=3.6" [package.extras] docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] [metadata] lock-version = "1.1" python-versions = "^3.7.0" content-hash = "c4ca818edd86f4decb6ab4cff5b1029af7756c06764b82ca68e938abf2fb8406" [metadata.files] alabaster = [ {file = "alabaster-0.7.12-py2.py3-none-any.whl", hash = "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359"}, {file = "alabaster-0.7.12.tar.gz", hash = "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02"}, ] appdirs = [ {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, ] astroid = [ {file = "astroid-2.8.2-py3-none-any.whl", hash = "sha256:9eaeaf92b3e21b70bec1a262e7eb118d2e96294892a5de595c92a12adc80dfc2"}, {file = "astroid-2.8.2.tar.gz", hash = "sha256:304e99c129794f2cfda584a12b71fde85205da950e2f330f4be09150525ae949"}, ] autohooks = [ {file = "autohooks-21.7.0-py3-none-any.whl", hash = "sha256:54bda89bbd5b19d83538a110bca0088b38378a4c0e1cf14581792f3e41a5a260"}, {file = "autohooks-21.7.0.tar.gz", hash = "sha256:8d09ee52f67cedd5873578a9b4d97b6b80fd9db6dca6d1844621d02a197a12e2"}, ] autohooks-plugin-black = [ {file = "autohooks-plugin-black-21.7.1.tar.gz", hash = "sha256:e4df68d9bac84e33688fc4881243a874a3eac49fad8bcede36bd5167899d4f01"}, {file = "autohooks_plugin_black-21.7.1-py3-none-any.whl", hash = "sha256:74f615a753e365c6c5f259a884eb3e277f339e6b71a24d31158ce19a41cb28aa"}, ] autohooks-plugin-pylint = [ {file = "autohooks-plugin-pylint-21.6.0.tar.gz", hash = "sha256:6f1a486f19c8012618fecd9eaa985f5da3ef5c954b32d823323439547b947302"}, {file = "autohooks_plugin_pylint-21.6.0-py3-none-any.whl", hash = "sha256:0d6ab34739d4c494012aa1647c02e6a4fb9474e4050432ee82f378fcd05c70e4"}, ] babel = [ {file = "Babel-2.9.1-py2.py3-none-any.whl", hash = "sha256:ab49e12b91d937cd11f0b67cb259a57ab4ad2b59ac7a3b41d6c06c0ac5b0def9"}, {file = "Babel-2.9.1.tar.gz", hash = "sha256:bc0c176f9f6a994582230df350aa6e05ba2ebe4b3ac317eab29d9be5d2768da0"}, ] bcrypt = [ {file = "bcrypt-3.2.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:c95d4cbebffafcdd28bd28bb4e25b31c50f6da605c81ffd9ad8a3d1b2ab7b1b6"}, {file = "bcrypt-3.2.0-cp36-abi3-manylinux1_x86_64.whl", hash = "sha256:63d4e3ff96188e5898779b6057878fecf3f11cfe6ec3b313ea09955d587ec7a7"}, {file = "bcrypt-3.2.0-cp36-abi3-manylinux2010_x86_64.whl", hash = "sha256:cd1ea2ff3038509ea95f687256c46b79f5fc382ad0aa3664d200047546d511d1"}, {file = "bcrypt-3.2.0-cp36-abi3-manylinux2014_aarch64.whl", hash = "sha256:cdcdcb3972027f83fe24a48b1e90ea4b584d35f1cc279d76de6fc4b13376239d"}, {file = "bcrypt-3.2.0-cp36-abi3-win32.whl", hash = "sha256:a67fb841b35c28a59cebed05fbd3e80eea26e6d75851f0574a9273c80f3e9b55"}, {file = "bcrypt-3.2.0-cp36-abi3-win_amd64.whl", hash = "sha256:81fec756feff5b6818ea7ab031205e1d323d8943d237303baca2c5f9c7846f34"}, {file = "bcrypt-3.2.0.tar.gz", hash = "sha256:5b93c1726e50a93a033c36e5ca7fdcd29a5c7395af50a6892f5d9e7c6cfbfb29"}, ] black = [ {file = "black-21.7b0-py3-none-any.whl", hash = "sha256:1c7aa6ada8ee864db745b22790a32f94b2795c253a75d6d9b5e439ff10d23116"}, {file = "black-21.7b0.tar.gz", hash = "sha256:c8373c6491de9362e39271630b65b964607bc5c79c83783547d76c839b3aa219"}, ] certifi = [ {file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"}, {file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"}, ] cffi = [ {file = "cffi-1.14.6-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:22b9c3c320171c108e903d61a3723b51e37aaa8c81255b5e7ce102775bd01e2c"}, {file = "cffi-1.14.6-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:f0c5d1acbfca6ebdd6b1e3eded8d261affb6ddcf2186205518f1428b8569bb99"}, {file = "cffi-1.14.6-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:99f27fefe34c37ba9875f224a8f36e31d744d8083e00f520f133cab79ad5e819"}, {file = "cffi-1.14.6-cp27-cp27m-win32.whl", hash = "sha256:55af55e32ae468e9946f741a5d51f9896da6b9bf0bbdd326843fec05c730eb20"}, {file = "cffi-1.14.6-cp27-cp27m-win_amd64.whl", hash = "sha256:7bcac9a2b4fdbed2c16fa5681356d7121ecabf041f18d97ed5b8e0dd38a80224"}, {file = "cffi-1.14.6-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:ed38b924ce794e505647f7c331b22a693bee1538fdf46b0222c4717b42f744e7"}, {file = "cffi-1.14.6-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:e22dcb48709fc51a7b58a927391b23ab37eb3737a98ac4338e2448bef8559b33"}, {file = "cffi-1.14.6-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:aedb15f0a5a5949ecb129a82b72b19df97bbbca024081ed2ef88bd5c0a610534"}, {file = "cffi-1.14.6-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:48916e459c54c4a70e52745639f1db524542140433599e13911b2f329834276a"}, {file = "cffi-1.14.6-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:f627688813d0a4140153ff532537fbe4afea5a3dffce1f9deb7f91f848a832b5"}, {file = "cffi-1.14.6-cp35-cp35m-win32.whl", hash = "sha256:f0010c6f9d1a4011e429109fda55a225921e3206e7f62a0c22a35344bfd13cca"}, {file = "cffi-1.14.6-cp35-cp35m-win_amd64.whl", hash = "sha256:57e555a9feb4a8460415f1aac331a2dc833b1115284f7ded7278b54afc5bd218"}, {file = "cffi-1.14.6-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:e8c6a99be100371dbb046880e7a282152aa5d6127ae01783e37662ef73850d8f"}, {file = "cffi-1.14.6-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:19ca0dbdeda3b2615421d54bef8985f72af6e0c47082a8d26122adac81a95872"}, {file = "cffi-1.14.6-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:d950695ae4381ecd856bcaf2b1e866720e4ab9a1498cba61c602e56630ca7195"}, {file = "cffi-1.14.6-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9dc245e3ac69c92ee4c167fbdd7428ec1956d4e754223124991ef29eb57a09d"}, {file = "cffi-1.14.6-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a8661b2ce9694ca01c529bfa204dbb144b275a31685a075ce123f12331be790b"}, {file = "cffi-1.14.6-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b315d709717a99f4b27b59b021e6207c64620790ca3e0bde636a6c7f14618abb"}, {file = "cffi-1.14.6-cp36-cp36m-win32.whl", hash = "sha256:80b06212075346b5546b0417b9f2bf467fea3bfe7352f781ffc05a8ab24ba14a"}, {file = "cffi-1.14.6-cp36-cp36m-win_amd64.whl", hash = "sha256:a9da7010cec5a12193d1af9872a00888f396aba3dc79186604a09ea3ee7c029e"}, {file = "cffi-1.14.6-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:4373612d59c404baeb7cbd788a18b2b2a8331abcc84c3ba40051fcd18b17a4d5"}, {file = "cffi-1.14.6-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:f10afb1004f102c7868ebfe91c28f4a712227fe4cb24974350ace1f90e1febbf"}, {file = "cffi-1.14.6-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:fd4305f86f53dfd8cd3522269ed7fc34856a8ee3709a5e28b2836b2db9d4cd69"}, {file = "cffi-1.14.6-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d6169cb3c6c2ad50db5b868db6491a790300ade1ed5d1da29289d73bbe40b56"}, {file = "cffi-1.14.6-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5d4b68e216fc65e9fe4f524c177b54964af043dde734807586cf5435af84045c"}, {file = "cffi-1.14.6-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33791e8a2dc2953f28b8d8d300dde42dd929ac28f974c4b4c6272cb2955cb762"}, {file = "cffi-1.14.6-cp37-cp37m-win32.whl", hash = "sha256:0c0591bee64e438883b0c92a7bed78f6290d40bf02e54c5bf0978eaf36061771"}, {file = "cffi-1.14.6-cp37-cp37m-win_amd64.whl", hash = "sha256:8eb687582ed7cd8c4bdbff3df6c0da443eb89c3c72e6e5dcdd9c81729712791a"}, {file = "cffi-1.14.6-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:ba6f2b3f452e150945d58f4badd92310449876c4c954836cfb1803bdd7b422f0"}, {file = "cffi-1.14.6-cp38-cp38-manylinux1_i686.whl", hash = "sha256:64fda793737bc4037521d4899be780534b9aea552eb673b9833b01f945904c2e"}, {file = "cffi-1.14.6-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:9f3e33c28cd39d1b655ed1ba7247133b6f7fc16fa16887b120c0c670e35ce346"}, {file = "cffi-1.14.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26bb2549b72708c833f5abe62b756176022a7b9a7f689b571e74c8478ead51dc"}, {file = "cffi-1.14.6-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:eb687a11f0a7a1839719edd80f41e459cc5366857ecbed383ff376c4e3cc6afd"}, {file = "cffi-1.14.6-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d2ad4d668a5c0645d281dcd17aff2be3212bc109b33814bbb15c4939f44181cc"}, {file = "cffi-1.14.6-cp38-cp38-win32.whl", hash = "sha256:487d63e1454627c8e47dd230025780e91869cfba4c753a74fda196a1f6ad6548"}, {file = "cffi-1.14.6-cp38-cp38-win_amd64.whl", hash = "sha256:c33d18eb6e6bc36f09d793c0dc58b0211fccc6ae5149b808da4a62660678b156"}, {file = "cffi-1.14.6-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:06c54a68935738d206570b20da5ef2b6b6d92b38ef3ec45c5422c0ebaf338d4d"}, {file = "cffi-1.14.6-cp39-cp39-manylinux1_i686.whl", hash = "sha256:f174135f5609428cc6e1b9090f9268f5c8935fddb1b25ccb8255a2d50de6789e"}, {file = "cffi-1.14.6-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:f3ebe6e73c319340830a9b2825d32eb6d8475c1dac020b4f0aa774ee3b898d1c"}, {file = "cffi-1.14.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3c8d896becff2fa653dc4438b54a5a25a971d1f4110b32bd3068db3722c80202"}, {file = "cffi-1.14.6-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4922cd707b25e623b902c86188aca466d3620892db76c0bdd7b99a3d5e61d35f"}, {file = "cffi-1.14.6-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c9e005e9bd57bc987764c32a1bee4364c44fdc11a3cc20a40b93b444984f2b87"}, {file = "cffi-1.14.6-cp39-cp39-win32.whl", hash = "sha256:eb9e2a346c5238a30a746893f23a9535e700f8192a68c07c0258e7ece6ff3728"}, {file = "cffi-1.14.6-cp39-cp39-win_amd64.whl", hash = "sha256:818014c754cd3dba7229c0f5884396264d51ffb87ec86e927ef0be140bfdb0d2"}, {file = "cffi-1.14.6.tar.gz", hash = "sha256:c9a875ce9d7fe32887784274dd533c57909b7b1dcadcc128a2ac21331a9765dd"}, ] charset-normalizer = [ {file = "charset-normalizer-2.0.6.tar.gz", hash = "sha256:5ec46d183433dcbd0ab716f2d7f29d8dee50505b3fdb40c6b985c7c4f5a3591f"}, {file = "charset_normalizer-2.0.6-py3-none-any.whl", hash = "sha256:5d209c0a931f215cee683b6445e2d77677e7e75e159f78def0db09d68fafcaa6"}, ] click = [ {file = "click-8.0.3-py3-none-any.whl", hash = "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3"}, {file = "click-8.0.3.tar.gz", hash = "sha256:410e932b050f5eed773c4cda94de75971c89cdb3155a72a0831139a79e5ecb5b"}, ] colorama = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, ] colorful = [ {file = "colorful-0.5.4-py2.py3-none-any.whl", hash = "sha256:8d264b52a39aae4c0ba3e2a46afbaec81b0559a99be0d2cfe2aba4cf94531348"}, {file = "colorful-0.5.4.tar.gz", hash = "sha256:86848ad4e2eda60cd2519d8698945d22f6f6551e23e95f3f14dfbb60997807ea"}, ] coverage = [ {file = "coverage-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:abe8207dfb8a61ded9cd830d26c1073c8218fc0ae17eb899cfe8ec0fafae6e22"}, {file = "coverage-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:83faa3692e8306b20293889714fdf573d10ef5efc5843bd7c7aea6971487bd6a"}, {file = "coverage-6.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:f82a17f2a77958f3eef40ad385fc82d4c6ba9a77a51a174efe03ce75daebbc16"}, {file = "coverage-6.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:5b06f4f1729e2963281d9cd6e65e6976bf27b44d4c07ac5b47223ce45f822cec"}, {file = "coverage-6.0.1-cp310-cp310-win32.whl", hash = "sha256:7600fac458f74c68b097379f76f3a6e3a630493fc7fc94b6508fedd9d498c194"}, {file = "coverage-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:2c5f39d1556e75fc3c4fb071f9e7cfa618895a999a0de763a541d730775d0d5f"}, {file = "coverage-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:3edbb3ec580c73e5a264f5d04f30245bc98eff1a26765d46c5c65134f0a0e2f7"}, {file = "coverage-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ea452a2d83964d08232ade470091015e7ab9b8f53acbec10f2210fbab4ce7e43"}, {file = "coverage-6.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:1770d24f45f1f2daeae34cfa3b33fcb29702153544cd2ad40d58399dd4ff53b5"}, {file = "coverage-6.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ad7182a82843f9f85487f44567c8c688f16c906bdb8d0e44ae462aed61cb8f1b"}, {file = "coverage-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:9d242a2434801ef5125330deddb4cddba8990c9a49b3dec99dca17dd7eefba5a"}, {file = "coverage-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:e66c50f0ab445fec920a9f084914ea1776a809e3016c3738519048195f851bbb"}, {file = "coverage-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5b1ceacb86e0a9558061dcc6baae865ed25933ea57effea644f21657cdce19bc"}, {file = "coverage-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a2e15ab5afbee34abf716fece80ea33ea09a82e7450512f022723b1a82ec9a4e"}, {file = "coverage-6.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6873f3f954d3e3ab8b1881f4e5307cc19f70c9f931c41048d9f7e6fd946eabe7"}, {file = "coverage-6.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:0898d6948b31df13391cd40568de8f35fa5901bc922c5ae05cf070587cb9c666"}, {file = "coverage-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9c416ba03844608f45661a5b48dc59c6b5e89956efe388564dd138ca8caf540b"}, {file = "coverage-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:66fe33e9e0df58675e08e83fe257f89e7f625e7633ea93d0872154e09cce2724"}, {file = "coverage-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:353a50f123f0185cdb7a1e1e3e2cfb9d1fd7e293cfaf68eedaf5bd8e02e3ec32"}, {file = "coverage-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b81a4e667c45b13658b84f9b8f1d32ef86d5405fabcbd181b76b9e51d295f397"}, {file = "coverage-6.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:17426808e8e0824f864876312d41961223bf5e503bf8f1f846735279a60ea345"}, {file = "coverage-6.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e11cca9eb5c9b3eaad899728ee2ce916138399ee8cbbccaadc1871fecb750827"}, {file = "coverage-6.0.1-cp38-cp38-win32.whl", hash = "sha256:0a7e55cc9f7efa22d5cc9966276ec7a40a8803676f6ccbfdc06a486fba9aa9ee"}, {file = "coverage-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:4eb9cd910ca8e243f930243a9940ea1a522e32435d15668445753d087c30ee12"}, {file = "coverage-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:83682b73785d2e078e0b5f63410b8125b122e1a22422640c57edd4011c950f3e"}, {file = "coverage-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b45f89a8ef65c29195f8f28dbe215f44ccb29d934f3e862d2a5c12e38698a793"}, {file = "coverage-6.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:73880a80fad0597eca43e213e5e1711bf6c0fcdb7eb6b01b3b17841ebe5a7f8d"}, {file = "coverage-6.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f398d38e6ebc2637863db1d7be3d4f9c5174e7d24bb3b0716cdb1f204669cbcf"}, {file = "coverage-6.0.1-cp39-cp39-win32.whl", hash = "sha256:1864bdf9b2ccb43e724051bc23a1c558daf101ad4488ede1945f2a8be1facdad"}, {file = "coverage-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:c9c413c4397d4cdc7ca89286158d240ce524f9667b52c9a64dd7e13d16cf8815"}, {file = "coverage-6.0.1-pp36-none-any.whl", hash = "sha256:65da6e3e8325291f012921bbf71fea0a97824e1c573981871096aac6e2cf0ec5"}, {file = "coverage-6.0.1-pp37-none-any.whl", hash = "sha256:07efe1fbd72e67df026ad5109bcd216acbbd4a29d5208b3dab61779bae6b7b26"}, {file = "coverage-6.0.1.tar.gz", hash = "sha256:3490ff6dbf3f7accf0750136ed60ae1f487bccc1f097740e3b21262bc9c89854"}, ] cryptography = [ {file = "cryptography-35.0.0-cp36-abi3-macosx_10_10_x86_64.whl", hash = "sha256:d57e0cdc1b44b6cdf8af1d01807db06886f10177469312fbde8f44ccbb284bc9"}, {file = "cryptography-35.0.0-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:ced40344e811d6abba00295ced98c01aecf0c2de39481792d87af4fa58b7b4d6"}, {file = "cryptography-35.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:54b2605e5475944e2213258e0ab8696f4f357a31371e538ef21e8d61c843c28d"}, {file = "cryptography-35.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:7b7ceeff114c31f285528ba8b390d3e9cfa2da17b56f11d366769a807f17cbaa"}, {file = "cryptography-35.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d69645f535f4b2c722cfb07a8eab916265545b3475fdb34e0be2f4ee8b0b15e"}, {file = "cryptography-35.0.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a2d0e0acc20ede0f06ef7aa58546eee96d2592c00f450c9acb89c5879b61992"}, {file = "cryptography-35.0.0-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:07bb7fbfb5de0980590ddfc7f13081520def06dc9ed214000ad4372fb4e3c7f6"}, {file = "cryptography-35.0.0-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:7eba2cebca600a7806b893cb1d541a6e910afa87e97acf2021a22b32da1df52d"}, {file = "cryptography-35.0.0-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:18d90f4711bf63e2fb21e8c8e51ed8189438e6b35a6d996201ebd98a26abbbe6"}, {file = "cryptography-35.0.0-cp36-abi3-win32.whl", hash = "sha256:c10c797ac89c746e488d2ee92bd4abd593615694ee17b2500578b63cad6b93a8"}, {file = "cryptography-35.0.0-cp36-abi3-win_amd64.whl", hash = "sha256:7075b304cd567694dc692ffc9747f3e9cb393cc4aa4fb7b9f3abd6f5c4e43588"}, {file = "cryptography-35.0.0-pp36-pypy36_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a688ebcd08250eab5bb5bca318cc05a8c66de5e4171a65ca51db6bd753ff8953"}, {file = "cryptography-35.0.0-pp36-pypy36_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d99915d6ab265c22873f1b4d6ea5ef462ef797b4140be4c9d8b179915e0985c6"}, {file = "cryptography-35.0.0-pp36-pypy36_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:928185a6d1ccdb816e883f56ebe92e975a262d31cc536429041921f8cb5a62fd"}, {file = "cryptography-35.0.0-pp37-pypy37_pp73-macosx_10_10_x86_64.whl", hash = "sha256:ebeddd119f526bcf323a89f853afb12e225902a24d29b55fe18dd6fcb2838a76"}, {file = "cryptography-35.0.0-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:22a38e96118a4ce3b97509443feace1d1011d0571fae81fc3ad35f25ba3ea999"}, {file = "cryptography-35.0.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb80e8a1f91e4b7ef8b33041591e6d89b2b8e122d787e87eeb2b08da71bb16ad"}, {file = "cryptography-35.0.0-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:abb5a361d2585bb95012a19ed9b2c8f412c5d723a9836418fab7aaa0243e67d2"}, {file = "cryptography-35.0.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:1ed82abf16df40a60942a8c211251ae72858b25b7421ce2497c2eb7a1cee817c"}, {file = "cryptography-35.0.0.tar.gz", hash = "sha256:9933f28f70d0517686bd7de36166dda42094eac49415459d9bdf5e7df3e0086d"}, ] defusedxml = [ {file = "defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61"}, {file = "defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69"}, ] docutils = [ {file = "docutils-0.17.1-py2.py3-none-any.whl", hash = "sha256:cf316c8370a737a022b72b56874f6602acf974a37a9fba42ec2876387549fc61"}, {file = "docutils-0.17.1.tar.gz", hash = "sha256:686577d2e4c32380bb50cbb22f575ed742d58168cee37e99117a854bcd88f125"}, ] idna = [ {file = "idna-3.2-py3-none-any.whl", hash = "sha256:14475042e284991034cb48e06f6851428fb14c4dc953acd9be9a5e95c7b6dd7a"}, {file = "idna-3.2.tar.gz", hash = "sha256:467fbad99067910785144ce333826c71fb0e63a425657295239737f7ecd125f3"}, ] imagesize = [ {file = "imagesize-1.2.0-py2.py3-none-any.whl", hash = "sha256:6965f19a6a2039c7d48bca7dba2473069ff854c36ae6f19d2cde309d998228a1"}, {file = "imagesize-1.2.0.tar.gz", hash = "sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1"}, ] importlib-metadata = [ {file = "importlib_metadata-4.8.1-py3-none-any.whl", hash = "sha256:b618b6d2d5ffa2f16add5697cf57a46c76a56229b0ed1c438322e4e95645bd15"}, {file = "importlib_metadata-4.8.1.tar.gz", hash = "sha256:f284b3e11256ad1e5d03ab86bb2ccd6f5339688ff17a4d797a0fe7df326f23b1"}, ] isort = [ {file = "isort-5.9.3-py3-none-any.whl", hash = "sha256:e17d6e2b81095c9db0a03a8025a957f334d6ea30b26f9ec70805411e5c7c81f2"}, {file = "isort-5.9.3.tar.gz", hash = "sha256:9c2ea1e62d871267b78307fe511c0838ba0da28698c5732d54e2790bf3ba9899"}, ] jinja2 = [ {file = "Jinja2-3.0.2-py3-none-any.whl", hash = "sha256:8569982d3f0889eed11dd620c706d39b60c36d6d25843961f33f77fb6bc6b20c"}, {file = "Jinja2-3.0.2.tar.gz", hash = "sha256:827a0e32839ab1600d4eb1c4c33ec5a8edfbc5cb42dafa13b81f182f97784b45"}, ] lazy-object-proxy = [ {file = "lazy-object-proxy-1.6.0.tar.gz", hash = "sha256:489000d368377571c6f982fba6497f2aa13c6d1facc40660963da62f5c379726"}, {file = "lazy_object_proxy-1.6.0-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:c6938967f8528b3668622a9ed3b31d145fab161a32f5891ea7b84f6b790be05b"}, {file = "lazy_object_proxy-1.6.0-cp27-cp27m-win32.whl", hash = "sha256:ebfd274dcd5133e0afae738e6d9da4323c3eb021b3e13052d8cbd0e457b1256e"}, {file = "lazy_object_proxy-1.6.0-cp27-cp27m-win_amd64.whl", hash = "sha256:ed361bb83436f117f9917d282a456f9e5009ea12fd6de8742d1a4752c3017e93"}, {file = "lazy_object_proxy-1.6.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:d900d949b707778696fdf01036f58c9876a0d8bfe116e8d220cfd4b15f14e741"}, {file = "lazy_object_proxy-1.6.0-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:5743a5ab42ae40caa8421b320ebf3a998f89c85cdc8376d6b2e00bd12bd1b587"}, {file = "lazy_object_proxy-1.6.0-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:bf34e368e8dd976423396555078def5cfc3039ebc6fc06d1ae2c5a65eebbcde4"}, {file = "lazy_object_proxy-1.6.0-cp36-cp36m-win32.whl", hash = "sha256:b579f8acbf2bdd9ea200b1d5dea36abd93cabf56cf626ab9c744a432e15c815f"}, {file = "lazy_object_proxy-1.6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:4f60460e9f1eb632584c9685bccea152f4ac2130e299784dbaf9fae9f49891b3"}, {file = "lazy_object_proxy-1.6.0-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:d7124f52f3bd259f510651450e18e0fd081ed82f3c08541dffc7b94b883aa981"}, {file = "lazy_object_proxy-1.6.0-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:22ddd618cefe54305df49e4c069fa65715be4ad0e78e8d252a33debf00f6ede2"}, {file = "lazy_object_proxy-1.6.0-cp37-cp37m-win32.whl", hash = "sha256:9d397bf41caad3f489e10774667310d73cb9c4258e9aed94b9ec734b34b495fd"}, {file = "lazy_object_proxy-1.6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:24a5045889cc2729033b3e604d496c2b6f588c754f7a62027ad4437a7ecc4837"}, {file = "lazy_object_proxy-1.6.0-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:17e0967ba374fc24141738c69736da90e94419338fd4c7c7bef01ee26b339653"}, {file = "lazy_object_proxy-1.6.0-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:410283732af311b51b837894fa2f24f2c0039aa7f220135192b38fcc42bd43d3"}, {file = "lazy_object_proxy-1.6.0-cp38-cp38-win32.whl", hash = "sha256:85fb7608121fd5621cc4377a8961d0b32ccf84a7285b4f1d21988b2eae2868e8"}, {file = "lazy_object_proxy-1.6.0-cp38-cp38-win_amd64.whl", hash = "sha256:d1c2676e3d840852a2de7c7d5d76407c772927addff8d742b9808fe0afccebdf"}, {file = "lazy_object_proxy-1.6.0-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:b865b01a2e7f96db0c5d12cfea590f98d8c5ba64ad222300d93ce6ff9138bcad"}, {file = "lazy_object_proxy-1.6.0-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:4732c765372bd78a2d6b2150a6e99d00a78ec963375f236979c0626b97ed8e43"}, {file = "lazy_object_proxy-1.6.0-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:9698110e36e2df951c7c36b6729e96429c9c32b3331989ef19976592c5f3c77a"}, {file = "lazy_object_proxy-1.6.0-cp39-cp39-win32.whl", hash = "sha256:1fee665d2638491f4d6e55bd483e15ef21f6c8c2095f235fef72601021e64f61"}, {file = "lazy_object_proxy-1.6.0-cp39-cp39-win_amd64.whl", hash = "sha256:f5144c75445ae3ca2057faac03fda5a902eff196702b0a24daf1d6ce0650514b"}, ] lxml = [ {file = "lxml-4.6.3-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:df7c53783a46febb0e70f6b05df2ba104610f2fb0d27023409734a3ecbb78fb2"}, {file = "lxml-4.6.3-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:1b7584d421d254ab86d4f0b13ec662a9014397678a7c4265a02a6d7c2b18a75f"}, {file = "lxml-4.6.3-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:079f3ae844f38982d156efce585bc540c16a926d4436712cf4baee0cce487a3d"}, {file = "lxml-4.6.3-cp27-cp27m-win32.whl", hash = "sha256:bc4313cbeb0e7a416a488d72f9680fffffc645f8a838bd2193809881c67dd106"}, {file = "lxml-4.6.3-cp27-cp27m-win_amd64.whl", hash = "sha256:8157dadbb09a34a6bd95a50690595e1fa0af1a99445e2744110e3dca7831c4ee"}, {file = "lxml-4.6.3-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:7728e05c35412ba36d3e9795ae8995e3c86958179c9770e65558ec3fdfd3724f"}, {file = "lxml-4.6.3-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:4bff24dfeea62f2e56f5bab929b4428ae6caba2d1eea0c2d6eb618e30a71e6d4"}, {file = "lxml-4.6.3-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_24_i686.whl", hash = "sha256:64812391546a18896adaa86c77c59a4998f33c24788cadc35789e55b727a37f4"}, {file = "lxml-4.6.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl", hash = "sha256:c1a40c06fd5ba37ad39caa0b3144eb3772e813b5fb5b084198a985431c2f1e8d"}, {file = "lxml-4.6.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:74f7d8d439b18fa4c385f3f5dfd11144bb87c1da034a466c5b5577d23a1d9b51"}, {file = "lxml-4.6.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:f90ba11136bfdd25cae3951af8da2e95121c9b9b93727b1b896e3fa105b2f586"}, {file = "lxml-4.6.3-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:4c61b3a0db43a1607d6264166b230438f85bfed02e8cff20c22e564d0faff354"}, {file = "lxml-4.6.3-cp35-cp35m-manylinux2014_x86_64.whl", hash = "sha256:5c8c163396cc0df3fd151b927e74f6e4acd67160d6c33304e805b84293351d16"}, {file = "lxml-4.6.3-cp35-cp35m-win32.whl", hash = "sha256:f2380a6376dfa090227b663f9678150ef27543483055cc327555fb592c5967e2"}, {file = "lxml-4.6.3-cp35-cp35m-win_amd64.whl", hash = "sha256:c4f05c5a7c49d2fb70223d0d5bcfbe474cf928310ac9fa6a7c6dddc831d0b1d4"}, {file = "lxml-4.6.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:d2e35d7bf1c1ac8c538f88d26b396e73dd81440d59c1ef8522e1ea77b345ede4"}, {file = "lxml-4.6.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:289e9ca1a9287f08daaf796d96e06cb2bc2958891d7911ac7cae1c5f9e1e0ee3"}, {file = "lxml-4.6.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:bccbfc27563652de7dc9bdc595cb25e90b59c5f8e23e806ed0fd623755b6565d"}, {file = "lxml-4.6.3-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:d916d31fd85b2f78c76400d625076d9124de3e4bda8b016d25a050cc7d603f24"}, {file = "lxml-4.6.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:820628b7b3135403540202e60551e741f9b6d3304371712521be939470b454ec"}, {file = "lxml-4.6.3-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:c47ff7e0a36d4efac9fd692cfa33fbd0636674c102e9e8d9b26e1b93a94e7617"}, {file = "lxml-4.6.3-cp36-cp36m-win32.whl", hash = "sha256:5a0a14e264069c03e46f926be0d8919f4105c1623d620e7ec0e612a2e9bf1c04"}, {file = "lxml-4.6.3-cp36-cp36m-win_amd64.whl", hash = "sha256:92e821e43ad382332eade6812e298dc9701c75fe289f2a2d39c7960b43d1e92a"}, {file = "lxml-4.6.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:efd7a09678fd8b53117f6bae4fa3825e0a22b03ef0a932e070c0bdbb3a35e654"}, {file = "lxml-4.6.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:efac139c3f0bf4f0939f9375af4b02c5ad83a622de52d6dfa8e438e8e01d0eb0"}, {file = "lxml-4.6.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:0fbcf5565ac01dff87cbfc0ff323515c823081c5777a9fc7703ff58388c258c3"}, {file = "lxml-4.6.3-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:36108c73739985979bf302006527cf8a20515ce444ba916281d1c43938b8bb96"}, {file = "lxml-4.6.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:122fba10466c7bd4178b07dba427aa516286b846b2cbd6f6169141917283aae2"}, {file = "lxml-4.6.3-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:cdaf11d2bd275bf391b5308f86731e5194a21af45fbaaaf1d9e8147b9160ea92"}, {file = "lxml-4.6.3-cp37-cp37m-win32.whl", hash = "sha256:3439c71103ef0e904ea0a1901611863e51f50b5cd5e8654a151740fde5e1cade"}, {file = "lxml-4.6.3-cp37-cp37m-win_amd64.whl", hash = "sha256:4289728b5e2000a4ad4ab8da6e1db2e093c63c08bdc0414799ee776a3f78da4b"}, {file = "lxml-4.6.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b007cbb845b28db4fb8b6a5cdcbf65bacb16a8bd328b53cbc0698688a68e1caa"}, {file = "lxml-4.6.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:76fa7b1362d19f8fbd3e75fe2fb7c79359b0af8747e6f7141c338f0bee2f871a"}, {file = "lxml-4.6.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:26e761ab5b07adf5f555ee82fb4bfc35bf93750499c6c7614bd64d12aaa67927"}, {file = "lxml-4.6.3-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:e1cbd3f19a61e27e011e02f9600837b921ac661f0c40560eefb366e4e4fb275e"}, {file = "lxml-4.6.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:66e575c62792c3f9ca47cb8b6fab9e35bab91360c783d1606f758761810c9791"}, {file = "lxml-4.6.3-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:1b38116b6e628118dea5b2186ee6820ab138dbb1e24a13e478490c7db2f326ae"}, {file = "lxml-4.6.3-cp38-cp38-win32.whl", hash = "sha256:89b8b22a5ff72d89d48d0e62abb14340d9e99fd637d046c27b8b257a01ffbe28"}, {file = "lxml-4.6.3-cp38-cp38-win_amd64.whl", hash = "sha256:2a9d50e69aac3ebee695424f7dbd7b8c6d6eb7de2a2eb6b0f6c7db6aa41e02b7"}, {file = "lxml-4.6.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ce256aaa50f6cc9a649c51be3cd4ff142d67295bfc4f490c9134d0f9f6d58ef0"}, {file = "lxml-4.6.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:7610b8c31688f0b1be0ef882889817939490a36d0ee880ea562a4e1399c447a1"}, {file = "lxml-4.6.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:f8380c03e45cf09f8557bdaa41e1fa7c81f3ae22828e1db470ab2a6c96d8bc23"}, {file = "lxml-4.6.3-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:3082c518be8e97324390614dacd041bb1358c882d77108ca1957ba47738d9d59"}, {file = "lxml-4.6.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:884ab9b29feaca361f7f88d811b1eea9bfca36cf3da27768d28ad45c3ee6f969"}, {file = "lxml-4.6.3-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:6f12e1427285008fd32a6025e38e977d44d6382cf28e7201ed10d6c1698d2a9a"}, {file = "lxml-4.6.3-cp39-cp39-win32.whl", hash = "sha256:33bb934a044cf32157c12bfcfbb6649807da20aa92c062ef51903415c704704f"}, {file = "lxml-4.6.3-cp39-cp39-win_amd64.whl", hash = "sha256:542d454665a3e277f76954418124d67516c5f88e51a900365ed54a9806122b83"}, {file = "lxml-4.6.3.tar.gz", hash = "sha256:39b78571b3b30645ac77b95f7c69d1bffc4cf8c3b157c435a34da72e78c82468"}, ] markupsafe = [ {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53"}, {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38"}, {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad"}, {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d"}, {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646"}, {file = "MarkupSafe-2.0.1-cp310-cp310-win32.whl", hash = "sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28"}, {file = "MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-win32.whl", hash = "sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:6557b31b5e2c9ddf0de32a691f2312a32f77cd7681d8af66c2692efdbef84c18"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:49e3ceeabbfb9d66c3aef5af3a60cc43b85c33df25ce03d0031a608b0a8b2e3f"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-win32.whl", hash = "sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914"}, {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9"}, {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6"}, {file = "MarkupSafe-2.0.1-cp38-cp38-win32.whl", hash = "sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64"}, {file = "MarkupSafe-2.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833"}, {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26"}, {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3c112550557578c26af18a1ccc9e090bfe03832ae994343cfdacd287db6a6ae7"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:53edb4da6925ad13c07b6d26c2a852bd81e364f95301c66e930ab2aef5b5ddd8"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:f5653a225f31e113b152e56f154ccbe59eeb1c7487b39b9d9f9cdb58e6c79dc5"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6"}, {file = "MarkupSafe-2.0.1-cp39-cp39-win32.whl", hash = "sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74"}, {file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"}, {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"}, ] mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] packaging = [ {file = "packaging-20.9-py2.py3-none-any.whl", hash = "sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21f051443c20947a"}, {file = "packaging-20.9.tar.gz", hash = "sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a230374cc1fd776feae5"}, ] paramiko = [ {file = "paramiko-2.8.0-py2.py3-none-any.whl", hash = "sha256:def3ec612399bab4e9f5eb66b0ae5983980db9dd9120d9e9c6ea3ff673865d1c"}, {file = "paramiko-2.8.0.tar.gz", hash = "sha256:e673b10ee0f1c80d46182d3af7751d033d9b573dd7054d2d0aa46be186c3c1d2"}, ] pathspec = [ {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"}, {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, ] platformdirs = [ {file = "platformdirs-2.4.0-py3-none-any.whl", hash = "sha256:8868bbe3c3c80d42f20156f22e7131d2fb321f5bc86a2a345375c6481a67021d"}, {file = "platformdirs-2.4.0.tar.gz", hash = "sha256:367a5e80b3d04d2428ffa76d33f124cf11e8fff2acdaa9b43d545f5c7d661ef2"}, ] pontos = [ {file = "pontos-21.10.2-py3-none-any.whl", hash = "sha256:7800e54f34c2403e64dcf340dc5ebb3b6ff44867a6c31f4744d0d195af25e24a"}, {file = "pontos-21.10.2.tar.gz", hash = "sha256:554db92fecd3ec93a7d5b8b0fcedede74e41e5e685a5664a0b83b4acb6328fef"}, ] pycparser = [ {file = "pycparser-2.20-py2.py3-none-any.whl", hash = "sha256:7582ad22678f0fcd81102833f60ef8d0e57288b6b5fb00323d101be910e35705"}, {file = "pycparser-2.20.tar.gz", hash = "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"}, ] pygments = [ {file = "Pygments-2.10.0-py3-none-any.whl", hash = "sha256:b8e67fe6af78f492b3c4b3e2970c0624cbf08beb1e493b2c99b9fa1b67a20380"}, {file = "Pygments-2.10.0.tar.gz", hash = "sha256:f398865f7eb6874156579fdf36bc840a03cab64d1cde9e93d68f46a425ec52c6"}, ] pylint = [ {file = "pylint-2.11.1-py3-none-any.whl", hash = "sha256:0f358e221c45cbd4dad2a1e4b883e75d28acdcccd29d40c76eb72b307269b126"}, {file = "pylint-2.11.1.tar.gz", hash = "sha256:2c9843fff1a88ca0ad98a256806c82c5a8f86086e7ccbdb93297d86c3f90c436"}, ] pynacl = [ {file = "PyNaCl-1.4.0-cp27-cp27m-macosx_10_10_x86_64.whl", hash = "sha256:ea6841bc3a76fa4942ce00f3bda7d436fda21e2d91602b9e21b7ca9ecab8f3ff"}, {file = "PyNaCl-1.4.0-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:d452a6746f0a7e11121e64625109bc4468fc3100452817001dbe018bb8b08514"}, {file = "PyNaCl-1.4.0-cp27-cp27m-win32.whl", hash = "sha256:2fe0fc5a2480361dcaf4e6e7cea00e078fcda07ba45f811b167e3f99e8cff574"}, {file = "PyNaCl-1.4.0-cp27-cp27m-win_amd64.whl", hash = "sha256:f8851ab9041756003119368c1e6cd0b9c631f46d686b3904b18c0139f4419f80"}, {file = "PyNaCl-1.4.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:7757ae33dae81c300487591c68790dfb5145c7d03324000433d9a2c141f82af7"}, {file = "PyNaCl-1.4.0-cp35-abi3-macosx_10_10_x86_64.whl", hash = "sha256:757250ddb3bff1eecd7e41e65f7f833a8405fede0194319f87899690624f2122"}, {file = "PyNaCl-1.4.0-cp35-abi3-manylinux1_x86_64.whl", hash = "sha256:30f9b96db44e09b3304f9ea95079b1b7316b2b4f3744fe3aaecccd95d547063d"}, {file = "PyNaCl-1.4.0-cp35-abi3-win32.whl", hash = "sha256:4e10569f8cbed81cb7526ae137049759d2a8d57726d52c1a000a3ce366779634"}, {file = "PyNaCl-1.4.0-cp35-abi3-win_amd64.whl", hash = "sha256:c914f78da4953b33d4685e3cdc7ce63401247a21425c16a39760e282075ac4a6"}, {file = "PyNaCl-1.4.0-cp35-cp35m-win32.whl", hash = "sha256:06cbb4d9b2c4bd3c8dc0d267416aaed79906e7b33f114ddbf0911969794b1cc4"}, {file = "PyNaCl-1.4.0-cp35-cp35m-win_amd64.whl", hash = "sha256:511d269ee845037b95c9781aa702f90ccc36036f95d0f31373a6a79bd8242e25"}, {file = "PyNaCl-1.4.0-cp36-cp36m-win32.whl", hash = "sha256:11335f09060af52c97137d4ac54285bcb7df0cef29014a1a4efe64ac065434c4"}, {file = "PyNaCl-1.4.0-cp36-cp36m-win_amd64.whl", hash = "sha256:cd401ccbc2a249a47a3a1724c2918fcd04be1f7b54eb2a5a71ff915db0ac51c6"}, {file = "PyNaCl-1.4.0-cp37-cp37m-win32.whl", hash = "sha256:8122ba5f2a2169ca5da936b2e5a511740ffb73979381b4229d9188f6dcb22f1f"}, {file = "PyNaCl-1.4.0-cp37-cp37m-win_amd64.whl", hash = "sha256:537a7ccbea22905a0ab36ea58577b39d1fa9b1884869d173b5cf111f006f689f"}, {file = "PyNaCl-1.4.0-cp38-cp38-win32.whl", hash = "sha256:9c4a7ea4fb81536c1b1f5cc44d54a296f96ae78c1ebd2311bd0b60be45a48d96"}, {file = "PyNaCl-1.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:7c6092102219f59ff29788860ccb021e80fffd953920c4a8653889c029b2d420"}, {file = "PyNaCl-1.4.0.tar.gz", hash = "sha256:54e9a2c849c742006516ad56a88f5c74bf2ce92c9f67435187c3c5953b346505"}, ] pyparsing = [ {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, ] pytz = [ {file = "pytz-2021.3-py2.py3-none-any.whl", hash = "sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c"}, {file = "pytz-2021.3.tar.gz", hash = "sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326"}, ] regex = [ {file = "regex-2021.10.8-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:981c786293a3115bc14c103086ae54e5ee50ca57f4c02ce7cf1b60318d1e8072"}, {file = "regex-2021.10.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:51feefd58ac38eb91a21921b047da8644155e5678e9066af7bcb30ee0dca7361"}, {file = "regex-2021.10.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ea8de658d7db5987b11097445f2b1f134400e2232cb40e614e5f7b6f5428710e"}, {file = "regex-2021.10.8-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:1ce02f420a7ec3b2480fe6746d756530f69769292eca363218c2291d0b116a01"}, {file = "regex-2021.10.8-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:39079ebf54156be6e6902f5c70c078f453350616cfe7bfd2dd15bdb3eac20ccc"}, {file = "regex-2021.10.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ff24897f6b2001c38a805d53b6ae72267025878d35ea225aa24675fbff2dba7f"}, {file = "regex-2021.10.8-cp310-cp310-win32.whl", hash = "sha256:c6569ba7b948c3d61d27f04e2b08ebee24fec9ff8e9ea154d8d1e975b175bfa7"}, {file = "regex-2021.10.8-cp310-cp310-win_amd64.whl", hash = "sha256:45cb0f7ff782ef51bc79e227a87e4e8f24bc68192f8de4f18aae60b1d60bc152"}, {file = "regex-2021.10.8-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:fab3ab8aedfb443abb36729410403f0fe7f60ad860c19a979d47fb3eb98ef820"}, {file = "regex-2021.10.8-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74e55f8d66f1b41d44bc44c891bcf2c7fad252f8f323ee86fba99d71fd1ad5e3"}, {file = "regex-2021.10.8-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d52c5e089edbdb6083391faffbe70329b804652a53c2fdca3533e99ab0580d9"}, {file = "regex-2021.10.8-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:1abbd95cbe9e2467cac65c77b6abd9223df717c7ae91a628502de67c73bf6838"}, {file = "regex-2021.10.8-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b9b5c215f3870aa9b011c00daeb7be7e1ae4ecd628e9beb6d7e6107e07d81287"}, {file = "regex-2021.10.8-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f540f153c4f5617bc4ba6433534f8916d96366a08797cbbe4132c37b70403e92"}, {file = "regex-2021.10.8-cp36-cp36m-win32.whl", hash = "sha256:1f51926db492440e66c89cd2be042f2396cf91e5b05383acd7372b8cb7da373f"}, {file = "regex-2021.10.8-cp36-cp36m-win_amd64.whl", hash = "sha256:5f55c4804797ef7381518e683249310f7f9646da271b71cb6b3552416c7894ee"}, {file = "regex-2021.10.8-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:fb2baff66b7d2267e07ef71e17d01283b55b3cc51a81b54cc385e721ae172ba4"}, {file = "regex-2021.10.8-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9e527ab1c4c7cf2643d93406c04e1d289a9d12966529381ce8163c4d2abe4faf"}, {file = "regex-2021.10.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:36c98b013273e9da5790ff6002ab326e3f81072b4616fd95f06c8fa733d2745f"}, {file = "regex-2021.10.8-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:55ef044899706c10bc0aa052f2fc2e58551e2510694d6aae13f37c50f3f6ff61"}, {file = "regex-2021.10.8-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aa0ab3530a279a3b7f50f852f1bab41bc304f098350b03e30a3876b7dd89840e"}, {file = "regex-2021.10.8-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:a37305eb3199d8f0d8125ec2fb143ba94ff6d6d92554c4b8d4a8435795a6eccd"}, {file = "regex-2021.10.8-cp37-cp37m-win32.whl", hash = "sha256:2efd47704bbb016136fe34dfb74c805b1ef5c7313aef3ce6dcb5ff844299f432"}, {file = "regex-2021.10.8-cp37-cp37m-win_amd64.whl", hash = "sha256:924079d5590979c0e961681507eb1773a142553564ccae18d36f1de7324e71ca"}, {file = "regex-2021.10.8-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b09d3904bf312d11308d9a2867427479d277365b1617e48ad09696fa7dfcdf59"}, {file = "regex-2021.10.8-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f125fce0a0ae4fd5c3388d369d7a7d78f185f904c90dd235f7ecf8fe13fa741"}, {file = "regex-2021.10.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f199419a81c1016e0560c39773c12f0bd924c37715bffc64b97140d2c314354"}, {file = "regex-2021.10.8-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:09e1031e2059abd91177c302da392a7b6859ceda038be9e015b522a182c89e4f"}, {file = "regex-2021.10.8-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9c070d5895ac6aeb665bd3cd79f673775caf8d33a0b569e98ac434617ecea57d"}, {file = "regex-2021.10.8-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:176796cb7f82a7098b0c436d6daac82f57b9101bb17b8e8119c36eecf06a60a3"}, {file = "regex-2021.10.8-cp38-cp38-win32.whl", hash = "sha256:5e5796d2f36d3c48875514c5cd9e4325a1ca172fc6c78b469faa8ddd3d770593"}, {file = "regex-2021.10.8-cp38-cp38-win_amd64.whl", hash = "sha256:e4204708fa116dd03436a337e8e84261bc8051d058221ec63535c9403a1582a1"}, {file = "regex-2021.10.8-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b8b6ee6555b6fbae578f1468b3f685cdfe7940a65675611365a7ea1f8d724991"}, {file = "regex-2021.10.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:973499dac63625a5ef9dfa4c791aa33a502ddb7615d992bdc89cf2cc2285daa3"}, {file = "regex-2021.10.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88dc3c1acd3f0ecfde5f95c32fcb9beda709dbdf5012acdcf66acbc4794468eb"}, {file = "regex-2021.10.8-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:4786dae85c1f0624ac77cb3813ed99267c9adb72e59fdc7297e1cf4d6036d493"}, {file = "regex-2021.10.8-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe6ce4f3d3c48f9f402da1ceb571548133d3322003ce01b20d960a82251695d2"}, {file = "regex-2021.10.8-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:9e3e2cea8f1993f476a6833ef157f5d9e8c75a59a8d8b0395a9a6887a097243b"}, {file = "regex-2021.10.8-cp39-cp39-win32.whl", hash = "sha256:82cfb97a36b1a53de32b642482c6c46b6ce80803854445e19bc49993655ebf3b"}, {file = "regex-2021.10.8-cp39-cp39-win_amd64.whl", hash = "sha256:b04e512eb628ea82ed86eb31c0f7fc6842b46bf2601b66b1356a7008327f7700"}, {file = "regex-2021.10.8.tar.gz", hash = "sha256:26895d7c9bbda5c52b3635ce5991caa90fbb1ddfac9c9ff1c7ce505e2282fb2a"}, ] requests = [ {file = "requests-2.26.0-py2.py3-none-any.whl", hash = "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24"}, {file = "requests-2.26.0.tar.gz", hash = "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7"}, ] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] snowballstemmer = [ {file = "snowballstemmer-2.1.0-py2.py3-none-any.whl", hash = "sha256:b51b447bea85f9968c13b650126a888aabd4cb4463fca868ec596826325dedc2"}, {file = "snowballstemmer-2.1.0.tar.gz", hash = "sha256:e997baa4f2e9139951b6f4c631bad912dfd3c792467e2f03d7239464af90e914"}, ] sphinx = [ {file = "Sphinx-4.2.0-py3-none-any.whl", hash = "sha256:98a535c62a4fcfcc362528592f69b26f7caec587d32cd55688db580be0287ae0"}, {file = "Sphinx-4.2.0.tar.gz", hash = "sha256:94078db9184491e15bce0a56d9186e0aec95f16ac20b12d00e06d4e36f1058a6"}, ] sphinx-autodoc-typehints = [ {file = "sphinx-autodoc-typehints-1.12.0.tar.gz", hash = "sha256:193617d9dbe0847281b1399d369e74e34cd959c82e02c7efde077fca908a9f52"}, {file = "sphinx_autodoc_typehints-1.12.0-py3-none-any.whl", hash = "sha256:5e81776ec422dd168d688ab60f034fccfafbcd94329e9537712c93003bddc04a"}, ] sphinxcontrib-applehelp = [ {file = "sphinxcontrib-applehelp-1.0.2.tar.gz", hash = "sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58"}, {file = "sphinxcontrib_applehelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:806111e5e962be97c29ec4c1e7fe277bfd19e9652fb1a4392105b43e01af885a"}, ] sphinxcontrib-devhelp = [ {file = "sphinxcontrib-devhelp-1.0.2.tar.gz", hash = "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4"}, {file = "sphinxcontrib_devhelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e"}, ] sphinxcontrib-htmlhelp = [ {file = "sphinxcontrib-htmlhelp-2.0.0.tar.gz", hash = "sha256:f5f8bb2d0d629f398bf47d0d69c07bc13b65f75a81ad9e2f71a63d4b7a2f6db2"}, {file = "sphinxcontrib_htmlhelp-2.0.0-py2.py3-none-any.whl", hash = "sha256:d412243dfb797ae3ec2b59eca0e52dac12e75a241bf0e4eb861e450d06c6ed07"}, ] sphinxcontrib-jsmath = [ {file = "sphinxcontrib-jsmath-1.0.1.tar.gz", hash = "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8"}, {file = "sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl", hash = "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178"}, ] sphinxcontrib-qthelp = [ {file = "sphinxcontrib-qthelp-1.0.3.tar.gz", hash = "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72"}, {file = "sphinxcontrib_qthelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6"}, ] sphinxcontrib-serializinghtml = [ {file = "sphinxcontrib-serializinghtml-1.1.5.tar.gz", hash = "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952"}, {file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"}, ] toml = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] tomli = [ {file = "tomli-1.2.1-py3-none-any.whl", hash = "sha256:8dd0e9524d6f386271a36b41dbf6c57d8e32fd96fd22b6584679dc569d20899f"}, {file = "tomli-1.2.1.tar.gz", hash = "sha256:a5b75cb6f3968abb47af1b40c1819dc519ea82bcc065776a866e8d74c5ca9442"}, ] tomlkit = [ {file = "tomlkit-0.7.2-py2.py3-none-any.whl", hash = "sha256:173ad840fa5d2aac140528ca1933c29791b79a374a0861a80347f42ec9328117"}, {file = "tomlkit-0.7.2.tar.gz", hash = "sha256:d7a454f319a7e9bd2e249f239168729327e4dd2d27b17dc68be264ad1ce36754"}, ] typed-ast = [ {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6"}, {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075"}, {file = "typed_ast-1.4.3-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528"}, {file = "typed_ast-1.4.3-cp35-cp35m-win32.whl", hash = "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428"}, {file = "typed_ast-1.4.3-cp35-cp35m-win_amd64.whl", hash = "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3"}, {file = "typed_ast-1.4.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f"}, {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341"}, {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace"}, {file = "typed_ast-1.4.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f"}, {file = "typed_ast-1.4.3-cp36-cp36m-win32.whl", hash = "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363"}, {file = "typed_ast-1.4.3-cp36-cp36m-win_amd64.whl", hash = "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7"}, {file = "typed_ast-1.4.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266"}, {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e"}, {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04"}, {file = "typed_ast-1.4.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899"}, {file = "typed_ast-1.4.3-cp37-cp37m-win32.whl", hash = "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c"}, {file = "typed_ast-1.4.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805"}, {file = "typed_ast-1.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a"}, {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff"}, {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41"}, {file = "typed_ast-1.4.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39"}, {file = "typed_ast-1.4.3-cp38-cp38-win32.whl", hash = "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927"}, {file = "typed_ast-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40"}, {file = "typed_ast-1.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3"}, {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4"}, {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0"}, {file = "typed_ast-1.4.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3"}, {file = "typed_ast-1.4.3-cp39-cp39-win32.whl", hash = "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808"}, {file = "typed_ast-1.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c"}, {file = "typed_ast-1.4.3.tar.gz", hash = "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"}, ] typing-extensions = [ {file = "typing_extensions-3.10.0.2-py2-none-any.whl", hash = "sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7"}, {file = "typing_extensions-3.10.0.2-py3-none-any.whl", hash = "sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34"}, {file = "typing_extensions-3.10.0.2.tar.gz", hash = "sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e"}, ] urllib3 = [ {file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"}, {file = "urllib3-1.26.7.tar.gz", hash = "sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece"}, ] wrapt = [ {file = "wrapt-1.12.1.tar.gz", hash = "sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"}, ] zipp = [ {file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"}, {file = "zipp-3.6.0.tar.gz", hash = "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832"}, ] python-gvm-21.10.0/poetry.toml000066400000000000000000000000401413122500400161640ustar00rootroot00000000000000[virtualenvs] in-project = true python-gvm-21.10.0/pyproject.toml000066400000000000000000000034671413122500400167010ustar00rootroot00000000000000[build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry] name = "python-gvm" version = "21.10.0" description = "Library to communicate with remote servers over GMP or OSP" license = "GPL-3.0-or-later" authors = ["Greenbone Networks GmbH "] readme = "README.md" homepage = "https://github.com/greenbone/python-gvm" repository = "https://github.com/greenbone/python-gvm" documentation = "https://python-gvm.readthedocs.io/" classifiers = [ # Full list: https://pypi.org/pypi?%3Aaction=list_classifiers "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Environment :: Console", "Intended Audience :: Developers", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Operating System :: OS Independent", "Topic :: Software Development :: Libraries :: Python Modules", ] packages = [ { include = "gvm" }, { include = "tests", format = "sdist" }, ] [tool.poetry.dependencies] python = "^3.7.0" paramiko = "^2.7.1" lxml = "^4.5.0" defusedxml = ">=0.6,<0.8" [tool.poetry.dev-dependencies] coverage = "^6.0" pylint = "^2.11" sphinx = "^4.2.0" sphinx-autodoc-typehints = "^1.12.0" autohooks = "^21.7.0" autohooks-plugin-pylint = "^21.6.0" autohooks-plugin-black = "^21.7.1" black = "21.7b0" pontos = "^21.9.1" [tool.black] line-length = 80 target-version = ['py37', 'py38'] skip-string-normalization = true exclude = ''' /( \.git | \.hg | \.venv | \.circleci | \.github | \.vscode | _build | build | dist | docs )/ ''' [tool.autohooks] mode = "poetry" pre-commit = ['autohooks.plugins.black', 'autohooks.plugins.pylint'] [tool.pontos.version] version-module-file = "gvm/__version__.py" python-gvm-21.10.0/tests/000077500000000000000000000000001413122500400151155ustar00rootroot00000000000000python-gvm-21.10.0/tests/__init__.py000066400000000000000000000040101413122500400172210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class CallableMock: def __init__(self, name): self.name = name self.calls = [] self.result = None def __call__(self, *args, **kwargs): self.calls.append({'args': args, 'kwargs': kwargs}) return self.result def return_value(self, value): self.result = value def has_not_been_called(self): assert len(self.calls) == 0, f"{self.name} has been called." def has_been_called(self): assert len(self.calls) > 0, f"{self.name} has not been called." def has_been_called_times(self, times): assert ( len(self.calls) == times ), f"{self.name} has not been called {times} times." def has_been_called_with(self, *args, **kwargs): if len(self.calls) == 0: assert False lastcall = self.calls[-1] resp = ( "Expected arguments {eargs} {ekwargs} of {name} do not match. " "Received: {rargs} {rkwargs}" ) # not sure if this is correct assert ( lastcall['args'] == args and lastcall['kwargs'] == kwargs ), resp.format( name=self.name, eargs=args, ekwargs=kwargs, rargs=lastcall['args'], rkwargs=lastcall['kwargs'], ) python-gvm-21.10.0/tests/connections/000077500000000000000000000000001413122500400174375ustar00rootroot00000000000000python-gvm-21.10.0/tests/connections/__init__.py000066400000000000000000000000001413122500400215360ustar00rootroot00000000000000python-gvm-21.10.0/tests/connections/test_gvm_connection.py000066400000000000000000000053361413122500400240670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from unittest.mock import patch from gvm.connections import GvmConnection, DEFAULT_TIMEOUT from gvm.errors import GvmError class GvmConnectionTestCase(unittest.TestCase): # pylint: disable=protected-access def test_init_no_args(self): connection = GvmConnection() self.check_for_default_values(connection) def test_init_with_none(self): connection = GvmConnection(timeout=None) self.check_for_default_values(connection) def check_for_default_values(self, gvm_connection: GvmConnection): self.assertIsNone(gvm_connection._socket) self.assertEqual(gvm_connection._timeout, DEFAULT_TIMEOUT) def test_connect_not_implemented(self): connection = GvmConnection() with self.assertRaises(NotImplementedError): connection.connect() def test_is_end_xml_false(self): connection = GvmConnection() connection._start_xml() false = connection._is_end_xml() self.assertFalse(false) def test_feed_xml_error(self): connection = GvmConnection() connection._start_xml() with self.assertRaises( GvmError, msg='Cannot parse XML response. Response data read bla' ): connection._feed_xml("bla") @patch('gvm.connections.GvmConnection._read') def test_read_no_data(self, _read_mock): _read_mock.return_value = None connection = GvmConnection() with self.assertRaises(GvmError, msg="Remote closed the connection"): connection.read() @patch('gvm.connections.GvmConnection._read') def test_read_trigger_timeout(self, _read_mock): # mocking the response into two parts, so we run into the timeout # check in the loop _read_mock.side_effect = [b"xyz", b""] connection = GvmConnection(timeout=0) with self.assertRaises( GvmError, msg='Timeout while reading the response' ): connection.read() python-gvm-21.10.0/tests/connections/test_ssh_connection.py000066400000000000000000000425141413122500400240720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from io import StringIO import unittest from unittest.mock import patch, Mock from pathlib import Path import paramiko from gvm.connections import ( SSHConnection, DEFAULT_SSH_PORT, DEFAULT_SSH_USERNAME, DEFAULT_SSH_PASSWORD, DEFAULT_HOSTNAME, DEFAULT_KNOWN_HOSTS_FILE, ) from gvm.errors import GvmError class SSHConnectionTestCase(unittest.TestCase): # pylint: disable=protected-access, invalid-name def setUp(self): self.known_hosts_file = Path('known_hosts') with self.known_hosts_file.open("a", encoding='utf-8') as fp: fp.write( '127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBOZWi' 'fs+DoMqIa5Nr0wiVrzQNpMbUwaLzuSTN6rNrYA\n' ) def tearDown(self): if self.known_hosts_file.exists(): self.known_hosts_file.unlink() def test_init_no_args(self): ssh_connection = SSHConnection() self.check_ssh_connection_for_default_values(ssh_connection) def test_init_with_none(self): ssh_connection = SSHConnection( timeout=None, hostname=None, port=None, username=None, password=None ) self.check_ssh_connection_for_default_values(ssh_connection) def check_ssh_connection_for_default_values(self, ssh_connection): self.assertIsInstance(ssh_connection, SSHConnection) self.assertEqual(ssh_connection.hostname, DEFAULT_HOSTNAME) self.assertEqual(ssh_connection.port, DEFAULT_SSH_PORT) self.assertEqual(ssh_connection.username, DEFAULT_SSH_USERNAME) self.assertEqual(ssh_connection.password, DEFAULT_SSH_PASSWORD) self.assertEqual( ssh_connection.known_hosts_file, Path.home() / DEFAULT_KNOWN_HOSTS_FILE, ) def test_connect_error(self): print(self.known_hosts_file.read_text(encoding='utf-8')) ssh_connection = SSHConnection(known_hosts_file=self.known_hosts_file) with self.assertRaises(GvmError, msg="SSH Connection failed"): ssh_connection.connect() def test_connect(self): with patch('paramiko.SSHClient') as SSHClientMock: client_mock = SSHClientMock.return_value client_mock.exec_command.return_value = ['a', 'b', 'c'] ssh_connection = SSHConnection( known_hosts_file=self.known_hosts_file ) ssh_connection.connect() self.assertEqual(ssh_connection._stdin, 'a') self.assertEqual(ssh_connection._stdout, 'b') self.assertEqual(ssh_connection._stderr, 'c') ssh_connection.disconnect() def test_connect_unknown_host(self): ssh_connection = SSHConnection( hostname='0.0.0.1', known_hosts_file=self.known_hosts_file ) with self.assertRaises( GvmError, msg=( "Could'nt establish a connection to fetch the remote " "server key: [Errno 65] No route to host" ), ): ssh_connection.connect() @patch('builtins.input') def test_connect_adding_and_save_hostkey(self, input_mock): key_io = StringIO( """-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACB69SvZKJh/9VgSL0G27b5xVYa8nethH3IERbi0YqJDXwAAAKhjwAdrY8AH awAAAAtzc2gtZWQyNTUxOQAAACB69SvZKJh/9VgSL0G27b5xVYa8nethH3IERbi0YqJDXw AAAEA9tGQi2IrprbOSbDCF+RmAHd6meNSXBUQ2ekKXm4/8xnr1K9komH/1WBIvQbbtvnFV hryd62EfcgRFuLRiokNfAAAAI2FsZXhfZ2F5bm9yQEFsZXhzLU1hY0Jvb2stQWlyLmxvY2 FsAQI= -----END OPENSSH PRIVATE KEY-----""" ) key = paramiko.Ed25519Key.from_private_key(key_io) key_type = key.get_name().replace('ssh-', '').upper() hostname = '0.0.0.0' input_mock.side_effect = ['yes', 'yes'] ssh_connection = SSHConnection( hostname=hostname, known_hosts_file=self.known_hosts_file ) ssh_connection._socket = paramiko.SSHClient() keys = self.known_hosts_file.read_text(encoding='utf-8') self.assertEqual( keys, '127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBOZWi' 'fs+DoMqIa5Nr0wiVrzQNpMbUwaLzuSTN6rNrYA\n', ) with self.assertLogs('gvm.connections', level='INFO') as cm: hostkeys = paramiko.HostKeys(filename=self.known_hosts_file) ssh_connection._ssh_authentication_input_loop( hostkeys=hostkeys, key=key ) keys = self.known_hosts_file.read_text(encoding='utf-8') self.assertEqual( cm.output, [ "INFO:gvm.connections:Warning: " f"Permanently added '{hostname}' ({key_type}) to " "the list of known hosts." ], ) self.assertEqual( keys, '127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBOZWi' 'fs+DoMqIa5Nr0wiVrzQNpMbUwaLzuSTN6rNrYA\n' f'0.0.0.0 {key.get_name()} {key.get_base64()}\n', ) @patch('builtins.input') def test_connect_adding_and_dont_save_hostkey(self, input_mock): key_io = StringIO( """-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACB69SvZKJh/9VgSL0G27b5xVYa8nethH3IERbi0YqJDXwAAAKhjwAdrY8AH awAAAAtzc2gtZWQyNTUxOQAAACB69SvZKJh/9VgSL0G27b5xVYa8nethH3IERbi0YqJDXw AAAEA9tGQi2IrprbOSbDCF+RmAHd6meNSXBUQ2ekKXm4/8xnr1K9komH/1WBIvQbbtvnFV hryd62EfcgRFuLRiokNfAAAAI2FsZXhfZ2F5bm9yQEFsZXhzLU1hY0Jvb2stQWlyLmxvY2 FsAQI= -----END OPENSSH PRIVATE KEY-----""" ) key = paramiko.Ed25519Key.from_private_key(key_io) key_type = key.get_name().replace('ssh-', '').upper() hostname = '0.0.0.0' input_mock.side_effect = ['yes', 'no'] ssh_connection = SSHConnection( hostname=hostname, known_hosts_file=self.known_hosts_file ) ssh_connection._socket = paramiko.SSHClient() keys = self.known_hosts_file.read_text(encoding='utf-8') self.assertEqual( keys, '127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBOZWi' 'fs+DoMqIa5Nr0wiVrzQNpMbUwaLzuSTN6rNrYA\n', ) with self.assertLogs('gvm.connections', level='INFO') as cm: hostkeys = paramiko.HostKeys(filename=self.known_hosts_file) ssh_connection._ssh_authentication_input_loop( hostkeys=hostkeys, key=key ) keys = self.known_hosts_file.read_text(encoding='utf-8') self.assertEqual( cm.output, [ "INFO:gvm.connections:Warning: " f"Host '{hostname}' ({key_type}) not added to " "the list of known hosts." ], ) self.assertEqual( keys, '127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBOZWi' 'fs+DoMqIa5Nr0wiVrzQNpMbUwaLzuSTN6rNrYA\n', ) @patch('builtins.input') @patch('sys.stdout', new_callable=StringIO) def test_connect_wrong_input(self, stdout_mock, input_mock): key_io = StringIO( """-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACB69SvZKJh/9VgSL0G27b5xVYa8nethH3IERbi0YqJDXwAAAKhjwAdrY8AH awAAAAtzc2gtZWQyNTUxOQAAACB69SvZKJh/9VgSL0G27b5xVYa8nethH3IERbi0YqJDXw AAAEA9tGQi2IrprbOSbDCF+RmAHd6meNSXBUQ2ekKXm4/8xnr1K9komH/1WBIvQbbtvnFV hryd62EfcgRFuLRiokNfAAAAI2FsZXhfZ2F5bm9yQEFsZXhzLU1hY0Jvb2stQWlyLmxvY2 FsAQI= -----END OPENSSH PRIVATE KEY-----""" ) key = paramiko.Ed25519Key.from_private_key(key_io) hostname = '0.0.0.0' key_type = key.get_name().replace('ssh-', '').upper() inputs = ['asd', 'yes', 'yoo', 'no'] input_mock.side_effect = inputs ssh_connection = SSHConnection( hostname=hostname, known_hosts_file=self.known_hosts_file ) ssh_connection._socket = paramiko.SSHClient() with self.assertLogs('gvm.connections', level='INFO') as cm: hostkeys = paramiko.HostKeys(filename=self.known_hosts_file) ssh_connection._ssh_authentication_input_loop( hostkeys=hostkeys, key=key ) ret = stdout_mock.getvalue() self.assertEqual( cm.output, [ "INFO:gvm.connections:Warning: " f"Host '{hostname}' ({key_type}) not added to " "the list of known hosts." ], ) self.assertEqual( ret, f"The authenticity of host '{hostname}' can't be established.\n" f"{key_type} key fingerprint is " "J6VESFdD3xSChn8y9PzWzeF+1tl892mOy2TqkMLO4ow.\n" "Are you sure you want to continue connecting (yes/no)? " "Please type 'yes' or 'no': " "Do you want to add 0.0.0.0 to known_hosts (yes/no)? " "Please type 'yes' or 'no': ", ) @patch('builtins.input') def test_user_denies_auth(self, input_mock): key_io = StringIO( """-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACB69SvZKJh/9VgSL0G27b5xVYa8nethH3IERbi0YqJDXwAAAKhjwAdrY8AH awAAAAtzc2gtZWQyNTUxOQAAACB69SvZKJh/9VgSL0G27b5xVYa8nethH3IERbi0YqJDXw AAAEA9tGQi2IrprbOSbDCF+RmAHd6meNSXBUQ2ekKXm4/8xnr1K9komH/1WBIvQbbtvnFV hryd62EfcgRFuLRiokNfAAAAI2FsZXhfZ2F5bm9yQEFsZXhzLU1hY0Jvb2stQWlyLmxvY2 FsAQI= -----END OPENSSH PRIVATE KEY-----""" ) key = paramiko.Ed25519Key.from_private_key(key_io) hostname = '0.0.0.0' input_mock.return_value = 'no' ssh_connection = SSHConnection( hostname=hostname, known_hosts_file=self.known_hosts_file ) ssh_connection._socket = paramiko.SSHClient() with self.assertRaises( SystemExit, msg='User denied key. Host key verification failed.' ): hostkeys = paramiko.HostKeys(filename=self.known_hosts_file) ssh_connection._ssh_authentication_input_loop( hostkeys=hostkeys, key=key ) def test_disconnect(self): with patch('paramiko.SSHClient') as SSHClientMock: client_mock = SSHClientMock.return_value client_mock.exec_command.return_value = ['a', 'b', 'c'] ssh_connection = SSHConnection( known_hosts_file=self.known_hosts_file ) ssh_connection.connect() self.assertEqual(ssh_connection._stdin, 'a') self.assertEqual(ssh_connection._stdout, 'b') self.assertEqual(ssh_connection._stderr, 'c') ssh_connection.disconnect() # make sure the attributes have been deleted with self.assertRaises(AttributeError): type(ssh_connection._stdin) with self.assertRaises(AttributeError): type(ssh_connection._stdout) with self.assertRaises(AttributeError): type(ssh_connection._stderr) with self.assertRaises(AttributeError): type(ssh_connection._socket) with self.assertRaises(AttributeError): with self.assertLogs('gvm.connections', level='INFO') as cm: # disconnect twice should not work ... ssh_connection.disconnect() self.assertEqual( cm.output, [ 'Connection might already be' ' closed. No socket found.', ], ) ssh_connection._socket = None ssh_connection.disconnect() def test_disconnect_os_error(self): with patch('paramiko.SSHClient') as SSHClientMock: client_mock = SSHClientMock.return_value client_mock.exec_command.return_value = ['a', 'b', 'c'] client_mock.close.side_effect = OSError ssh_connection = SSHConnection( known_hosts_file=self.known_hosts_file ) ssh_connection.connect() with self.assertRaises(OSError): with self.assertLogs('gvm.connections', level='INFO') as cm: ssh_connection.disconnect() self.assertEqual(cm.output, ['Connection closing error: ']) def test_trigger_paramiko_ssh_except_in_get_remote_key(self): with patch('paramiko.transport.Transport') as TransportMock: client_mock = TransportMock.return_value client_mock.start_client.side_effect = paramiko.SSHException('foo') ssh_connection = SSHConnection( hostname="0.0.0.0", ) with self.assertRaises( GvmError, msg="Couldn't fetch the remote server key: foo", ): ssh_connection._get_remote_host_key() def test_trigger_oserror_in_get_remote_key_connect(self): with patch('socket.socket') as SocketMock: client_mock = SocketMock.return_value client_mock.connect.side_effect = OSError('foo') ssh_connection = SSHConnection( hostname="0.0.0.0", ) with self.assertRaises( GvmError, msg="Couldn't establish a connection to fetch the" "remote server key: foo", ): ssh_connection._get_remote_host_key() def test_trigger_oserror_in_get_remote_key_disconnect(self): with patch('paramiko.transport.Transport') as TransportMock: client_mock = TransportMock.return_value client_mock.close.side_effect = paramiko.SSHException('foo') ssh_connection = SSHConnection( hostname="0.0.0.0", ) with self.assertRaises( GvmError, msg="Couldn't close the connection to the" "remote server key: foo", ): ssh_connection._get_remote_host_key() def test_send(self): with patch('paramiko.SSHClient') as SSHClientMock: client_mock = SSHClientMock.return_value stdin = Mock() stdin.channel.send.return_value = 4 client_mock.exec_command.return_value = [stdin, None, None] ssh_connection = SSHConnection( known_hosts_file=self.known_hosts_file ) ssh_connection.connect() req = ssh_connection.send("blah") self.assertEqual(req, 4) ssh_connection.disconnect() def test_send_error(self): with patch('paramiko.SSHClient') as SSHClientMock: client_mock = SSHClientMock.return_value stdin = Mock() stdin.channel.send.return_value = None client_mock.exec_command.return_value = [stdin, None, None] ssh_connection = SSHConnection( known_hosts_file=self.known_hosts_file ) ssh_connection.connect() with self.assertRaises( GvmError, msg='Remote closed the connection' ): ssh_connection.send("blah") ssh_connection.disconnect() def test_send_and_slice(self): with patch('paramiko.SSHClient') as SSHClientMock: client_mock = SSHClientMock.return_value stdin = Mock() stdin.channel.send.side_effect = [2, 2] client_mock.exec_command.return_value = [stdin, None, None] ssh_connection = SSHConnection( known_hosts_file=self.known_hosts_file ) ssh_connection.connect() req = ssh_connection.send("blah") self.assertEqual(req, 4) stdin.channel.send.assert_called() with self.assertRaises(AssertionError): stdin.channel.send.assert_called_once() ssh_connection.disconnect() def test_read(self): with patch('paramiko.SSHClient') as SSHClientMock: client_mock = SSHClientMock.return_value stdout = Mock() stdout.channel.recv.return_value = b"foo bar baz" client_mock.exec_command.return_value = [None, stdout, None] ssh_connection = SSHConnection( known_hosts_file=self.known_hosts_file ) ssh_connection.connect() recved = ssh_connection._read() self.assertEqual(recved, b'foo bar baz') ssh_connection.disconnect() python-gvm-21.10.0/tests/connections/test_tls_connection.py000066400000000000000000000053161413122500400240760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from unittest.mock import Mock, patch from gvm.connections import ( TLSConnection, DEFAULT_HOSTNAME, DEFAULT_GVM_PORT, DEFAULT_TIMEOUT, ) class TLSConnectionTestCase(unittest.TestCase): # pylint: disable=protected-access, invalid-name def test_init_no_args(self): connection = TLSConnection() self.check_default_values(connection) def test_init_with_none(self): connection = TLSConnection( certfile=None, cafile=None, keyfile=None, hostname=None, port=None, password=None, timeout=None, ) self.check_default_values(connection) def check_default_values(self, tls_connection: TLSConnection): self.assertIsNone(tls_connection.certfile) self.assertIsNone(tls_connection.cafile) self.assertIsNone(tls_connection.keyfile) self.assertEqual(tls_connection.hostname, DEFAULT_HOSTNAME) self.assertEqual(tls_connection.port, DEFAULT_GVM_PORT) self.assertIsNone(tls_connection.password) self.assertEqual(tls_connection._timeout, DEFAULT_TIMEOUT) def test_connect(self): with patch('ssl.SSLContext') as SSHContextMock: context_mock = SSHContextMock.return_value connection = TLSConnection() connection.connect() context_mock.wrap_socket.assert_called_once() def test_connect_auth(self): with patch('ssl.SSLContext') as SSHContextMock: context_mock = SSHContextMock.return_value cert_file = Mock() ca_file = Mock() key_file = Mock() connection = TLSConnection( certfile=cert_file, cafile=ca_file, keyfile=key_file ) connection.connect() context_mock.load_cert_chain.assert_called_once() context_mock.wrap_socket.assert_called_once() self.assertFalse(context_mock.check_hostname) python-gvm-21.10.0/tests/connections/test_unix_socket_connection.py000066400000000000000000000112751413122500400256300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from unittest.mock import patch import os import socketserver import tempfile import threading import uuid from gvm.connections import ( UnixSocketConnection, DEFAULT_TIMEOUT, DEFAULT_UNIX_SOCKET_PATH, ) from gvm.errors import GvmError class DummyRequestHandler(socketserver.BaseRequestHandler): def handle(self): response = bytes( '', 'utf-8' ) self.request.sendall(response) class ThreadedUnixStreamServer( socketserver.ThreadingMixIn, socketserver.UnixStreamServer ): pass class UnixSocketConnectionTestCase(unittest.TestCase): # pylint: disable=protected-access, invalid-name def setUp(self): self.socketname = f"{tempfile.gettempdir()}/{str(uuid.uuid4())}.sock" self.sockserv = ThreadedUnixStreamServer( self.socketname, DummyRequestHandler ) self.server_thread = threading.Thread( target=self.sockserv.serve_forever ) self.server_thread.daemon = True self.server_thread.start() def tearDown(self): self.sockserv.shutdown() self.sockserv.server_close() os.unlink(self.socketname) def test_unix_socket_connection_connect_read(self): connection = UnixSocketConnection( path=self.socketname, timeout=DEFAULT_TIMEOUT ) connection.connect() resp = connection.read() self.assertEqual(resp, '') connection.disconnect() def test_unix_socket_connection_connect_send_bytes_read(self): connection = UnixSocketConnection( path=self.socketname, timeout=DEFAULT_TIMEOUT ) connection.connect() req = connection.send(bytes("", 'utf-8')) self.assertIsNone(req) resp = connection.read() self.assertEqual(resp, '') connection.disconnect() def test_unix_socket_connection_connect_send_str_read(self): connection = UnixSocketConnection( path=self.socketname, timeout=DEFAULT_TIMEOUT ) connection.connect() req = connection.send("") self.assertIsNone(req) resp = connection.read() self.assertEqual(resp, '') connection.disconnect() def test_unix_socket_connect_file_not_found(self): connection = UnixSocketConnection(path="foo", timeout=DEFAULT_TIMEOUT) with self.assertRaises(GvmError, msg='Socket foo does not exist'): connection.connect() connection.disconnect() def test_unix_socket_connect_could_not_connect(self): connection = UnixSocketConnection( path=self.socketname, timeout=DEFAULT_TIMEOUT ) with patch('socket.socket.connect') as ConnectMock: connect_mock = ConnectMock connect_mock.side_effect = ConnectionError with self.assertRaises( GvmError, msg=f'Could not connect to socket {self.socketname}' ): connection.connect() connection.disconnect() def test_unix_socket_send_unconnected_socket(self): connection = UnixSocketConnection( path=self.socketname, timeout=DEFAULT_TIMEOUT ) with self.assertRaises(GvmError, msg='Socket is not connected'): connection.send("/") def test_init_no_args(self): connection = UnixSocketConnection() self.check_default_values(connection) def test_init_with_none(self): connection = UnixSocketConnection(path=None, timeout=None) self.check_default_values(connection) def check_default_values(self, connection: UnixSocketConnection): self.assertEqual(connection._timeout, DEFAULT_TIMEOUT) self.assertEqual(connection.path, DEFAULT_UNIX_SOCKET_PATH) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/000077500000000000000000000000001413122500400171415ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/__init__.py000066400000000000000000000025321413122500400212540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from tests import CallableMock class MockConnection: def __init__(self): self.connect = CallableMock('connect') self.disconnect = CallableMock('disconnect') self.send = CallableMock('send') self.read = CallableMock('read') self.read.return_value('') self.finish_send = CallableMock('finish_send') class GmpTestCase(unittest.TestCase): gmp_class = None def setUp(self): self.connection = MockConnection() # pylint: disable=not-callable self.gmp = self.gmp_class(self.connection) python-gvm-21.10.0/tests/protocols/gmp/000077500000000000000000000000001413122500400177245ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmp/__init__.py000066400000000000000000000013641413122500400220410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/tests/protocols/gmp/test_context_manager.py000066400000000000000000000071131413122500400245150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from tests.protocols import GmpTestCase from gvm.errors import GvmError from gvm.protocols.gmp import Gmp from gvm.protocols.gmpv208 import Gmp as Gmpv208 from gvm.protocols.gmpv214 import Gmp as Gmpv214 class GmpContextManagerTestCase(GmpTestCase): gmp_class = Gmp def test_select_gmpv7(self): self.connection.read.return_value( '' '7.0' '' ) with self.assertRaises(GvmError): with self.gmp: pass def test_select_gmpv8(self): self.connection.read.return_value( '' '8.0' '' ) with self.assertRaises(GvmError): with self.gmp: pass def test_select_gmpv9(self): self.connection.read.return_value( '' '9.0' '' ) with self.assertRaises(GvmError): with self.gmp: pass def test_select_gmpv208(self): self.connection.read.return_value( '' '20.08' '' ) with self.gmp as gmp: self.assertEqual(gmp.get_protocol_version(), (20, 8)) self.assertIsInstance(gmp, Gmpv208) def test_select_gmpv214(self): self.connection.read.return_value( '' '21.04' '' ) with self.gmp as gmp: self.assertEqual(gmp.get_protocol_version(), (21, 4)) self.assertIsInstance(gmp, Gmpv214) def test_unknown_protocol(self): self.connection.read.return_value( '' '1.0' '' ) with self.assertRaises(GvmError): with self.gmp: pass def test_missing_version_in_response(self): self.connection.read.return_value( '' 'bar' '' ) with self.assertRaises(GvmError): with self.gmp: pass def test_invalid_response(self): self.connection.read.return_value('') with self.assertRaises(GvmError): with self.gmp: pass if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/000077500000000000000000000000001413122500400203445ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/__init__.py000066400000000000000000000015621413122500400224610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.protocols.gmpv208 import Gmp from .. import GmpTestCase class Gmpv208TestCase(GmpTestCase): gmp_class = Gmp python-gvm-21.10.0/tests/protocols/gmpv208/entities/000077500000000000000000000000001413122500400221705ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/__init__.py000066400000000000000000000013571413122500400243070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/000077500000000000000000000000001413122500400234625ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/__init__.py000066400000000000000000000022321413122500400255720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_alert import GmpCloneAlertTestMixin from .test_create_alert import GmpCreateAlertTestMixin from .test_delete_alert import GmpDeleteAlertTestMixin from .test_get_alert import GmpGetAlertTestMixin from .test_get_alerts import GmpGetAlertsTestMixin from .test_modify_alert import GmpModifyAlertTestMixin from .test_test_alert import GmpTestAlertTestMixin from .test_trigger_alert import GmpTriggerAlertTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/test_clone_alert.py000066400000000000000000000023121413122500400273600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneAlertTestMixin: def test_clone(self): self.gmp.clone_alert('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_alert('') with self.assertRaises(RequiredArgument): self.gmp.clone_alert(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/test_create_alert.py000066400000000000000000000346161413122500400275370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.protocols.gmpv208 import AlertCondition, AlertEvent, AlertMethod class GmpCreateAlertTestMixin: def test_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) with self.assertRaises(RequiredArgument): self.gmp.create_alert( name=None, condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) def test_missing_condition(self): with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='foo', condition='', event='bar', method='lorem' ) with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='foo', condition=None, event='bar', method='lorem' ) def test_missing_event(self): with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='foo', condition='bar', event='', method='lorem' ) with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='foo', condition='bar', event=None, method='lorem' ) def test_missing_method(self): with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='foo', condition='bar', event='lorem', method='' ) with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='foo', condition='bar', event='lorem', method=None ) def test_invalid_condition(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_alert( name='foo', condition='bar', event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) def test_invalid_event(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event='lorem', method=AlertMethod.EMAIL, ) def test_invalid_method(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method='ipsum', ) def test_invalid_condition_for_secinfo(self): with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.SEVERITY_AT_LEAST, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.EMAIL, ) def test_invalid_method_for_secinfo(self): with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.HTTP_GET, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.ALEMBA_VFIRE, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.SOURCEFIRE_CONNECTOR, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.START_TASK, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.TIPPINGPOINT_SMS, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.VERINICE_CONNECTOR, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.HTTP_GET, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.ALEMBA_VFIRE, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.SOURCEFIRE_CONNECTOR, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.START_TASK, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.TIPPINGPOINT_SMS, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.VERINICE_CONNECTOR, ) def test_missing_method_for_ticket_received(self): with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=None, ) def test_missing_condition_for_ticket_received(self): with self.assertRaises(RequiredArgument): self.gmp.create_alert( name='foo', condition=None, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.EMAIL, ) def test_invalid_method_for_ticket_received(self): with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.HTTP_GET, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SCP, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SEND, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SMB, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SNMP, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.ALEMBA_VFIRE, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.VERINICE_CONNECTOR, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.TIPPINGPOINT_SMS, ) with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SOURCEFIRE_CONNECTOR, ) def test_invalid_condition_for_task_run_status_changed(self): with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.ERROR, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) def test_invalid_condition_for_ticket_received(self): with self.assertRaises(InvalidArgument): self.gmp.create_alert( name='foo', condition=AlertCondition.FILTER_COUNT_AT_LEAST, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.EMAIL, ) def test_create_alert(self): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) self.connection.send.has_been_called_with( '' 'foo' 'Always' 'Task run status changed' 'Email' '' ) def test_create_alert_with_filter_id(self): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, filter_id='f1', ) self.connection.send.has_been_called_with( '' 'foo' 'Always' 'Task run status changed' 'Email' '' '' ) def test_create_alert_with_comment(self): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, comment='hello', ) self.connection.send.has_been_called_with( '' 'foo' 'Always' 'Task run status changed' 'Email' 'hello' '' ) def test_create_alert_with_condition_data(self): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, condition_data={'foo': 'bar'}, ) self.connection.send.has_been_called_with( '' 'foo' 'Alwaysbarfoo' 'Task run status changed' 'Email' '' ) def test_create_alert_with_event_data(self): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, event_data={'foo': 'bar'}, ) self.connection.send.has_been_called_with( '' 'foo' 'Always' 'Task run status changed' 'barfoo' '' 'Email' '' ) def test_create_alert_with_method_data(self): self.gmp.create_alert( name='foo', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, method_data={'foo': 'bar'}, ) self.connection.send.has_been_called_with( '' 'foo' 'Always' 'Task run status changed' 'Emailbarfoo' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/test_delete_alert.py000066400000000000000000000026341413122500400275310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpDeleteAlertTestMixin: def test_delete(self): self.gmp.delete_alert('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_alert('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_alert_id(self): with self.assertRaises(RequiredArgument): self.gmp.delete_alert(None) with self.assertRaises(RequiredArgument): self.gmp.delete_alert('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/test_get_alert.py000066400000000000000000000032641413122500400270460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetAlertTestMixin: def test_get_alert(self): self.gmp.get_alert('a1') self.connection.send.has_been_called_with('') self.gmp.get_alert(alert_id='a1') self.connection.send.has_been_called_with('') def test_get_alert_invalid_alert_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_alert(alert_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_alert(alert_id='') def test_get_alert_with_tasks(self): self.gmp.get_alert(alert_id='a1', tasks=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_alert(alert_id='a1', tasks=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/test_get_alerts.py000066400000000000000000000035051413122500400272270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetAlertsTestMixin: def test_get_alerts(self): self.gmp.get_alerts() self.connection.send.has_been_called_with('') def test_get_alerts_with_trash(self): self.gmp.get_alerts(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_alerts(trash=False) self.connection.send.has_been_called_with('') def test_get_alerts_with_filter_string(self): self.gmp.get_alerts(filter_string="foo=bar") self.connection.send.has_been_called_with( '' ) def test_get_alerts_with_filter_id(self): self.gmp.get_alerts(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_alerts_with_tasks(self): self.gmp.get_alerts(tasks=True) self.connection.send.has_been_called_with('') self.gmp.get_alerts(tasks=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/test_modify_alert.py000066400000000000000000000174561413122500400275660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import AlertCondition, AlertEvent, AlertMethod class GmpModifyAlertTestMixin: def test_modify_alert(self): self.gmp.modify_alert(alert_id='a1') self.connection.send.has_been_called_with( '' ) def test_modify_alert_without_alert_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_alert(alert_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_alert(alert_id='') with self.assertRaises(RequiredArgument): self.gmp.modify_alert('') def test_modify_alert_with_comment(self): self.gmp.modify_alert(alert_id='a1', comment='lorem') self.connection.send.has_been_called_with( '' 'lorem' '' ) def test_modify_alert_with_name(self): self.gmp.modify_alert(alert_id='a1', name='lorem') self.connection.send.has_been_called_with( '' 'lorem' '' ) def test_modify_alert_with_filter_id(self): self.gmp.modify_alert(alert_id='a1', filter_id='f1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_alert_invalid_condition(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_alert( alert_id='a1', condition='bar', event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.SCP, ) def test_modify_alert_invalid_event(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_alert( alert_id='a1', condition=AlertCondition.ALWAYS, event='lorem', method=AlertMethod.SCP, ) def test_modify_alert_invalid_method(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_alert( alert_id='a1', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method='ipsum', ) def test_modify_alert_with_event_missing_method(self): with self.assertRaisesRegex(RequiredArgument, "method is required"): self.gmp.modify_alert( alert_id='a1', event=AlertEvent.TASK_RUN_STATUS_CHANGED, condition=AlertCondition.ALWAYS, ) with self.assertRaisesRegex(RequiredArgument, "method is required"): self.gmp.modify_alert( alert_id='a1', event=AlertEvent.NEW_SECINFO_ARRIVED, condition=AlertCondition.ALWAYS, ) with self.assertRaisesRegex(RequiredArgument, "method is required"): self.gmp.modify_alert( alert_id='a1', event=AlertEvent.UPDATED_SECINFO_ARRIVED, condition=AlertCondition.ALWAYS, ) def test_modify_alert_with_event_missing_condition(self): with self.assertRaisesRegex(RequiredArgument, "condition is required"): self.gmp.modify_alert( alert_id='a1', event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.SCP, ) with self.assertRaisesRegex(RequiredArgument, "condition is required"): self.gmp.modify_alert( alert_id='a1', event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.SCP, ) with self.assertRaisesRegex(RequiredArgument, "condition is required"): self.gmp.modify_alert( alert_id='a1', event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.SCP, ) def test_modify_alert_invalid_condition_for_secinfo(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_alert( alert_id='a1', condition='Severity at least', event='Updated SecInfo arrived', method='Email', ) def test_modify_alert_invalid_method_for_secinfo(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_alert( alert_id='a1', condition='Always', event='Updated SecInfo arrived', method='HTTP Get', ) def test_modify_alert_with_event_data(self): self.gmp.modify_alert( alert_id='a1', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, event_data={'foo': 'bar'}, ) self.connection.send.has_been_called_with( '' 'Always' 'Email' 'Task run status changed' 'barfoo' '' '' ) def test_modify_alert_with_condition_data(self): self.gmp.modify_alert( alert_id='a1', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, condition_data={'foo': 'bar'}, ) self.connection.send.has_been_called_with( '' 'Alwaysbarfoo' 'Email' 'Task run status changed' '' ) def test_modify_alert_with_method_data(self): self.gmp.modify_alert( alert_id='a1', condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, method_data={'foo': 'bar'}, ) self.connection.send.has_been_called_with( '' 'Always' 'Emailbarfoo' 'Task run status changed' '' ) def test_modify_missing_method_for_ticket_received(self): with self.assertRaises(RequiredArgument): self.gmp.modify_alert( alert_id='a1', condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=None, ) def test_modify_missing_condition_for_ticket_received(self): with self.assertRaises(RequiredArgument): self.gmp.modify_alert( alert_id='a1', condition=None, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.EMAIL, ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/test_test_alert.py000066400000000000000000000022061413122500400272410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpTestAlertTestMixin: def test_test_alert(self): self.gmp.test_alert('a1') self.connection.send.has_been_called_with('') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.test_alert(None) with self.assertRaises(GvmError): self.gmp.test_alert('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/alerts/test_trigger_alert.py000066400000000000000000000063131413122500400277300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument from gvm.protocols.gmpv208.entities.report_formats import ReportFormatType class GmpTriggerAlertTestMixin: def test_trigger_alert_without_alert_id(self): with self.assertRaises(RequiredArgument): self.gmp.trigger_alert(alert_id=None, report_id='r1') with self.assertRaises(RequiredArgument): self.gmp.trigger_alert(alert_id='', report_id='r1') def test_trigger_alert_without_report_id(self): with self.assertRaises(RequiredArgument): self.gmp.trigger_alert(alert_id='a1', report_id=None) with self.assertRaises(RequiredArgument): self.gmp.trigger_alert(alert_id='a1', report_id='') def test_trigger_alert(self): self.gmp.trigger_alert(alert_id='a1', report_id='r1') self.connection.send.has_been_called_with( '' ) def test_trigger_alert_with_filter_string(self): self.gmp.trigger_alert( alert_id='a1', report_id='r1', filter_string='name=foo' ) self.connection.send.has_been_called_with( '' ) def test_trigger_alert_with_filter_id(self): self.gmp.trigger_alert(alert_id="a1", report_id='r1', filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_trigger_alert_with_report_format_id(self): self.gmp.trigger_alert( alert_id="a1", report_id='r1', report_format_id='bar' ) self.connection.send.has_been_called_with( '' ) def test_trigger_alert_with_report_format_type(self): self.gmp.trigger_alert( alert_id="a1", report_id='r1', report_format_id=ReportFormatType.SVG ) report_format_id = ReportFormatType.from_string('svg').value self.connection.send.has_been_called_with( '' ) def test_trigger_alert_with_delta_report_id(self): self.gmp.trigger_alert( alert_id='a1', report_id='r1', delta_report_id='r2' ) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/000077500000000000000000000000001413122500400234615ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/__init__.py000066400000000000000000000023151413122500400255730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_audit import GmpCloneAuditTestMixin from .test_create_audit import GmpCreateAuditTestMixin from .test_delete_audit import GmpDeleteAuditTestMixin from .test_get_audit import GmpGetAuditTestMixin from .test_get_audits import GmpGetAuditsTestMixin from .test_modify_audit import GmpModifyAuditTestMixin from .test_resume_audit import GmpResumeAuditTestMixin from .test_start_audit import GmpStartAuditTestMixin from .test_stop_audit import GmpStopAuditTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_clone_audit.py000066400000000000000000000023021413122500400273550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneAuditTestMixin: def test_clone(self): self.gmp.clone_audit('a1') self.connection.send.has_been_called_with( 'a1' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_audit('') with self.assertRaises(RequiredArgument): self.gmp.clone_audit(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_create_audit.py000066400000000000000000000317601413122500400275320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from collections import OrderedDict from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.protocols.gmpv208 import HostsOrdering class GmpCreateAuditTestMixin: def test_create_audit(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1' ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '' ) def test_create_audit_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_audit( name=None, policy_id='c1', target_id='t1', scanner_id='s1' ) with self.assertRaises(RequiredArgument): self.gmp.create_audit( name='', policy_id='c1', target_id='t1', scanner_id='s1' ) def test_create_audit_missing_policy_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_audit( name='foo', policy_id=None, target_id='t1', scanner_id='s1' ) with self.assertRaises(RequiredArgument): self.gmp.create_audit( name='foo', policy_id='', target_id='t1', scanner_id='s1' ) def test_create_audit_missing_target_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_audit( name='foo', policy_id='c1', target_id=None, scanner_id='s1' ) with self.assertRaises(RequiredArgument): self.gmp.create_audit( name='foo', policy_id='c1', target_id='', scanner_id='s1' ) def test_create_audit_missing_scanner_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id=None ) with self.assertRaises(RequiredArgument): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='' ) def test_create_audit_with_comment(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', comment='bar', ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' 'bar' '' ) def test_create_audit_single_alert(self): # pylint: disable=invalid-name self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', alert_ids=['a1'], ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '' '' ) def test_create_audit_multiple_alerts(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', alert_ids=['a1', 'a2', 'a3'], ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '' '' '' '' ) def test_create_audit_invalid_alerts(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', alert_ids='invalid', ) def test_create_audit_with_empty_alert_ids(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', alert_ids=[], ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '' ) def test_create_audit_with_alterable(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', alterable=True, ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '1' '' ) self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', alterable=False, ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '0' '' ) def test_create_audit_with_hosts_ordering(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', hosts_ordering=HostsOrdering.REVERSE, ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' 'reverse' '' ) def test_create_audit_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', hosts_ordering='foo', ) def test_create_audit_with_schedule(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '' '' ) def test_create_audit_with_schedule_and_schedule_periods(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', schedule_periods=0, ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '' '0' '' ) self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', schedule_periods=5, ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '' '5' '' ) def test_create_audit_with_schedule_and_invalid_schedule_periods(self): with self.assertRaises(InvalidArgument): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', schedule_periods='foo', ) with self.assertRaises(InvalidArgument): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', schedule_periods=-1, ) def test_create_audit_with_observers(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', observers=['u1', 'u2'], ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' 'u1,u2' '' ) def test_create_audit_invalid_observers(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', observers='', ) with self.assertRaises(InvalidArgumentType): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', observers='foo', ) def test_create_audit_with_preferences(self): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', preferences=OrderedDict([('foo', 'bar'), ('lorem', 'ipsum')]), ) self.connection.send.has_been_called_with( '' 'foo' 'audit' '' '' '' '' '' 'foo' 'bar' '' '' 'lorem' 'ipsum' '' '' '' ) def test_create_audit_invalid_preferences(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', preferences='', ) with self.assertRaises(InvalidArgumentType): self.gmp.create_audit( name='foo', policy_id='c1', target_id='t1', scanner_id='s1', preferences=['foo', 'bar'], ) def test_create_audit_don_t_allow_container_task(self): with self.assertRaises(InvalidArgument): self.gmp.create_audit( name='foo', policy_id='c1', target_id='0', scanner_id='s1', observers='', ) # target_id=0 is considered as False with self.assertRaises(RequiredArgument): self.gmp.create_audit( name='foo', policy_id='c1', target_id=0, scanner_id='s1', observers='', ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_delete_audit.py000066400000000000000000000025721413122500400275300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteAuditTestMixin: def test_delete(self): self.gmp.delete_audit('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_audit('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_audit(None) with self.assertRaises(GvmError): self.gmp.delete_audit('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_get_audit.py000066400000000000000000000022771413122500400270470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpGetAuditTestMixin: def test_get_audit(self): self.gmp.get_audit('a1') self.connection.send.has_been_called_with( '' ) def test_fail_without_audit_id(self): with self.assertRaises(GvmError): self.gmp.get_audit(None) with self.assertRaises(GvmError): self.gmp.get_audit('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_get_audits.py000066400000000000000000000043151413122500400272250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetAuditsTestMixin: def test_get_audits_simple(self): self.gmp.get_audits() self.connection.send.has_been_called_with( '' ) def test_get_audits_with_filter_string(self): self.gmp.get_audits(filter_string='name=foo') self.connection.send.has_been_called_with( '' ) def test_get_audits_with_filter_id(self): self.gmp.get_audits(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_audits_from_trash(self): self.gmp.get_audits(trash=True) self.connection.send.has_been_called_with( '' ) def test_get_audits_with_details(self): self.gmp.get_audits(details=True) self.connection.send.has_been_called_with( '' ) def test_get_audits_without_details(self): self.gmp.get_audits(details=False) self.connection.send.has_been_called_with( '' ) def test_get_audits_with_schedules_only(self): self.gmp.get_audits(schedules_only=True) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_modify_audit.py000066400000000000000000000165641413122500400275630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from collections import OrderedDict from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.protocols.gmpv208 import HostsOrdering class GmpModifyAuditTestMixin: def test_modify_task(self): self.gmp.modify_audit('t1') self.connection.send.has_been_called_with('') def test_modify_audit_missing_task_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_audit(None) with self.assertRaises(RequiredArgument): self.gmp.modify_audit('') with self.assertRaises(RequiredArgument): self.gmp.modify_audit(audit_id='') def test_modify_audit_with_name(self): self.gmp.modify_audit(audit_id='t1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_audit_with_policy_id(self): self.gmp.modify_audit(audit_id='t1', policy_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_audit_with_target_id(self): self.gmp.modify_audit(audit_id='t1', target_id='t1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_audit_with_scanner_id(self): self.gmp.modify_audit(audit_id='t1', scanner_id='s1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_audit_with_schedule_id(self): self.gmp.modify_audit(audit_id='t1', schedule_id='s1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_audit_with_comment(self): self.gmp.modify_audit(audit_id='t1', comment='bar') self.connection.send.has_been_called_with( '' 'bar' '' ) def test_modify_audit_with_alerts_ids(self): self.gmp.modify_audit(audit_id='t1', alert_ids=['a1', 'a2', 'a3']) self.connection.send.has_been_called_with( '' '' '' '' '' ) def test_modify_audit_invalid_alerts_ids(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_audit(audit_id='t1', alert_ids='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_audit(audit_id='t1', alert_ids='a1') def test_modify_audit_with_empty_alert_ids(self): self.gmp.modify_audit(audit_id='t1', alert_ids=[]) self.connection.send.has_been_called_with( '' '' '' ) def test_modify_audit_with_alterable(self): self.gmp.modify_audit(audit_id='t1', alterable=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_audit(audit_id='t1', alterable=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_audit_with_hosts_ordering(self): self.gmp.modify_audit( audit_id='t1', hosts_ordering=HostsOrdering.REVERSE ) self.connection.send.has_been_called_with( '' 'reverse' '' ) def test_modify_audit_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_audit(audit_id='t1', hosts_ordering='foo') def test_modify_audit_with_schedule(self): self.gmp.modify_audit(audit_id='t1', schedule_id='s1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_audit_with_schedule_periods(self): self.gmp.modify_audit(audit_id='t1', schedule_periods=0) self.connection.send.has_been_called_with( '' '0' '' ) self.gmp.modify_audit(audit_id='t1', schedule_periods=5) self.connection.send.has_been_called_with( '' '5' '' ) def test_modify_audit_invalid_schedule_periods(self): with self.assertRaises(InvalidArgument): self.gmp.modify_audit(audit_id='t1', schedule_periods='foo') with self.assertRaises(InvalidArgument): self.gmp.modify_audit(audit_id='t1', schedule_periods=-1) def test_modify_audit_with_observers(self): self.gmp.modify_audit(audit_id='t1', observers=['u1', 'u2']) self.connection.send.has_been_called_with( '' 'u1,u2' '' ) def test_modify_audit_invalid_observers(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_audit(audit_id='t1', observers='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_audit(audit_id='t1', observers='foo') def test_modify_audit_with_preferences(self): self.gmp.modify_audit( audit_id='t1', preferences=OrderedDict([('foo', 'bar'), ('lorem', 'ipsum')]), ) self.connection.send.has_been_called_with( '' '' '' 'foo' 'bar' '' '' 'lorem' 'ipsum' '' '' '' ) def test_modify_audit_invalid_preferences(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_audit(audit_id='t1', preferences='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_audit(audit_id='t1', preferences=['foo', 'bar']) python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_resume_audit.py000066400000000000000000000022201413122500400275540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpResumeAuditTestMixin: def test_resume_audit(self): self.gmp.resume_audit('a1') self.connection.send.has_been_called_with('') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.resume_audit(None) with self.assertRaises(GvmError): self.gmp.resume_audit('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_start_audit.py000066400000000000000000000022121413122500400274120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpStartAuditTestMixin: def test_start_audit(self): self.gmp.start_audit('a1') self.connection.send.has_been_called_with('') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.start_audit(None) with self.assertRaises(GvmError): self.gmp.start_audit('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/audits/test_stop_audit.py000066400000000000000000000022041413122500400272430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpStopAuditTestMixin: def test_stop_audit(self): self.gmp.stop_audit('a1') self.connection.send.has_been_called_with('') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.stop_audit(None) with self.assertRaises(GvmError): self.gmp.stop_audit('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/credentials/000077500000000000000000000000001413122500400244655ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/credentials/__init__.py000066400000000000000000000021521413122500400265760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_credential import GmpCloneCredentialTestMixin from .test_create_credential import GmpCreateCredentialTestMixin from .test_delete_credential import GmpDeleteCredentialTestMixin from .test_get_credential import GmpGetCredentialTestMixin from .test_get_credentials import GmpGetCredentialsTestMixin from .test_modify_credential import GmpModifyCredentialTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/credentials/test_clone_credential.py000066400000000000000000000023501413122500400313700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneCredentialTestMixin: def test_clone(self): self.gmp.clone_credential('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_credential('') with self.assertRaises(RequiredArgument): self.gmp.clone_credential(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/credentials/test_create_credential.py000066400000000000000000000332661413122500400315450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import ( CredentialType, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, ) class GmpCreateCredentialTestMixin: def test_create_up_credential_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_credential( name='', credential_type=CredentialType.USERNAME_PASSWORD, login='foo', ) with self.assertRaises(RequiredArgument): self.gmp.create_credential( name=None, credential_type=CredentialType.USERNAME_PASSWORD, login='foo', ) def test_create_up_credential(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.USERNAME_PASSWORD, comment='bar', login='Max', password='123', ) self.connection.send.has_been_called_with( '' 'foo' 'up' 'bar' 'Max' '123' '' ) def test_create_up_credential_with_allow_insecure(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.USERNAME_PASSWORD, comment='bar', login='Max', password='123', allow_insecure=True, ) self.connection.send.has_been_called_with( '' 'foo' 'up' 'bar' '1' 'Max' '123' '' ) self.gmp.create_credential( name='foo', credential_type=CredentialType.USERNAME_PASSWORD, comment='bar', login='Max', password='123', allow_insecure=False, ) self.connection.send.has_been_called_with( '' 'foo' 'up' 'bar' '0' 'Max' '123' '' ) def test_create_cc_credential_missing_certificate(self): with self.assertRaises(RequiredArgument): self.gmp.create_credential( name='foo', credential_type=CredentialType.CLIENT_CERTIFICATE ) def test_create_cc_credential(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.CLIENT_CERTIFICATE, certificate='abcdef', ) self.connection.send.has_been_called_with( '' 'foo' 'cc' 'abcdef' '' ) def test_create_cc_credential_with_private_key(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.CLIENT_CERTIFICATE, certificate='abcdef', private_key='123456', ) self.connection.send.has_been_called_with( '' 'foo' 'cc' 'abcdef' '' '123456' '' '' ) def test_create_usk_credential_missing_private_key(self): with self.assertRaises(RequiredArgument): self.gmp.create_credential( name='foo', credential_type=CredentialType.USERNAME_SSH_KEY, login='foo', ) def test_create_usk_credential_missing_login(self): with self.assertRaises(RequiredArgument): self.gmp.create_credential( name='foo', credential_type=CredentialType.USERNAME_SSH_KEY, private_key='123456', ) def test_create_usk_credential(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.USERNAME_SSH_KEY, private_key='123456', login='foo', ) self.connection.send.has_been_called_with( '' 'foo' 'usk' 'foo' '' '123456' '' '' ) def test_create_usk_credential_with_key_phrase(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.USERNAME_SSH_KEY, private_key='123456', login='foo', key_phrase='abcdef', ) self.connection.send.has_been_called_with( '' 'foo' 'usk' 'foo' '' '123456' 'abcdef' '' '' ) def test_create_snmp_credential_invalid_auth_algorithm(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo' ) with self.assertRaises(InvalidArgumentType): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm='', ) with self.assertRaises(InvalidArgumentType): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm='bar', ) def test_create_snmp_credential_auth_algorithm_md5(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm=SnmpAuthAlgorithm.MD5, ) self.connection.send.has_been_called_with( '' 'foo' 'snmp' 'foo' 'md5' '' ) def test_create_snmp_credential_auth_algorithm_sha1(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm=SnmpAuthAlgorithm.SHA1, ) self.connection.send.has_been_called_with( '' 'foo' 'snmp' 'foo' 'sha1' '' ) def test_create_snmp_credential_with_community(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm=SnmpAuthAlgorithm.SHA1, community='ipsum', ) self.connection.send.has_been_called_with( '' 'foo' 'snmp' 'foo' 'sha1' 'ipsum' '' ) def test_create_snmp_credential_invalid_privacy_algorithm(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm=SnmpAuthAlgorithm.SHA1, privacy_algorithm='', ) with self.assertRaises(InvalidArgumentType): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm=SnmpAuthAlgorithm.SHA1, privacy_algorithm='foo', ) def test_create_snmp_credential_with_privacy_algorithm_aes(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm=SnmpAuthAlgorithm.SHA1, privacy_algorithm=SnmpPrivacyAlgorithm.AES, ) self.connection.send.has_been_called_with( '' 'foo' 'snmp' 'foo' 'sha1' '' 'aes' '' '' ) def test_create_snmp_credential_with_privacy_algorithm_des(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm=SnmpAuthAlgorithm.SHA1, privacy_algorithm=SnmpPrivacyAlgorithm.DES, ) self.connection.send.has_been_called_with( '' 'foo' 'snmp' 'foo' 'sha1' '' 'des' '' '' ) def test_create_snmp_credential_with_privacy_password(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.SNMP, login='foo', auth_algorithm=SnmpAuthAlgorithm.SHA1, privacy_password='123', ) self.connection.send.has_been_called_with( '' 'foo' 'snmp' 'foo' 'sha1' '' '123' '' '' ) def test_create_smime_credential(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.SMIME_CERTIFICATE, certificate='ipsum', ) self.connection.send.has_been_called_with( '' 'foo' 'smime' 'ipsum' '' ) def test_create_smime_credential_missing_certificate(self): with self.assertRaises(RequiredArgument): self.gmp.create_credential( name='foo', credential_type=CredentialType.SMIME_CERTIFICATE ) def test_create_pgp_credential(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.PGP_ENCRYPTION_KEY, public_key='ipsum', ) self.connection.send.has_been_called_with( '' 'foo' 'pgp' '' 'ipsum' '' '' ) def test_create_pgp_credential_missing_public_key(self): with self.assertRaises(RequiredArgument): self.gmp.create_credential( name='foo', credential_type=CredentialType.PGP_ENCRYPTION_KEY ) def test_create_credential_invalid_credential_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_credential(name='foo', credential_type=None) with self.assertRaises(InvalidArgumentType): self.gmp.create_credential(name='foo', credential_type='') with self.assertRaises(InvalidArgumentType): self.gmp.create_credential(name='foo', credential_type='bar') def test_create_pw_credential_missing_password(self): with self.assertRaises(RequiredArgument): self.gmp.create_credential( name='foo', credential_type=CredentialType.PASSWORD_ONLY ) def test_create_pw_credential(self): self.gmp.create_credential( name='foo', credential_type=CredentialType.PASSWORD_ONLY, password='foo', ) self.connection.send.has_been_called_with( '' 'foo' 'pw' 'foo' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/credentials/test_delete_credential.py000066400000000000000000000026661413122500400315440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteCredentialTestMixin: def test_delete(self): self.gmp.delete_credential('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_credential('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_credential_id(self): with self.assertRaises(GvmError): self.gmp.delete_credential(None) with self.assertRaises(GvmError): self.gmp.delete_credential('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/credentials/test_get_credential.py000066400000000000000000000070071413122500400310530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import InvalidArgumentType, RequiredArgument from gvm.protocols.gmpv208 import CredentialFormat class GmpGetCredentialTestMixin: def test_get_credential(self): self.gmp.get_credential('id') self.connection.send.has_been_called_with( '' ) def test_get_credential_missing_credential_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_credential(None) def test_get_credential_invalid_credential_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_credential(credential_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_credential('') def test_get_credential_with_credential_format(self): self.gmp.get_credential('id', credential_format=CredentialFormat.KEY) self.connection.send.has_been_called_with( '' ) self.gmp.get_credential('id', credential_format=CredentialFormat.RPM) self.connection.send.has_been_called_with( '' ) self.gmp.get_credential('id', credential_format=CredentialFormat.DEB) self.connection.send.has_been_called_with( '' ) self.gmp.get_credential('id', credential_format=CredentialFormat.EXE) self.connection.send.has_been_called_with( '' ) self.gmp.get_credential('id', credential_format=CredentialFormat.PEM) self.connection.send.has_been_called_with( '' ) def test_get_credential_with_invalid_credential_format(self): with self.assertRaises(InvalidArgumentType): self.gmp.get_credential('id', credential_format='foo') def test_get_credential_with_scanners(self): self.gmp.get_credential('id', scanners=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_credential('id', scanners=False) self.connection.send.has_been_called_with( '' ) def test_get_credential_with_targets(self): self.gmp.get_credential('id', targets=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_credential('id', targets=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/credentials/test_get_credentials.py000066400000000000000000000046161413122500400312410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetCredentialsTestMixin: def test_get_credentials(self): self.gmp.get_credentials() self.connection.send.has_been_called_with('') def test_get_credentials_with_filter_string(self): self.gmp.get_credentials(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_credentials_with_filter_id(self): self.gmp.get_credentials(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_credentials_with_scanners(self): self.gmp.get_credentials(scanners=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_credentials(scanners=False) self.connection.send.has_been_called_with( '' ) def test_get_credentials_with_trash(self): self.gmp.get_credentials(trash=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_credentials(trash=False) self.connection.send.has_been_called_with( '' ) def test_get_credentials_with_targets(self): self.gmp.get_credentials(targets=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_credentials(targets=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/credentials/test_modify_credential.py000066400000000000000000000166331413122500400315700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import SnmpAuthAlgorithm, SnmpPrivacyAlgorithm class GmpModifyCredentialTestMixin: def test_modify_credential(self): self.gmp.modify_credential(credential_id='c1') self.connection.send.has_been_called_with( '' ) def test_modify_credential_missing_credential_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_credential(None) with self.assertRaises(RequiredArgument): self.gmp.modify_credential('') with self.assertRaises(RequiredArgument): self.gmp.modify_credential(credential_id='') def test_modify_credential_with_name(self): self.gmp.modify_credential(credential_id='c1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_credential_with_comment(self): self.gmp.modify_credential(credential_id='c1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_credential_with_certificate(self): self.gmp.modify_credential(credential_id='c1', certificate='abcdef') self.connection.send.has_been_called_with( '' 'abcdef' '' ) def test_modify_credential_with_private_key_and_key_phrase(self): self.gmp.modify_credential( credential_id='c1', private_key='123456', key_phrase='foo' ) self.connection.send.has_been_called_with( '' '' 'foo' '123456' '' '' ) def test_modify_credential_missing_private_key(self): with self.assertRaises(RequiredArgument): self.gmp.modify_credential(credential_id='c1', key_phrase='foo') def test_modify_credential_missing_key_phrase(self): with self.assertRaises(RequiredArgument): self.gmp.modify_credential(credential_id='c1', private_key='123456') def test_modify_credential_with_allow_insecure(self): self.gmp.modify_credential(credential_id='c1', allow_insecure=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_credential(credential_id='c1', allow_insecure=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_credential_with_login(self): self.gmp.modify_credential(credential_id='c1', login='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_credential_with_password(self): self.gmp.modify_credential(credential_id='c1', password='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_credential_with_auth_algorithm(self): self.gmp.modify_credential( credential_id='c1', auth_algorithm=SnmpAuthAlgorithm.MD5 ) self.connection.send.has_been_called_with( '' 'md5' '' ) self.gmp.modify_credential( credential_id='c1', auth_algorithm=SnmpAuthAlgorithm.SHA1 ) self.connection.send.has_been_called_with( '' 'sha1' '' ) def test_modify_credential_invalid_auth_algorithm(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_credential(credential_id='c1', auth_algorithm='foo') def test_modify_credential_with_community(self): self.gmp.modify_credential(credential_id='c1', community='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_credential_with_privacy_algorithm(self): self.gmp.modify_credential( credential_id='c1', privacy_algorithm=SnmpPrivacyAlgorithm.AES ) self.connection.send.has_been_called_with( '' '' 'aes' '' '' ) self.gmp.modify_credential( credential_id='c1', privacy_algorithm=SnmpPrivacyAlgorithm.DES ) self.connection.send.has_been_called_with( '' '' 'des' '' '' ) def test_modify_credential_invalid_privacy_algorithm(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_credential(credential_id='c1', privacy_algorithm='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_credential( credential_id='c1', privacy_algorithm='foo' ) def test_modify_credential_with_privacy_password(self): self.gmp.modify_credential(credential_id='c1', privacy_password='foo') self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) def test_modify_credential_with_public_key(self): self.gmp.modify_credential(credential_id='c1', public_key='foo') self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/filters/000077500000000000000000000000001413122500400236405ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/filters/__init__.py000066400000000000000000000020721413122500400257520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_filter import GmpCloneFilterTestMixin from .test_create_filter import GmpCreateFilterTestMixin from .test_delete_filter import GmpDeleteFilterTestMixin from .test_get_filter import GmpGetFilterTestMixin from .test_get_filters import GmpGetFiltersTestMixin from .test_modify_filter import GmpModifyFilterTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/filters/test_clone_filter.py000066400000000000000000000023201413122500400277130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneFilterTestMixin: def test_clone(self): self.gmp.clone_filter('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_filter('') with self.assertRaises(RequiredArgument): self.gmp.clone_filter(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/filters/test_create_filter.py000066400000000000000000000100011413122500400300510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import InvalidArgumentType, RequiredArgument from gvm.protocols.gmpv208 import FilterType class GmpCreateFilterTestMixin: def test_all_available_filters_types_correct(self): for filter_type in list(FilterType): self.gmp.create_filter( name='f1', term='sort-reverse=threat first=1 rows=1000', filter_type=filter_type, ) self.connection.send.has_been_called_with( '' 'f1' 'sort-reverse=threat first=1 rows=1000' f'{filter_type.value}' '' ) def test_create_filter_invalid_filter_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_filter( name='f1', term='sort-reverse=threat result_hosts_only=1 ' 'notes=1 overrides=1 levels=hml first=1 rows=1000', filter_type='foo', ) def test_create_filter_no_filter_type(self): self.gmp.create_filter( name='f1', term='sort-reverse=threat result_hosts_only=1 ' 'notes=1 overrides=1 levels=hml first=1 rows=1000', comment='foo', ) self.connection.send.has_been_called_with( '' 'f1' 'foo' 'sort-reverse=threat result_hosts_only=1 notes=1 ' 'overrides=1 levels=hml first=1 rows=1000' '' ) def test_create_filter(self): self.gmp.create_filter( name='f1', term='sort-reverse=threat result_hosts_only=1 ' 'notes=1 overrides=1 levels=hml first=1 rows=1000', filter_type=FilterType.TASK, comment='foo', ) self.connection.send.has_been_called_with( '' 'f1' 'foo' 'sort-reverse=threat result_hosts_only=1 notes=1 ' 'overrides=1 levels=hml first=1 rows=1000' 'task' '' ) def test_create_filter_without_term(self): self.gmp.create_filter( name='f1', filter_type=FilterType.TASK, comment='foo', ) self.connection.send.has_been_called_with( '' 'f1' 'foo' 'task' '' ) def test_create_filter_make_unique(self): with self.assertRaises(TypeError): self.gmp.create_filter( name='f1', term='sort-reverse=threat result_hosts_only=1 ' 'notes=1 overrides=1 levels=hml first=1 rows=1000', filter_type=FilterType.TASK, make_unique=True, comment='foo', ) def test_create_filter_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_filter('') with self.assertRaises(RequiredArgument): self.gmp.create_filter(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/filters/test_delete_filter.py000066400000000000000000000026161413122500400300650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteFilterTestMixin: def test_delete(self): self.gmp.delete_filter('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_filter('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_filter_id(self): with self.assertRaises(GvmError): self.gmp.delete_filter(None) with self.assertRaises(GvmError): self.gmp.delete_filter('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/filters/test_get_filter.py000066400000000000000000000033631413122500400274020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetFilterTestMixin: def test_get_filter(self): self.gmp.get_filter('f1') self.connection.send.has_been_called_with( '' ) self.gmp.get_filter(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_filter_missing_filter_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_filter(filter_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_filter('') def test_get_filter_with_alerts(self): self.gmp.get_filter(filter_id='f1', alerts=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_filter(filter_id='f1', alerts=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/filters/test_get_filters.py000066400000000000000000000035361413122500400275670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetFiltersTestMixin: def test_get_filters(self): self.gmp.get_filters() self.connection.send.has_been_called_with('') def test_get_filters_with_filter_string(self): self.gmp.get_filters(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_filters_with_filter_id(self): self.gmp.get_filters(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_filters_with_trash(self): self.gmp.get_filters(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_filters(trash=False) self.connection.send.has_been_called_with('') def test_get_filters_with_alerts(self): self.gmp.get_filters(alerts=True) self.connection.send.has_been_called_with('') self.gmp.get_filters(alerts=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/filters/test_modify_filter.py000066400000000000000000000052711413122500400301120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import FilterType class GmpModifyFilterTestMixin: def test_modify_filter(self): self.gmp.modify_filter(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_modify_filter_with_filter_type(self): self.gmp.modify_filter(filter_id='f1', filter_type=FilterType.TASK) self.connection.send.has_been_called_with( '' 'task' '' ) def test_modify_filter_invalid_filter_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_filter(filter_id='f1', filter_type='foo') def test_modify_filter_missing_filter_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_filter(filter_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_filter(filter_id='') with self.assertRaises(RequiredArgument): self.gmp.modify_filter('') def test_modify_filter_with_comment(self): self.gmp.modify_filter(filter_id='f1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_filter_with_name(self): self.gmp.modify_filter(filter_id='f1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_filter_with_term(self): self.gmp.modify_filter(filter_id='f1', term='foo=bar') self.connection.send.has_been_called_with( '' 'foo=bar' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/groups/000077500000000000000000000000001413122500400235075ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/groups/__init__.py000066400000000000000000000020561413122500400256230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_group import GmpCloneGroupTestMixin from .test_create_group import GmpCreateGroupTestMixin from .test_delete_group import GmpDeleteGroupTestMixin from .test_get_group import GmpGetGroupTestMixin from .test_get_groups import GmpGetGroupsTestMixin from .test_modify_group import GmpModifyGroupTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/groups/test_clone_group.py000066400000000000000000000023121413122500400274320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneGroupTestMixin: def test_clone(self): self.gmp.clone_group('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_group('') with self.assertRaises(RequiredArgument): self.gmp.clone_group(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/groups/test_create_group.py000066400000000000000000000044411413122500400276020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateGroupTestMixin: def test_create_group(self): self.gmp.create_group(name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_group(None) with self.assertRaises(RequiredArgument): self.gmp.create_group('') def test_create_group_with_comment(self): self.gmp.create_group(name='foo', comment='bar') self.connection.send.has_been_called_with( '' 'foo' 'bar' '' ) def test_create_special_group(self): self.gmp.create_group(name='foo', special=True) self.connection.send.has_been_called_with( '' 'foo' '' '' '' '' ) def test_create_group_with_users(self): self.gmp.create_group(name='foo', users=[]) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.create_group(name='foo', users=['u1', 'u2']) self.connection.send.has_been_called_with( '' 'foo' 'u1,u2' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/groups/test_delete_group.py000066400000000000000000000026041413122500400276000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteGroupTestMixin: def test_delete(self): self.gmp.delete_group('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_group('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_group_id(self): with self.assertRaises(GvmError): self.gmp.delete_group(None) with self.assertRaises(GvmError): self.gmp.delete_group('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/groups/test_get_group.py000066400000000000000000000024571413122500400271230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetGroupTestMixin: def test_get_group(self): self.gmp.get_group('f1') self.connection.send.has_been_called_with('') self.gmp.get_group(group_id='f1') self.connection.send.has_been_called_with('') def test_get_group_missing_group_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_group(group_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_group('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/groups/test_get_groups.py000066400000000000000000000030541413122500400273000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetGroupsTestMixin: def test_get_groups(self): self.gmp.get_groups() self.connection.send.has_been_called_with('') def test_get_groups_with_filter_string(self): self.gmp.get_groups(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_groups_with_filter_id(self): self.gmp.get_groups(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_groups_with_trash(self): self.gmp.get_groups(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_groups(trash=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/groups/test_modify_group.py000066400000000000000000000045221413122500400276260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyGroupTestMixin: def test_modify_group(self): self.gmp.modify_group(group_id='f1') self.connection.send.has_been_called_with( '' ) def test_modify_group_missing_group_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_group(group_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_group(group_id='') with self.assertRaises(RequiredArgument): self.gmp.modify_group('') def test_modify_group_with_comment(self): self.gmp.modify_group(group_id='f1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_group_with_name(self): self.gmp.modify_group(group_id='f1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_group_with_users(self): self.gmp.modify_group(group_id='f1', users=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_group(group_id='f1', users=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/hosts/000077500000000000000000000000001413122500400233305ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/hosts/__init__.py000066400000000000000000000017571413122500400254530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_create_host import GmpCreateHostTestMixin from .test_delete_host import GmpDeleteHostTestMixin from .test_get_host import GmpGetHostTestMixin from .test_get_hosts import GmpGetHostsTestMixin from .test_modify_host import GmpModifyHostTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/hosts/test_create_host.py000066400000000000000000000033131413122500400272410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateHostTestMixin: def test_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_host(name=None) with self.assertRaises(RequiredArgument): self.gmp.create_host(name='') def test_create_host_asset(self): self.gmp.create_host(name='ipsum') self.connection.send.has_been_called_with( '' '' 'host' 'ipsum' '' '' ) def test_create_asset_with_comment(self): self.gmp.create_host(name='ipsum', comment='lorem') self.connection.send.has_been_called_with( '' '' 'host' 'ipsum' 'lorem' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/hosts/test_delete_host.py000066400000000000000000000021421413122500400272370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteHostTestMixin: def test_delete_host(self): self.gmp.delete_host(host_id='a1') self.connection.send.has_been_called_with( '' ) def test_missing_arguments(self): with self.assertRaises(GvmError): self.gmp.delete_host(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/hosts/test_get_host.py000066400000000000000000000026571413122500400265670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetHostTestMixin: def test_get_host(self): self.gmp.get_host('a1') self.connection.send.has_been_called_with( '' ) self.gmp.get_host(host_id='a1') self.connection.send.has_been_called_with( '' ) def test_get_host_missing_host_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_host( host_id=None, ) with self.assertRaises(RequiredArgument): self.gmp.get_host( host_id='', ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/hosts/test_get_hosts.py000066400000000000000000000025061413122500400267430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetHostsTestMixin: def test_get_hosts(self): self.gmp.get_hosts() self.connection.send.has_been_called_with('') def test_get_hosts_with_filter_string(self): self.gmp.get_hosts(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_hosts_with_filter_id(self): self.gmp.get_hosts(filter_id='f1') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/hosts/test_modify_host.py000066400000000000000000000045071413122500400272730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyHostTestMixin: def test_modify_host(self): self.gmp.modify_host(host_id='a1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_host_without_host_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_host(host_id=None, comment='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_host(host_id='', comment='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_host('', comment='foo') def test_modify_host_with_comment(self): self.gmp.modify_host('a1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_host('a1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_host('a1', comment='') self.connection.send.has_been_called_with( '' '' '' ) self.gmp.modify_host('a1', comment=None) self.connection.send.has_been_called_with( '' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/notes/000077500000000000000000000000001413122500400233205ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/notes/__init__.py000066400000000000000000000020421413122500400254270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_note import GmpCloneNoteTestMixin from .test_create_note import GmpCreateNoteTestMixin from .test_delete_note import GmpDeleteNoteTestMixin from .test_get_note import GmpGetNoteTestMixin from .test_get_notes import GmpGetNotesTestMixin from .test_modify_note import GmpModifyNoteTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/notes/test_clone_note.py000066400000000000000000000023041413122500400270550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneNoteTestMixin: def test_clone(self): self.gmp.clone_note('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_note('') with self.assertRaises(RequiredArgument): self.gmp.clone_note(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/notes/test_create_note.py000066400000000000000000000135111413122500400272220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from decimal import Decimal from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import SeverityLevel class GmpCreateNoteTestMixin: def test_create_note(self): self.gmp.create_note('foo', nvt_oid='oid1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_note_missing_text(self): with self.assertRaises(RequiredArgument): self.gmp.create_note(None, 'od1') with self.assertRaises(RequiredArgument): self.gmp.create_note('', 'oid1') def test_create_note_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): self.gmp.create_note('foo', None) with self.assertRaises(RequiredArgument): self.gmp.create_note('foo', '') def test_create_note_with_hosts(self): self.gmp.create_note('foo', nvt_oid='oid1', hosts=[]) self.connection.send.has_been_called_with( '' 'foo' '' '' ) self.gmp.create_note('foo', nvt_oid='oid1', hosts=['h1', 'h2']) self.connection.send.has_been_called_with( '' 'foo' '' 'h1,h2' '' ) def test_create_note_with_port(self): self.gmp.create_note('foo', nvt_oid='oid1', port='666') self.connection.send.has_been_called_with( '' 'foo' '' '666' '' ) self.gmp.create_note('foo', nvt_oid='oid1', port=666) self.connection.send.has_been_called_with( '' 'foo' '' '666' '' ) def test_create_note_with_result_id(self): self.gmp.create_note('foo', nvt_oid='oid1', result_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_note_with_task_id(self): self.gmp.create_note('foo', nvt_oid='oid1', task_id='t1') self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_note_with_severity(self): self.gmp.create_note('foo', nvt_oid='oid1', severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_note('foo', nvt_oid='oid1', severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_note('foo', nvt_oid='oid1', severity=Decimal(5.5)) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) def test_create_note_with_threat(self): self.gmp.create_note('foo', nvt_oid='oid1', threat=SeverityLevel.HIGH) self.connection.send.has_been_called_with( '' 'foo' '' 'High' '' ) def test_create_note_invalid_threat(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_note('foo', nvt_oid='oid1', threat='') with self.assertRaises(InvalidArgumentType): self.gmp.create_note('foo', nvt_oid='oid1', threat='foo') def test_create_note_with_days_active(self): self.gmp.create_note('foo', nvt_oid='oid1', days_active=0) self.connection.send.has_been_called_with( '' 'foo' '' '0' '' ) self.gmp.create_note('foo', nvt_oid='oid1', days_active=-1) self.connection.send.has_been_called_with( '' 'foo' '' '-1' '' ) self.gmp.create_note('foo', nvt_oid='oid1', days_active=3600) self.connection.send.has_been_called_with( '' 'foo' '' '3600' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/notes/test_delete_note.py000066400000000000000000000025651413122500400272300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteNoteTestMixin: def test_delete(self): self.gmp.delete_note('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_note('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_note(None) with self.assertRaises(GvmError): self.gmp.delete_note('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/notes/test_get_note.py000066400000000000000000000025451413122500400265430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetNoteTestMixin: def test_get_note(self): self.gmp.get_note('n1') self.connection.send.has_been_called_with( '' ) self.gmp.get_note(note_id='n1') self.connection.send.has_been_called_with( '' ) def test_get_note_missing_note_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_note(note_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_note('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/notes/test_get_notes.py000066400000000000000000000035001413122500400267160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetNotesTestMixin: def test_get_notes(self): self.gmp.get_notes() self.connection.send.has_been_called_with('') def test_get_notes_with_filter_string(self): self.gmp.get_notes(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_notes_with_filter_id(self): self.gmp.get_notes(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_notes_with_details(self): self.gmp.get_notes(details=True) self.connection.send.has_been_called_with('') self.gmp.get_notes(details=False) self.connection.send.has_been_called_with('') def test_get_notes_with_result(self): self.gmp.get_notes(result=True) self.connection.send.has_been_called_with('') self.gmp.get_notes(result=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/notes/test_modify_note.py000066400000000000000000000136101413122500400272460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from decimal import Decimal from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import SeverityLevel class GmpModifyNoteTestMixin: def test_modify_note(self): self.gmp.modify_note(note_id='n1', text='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_note_missing_note_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_note(note_id=None, text='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_note(note_id='', text='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_note('', text='foo') def test_modify_note_missing_text(self): with self.assertRaises(RequiredArgument): self.gmp.modify_note(note_id='n1', text='') with self.assertRaises(RequiredArgument): self.gmp.modify_note(note_id='n1', text=None) with self.assertRaises(RequiredArgument): self.gmp.modify_note('n1', '') def test_modify_note_with_days_active(self): self.gmp.modify_note(note_id='n1', text='foo', days_active=0) self.connection.send.has_been_called_with( '' 'foo' '0' '' ) self.gmp.modify_note(note_id='n1', text='foo', days_active=-1) self.connection.send.has_been_called_with( '' 'foo' '-1' '' ) self.gmp.modify_note(note_id='n1', text='foo', days_active=600) self.connection.send.has_been_called_with( '' 'foo' '600' '' ) def test_modify_note_with_port(self): self.gmp.modify_note(note_id='n1', text='foo', port='123') self.connection.send.has_been_called_with( '' 'foo' '123' '' ) self.gmp.modify_note(note_id='n1', text='foo', port=123) self.connection.send.has_been_called_with( '' 'foo' '123' '' ) def test_modify_note_with_hosts(self): self.gmp.modify_note(note_id='n1', text='foo', hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' ) self.gmp.modify_note(note_id='n1', text='foo', hosts=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo' 'foo,bar' '' ) def test_modify_note_with_result_id(self): self.gmp.modify_note(note_id='n1', text='foo', result_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_modify_note_with_task_id(self): self.gmp.modify_note(note_id='n1', text='foo', task_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_modify_note_with_severity(self): self.gmp.modify_note(note_id='n1', text='foo', severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_note(note_id='n1', text='foo', severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_note(note_id='n1', text='foo', severity=Decimal(5.5)) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) def test_modify_note_with_threat(self): self.gmp.modify_note( note_id='n1', text='foo', threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' 'High' '' ) def test_modify_note_invalid_threat(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_note(note_id='n1', text='foo', threat='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_note(note_id='n1', text='foo', threat='foo') python-gvm-21.10.0/tests/protocols/gmpv208/entities/operating_systems/000077500000000000000000000000001413122500400257475ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/operating_systems/__init__.py000066400000000000000000000020261413122500400300600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_delete_operating_system import GmpDeleteOperatingSystemTestMixin from .test_get_operating_system import GmpGetOperatingSystemTestMixin from .test_get_operating_systems import GmpGetOperatingSystemsTestMixin from .test_modify_operating_system import GmpModifyOperatingSystemTestMixin test_delete_operating_system.py000066400000000000000000000022351413122500400342210ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/operating_systems# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteOperatingSystemTestMixin: def test_delete_operating_system(self): self.gmp.delete_operating_system(operating_system_id='a1') self.connection.send.has_been_called_with( '' ) def test_missing_arguments(self): with self.assertRaises(GvmError): self.gmp.delete_operating_system(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/operating_systems/test_get_operating_system.py000066400000000000000000000027441413122500400336220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetOperatingSystemTestMixin: def test_get_operating_system(self): self.gmp.get_operating_system('a1') self.connection.send.has_been_called_with( '' ) self.gmp.get_operating_system(operating_system_id='a1') self.connection.send.has_been_called_with( '' ) def test_get_asset_missing_operating_system_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_operating_system(operating_system_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_operating_system(operating_system_id='') python-gvm-21.10.0/tests/protocols/gmpv208/entities/operating_systems/test_get_operating_systems.py000066400000000000000000000026231413122500400340010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetOperatingSystemsTestMixin: def test_get_operating_systems(self): self.gmp.get_operating_systems() self.connection.send.has_been_called_with('') def test_get_operating_systems_with_filter_string(self): self.gmp.get_operating_systems(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_operating_systems_with_filter_id(self): self.gmp.get_operating_systems(filter_id='f1') self.connection.send.has_been_called_with( '' ) test_modify_operating_system.py000066400000000000000000000051021413122500400342420ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/operating_systems# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyOperatingSystemTestMixin: def test_modify_operating_system(self): self.gmp.modify_operating_system(operating_system_id='a1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_operating_system_without_operating_system_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_operating_system( operating_system_id=None, comment='foo' ) with self.assertRaises(RequiredArgument): self.gmp.modify_operating_system( operating_system_id='', comment='foo' ) with self.assertRaises(RequiredArgument): self.gmp.modify_operating_system('', comment='foo') def test_modify_operating_system_with_comment(self): self.gmp.modify_operating_system('a1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_operating_system('a1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_operating_system('a1', comment='') self.connection.send.has_been_called_with( '' '' '' ) self.gmp.modify_operating_system('a1', comment=None) self.connection.send.has_been_called_with( '' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/overrides/000077500000000000000000000000001413122500400241725ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/overrides/__init__.py000066400000000000000000000021221413122500400263000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_override import GmpCloneOverrideTestMixin from .test_create_override import GmpCreateOverrideTestMixin from .test_delete_override import GmpDeleteOverrideTestMixin from .test_get_override import GmpGetOverrideTestMixin from .test_get_overrides import GmpGetOverridesTestMixin from .test_modify_override import GmpModifyOverrideTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/overrides/test_clone_override.py000066400000000000000000000023341413122500400306040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneOverrideTestMixin: def test_clone(self): self.gmp.clone_override('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_override('') with self.assertRaises(RequiredArgument): self.gmp.clone_override(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/overrides/test_create_override.py000066400000000000000000000174261413122500400307570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from decimal import Decimal from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import SeverityLevel class GmpCreateOverrideTestMixin: def test_create_override(self): self.gmp.create_override('foo', nvt_oid='oid1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_override_missing_text(self): with self.assertRaises(RequiredArgument): self.gmp.create_override(None, 'od1') with self.assertRaises(RequiredArgument): self.gmp.create_override('', 'oid1') def test_create_override_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): self.gmp.create_override('foo', None) with self.assertRaises(RequiredArgument): self.gmp.create_override('foo', '') def test_create_override_with_hosts(self): self.gmp.create_override('foo', nvt_oid='oid1', hosts=[]) self.connection.send.has_been_called_with( '' 'foo' '' '' ) self.gmp.create_override('foo', nvt_oid='oid1', hosts=['h1', 'h2']) self.connection.send.has_been_called_with( '' 'foo' '' 'h1,h2' '' ) def test_create_override_with_port(self): self.gmp.create_override('foo', nvt_oid='oid1', port='666') self.connection.send.has_been_called_with( '' 'foo' '' '666' '' ) self.gmp.create_override('foo', nvt_oid='oid1', port=666) self.connection.send.has_been_called_with( '' 'foo' '' '666' '' ) def test_create_override_with_result_id(self): self.gmp.create_override('foo', nvt_oid='oid1', result_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_override_with_task_id(self): self.gmp.create_override('foo', nvt_oid='oid1', task_id='t1') self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_override_with_severity(self): self.gmp.create_override('foo', nvt_oid='oid1', severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_override('foo', nvt_oid='oid1', severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_override('foo', nvt_oid='oid1', severity=Decimal(5.5)) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) def test_create_override_with_new_severity(self): self.gmp.create_override('foo', nvt_oid='oid1', new_severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_override('foo', nvt_oid='oid1', new_severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_override( 'foo', nvt_oid='oid1', new_severity=Decimal(5.5) ) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) def test_create_override_with_threat(self): self.gmp.create_override( 'foo', nvt_oid='oid1', threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' '' 'High' '' ) def test_create_override_invalid_threat(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_override('foo', nvt_oid='oid1', threat='') with self.assertRaises(InvalidArgumentType): self.gmp.create_override('foo', nvt_oid='oid1', threat='foo') def test_create_override_with_new_threat(self): self.gmp.create_override( 'foo', nvt_oid='oid1', new_threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' '' 'High' '' ) def test_create_override_invalid_new_threat(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_override('foo', nvt_oid='oid1', new_threat='') with self.assertRaises(InvalidArgumentType): self.gmp.create_override('foo', nvt_oid='oid1', new_threat='foo') def test_create_override_with_days_active(self): self.gmp.create_override('foo', nvt_oid='oid1', days_active=0) self.connection.send.has_been_called_with( '' 'foo' '' '0' '' ) self.gmp.create_override('foo', nvt_oid='oid1', days_active=-1) self.connection.send.has_been_called_with( '' 'foo' '' '-1' '' ) self.gmp.create_override('foo', nvt_oid='oid1', days_active=3600) self.connection.send.has_been_called_with( '' 'foo' '' '3600' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/overrides/test_delete_override.py000066400000000000000000000026311413122500400307460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteOverrideTestMixin: def test_delete(self): self.gmp.delete_override('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_override('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_override(None) with self.assertRaises(GvmError): self.gmp.delete_override('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/overrides/test_get_override.py000066400000000000000000000026351413122500400302670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetOverrideTestMixin: def test_get_override(self): self.gmp.get_override('o1') self.connection.send.has_been_called_with( '' ) self.gmp.get_override(override_id='o1') self.connection.send.has_been_called_with( '' ) def test_get_override_missing_override_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_override(override_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_override('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/overrides/test_get_overrides.py000066400000000000000000000037221413122500400304500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetOverridesTestMixin: def test_get_overrides(self): self.gmp.get_overrides() self.connection.send.has_been_called_with('') def test_get_overrides_with_filter_string(self): self.gmp.get_overrides(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_overrides_with_filter_id(self): self.gmp.get_overrides(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_overrides_with_details(self): self.gmp.get_overrides(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_overrides(details=False) self.connection.send.has_been_called_with( '' ) def test_get_overrides_with_result(self): self.gmp.get_overrides(result=True) self.connection.send.has_been_called_with('') self.gmp.get_overrides(result=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/overrides/test_modify_override.py000066400000000000000000000201271413122500400307730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from decimal import Decimal from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import SeverityLevel class GmpModifyOverrideTestMixin: def test_modify_override(self): self.gmp.modify_override(override_id='o1', text='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_override_missing_override_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_override(override_id=None, text='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_override(override_id='', text='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_override('', text='foo') def test_modify_override_missing_text(self): with self.assertRaises(RequiredArgument): self.gmp.modify_override(override_id='o1', text='') with self.assertRaises(RequiredArgument): self.gmp.modify_override(override_id='o1', text=None) with self.assertRaises(RequiredArgument): self.gmp.modify_override('o1', '') def test_modify_override_with_days_active(self): self.gmp.modify_override(override_id='o1', text='foo', days_active=0) self.connection.send.has_been_called_with( '' 'foo' '0' '' ) self.gmp.modify_override(override_id='o1', text='foo', days_active=-1) self.connection.send.has_been_called_with( '' 'foo' '-1' '' ) self.gmp.modify_override(override_id='o1', text='foo', days_active=600) self.connection.send.has_been_called_with( '' 'foo' '600' '' ) def test_modify_override_with_port(self): self.gmp.modify_override(override_id='o1', text='foo', port='123') self.connection.send.has_been_called_with( '' 'foo' '123' '' ) self.gmp.modify_override(override_id='o1', text='foo', port=123) self.connection.send.has_been_called_with( '' 'foo' '123' '' ) def test_modify_override_with_hosts(self): self.gmp.modify_override(override_id='o1', text='foo', hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' ) self.gmp.modify_override( override_id='o1', text='foo', hosts=['foo', 'bar'] ) self.connection.send.has_been_called_with( '' 'foo' 'foo,bar' '' ) def test_modify_override_with_result_id(self): self.gmp.modify_override(override_id='o1', text='foo', result_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_modify_override_with_task_id(self): self.gmp.modify_override(override_id='o1', text='foo', task_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_modify_override_with_severity(self): self.gmp.modify_override(override_id='o1', text='foo', severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_override(override_id='o1', text='foo', severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_override( override_id='o1', text='foo', severity=Decimal(5.5) ) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) def test_modify_override_with_new_severity(self): self.gmp.modify_override( override_id='o1', text='foo', new_severity='5.5' ) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_override(override_id='o1', text='foo', new_severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_override( override_id='o1', text='foo', new_severity=Decimal(5.5) ) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) def test_modify_override_with_threat(self): self.gmp.modify_override( override_id='o1', text='foo', threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' 'High' '' ) def test_modify_override_invalid_threat(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_override(override_id='o1', text='foo', threat='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_override(override_id='o1', text='foo', threat='foo') def test_modify_override_with_new_threat(self): self.gmp.modify_override( override_id='o1', text='foo', new_threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' 'High' '' ) def test_modify_override_invalid_new_threat(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_override( override_id='o1', text='foo', new_threat='' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_override( override_id='o1', text='foo', new_threat='foo' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/permissions/000077500000000000000000000000001413122500400245435ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/permissions/__init__.py000066400000000000000000000021521413122500400266540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_permission import GmpClonePermissionTestMixin from .test_create_permission import GmpCreatePermissionTestMixin from .test_delete_permission import GmpDeletePermissionTestMixin from .test_get_permission import GmpGetPermissionTestMixin from .test_get_permissions import GmpGetPermissionsTestMixin from .test_modify_permission import GmpModifyPermissionTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/permissions/test_clone_permission.py000066400000000000000000000023501413122500400315240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpClonePermissionTestMixin: def test_clone(self): self.gmp.clone_permission('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_permission('') with self.assertRaises(RequiredArgument): self.gmp.clone_permission(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/permissions/test_create_permission.py000066400000000000000000000142361413122500400316750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import PermissionSubjectType, EntityType class GmpCreatePermissionTestMixin: def test_create_permission(self): self.gmp.create_permission( 'foo', subject_id='u1', subject_type=PermissionSubjectType.USER ) self.connection.send.has_been_called_with( '' 'foo' '' 'user' '' '' ) def test_create_permission_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_permission( None, subject_id='u1', subject_type=PermissionSubjectType.USER ) with self.assertRaises(RequiredArgument): self.gmp.create_permission( '', subject_id='u1', subject_type=PermissionSubjectType.USER ) def test_create_permission_missing_subject_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_permission( 'create_task', subject_id=None, subject_type=PermissionSubjectType.USER, ) with self.assertRaises(RequiredArgument): self.gmp.create_permission( 'create_task', subject_id='', subject_type=PermissionSubjectType.USER, ) def test_create_permission_invalid_subject_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type='' ) with self.assertRaises(InvalidArgumentType): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type=None ) with self.assertRaises(InvalidArgumentType): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type='foo' ) def test_create_permission_with_comment(self): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type=PermissionSubjectType.USER, comment='foo', ) self.connection.send.has_been_called_with( '' 'create_task' '' 'user' '' 'foo' '' ) def test_create_permission_missing_resource_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type=PermissionSubjectType.USER, resource_type=EntityType.TASK, ) def test_create_permission_missing_resource_type(self): with self.assertRaises(RequiredArgument): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type=PermissionSubjectType.USER, resource_id='t1', ) def test_create_permission_invalid_resource_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type=PermissionSubjectType.USER, resource_type='foo', resource_id='t1', ) def test_create_permission_with_resource(self): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type=PermissionSubjectType.USER, resource_id='t1', resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( '' 'create_task' '' 'user' '' '' 'task' '' '' ) def test_create_permission_with_resource_type_audit(self): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type=PermissionSubjectType.USER, resource_id='t1', resource_type=EntityType.AUDIT, ) self.connection.send.has_been_called_with( '' 'create_task' '' 'user' '' '' 'task' '' '' ) def test_create_permission_with_resource_type_policy(self): self.gmp.create_permission( 'create_task', subject_id='u1', subject_type=PermissionSubjectType.USER, resource_id='t1', resource_type=EntityType.POLICY, ) self.connection.send.has_been_called_with( '' 'create_task' '' 'user' '' '' 'config' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/permissions/test_delete_permission.py000066400000000000000000000026531413122500400316740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeletePermissionTestMixin: def test_delete(self): self.gmp.delete_permission('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_permission('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_permission(None) with self.assertRaises(GvmError): self.gmp.delete_permission('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/permissions/test_get_permission.py000066400000000000000000000026411413122500400312060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetPermissionTestMixin: def test_get_permission(self): self.gmp.get_permission('p1') self.connection.send.has_been_called_with( '' ) self.gmp.get_permission(permission_id='p1') self.connection.send.has_been_called_with( '' ) def test_get_permission_missing_permission_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_permission(permission_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_permission('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/permissions/test_get_permissions.py000066400000000000000000000032711413122500400313710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetPermissionsTestMixin: def test_get_permissions(self): self.gmp.get_permissions() self.connection.send.has_been_called_with('') def test_get_permissions_with_filter_string(self): self.gmp.get_permissions(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_permissions_with_filter_id(self): self.gmp.get_permissions(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_permissions_with_trash(self): self.gmp.get_permissions(trash=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_permissions(trash=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/permissions/test_modify_permission.py000066400000000000000000000164701413122500400317230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import PermissionSubjectType, EntityType class GmpModifyPermissionTestMixin: def test_modify_permission(self): self.gmp.modify_permission(permission_id='p1') self.connection.send.has_been_called_with( '' ) def test_modify_permission_missing_permission_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_permission(permission_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_permission(permission_id='') with self.assertRaises(RequiredArgument): self.gmp.modify_permission('') def test_modify_permission_with_comment(self): self.gmp.modify_permission(permission_id='p1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_permission_with_resource_id_and_type(self): self.gmp.modify_permission( permission_id='p1', resource_id='r1', resource_type=EntityType.TASK ) self.connection.send.has_been_called_with( '' '' 'task' '' '' ) def test_modify_permission_with_resource_id_and_type_audit(self): self.gmp.modify_permission( permission_id='p1', resource_id='r1', resource_type=EntityType.AUDIT ) self.connection.send.has_been_called_with( '' '' 'task' '' '' ) def test_modify_permission_with_resource_id_and_type_policy(self): self.gmp.modify_permission( permission_id='p1', resource_id='r1', resource_type=EntityType.POLICY, ) self.connection.send.has_been_called_with( '' '' 'config' '' '' ) def test_modify_permission_with_missing_resource_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id='p1', resource_id='', resource_type=EntityType.TASK, ) with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id='p1', resource_type=EntityType.TASK ) with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id='p1', resource_id=None, resource_type=EntityType.TASK, ) def test_modify_permission_with_missing_resource_type(self): with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id='p1', resource_id='r1', resource_type='' ) with self.assertRaises(RequiredArgument): self.gmp.modify_permission(permission_id='p1', resource_id='r1') with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id='p1', resource_id='r1', resource_type=None ) def test_modify_permission_with_invalid_resource_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_permission( permission_id='p1', resource_id='r1', resource_type='blah' ) def test_modify_permission_with_subject_id_and_type(self): self.gmp.modify_permission( permission_id='p1', subject_id='s1', subject_type=PermissionSubjectType.ROLE, ) self.connection.send.has_been_called_with( '' '' 'role' '' '' ) self.gmp.modify_permission( permission_id='p1', subject_id='s1', subject_type=PermissionSubjectType.USER, ) self.connection.send.has_been_called_with( '' '' 'user' '' '' ) self.gmp.modify_permission( permission_id='p1', subject_id='s1', subject_type=PermissionSubjectType.GROUP, ) self.connection.send.has_been_called_with( '' '' 'group' '' '' ) def test_modify_permission_missing_subject_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id='p1', subject_type=PermissionSubjectType.ROLE ) with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id='p1', subject_type=PermissionSubjectType.ROLE, subject_id='', ) with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id='p1', subject_type=PermissionSubjectType.ROLE, subject_id=None, ) def test_modify_permission_invalid_subject_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_permission( permission_id='p1', subject_id='s1', subject_type='foo' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_permission( permission_id='p1', subject_id='s1', subject_type='' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_permission( permission_id='p1', subject_id='s1', subject_type=None ) def test_modify_permission_with_name(self): self.gmp.modify_permission(permission_id='p1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/000077500000000000000000000000001413122500400237775ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/__init__.py000066400000000000000000000032041413122500400261070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_policy import GmpClonePolicyTestMixin from .test_create_policy import GmpCreatePolicyTestMixin from .test_delete_policy import GmpDeletePolicyTestMixin from .test_get_policy import GmpGetPolicyTestMixin from .test_get_policies import GmpGetPoliciesTestMixin from .test_import_policy import GmpImportPolicyTestMixin from .test_modify_policy_set_comment import ( GmpModifyPolicySetCommentTestMixin, ) from .test_modify_policy_set_family_selection import ( GmpModifyPolicySetFamilySelectionTestMixin, ) from .test_modify_policy_set_name import ( GmpModifyPolicySetNameTestMixin, ) from .test_modify_policy_set_nvt_preference import ( GmpModifyPolicySetNvtPreferenceTestMixin, ) from .test_modify_policy_set_nvt_selection import ( GmpModifyPolicySetNvtSelectionTestMixin, ) from .test_modify_policy_set_scanner_preference import ( GmpModifyPolicySetScannerPreferenceTestMixin, ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_clone_policy.py000066400000000000000000000023121413122500400300650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpClonePolicyTestMixin: def test_clone(self): self.gmp.clone_policy('a1') self.connection.send.has_been_called_with( 'a1' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_policy('') with self.assertRaises(RequiredArgument): self.gmp.clone_policy(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_create_policy.py000066400000000000000000000034271413122500400302400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreatePolicyTestMixin: def test_create_policy(self): self.gmp.create_policy('foo') self.connection.send.has_been_called_with( '' '085569ce-73ed-11df-83c3-002264764cea' 'foo' 'policy' '' ) def test_create_with_policy_id_and_comment(self): self.gmp.create_policy('foo', policy_id='p1', comment="foo") self.connection.send.has_been_called_with( '' 'foo' 'p1' 'foo' 'policy' '' ) def test_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_policy(policy_id='c1', name=None) with self.assertRaises(RequiredArgument): self.gmp.create_policy(policy_id='c1', name='') python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_delete_policy.py000066400000000000000000000026161413122500400302360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeletePolicyTestMixin: def test_delete(self): self.gmp.delete_policy('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_policy('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_config_id(self): with self.assertRaises(GvmError): self.gmp.delete_policy(None) with self.assertRaises(GvmError): self.gmp.delete_policy('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_get_policies.py000066400000000000000000000064731413122500400300700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetPoliciesTestMixin: def test_get_policies_simple(self): self.gmp.get_policies() self.connection.send.has_been_called_with( '' ) def test_get_policies_with_filter_string(self): self.gmp.get_policies(filter_string='name=foo') self.connection.send.has_been_called_with( '' ) def test_get_policies_with_filter_id(self): self.gmp.get_policies(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_policies_from_trash(self): self.gmp.get_policies(trash=True) self.connection.send.has_been_called_with( '' ) def test_get_policies_with_details(self): self.gmp.get_policies(details=True) self.connection.send.has_been_called_with( '' ) def test_get_policies_without_details(self): self.gmp.get_policies(details=False) self.connection.send.has_been_called_with( '' ) def test_get_policies_with_families(self): self.gmp.get_policies(families=True) self.connection.send.has_been_called_with( '' ) def test_get_policies_without_families(self): self.gmp.get_policies(families=False) self.connection.send.has_been_called_with( '' ) def test_get_policies_with_preferences(self): self.gmp.get_policies(preferences=True) self.connection.send.has_been_called_with( '' ) def test_get_policies_without_preferences(self): self.gmp.get_policies(preferences=False) self.connection.send.has_been_called_with( '' ) def test_get_policies_with_audits(self): self.gmp.get_policies(audits=True) self.connection.send.has_been_called_with( '' ) def test_get_policies_without_audits(self): self.gmp.get_policies(audits=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_get_policy.py000066400000000000000000000027101413122500400275460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpGetPolicyTestMixin: def test_get_policy(self): self.gmp.get_policy('a1') self.connection.send.has_been_called_with( '' ) def test_get_policy_with_audits(self): self.gmp.get_policy('a1', audits=True) self.connection.send.has_been_called_with( '' ) def test_fail_without_policy_id(self): with self.assertRaises(GvmError): self.gmp.get_policy(None) with self.assertRaises(GvmError): self.gmp.get_policy('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_import_policy.py000066400000000000000000000034771413122500400303140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgument class GmpImportPolicyTestMixin: POLICY_XML_STRING = ( '' '' 'Foobar' 'Foobar config' '2018-11-09T10:48:03Z' '2018-11-09T10:48:03Z' '' '' ) def test_import_policy(self): self.gmp.import_policy(self.POLICY_XML_STRING) self.connection.send.has_been_called_with( '' f'{self.POLICY_XML_STRING}' '' ) def test_import_missing_policy_xml(self): with self.assertRaises(RequiredArgument): self.gmp.import_policy(None) with self.assertRaises(RequiredArgument): self.gmp.import_policy('') def test_import_invalid_xml(self): with self.assertRaises(InvalidArgument): self.gmp.import_policy('abcdef') python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_modify_policy_set_comment.py000066400000000000000000000036701413122500400326610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyPolicySetCommentTestMixin: def test_modify_policy_set_comment(self): self.gmp.modify_policy_set_comment('c1') self.connection.send.has_been_called_with( '' '' '' ) self.gmp.modify_policy_set_comment('c1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_policy_set_comment('c1', comment=None) self.connection.send.has_been_called_with( '' '' '' ) def test_modify_policy_set_comment_missing_policy_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_comment(policy_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_comment('') with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_comment(policy_id='') test_modify_policy_set_family_selection.py000066400000000000000000000167331413122500400344720ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType, InvalidArgument class GmpModifyPolicySetFamilySelectionTestMixin: def test_modify_policy_set_family_selection(self): self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', True, True)] ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' '' ) self.gmp.modify_policy_set_family_selection( policy_id='c1', families=(('foo', True, True), ('bar', True, True)) ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' 'bar' '1' '1' '' '' '' ) self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', True, False), ('bar', False, True)], ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '0' '1' '' '' 'bar' '1' '0' '' '' '' ) def test_modify_policy_set_family_selection_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_family_selection( policy_id=None, families=[('foo', True, True)] ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_family_selection( policy_id='', families=[('foo', True, True)] ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_family_selection( '', [('foo', True, True)] ) def test_modify_policy_set_family_selection_invalid_families(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_family_selection( policy_id='c1', families=None ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_family_selection( policy_id='c1', families='' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_family_selection('c1', '') def test_modify_policy_set_family_selection_with_auto_add_new_families( self, ): self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', True, True)], auto_add_new_families=True, ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' '' ) self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', True, True)], auto_add_new_families=False, ) self.connection.send.has_been_called_with( '' '' '0' '' 'foo' '1' '1' '' '' '' ) def test_modify_policy_set_family_selection_with_auto_add_new_nvts(self): self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', True, True)] ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' '' ) self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', False, True)] ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '0' '' '' '' ) self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', False, True), ('bar', True, False)], ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '0' '' '' 'bar' '0' '1' '' '' '' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', 'False', 'True')] ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', True, None)] ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo', 'True', False)] ) with self.assertRaises(InvalidArgument): self.gmp.modify_policy_set_family_selection( policy_id='c1', families=[('foo',)] ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_modify_policy_set_name.py000066400000000000000000000036021413122500400321320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyPolicySetNameTestMixin: def test_modify_policy_set_name(self): self.gmp.modify_policy_set_name('c1', 'foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_policy_set_name_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_name(policy_id=None, name='name') with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_name('', name='name') with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_name(policy_id='', name='name') def test_modify_policy_set_name_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_name(policy_id='c', name='') with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_name(policy_id='c', name=None) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_name('c', '') test_modify_policy_set_nvt_preference.py000066400000000000000000000072371413122500400341500ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyPolicySetNvtPreferenceTestMixin: def test_modify_policy_set_nvt_pref(self): self.gmp.modify_policy_set_nvt_preference( policy_id='c1', nvt_oid='o1', name='foo' ) self.connection.send.has_been_called_with( '' '' '' 'foo' '' '' ) self.gmp.modify_policy_set_nvt_preference('c1', 'foo', 'o1') self.connection.send.has_been_called_with( '' '' '' 'foo' '' '' ) def test_modify_policy_set_nvt_pref_with_value(self): self.gmp.modify_policy_set_nvt_preference( 'c1', 'foo', nvt_oid='o1', value='bar' ) self.connection.send.has_been_called_with( '' '' '' 'foo' 'YmFy' '' '' ) def test_modify_policy_set_nvt_pref_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference( 'c1', 'foo', nvt_oid=None, value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference( 'c1', 'foo', nvt_oid='', value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference( 'c1', 'foo', '', value='bar' ) def test_modify_policy_nvt_pref_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference( 'c1', name=None, nvt_oid='o1', value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference( 'c1', name='', nvt_oid='o1', value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference( 'c1', '', nvt_oid='o1', value='bar' ) def test_modify_policy_set_comment_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference( policy_id=None, name='foo', nvt_oid='o1' ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference('', 'foo', 'o1') with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_preference( policy_id='', name='foo', nvt_oid='o1' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies/test_modify_policy_set_nvt_selection.py000066400000000000000000000105161413122500400340700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType class GmpModifyPolicySetNvtSelectionTestMixin: def test_modify_policy_set_nvt_selection(self): self.gmp.modify_policy_set_nvt_selection( policy_id='c1', family='foo', nvt_oids=['o1'] ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' ) self.gmp.modify_policy_set_nvt_selection( policy_id='c1', family='foo', nvt_oids=['o1', 'o2'] ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' '' ) self.gmp.modify_policy_set_nvt_selection('c1', 'foo', ['o1']) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' ) self.gmp.modify_policy_set_nvt_selection('c1', 'foo', ('o1', 'o2')) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' '' ) self.gmp.modify_policy_set_nvt_selection( policy_id='c1', family='foo', nvt_oids=[] ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) def test_modify_policy_set_nvt_selection_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_selection( policy_id=None, family='foo', nvt_oids=['o1'] ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_selection( policy_id='', family='foo', nvt_oids=['o1'] ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_selection('', 'foo', ['o1']) def test_modify_policy_set_nvt_selection_missing_family(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_selection( policy_id='c1', family=None, nvt_oids=['o1'] ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_selection( policy_id='c1', family='', nvt_oids=['o1'] ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_nvt_selection('c1', '', ['o1']) def test_modify_policy_set_nvt_selection_invalid_nvt_oids(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_nvt_selection( policy_id='c1', family='foo', nvt_oids=None ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_nvt_selection( policy_id='c1', family='foo', nvt_oids='' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_policy_set_nvt_selection('c1', 'foo', '') test_modify_policy_set_scanner_preference.py000066400000000000000000000056271413122500400347730ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/policies# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyPolicySetScannerPreferenceTestMixin: def test_modify_policy_set_scanner_pref(self): self.gmp.modify_policy_set_scanner_preference( policy_id='c1', name='foo' ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) self.gmp.modify_policy_set_scanner_preference('c1', 'foo') self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) def test_modify_policy_set_scanner_pref_with_value(self): self.gmp.modify_policy_set_scanner_preference('c1', 'foo', value='bar') self.connection.send.has_been_called_with( '' '' 'foo' 'YmFy' '' '' ) def test_modify_policy_scanner_pref_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_scanner_preference( 'c1', name=None, value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_scanner_preference( 'c1', name='', value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_scanner_preference('c1', '', value='bar') def test_modify_policy_set_comment_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_scanner_preference( policy_id=None, name='foo' ) with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_scanner_preference('', 'foo') with self.assertRaises(RequiredArgument): self.gmp.modify_policy_set_scanner_preference( policy_id='', name='foo' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/000077500000000000000000000000001413122500400243725ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/__init__.py000066400000000000000000000023301413122500400265010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_port_list import GmpClonePortListTestMixin from .test_create_port_list import GmpCreatePortListTestMixin from .test_create_port_range import GmpCreatePortRangeTestMixin from .test_delete_port_list import GmpDeletePortListTestMixin from .test_delete_port_range import GmpDeletePortRangeTestMixin from .test_get_port_list import GmpGetPortListTestMixin from .test_get_port_lists import GmpGetPortListsTestMixin from .test_modify_port_list import GmpModifyPortListTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/test_clone_port_list.py000066400000000000000000000023411413122500400312020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpClonePortListTestMixin: def test_clone(self): self.gmp.clone_port_list('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_port_list('') with self.assertRaises(RequiredArgument): self.gmp.clone_port_list(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/test_create_port_list.py000066400000000000000000000041311413122500400313440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreatePortListTestMixin: def test_create_port_list_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_port_list(name=None, port_range='T:1-1234') with self.assertRaises(RequiredArgument): self.gmp.create_port_list(name='', port_range='T:1-1234') def test_create_port_list_missing_port_range(self): with self.assertRaises(RequiredArgument): self.gmp.create_port_list(name='foo', port_range=None) with self.assertRaises(RequiredArgument): self.gmp.create_port_list(name='foo', port_range='') def test_create_port_list(self): self.gmp.create_port_list(name='foo', port_range='T:1-1234') self.connection.send.has_been_called_with( '' 'foo' 'T:1-1234' '' ) def test_create_port_list_with_comment(self): self.gmp.create_port_list( name='foo', port_range='T:1-1234', comment='lorem' ) self.connection.send.has_been_called_with( '' 'foo' 'T:1-1234' 'lorem' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/test_create_port_range.py000066400000000000000000000117341413122500400314740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208.entities.port_lists import PortRangeType class GmpCreatePortRangeTestMixin: def test_create_port_range_missing_port_list_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_port_range( port_list_id=None, start=1, end=1234, port_range_type=PortRangeType.TCP, ) with self.assertRaises(RequiredArgument): self.gmp.create_port_range( port_list_id='', start=1, end=1234, port_range_type=PortRangeType.TCP, ) def test_create_port_range_missing_start(self): with self.assertRaises(RequiredArgument): self.gmp.create_port_range( port_list_id='pl1', start=None, end=1234, port_range_type=PortRangeType.TCP, ) with self.assertRaises(RequiredArgument): self.gmp.create_port_range( port_list_id='pl1', start='', end=1234, port_range_type=PortRangeType.TCP, ) def test_create_port_range_missing_end(self): with self.assertRaises(RequiredArgument): self.gmp.create_port_range( port_list_id='pl1', start=1, end=None, port_range_type=PortRangeType.TCP, ) with self.assertRaises(RequiredArgument): self.gmp.create_port_range( port_list_id='pl1', start=1, end='', port_range_type=PortRangeType.TCP, ) def test_create_port_range_missing_port_range_type(self): with self.assertRaises(RequiredArgument): self.gmp.create_port_range( port_list_id='pl1', start=1, end=1234, port_range_type=None ) with self.assertRaises(RequiredArgument): self.gmp.create_port_range( port_list_id='pl1', start=1, end=1234, port_range_type='' ) def test_create_port_range_invalid_port_range_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_port_range( port_list_id='pl1', start=1, end=1234, port_range_type="blubb" ) def test_create_port_range(self): self.gmp.create_port_range( port_list_id='pl1', start=1, end=1234, port_range_type=PortRangeType.TCP, ) self.connection.send.has_been_called_with( '' '' '1' '1234' 'TCP' '' ) self.gmp.create_port_range( port_list_id='pl1', start=1, end=1234, port_range_type=PortRangeType.UDP, ) self.connection.send.has_been_called_with( '' '' '1' '1234' 'UDP' '' ) self.gmp.create_port_range( port_list_id='pl1', start='1', end='1234', port_range_type=PortRangeType.TCP, ) self.connection.send.has_been_called_with( '' '' '1' '1234' 'TCP' '' ) def test_create_port_range_with_comment(self): self.gmp.create_port_range( port_list_id='pl1', start=1, end=1234, port_range_type=PortRangeType.TCP, comment='lorem', ) self.connection.send.has_been_called_with( '' '' '1' '1234' 'TCP' 'lorem' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/test_delete_port_list.py000066400000000000000000000026411413122500400313470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeletePortListTestMixin: def test_delete(self): self.gmp.delete_port_list('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_port_list('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_port_list(None) with self.assertRaises(GvmError): self.gmp.delete_port_list('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/test_delete_port_range.py000066400000000000000000000022771413122500400314750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeletePortRangeTestMixin: def test_delete(self): self.gmp.delete_port_range('a1') self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_port_range(None) with self.assertRaises(GvmError): self.gmp.delete_port_range('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/test_get_port_list.py000066400000000000000000000026031413122500400306620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetPortListTestMixin: def test_get_port_list(self): self.gmp.get_port_list(port_list_id='port_list_id') self.connection.send.has_been_called_with( '' ) def test_get_port_list_missing_port_list_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_port_list(port_list_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_port_list(port_list_id='') with self.assertRaises(RequiredArgument): self.gmp.get_port_list('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/test_get_port_lists.py000066400000000000000000000045031413122500400310460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetPortListsTestMixin: def test_get_port_lists(self): self.gmp.get_port_lists() self.connection.send.has_been_called_with('') def test_get_port_lists_with_filter_string(self): self.gmp.get_port_lists(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_port_lists_with_filter_id(self): self.gmp.get_port_lists(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_port_lists_with_trash(self): self.gmp.get_port_lists(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_port_lists(trash=False) self.connection.send.has_been_called_with('') def test_get_port_lists_with_details(self): self.gmp.get_port_lists(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_port_lists(details=False) self.connection.send.has_been_called_with( '' ) def test_get_port_lists_with_targets(self): self.gmp.get_port_lists(targets=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_port_lists(targets=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/port_lists/test_modify_port_list.py000066400000000000000000000037141413122500400313760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyPortListTestMixin: def test_modify_port_list(self): self.gmp.modify_port_list(port_list_id='p1') self.connection.send.has_been_called_with( '' ) def test_modify_port_list_missing_port_list_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_port_list(port_list_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_port_list(port_list_id='') with self.assertRaises(RequiredArgument): self.gmp.modify_port_list('') def test_modify_port_list_with_comment(self): self.gmp.modify_port_list(port_list_id='p1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_port_list_with_name(self): self.gmp.modify_port_list(port_list_id='p1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/000077500000000000000000000000001413122500400252365ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/__init__.py000066400000000000000000000023161413122500400273510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_report_format import GmpCloneReportFormatTestMixin from .test_import_report_format import GmpImportReportFormatTestMixin from .test_delete_report_format import GmpDeleteReportFormatTestMixin from .test_get_report_format import GmpGetReportFormatTestMixin from .test_get_report_formats import GmpGetReportFormatsTestMixin from .test_modify_report_format import GmpModifyReportFormatTestMixin from .test_verify_report_format import GmpVerifyReportFormatTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/test_clone_report_format.py000066400000000000000000000032421413122500400327130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument from gvm.protocols.gmpv208.entities.report_formats import ReportFormatType class GmpCloneReportFormatTestMixin: def test_clone(self): self.gmp.clone_report_format('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_report_format('') with self.assertRaises(RequiredArgument): self.gmp.clone_report_format(None) def test_clone_with_type(self): self.gmp.clone_report_format(ReportFormatType.SVG) report_format_id = ReportFormatType.from_string('svg').value self.connection.send.has_been_called_with( '' f'{report_format_id}' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/test_delete_report_format.py000066400000000000000000000035361413122500400330630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError from gvm.protocols.gmpv208.entities.report_formats import ReportFormatType class GmpDeleteReportFormatTestMixin: def test_delete(self): self.gmp.delete_report_format('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_report_format('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_report_format(None) with self.assertRaises(GvmError): self.gmp.delete_report_format('') def test_delete_with_type(self): self.gmp.delete_report_format(ReportFormatType.SVG) report_format_id = ReportFormatType.from_string('svg').value self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/test_get_report_format.py000066400000000000000000000041551413122500400323760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument from gvm.protocols.gmpv208.entities.report_formats import ReportFormatType class GmpGetReportFormatTestMixin: def test_get_report_format(self): self.gmp.get_report_format('rf1') self.connection.send.has_been_called_with( '' ) self.gmp.get_report_format(report_format_id='rf1') self.connection.send.has_been_called_with( '' ) def test_get_report_format_missing_report_format_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_report_format(report_format_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_report_format('') def test_get_report_format_type(self): self.gmp.get_report_format(ReportFormatType.PDF) report_format_id = ReportFormatType.from_string('pdf').value self.connection.send.has_been_called_with( '' ) self.gmp.get_report_format(report_format_id=ReportFormatType.PDF) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/test_get_report_formats.py000066400000000000000000000055001413122500400325540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetReportFormatsTestMixin: def test_get_report_formats(self): self.gmp.get_report_formats() self.connection.send.has_been_called_with('') def test_get_report_formats_with_filter_string(self): self.gmp.get_report_formats(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_report_formats_with_filter_id(self): self.gmp.get_report_formats(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_report_formats_with_trash(self): self.gmp.get_report_formats(trash=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_report_formats(trash=False) self.connection.send.has_been_called_with( '' ) def test_get_report_formats_with_details(self): self.gmp.get_report_formats(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_report_formats(details=False) self.connection.send.has_been_called_with( '' ) def test_get_report_formats_with_alerts(self): self.gmp.get_report_formats(alerts=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_report_formats(alerts=False) self.connection.send.has_been_called_with( '' ) def test_get_report_formats_with_params(self): self.gmp.get_report_formats(params=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_report_formats(params=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/test_import_report_format.py000066400000000000000000000036761413122500400331400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgument class GmpImportReportFormatTestMixin: REPORT_FORMAT_XML_STRING = ( '' '' 'Foobar' 'Foobar report_format' '2018-11-09T10:48:03Z' '2018-11-09T10:48:03Z' '' '' ) def test_import_report_format(self): self.gmp.import_report_format(self.REPORT_FORMAT_XML_STRING) self.connection.send.has_been_called_with( '' f'{self.REPORT_FORMAT_XML_STRING}' ) def test_import_missing_report_format_xml(self): with self.assertRaises(RequiredArgument): self.gmp.import_report_format(None) with self.assertRaises(RequiredArgument): self.gmp.import_report_format('') def test_import_invalid_xml(self): with self.assertRaises(InvalidArgument): self.gmp.import_report_format('abcdef') python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/test_modify_report_format.py000066400000000000000000000105031413122500400331000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument from gvm.protocols.gmpv208.entities.report_formats import ReportFormatType class GmpModifyReportFormatTestMixin: def test_modify_report_format(self): self.gmp.modify_report_format(report_format_id='rf1') self.connection.send.has_been_called_with( '' ) def test_modify_report_format_missing_report_format_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_report_format(report_format_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_report_format(report_format_id='') with self.assertRaises(RequiredArgument): self.gmp.modify_report_format('') def test_modify_report_format_with_summary(self): self.gmp.modify_report_format(report_format_id='rf1', summary='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_report_format_with_name(self): self.gmp.modify_report_format(report_format_id='rf1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_report_format_with_name_and_type(self): self.gmp.modify_report_format( report_format_id=ReportFormatType.XML, name='foo' ) report_format_id = ReportFormatType.from_string('xml').value self.connection.send.has_been_called_with( f'' 'foo' ) def test_modify_report_format_with_active(self): self.gmp.modify_report_format(report_format_id='rf1', active=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_report_format(report_format_id='rf1', active=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_report_format_with_param_name(self): self.gmp.modify_report_format(report_format_id='rf1', param_name='foo') self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) def test_modify_report_format_with_param_name_and_value(self): self.gmp.modify_report_format( report_format_id='rf1', param_name='foo', param_value='bar' ) self.connection.send.has_been_called_with( '' '' 'foo' 'bar' '' '' ) self.gmp.modify_report_format( report_format_id='rf1', param_name='foo', param_value='' ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/report_formats/test_verify_report_format.py000066400000000000000000000031161413122500400331170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError from gvm.protocols.gmpv208.entities.report_formats import ReportFormatType class GmpVerifyReportFormatTestMixin: def test_verify(self): self.gmp.verify_report_format('a1') self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.verify_report_format(None) with self.assertRaises(GvmError): self.gmp.verify_report_format('') def test_verify_with_type(self): self.gmp.verify_report_format(ReportFormatType.SVG) report_format_id = ReportFormatType.from_string('svg').value self.connection.send.has_been_called_with( f'' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/reports/000077500000000000000000000000001413122500400236665ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/reports/__init__.py000066400000000000000000000017121413122500400260000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_delete_report import GmpDeleteReportTestMixin from .test_get_report import GmpGetReportTestMixin from .test_get_reports import GmpGetReportsTestMixin from .test_import_report import GmpImportReportTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/reports/test_delete_report.py000066400000000000000000000022501413122500400301330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteReportTestMixin: def test_delete(self): self.gmp.delete_report('a1') self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_report(None) with self.assertRaises(GvmError): self.gmp.delete_report('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/reports/test_get_report.py000066400000000000000000000065041413122500400274560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument from gvm.protocols.gmpv208.entities.report_formats import ReportFormatType class GmpGetReportTestMixin: def test_get_report_without_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_report(None) with self.assertRaises(RequiredArgument): self.gmp.get_report('') def test_get_report_with_filter_string(self): self.gmp.get_report(report_id='r1', filter_string='name=foo') self.connection.send.has_been_called_with( '' ) def test_get_report_with_filter_id(self): self.gmp.get_report(report_id='r1', filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_report_with_report_format_id(self): self.gmp.get_report(report_id='r1', report_format_id='bar') self.connection.send.has_been_called_with( '' ) def test_get_report_with_report_format_type(self): self.gmp.get_report( report_id='r1', report_format_id=ReportFormatType.TXT ) report_format_id = ReportFormatType.from_string('txt').value self.connection.send.has_been_called_with( '' ) def test_get_report_with_delta_report_id(self): self.gmp.get_report(report_id='r1', delta_report_id='r2') self.connection.send.has_been_called_with( '' ) def test_get_report_with_ignore_pagination(self): self.gmp.get_report(report_id='r1', ignore_pagination=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_report(report_id='r1', ignore_pagination=False) self.connection.send.has_been_called_with( '' ) def test_get_report_with_details(self): self.gmp.get_report(report_id='r1', details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_report(report_id='r1', details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/reports/test_get_reports.py000066400000000000000000000053771413122500400276500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetReportsTestMixin: def test_get_reports(self): self.gmp.get_reports() self.connection.send.has_been_called_with( '' ) def test_get_reports_with_filter_string(self): self.gmp.get_reports(filter_string='name=foo') self.connection.send.has_been_called_with( '' ) def test_get_reports_with_filter_id(self): self.gmp.get_reports(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_reports_without_note_details(self): self.gmp.get_reports(note_details=False) self.connection.send.has_been_called_with( '' ) def test_get_reports_with_note_details(self): self.gmp.get_reports(note_details=True) self.connection.send.has_been_called_with( '' ) def test_get_reports_without_override_details(self): self.gmp.get_reports(override_details=False) self.connection.send.has_been_called_with( '' ) def test_get_reports_with_override_details(self): self.gmp.get_reports(override_details=True) self.connection.send.has_been_called_with( '' ) def test_get_reports_with_details(self): self.gmp.get_reports(details=True) self.connection.send.has_been_called_with( '' ) def test_get_reports_without_details(self): self.gmp.get_reports(details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/reports/test_import_report.py000066400000000000000000000061011413122500400302020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgument class GmpImportReportTestMixin: TASK_ID = '00000000-0000-0000-0000-000000000001' REPORT_XML_STRING = ( '' '' '' '0.0' '' '132.67.253.114' '' ) def test_import_report_with_task_id(self): self.gmp.import_report(self.REPORT_XML_STRING, task_id=self.TASK_ID) self.connection.send.has_been_called_with( '' f'' f'{self.REPORT_XML_STRING}' '' ) def test_import_report_missing_report(self): with self.assertRaises(RequiredArgument): self.gmp.import_report(None, task_id=self.TASK_ID) with self.assertRaises(RequiredArgument): self.gmp.import_report('', task_id=self.TASK_ID) def test_import_report_missing_task(self): with self.assertRaises(RequiredArgument): self.gmp.import_report(self.REPORT_XML_STRING) def test_import_report_invalid_xml(self): with self.assertRaises(InvalidArgument): self.gmp.import_report('Foo', task_id=self.TASK_ID) # not root tag with self.assertRaises(InvalidArgument): self.gmp.import_report( '', task_id=self.TASK_ID # missing closing tag ) def test_import_report_with_in_assets(self): self.gmp.import_report( self.REPORT_XML_STRING, task_id=self.TASK_ID, in_assets=False ) self.connection.send.has_been_called_with( '' f'' '0' f'{self.REPORT_XML_STRING}' '' ) self.gmp.import_report( self.REPORT_XML_STRING, task_id=self.TASK_ID, in_assets=True ) self.connection.send.has_been_called_with( '' f'' '1' f'{self.REPORT_XML_STRING}' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/results/000077500000000000000000000000001413122500400236715ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/results/__init__.py000066400000000000000000000015301413122500400260010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_result import GmpGetResultTestMixin from .test_get_results import GmpGetResultsTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/results/test_get_result.py000066400000000000000000000026011413122500400274560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetResultTestMixin: def test_get_result(self): self.gmp.get_result('r1') self.connection.send.has_been_called_with( '' ) self.gmp.get_result(result_id='r1') self.connection.send.has_been_called_with( '' ) def test_get_result_missing_result_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_result(result_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_result('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/results/test_get_results.py000066400000000000000000000047361413122500400276540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetResultsTestMixin: def test_get_results(self): self.gmp.get_results() self.connection.send.has_been_called_with('') def test_get_results_with_filter_string(self): self.gmp.get_results(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_results_with_filter_id(self): self.gmp.get_results(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_results_with_note_details(self): self.gmp.get_results(note_details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_results(note_details=False) self.connection.send.has_been_called_with( '' ) def test_get_results_with_override_details(self): self.gmp.get_results(override_details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_results(override_details=False) self.connection.send.has_been_called_with( '' ) def test_get_results_with_details(self): self.gmp.get_results(details=True) self.connection.send.has_been_called_with('') self.gmp.get_results(details=False) self.connection.send.has_been_called_with('') def test_get_results_with_task_id(self): self.gmp.get_results(task_id='t1') self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/roles/000077500000000000000000000000001413122500400233145ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/roles/__init__.py000066400000000000000000000020421413122500400254230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_role import GmpCloneRoleTestMixin from .test_create_role import GmpCreateRoleTestMixin from .test_delete_role import GmpDeleteRoleTestMixin from .test_get_role import GmpGetRoleTestMixin from .test_get_roles import GmpGetRolesTestMixin from .test_modify_role import GmpModifyRoleTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/roles/test_clone_role.py000066400000000000000000000023041413122500400270450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneRoleTestMixin: def test_clone(self): self.gmp.clone_role('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_role('') with self.assertRaises(RequiredArgument): self.gmp.clone_role(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/roles/test_create_role.py000066400000000000000000000037141413122500400272160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateRoleTestMixin: def test_create_role(self): self.gmp.create_role(name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_role(None) with self.assertRaises(RequiredArgument): self.gmp.create_role('') def test_create_role_with_comment(self): self.gmp.create_role(name='foo', comment='bar') self.connection.send.has_been_called_with( '' 'foo' 'bar' '' ) def test_create_role_with_users(self): self.gmp.create_role(name='foo', users=[]) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.create_role(name='foo', users=['u1', 'u2']) self.connection.send.has_been_called_with( '' 'foo' 'u1,u2' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/roles/test_delete_role.py000066400000000000000000000025651413122500400272200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteRoleTestMixin: def test_delete(self): self.gmp.delete_role('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_role('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_role(None) with self.assertRaises(GvmError): self.gmp.delete_role('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/roles/test_get_role.py000066400000000000000000000024411413122500400265260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetRoleTestMixin: def test_get_role(self): self.gmp.get_role('r1') self.connection.send.has_been_called_with('') self.gmp.get_role(role_id='r1') self.connection.send.has_been_called_with('') def test_get_role_missing_role_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_role(role_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_role('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/roles/test_get_roles.py000066400000000000000000000030351413122500400267110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetRolesTestMixin: def test_get_roles(self): self.gmp.get_roles() self.connection.send.has_been_called_with('') def test_get_roles_with_filter_string(self): self.gmp.get_roles(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_roles_with_filter_id(self): self.gmp.get_roles(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_roles_with_trash(self): self.gmp.get_roles(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_roles(trash=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/roles/test_modify_role.py000066400000000000000000000046101413122500400272360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyRoleTestMixin: def test_modify_role(self): self.gmp.modify_role(role_id='r1') self.connection.send.has_been_called_with('') def test_modify_role_missing_role_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_role(role_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_role(role_id='') with self.assertRaises(RequiredArgument): self.gmp.modify_role('') def test_modify_role_with_comment(self): self.gmp.modify_role(role_id='r1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_role_with_name(self): self.gmp.modify_role(role_id='r1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_role_with_users(self): self.gmp.modify_role(role_id='r1', users=[]) self.connection.send.has_been_called_with('') self.gmp.modify_role(role_id='r1', users=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_role(role_id='r1', users=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/000077500000000000000000000000001413122500400246245ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/__init__.py000066400000000000000000000042051413122500400267360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_scan_config import GmpCloneScanConfigTestMixin from .test_create_scan_config import GmpCreateScanConfigTestMixin from .test_create_scan_config_from_osp_scanner import ( GmpCreateScanConfigFromOSPScannerTestMixin, ) from .test_delete_scan_config import GmpDeleteScanConfigTestMixin from .test_get_scan_config import GmpGetScanConfigTestMixin from .test_get_scan_configs import GmpGetScanConfigsTestMixin from .test_get_scan_config_preference import GmpGetScanConfigPreferenceTestMixin from .test_get_scan_config_preferences import ( GmpGetScanConfigPreferencesTestMixin, ) from .test_import_scan_config import GmpImportScanConfigTestMixin from .test_modify_scan_config import GmpModifyScanConfigTestMixin from .test_modify_scan_config_set_comment import ( GmpModifyScanConfigSetCommentTestMixin, ) from .test_modify_scan_config_set_family_selection import ( GmpModifyScanConfigSetFamilySelectionTestMixin, ) from .test_modify_scan_config_set_name import ( GmpModifyScanConfigSetNameTestMixin, ) from .test_modify_scan_config_set_nvt_preference import ( GmpModifyScanConfigSetNvtPreferenceTestMixin, ) from .test_modify_scan_config_set_nvt_selection import ( GmpModifyScanConfigSetNvtSelectionTestMixin, ) from .test_modify_scan_config_set_scanner_preference import ( GmpModifyScanConfigSetScannerPreferenceTestMixin, ) from .test_sync_scan_config import GmpSyncScanConfigTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_clone_scan_config.py000066400000000000000000000023351413122500400316710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneScanConfigTestMixin: def test_clone(self): self.gmp.clone_scan_config('a1') self.connection.send.has_been_called_with( 'a1' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_scan_config('') with self.assertRaises(RequiredArgument): self.gmp.clone_scan_config(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_create_scan_config.py000066400000000000000000000041151413122500400320320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateScanConfigTestMixin: def test_create_scan_config(self): self.gmp.create_scan_config('a1', 'foo') self.connection.send.has_been_called_with( '' 'a1' 'foo' 'scan' '' ) def test_create_scan_config_with_comment(self): self.gmp.create_scan_config('a1', 'foo', comment='comment') self.connection.send.has_been_called_with( '' 'comment' 'a1' 'foo' 'scan' '' ) def test_create_scan_config_missing_scan_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_scan_config(config_id='', name='foo') with self.assertRaises(RequiredArgument): self.gmp.create_scan_config(config_id=None, name='foo') def test_create_scan_config_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_scan_config(config_id='c1', name=None) with self.assertRaises(RequiredArgument): self.gmp.create_scan_config(config_id='c1', name='') test_create_scan_config_from_osp_scanner.py000066400000000000000000000046371413122500400354010ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateScanConfigFromOSPScannerTestMixin: def test_create_scan_config_from_osp_scanner(self): self.gmp.create_scan_config_from_osp_scanner('a1', 'foo') self.connection.send.has_been_called_with( '' 'a1' 'foo' 'scan' '' ) def test_create_scan_config_from_osp_scanner_with_comment(self): self.gmp.create_scan_config_from_osp_scanner( 'a1', 'foo', comment='comment' ) self.connection.send.has_been_called_with( '' 'comment' 'a1' 'foo' 'scan' '' ) def test_create_scan_config_from_osp_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_scan_config_from_osp_scanner( scanner_id='', name='foo' ) with self.assertRaises(RequiredArgument): self.gmp.create_scan_config_from_osp_scanner( scanner_id=None, name='foo' ) def test_create_scan_config_from_osp_scanner_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_scan_config_from_osp_scanner( scanner_id='c1', name=None ) with self.assertRaises(RequiredArgument): self.gmp.create_scan_config_from_osp_scanner( scanner_id='c1', name='' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_delete_scan_config.py000066400000000000000000000027261413122500400320370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteScanConfigTestMixin: def test_delete_scan_config(self): self.gmp.delete_scan_config('a1') self.connection.send.has_been_called_with( '' ) def test_delete_scan_config_ultimate(self): self.gmp.delete_scan_config('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_delete_scan_config_missing_scan_config_id(self): with self.assertRaises(GvmError): self.gmp.delete_scan_config(None) with self.assertRaises(GvmError): self.gmp.delete_scan_config('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_get_scan_config.py000066400000000000000000000027711413122500400313540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpGetScanConfigTestMixin: def test_get_scan_config(self): self.gmp.get_scan_config('a1') self.connection.send.has_been_called_with( '' ) def test_get_scan_config_with_tasks(self): self.gmp.get_scan_config('a1', tasks=True) self.connection.send.has_been_called_with( '' ) def test_get_scan_config_fail_without_scan_config_id(self): with self.assertRaises(GvmError): self.gmp.get_scan_config(None) with self.assertRaises(GvmError): self.gmp.get_scan_config('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_get_scan_config_preference.py000066400000000000000000000036321413122500400335470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetScanConfigPreferenceTestMixin: def test_get_preference(self): self.gmp.get_scan_config_preference(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_scan_config_preference_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.get_scan_config_preference(name=None) with self.assertRaises(RequiredArgument): self.gmp.get_scan_config_preference(name='') with self.assertRaises(RequiredArgument): self.gmp.get_scan_config_preference('') def test_get_scan_config_preference_with_nvt_oid(self): self.gmp.get_scan_config_preference(name='foo', nvt_oid='oid') self.connection.send.has_been_called_with( '' ) def test_get_scan_config_preference_with_config_id(self): self.gmp.get_scan_config_preference(name='foo', config_id='c1') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_get_scan_config_preferences.py000066400000000000000000000026341413122500400337330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetScanConfigPreferencesTestMixin: def test_get_scan_config_preferences(self): self.gmp.get_scan_config_preferences() self.connection.send.has_been_called_with('') def test_get_scan_config_preferences_with_nvt_oid(self): self.gmp.get_scan_config_preferences(nvt_oid='oid') self.connection.send.has_been_called_with( '' ) def test_get_scan_config_preferences_with_config_id(self): self.gmp.get_scan_config_preferences(config_id='c1') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_get_scan_configs.py000066400000000000000000000066021413122500400315340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetScanConfigsTestMixin: def test_get_scan_configs_simple(self): self.gmp.get_scan_configs() self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_with_filter_string(self): self.gmp.get_scan_configs(filter_string='name=foo') self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_with_filter_id(self): self.gmp.get_scan_configs(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_from_trash(self): self.gmp.get_scan_configs(trash=True) self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_with_details(self): self.gmp.get_scan_configs(details=True) self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_without_details(self): self.gmp.get_scan_configs(details=False) self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_with_families(self): self.gmp.get_scan_configs(families=True) self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_without_families(self): self.gmp.get_scan_configs(families=False) self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_with_preferences(self): self.gmp.get_scan_configs(preferences=True) self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_without_preferences(self): self.gmp.get_scan_configs(preferences=False) self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_with_tasks(self): self.gmp.get_scan_configs(tasks=True) self.connection.send.has_been_called_with( '' ) def test_get_scan_configs_without_tasks(self): self.gmp.get_scan_configs(tasks=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_import_scan_config.py000066400000000000000000000035411413122500400321030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgument class GmpImportScanConfigTestMixin: CONFIG_XML_STRING = ( '' '' 'Foobar' 'Foobar config' '2018-11-09T10:48:03Z' '2018-11-09T10:48:03Z' '' '' ) def test_import_scan_config(self): self.gmp.import_scan_config(self.CONFIG_XML_STRING) self.connection.send.has_been_called_with( '' f'{self.CONFIG_XML_STRING}' '' ) def test_import_missing_scan_config_xml(self): with self.assertRaises(RequiredArgument): self.gmp.import_scan_config(None) with self.assertRaises(RequiredArgument): self.gmp.import_scan_config('') def test_import_invalid_xml(self): with self.assertRaises(InvalidArgument): self.gmp.import_scan_config('abcdef') python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_modify_scan_config.py000066400000000000000000000122001413122500400320500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import warnings from gvm.errors import RequiredArgument, InvalidArgument class GmpModifyScanConfigTestMixin: def test_modify_scan_config_invalid_selection(self): with self.assertRaises(InvalidArgument): self.gmp.modify_scan_config(config_id='c1', selection='foo') with self.assertRaises(InvalidArgument): self.gmp.modify_scan_config(config_id='c1', selection='') def test_modify_scan_config_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config(config_id=None, selection='nvt_pref') with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config(config_id='', selection='nvt_pref') with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config('', selection='nvt_pref') def test_modify_scan_config_set_comment(self): # pylint: disable=invalid-name with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") self.gmp.modify_scan_config( config_id='c1', selection=None, comment='foo' ) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, DeprecationWarning)) self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scan_config_set_nvt_pref(self): # pylint: disable=invalid-name with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") self.gmp.modify_scan_config( config_id='c1', selection='nvt_pref', nvt_oid='o1', name='foo' ) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, DeprecationWarning)) self.connection.send.has_been_called_with( '' '' '' 'foo' '' '' ) def test_modify_scan_config_set_scanner_pref(self): # pylint: disable=invalid-name with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") self.gmp.modify_scan_config( config_id='c1', selection='scan_pref', name='foo', value='bar' ) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, DeprecationWarning)) self.connection.send.has_been_called_with( '' '' 'foo' 'YmFy' '' '' ) def test_modify_scan_config_set_nvt_selection(self): # pylint: disable=invalid-name with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") self.gmp.modify_scan_config( config_id='c1', selection='nvt_selection', nvt_oids=['o1'], family='foo', ) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, DeprecationWarning)) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' ) def test_modify_scan_config_set_family_selection(self): # pylint: disable=invalid-name with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") self.gmp.modify_scan_config( config_id='c1', selection='family_selection', families=[('foo', True, True)], ) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, DeprecationWarning)) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' '' ) test_modify_scan_config_set_comment.py000066400000000000000000000037441413122500400344030ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyScanConfigSetCommentTestMixin: def test_modify_scan_config_set_comment(self): self.gmp.modify_scan_config_set_comment('c1') self.connection.send.has_been_called_with( '' '' '' ) self.gmp.modify_scan_config_set_comment('c1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_scan_config_set_comment('c1', comment=None) self.connection.send.has_been_called_with( '' '' '' ) def test_modify_scan_config_set_comment_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_comment(config_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_comment('') with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_comment(config_id='') test_modify_scan_config_set_family_selection.py000066400000000000000000000203701413122500400362610ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType, InvalidArgument class GmpModifyScanConfigSetFamilySelectionTestMixin: def test_modify_scan_config_set_family_selection(self): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', True, True)] ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' '' ) self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', True, True), ('bar', True, True)] ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' 'bar' '1' '1' '' '' '' ) self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=(('foo', True, True), ('bar', True, True)) ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' 'bar' '1' '1' '' '' '' ) self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', True, False), ('bar', False, True)], ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '0' '1' '' '' 'bar' '1' '0' '' '' '' ) def test_modify_scan_config_set_family_selection_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_family_selection( config_id=None, families=[('foo', True, True)] ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_family_selection( config_id='', families=[('foo', True, True)] ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_family_selection( '', [('foo', True)] ) def test_modify_scan_config_set_family_selection_invalid_families(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=None ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families='' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_family_selection('c1', '') def test_modify_scan_config_set_family_selection_with_auto_add_new_families( self, ): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', True, True)], auto_add_new_families=True, ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' '' ) self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', True, True)], auto_add_new_families=False, ) self.connection.send.has_been_called_with( '' '' '0' '' 'foo' '1' '1' '' '' '' ) def test_modify_scan_config_set_family_selection_with_auto_add_new_nvts( self, ): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', True, True)] ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '1' '' '' '' ) self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', False, True)] ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '0' '' '' '' ) self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', False, True), ('bar', True, False)], ) self.connection.send.has_been_called_with( '' '' '1' '' 'foo' '1' '0' '' '' 'bar' '0' '1' '' '' '' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', 'False', 'True')] ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', True, None)] ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo', 'True', False)] ) with self.assertRaises(InvalidArgument): self.gmp.modify_scan_config_set_family_selection( config_id='c1', families=[('foo',)] ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_modify_scan_config_set_name.py000066400000000000000000000036701413122500400337360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyScanConfigSetNameTestMixin: def test_modify_scan_config_set_name(self): self.gmp.modify_scan_config_set_name('c1', 'foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scan_config_set_name_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_name(config_id=None, name='name') with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_name('', name='name') with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_name(config_id='', name='name') def test_modify_scan_config_set_name_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_name(config_id='c', name='') with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_name(config_id='c', name=None) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_name('c', '') test_modify_scan_config_set_nvt_preference.py000066400000000000000000000073701413122500400357450ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyScanConfigSetNvtPreferenceTestMixin: def test_modify_scan_config_set_nvt_pref(self): self.gmp.modify_scan_config_set_nvt_preference( config_id='c1', nvt_oid='o1', name='foo' ) self.connection.send.has_been_called_with( '' '' '' 'foo' '' '' ) self.gmp.modify_scan_config_set_nvt_preference('c1', 'foo', 'o1') self.connection.send.has_been_called_with( '' '' '' 'foo' '' '' ) def test_modify_scan_config_set_nvt_pref_with_value(self): self.gmp.modify_scan_config_set_nvt_preference( 'c1', 'foo', nvt_oid='o1', value='bar' ) self.connection.send.has_been_called_with( '' '' '' 'foo' 'YmFy' '' '' ) def test_modify_scan_config_set_nvt_pref_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference( 'c1', 'foo', nvt_oid=None, value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference( 'c1', 'foo', nvt_oid='', value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference( 'c1', 'foo', '', value='bar' ) def test_modify_scan_config_nvt_pref_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference( 'c1', name=None, nvt_oid='o1', value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference( 'c1', name='', nvt_oid='o1', value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference( 'c1', '', nvt_oid='o1', value='bar' ) def test_modify_scan_config_set_comment_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference( config_id=None, name='foo', nvt_oid='o1' ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference('', 'foo', 'o1') with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_preference( config_id='', name='foo', nvt_oid='o1' ) test_modify_scan_config_set_nvt_selection.py000066400000000000000000000106541413122500400356130ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType class GmpModifyScanConfigSetNvtSelectionTestMixin: def test_modify_scan_config_set_nvt_selection(self): self.gmp.modify_scan_config_set_nvt_selection( config_id='c1', family='foo', nvt_oids=['o1'] ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' ) self.gmp.modify_scan_config_set_nvt_selection( config_id='c1', family='foo', nvt_oids=['o1', 'o2'] ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' '' ) self.gmp.modify_scan_config_set_nvt_selection('c1', 'foo', ['o1']) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' ) self.gmp.modify_scan_config_set_nvt_selection('c1', 'foo', ('o1', 'o2')) self.connection.send.has_been_called_with( '' '' 'foo' '' '' '' '' ) self.gmp.modify_scan_config_set_nvt_selection( config_id='c1', family='foo', nvt_oids=[] ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) def test_modify_scan_config_set_nvt_selection_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_selection( config_id=None, family='foo', nvt_oids=['o1'] ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_selection( config_id='', family='foo', nvt_oids=['o1'] ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_selection('', 'foo', ['o1']) def test_modify_scan_config_set_nvt_selection_missing_family(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_selection( config_id='c1', family=None, nvt_oids=['o1'] ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_selection( config_id='c1', family='', nvt_oids=['o1'] ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_nvt_selection('c1', '', ['o1']) def test_modify_scan_config_set_nvt_selection_invalid_nvt_oids(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_nvt_selection( config_id='c1', family='foo', nvt_oids=None ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_nvt_selection( config_id='c1', family='foo', nvt_oids='' ) with self.assertRaises(InvalidArgumentType): self.gmp.modify_scan_config_set_nvt_selection('c1', 'foo', '') test_modify_scan_config_set_scanner_preference.py000066400000000000000000000060201413122500400365560ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyScanConfigSetScannerPreferenceTestMixin: def test_modify_scan_config_set_scanner_pref(self): self.gmp.modify_scan_config_set_scanner_preference( config_id='c1', name='foo' ) self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) self.gmp.modify_scan_config_set_scanner_preference('c1', 'foo') self.connection.send.has_been_called_with( '' '' 'foo' '' '' ) def test_modify_scan_config_set_scanner_pref_with_value(self): self.gmp.modify_scan_config_set_scanner_preference( 'c1', 'foo', value='bar' ) self.connection.send.has_been_called_with( '' '' 'foo' 'YmFy' '' '' ) def test_modify_scan_config_scanner_pref_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_scanner_preference( 'c1', name=None, value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_scanner_preference( 'c1', name='', value='bar' ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_scanner_preference( 'c1', '', value='bar' ) def test_modify_scan_config_set_comment_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_scanner_preference( config_id=None, name='foo' ) with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_scanner_preference('', 'foo') with self.assertRaises(RequiredArgument): self.gmp.modify_scan_config_set_scanner_preference( config_id='', name='foo' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scan_configs/test_sync_scan_config.py000066400000000000000000000016461413122500400315510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpSyncScanConfigTestMixin: def test_sync_scan_config(self): self.gmp.sync_scan_config() self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/000077500000000000000000000000001413122500400240045ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/__init__.py000066400000000000000000000022011413122500400261100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_scanner import GmpCloneScannerTestMixin from .test_create_scanner import GmpCreateScannerTestMixin from .test_delete_scanner import GmpDeleteScannerTestMixin from .test_get_scanner import GmpGetScannerTestMixin from .test_get_scanners import GmpGetScannersTestMixin from .test_modify_scanner import GmpModifyScannerTestMixin from .test_verify_scanner import GmpVerifyScannerTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/test_clone_scanner.py000066400000000000000000000023261413122500400302310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneScannerTestMixin: def test_clone(self): self.gmp.clone_scanner('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_scanner('') with self.assertRaises(RequiredArgument): self.gmp.clone_scanner(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/test_create_scanner.py000066400000000000000000000141551413122500400303770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import ScannerType class GmpCreateScannerTestMixin: def test_create_scanner(self): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) self.connection.send.has_been_called_with( '' 'foo' 'localhost' '1234' '1' '' '' ) def test_create_scanner_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name=None, host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='', host='localhost', port=1234, scanner_type='1', credential_id='c1', ) def test_create_scanner_missing_host(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host=None, port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) def test_create_scanner_missing_port(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=None, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port='', scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) def test_create_scanner_missing_scanner_type(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=None, credential_id='c1', ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type='', credential_id='c1', ) def test_create_scanner_missing_credential_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id=None, ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='', ) def test_create_scanner_invalid_scanner_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type='bar', credential_id='c1', ) with self.assertRaises(InvalidArgumentType): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type='55', credential_id='c1', ) def test_create_scanner_with_ca_pub(self): self.gmp.create_scanner( name='foo', host='localhost', port=1234, ca_pub='foo', scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) self.connection.send.has_been_called_with( '' 'foo' 'localhost' '1234' '1' 'foo' '' '' ) def test_create_scanner_with_comment(self): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', comment='bar', ) self.connection.send.has_been_called_with( '' 'foo' 'localhost' '1234' '1' '' 'bar' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/test_delete_scanner.py000066400000000000000000000026201413122500400303700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteScannerTestMixin: def test_delete(self): self.gmp.delete_scanner('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_scanner('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_scanner(None) with self.assertRaises(GvmError): self.gmp.delete_scanner('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/test_get_scanner.py000066400000000000000000000026171413122500400277130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetScannerTestMixin: def test_get_scanner(self): self.gmp.get_scanner('s1') self.connection.send.has_been_called_with( '' ) self.gmp.get_scanner(scanner_id='s1') self.connection.send.has_been_called_with( '' ) def test_get_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_scanner(scanner_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_scanner('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/test_get_scanners.py000066400000000000000000000036151413122500400300750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetScannersTestMixin: def test_get_scanners(self): self.gmp.get_scanners() self.connection.send.has_been_called_with('') def test_get_scanners_with_filter_string(self): self.gmp.get_scanners(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_scanners_with_filter_id(self): self.gmp.get_scanners(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_scanners_with_trash(self): self.gmp.get_scanners(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_scanners(trash=False) self.connection.send.has_been_called_with('') def test_get_scanners_with_details(self): self.gmp.get_scanners(details=True) self.connection.send.has_been_called_with('') self.gmp.get_scanners(details=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/test_modify_scanner.py000066400000000000000000000115031413122500400304150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import ScannerType class GmpModifyScannerTestMixin: def test_modify_scanner(self): self.gmp.modify_scanner(scanner_id='s1') self.connection.send.has_been_called_with( '' ) def test_modify_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scanner(scanner_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_scanner(scanner_id='') def test_modify_scanner_with_comment(self): self.gmp.modify_scanner(scanner_id='s1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scanner_with_host(self): self.gmp.modify_scanner(scanner_id='s1', host='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scanner_with_port(self): self.gmp.modify_scanner(scanner_id='s1', port=1234) self.connection.send.has_been_called_with( '' '1234' '' ) self.gmp.modify_scanner(scanner_id='s1', port='1234') self.connection.send.has_been_called_with( '' '1234' '' ) def test_modify_scanner_with_name(self): self.gmp.modify_scanner(scanner_id='s1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scanner_with_ca_pub(self): self.gmp.modify_scanner(scanner_id='s1', ca_pub='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scanner_with_credential_id(self): self.gmp.modify_scanner(scanner_id='s1', credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_scanner_with_scanner_type(self): self.gmp.modify_scanner( scanner_id='s1', scanner_type=ScannerType.OSP_SCANNER_TYPE ) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_scanner( scanner_id='s1', scanner_type=ScannerType.OPENVAS_SCANNER_TYPE ) self.connection.send.has_been_called_with( '' '2' '' ) self.gmp.modify_scanner( scanner_id='s1', scanner_type=ScannerType.CVE_SCANNER_TYPE ) self.connection.send.has_been_called_with( '' '3' '' ) self.gmp.modify_scanner( scanner_id='s1', scanner_type=ScannerType.GMP_SCANNER_TYPE ) self.connection.send.has_been_called_with( '' '4' '' ) def test_modify_scanner_invalid_scanner_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_scanner(scanner_id='s1', scanner_type='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_scanner(scanner_id='s1', scanner_type='-1') with self.assertRaises(InvalidArgumentType): self.gmp.modify_scanner(scanner_id='s1', scanner_type=1) python-gvm-21.10.0/tests/protocols/gmpv208/entities/scanners/test_verify_scanner.py000066400000000000000000000022561413122500400304370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpVerifyScannerTestMixin: def test_verify(self): self.gmp.verify_scanner('a1') self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.verify_scanner(None) with self.assertRaises(GvmError): self.gmp.verify_scanner('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/schedules/000077500000000000000000000000001413122500400241475ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/schedules/__init__.py000066400000000000000000000021221413122500400262550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_schedule import GmpCloneScheduleTestMixin from .test_create_schedule import GmpCreateScheduleTestMixin from .test_delete_schedule import GmpDeleteScheduleTestMixin from .test_get_schedule import GmpGetScheduleTestMixin from .test_get_schedules import GmpGetSchedulesTestMixin from .test_modify_schedule import GmpModifyScheduleTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/schedules/test_clone_schedule.py000066400000000000000000000023341413122500400305360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneScheduleTestMixin: def test_clone(self): self.gmp.clone_schedule('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_schedule('') with self.assertRaises(RequiredArgument): self.gmp.clone_schedule(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/schedules/test_create_schedule.py000066400000000000000000000063671413122500400307130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument ICAL = """ BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Greenbone.net//NONSGML Greenbone Security Manager 8.0.0//EN BEGIN:VEVENT UID:c35f82f1-7798-4b84-b2c4-761a33068956 DTSTAMP:20190715T124352Z DTSTART:20190716T040000Z END:VEVENT END:VCALENDAR """ class GmpCreateScheduleTestMixin: def test_missing_name(self): with self.assertRaises(RequiredArgument) as cm: self.gmp.create_schedule(name=None, icalendar=ICAL, timezone='UTC') ex = cm.exception self.assertEqual(ex.argument, "name") with self.assertRaises(RequiredArgument) as cm: self.gmp.create_schedule(name='', icalendar=ICAL, timezone='UTC') ex = cm.exception self.assertEqual(ex.argument, "name") def test_missing_icalendar(self): with self.assertRaises(RequiredArgument) as cm: self.gmp.create_schedule(name='foo', icalendar=None, timezone='UTC') ex = cm.exception self.assertEqual(ex.argument, "icalendar") with self.assertRaises(RequiredArgument) as cm: self.gmp.create_schedule(name='foo', icalendar='', timezone='UTC') ex = cm.exception self.assertEqual(ex.argument, "icalendar") def test_missing_timezone(self): with self.assertRaises(RequiredArgument) as cm: self.gmp.create_schedule(name='foo', icalendar=ICAL, timezone=None) ex = cm.exception self.assertEqual(ex.argument, "timezone") with self.assertRaises(RequiredArgument) as cm: self.gmp.create_schedule(name='foo', icalendar=ICAL, timezone='') ex = cm.exception self.assertEqual(ex.argument, "timezone") def test_create_schedule(self): self.gmp.create_schedule( name='foo', icalendar=ICAL, timezone='Europe/Berlin' ) self.connection.send.has_been_called_with( "" "foo" f"{ICAL}" "Europe/Berlin" "" ) def test_create_schedule_with_comment(self): self.gmp.create_schedule( name='foo', icalendar=ICAL, timezone='Europe/Berlin', comment="bar" ) self.connection.send.has_been_called_with( "" "foo" f"{ICAL}" "Europe/Berlin" "bar" "" ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/schedules/test_delete_schedule.py000066400000000000000000000026311413122500400307000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteScheduleTestMixin: def test_delete(self): self.gmp.delete_schedule('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_schedule('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_schedule(None) with self.assertRaises(GvmError): self.gmp.delete_schedule('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/schedules/test_get_schedule.py000066400000000000000000000034351413122500400302200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetScheduleTestMixin: def test_get_schedule(self): self.gmp.get_schedule('s1') self.connection.send.has_been_called_with( '' ) self.gmp.get_schedule(schedule_id='s1') self.connection.send.has_been_called_with( '' ) def test_get_schedule_missing_schedule_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_schedule(schedule_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_schedule('') def test_get_schedules_with_tasks(self): self.gmp.get_schedule(schedule_id='s1', tasks=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_schedule(schedule_id='s1', tasks=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/schedules/test_get_schedules.py000066400000000000000000000036271413122500400304060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetSchedulesTestMixin: def test_get_schedules(self): self.gmp.get_schedules() self.connection.send.has_been_called_with('') def test_get_schedules_with_filter_string(self): self.gmp.get_schedules(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_schedules_with_filter_id(self): self.gmp.get_schedules(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_schedules_with_trash(self): self.gmp.get_schedules(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_schedules(trash=False) self.connection.send.has_been_called_with('') def test_get_schedules_with_tasks(self): self.gmp.get_schedules(tasks=True) self.connection.send.has_been_called_with('') self.gmp.get_schedules(tasks=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/schedules/test_modify_schedule.py000066400000000000000000000052251413122500400307270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument ICAL = """ BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Greenbone.net//NONSGML Greenbone Security Manager 8.0.0//EN BEGIN:VEVENT UID:c35f82f1-7798-4b84-b2c4-761a33068956 DTSTAMP:20190715T124352Z DTSTART:20190716T040000Z END:VEVENT END:VCALENDAR """ class GmpModifyScheduleTestMixin: def test_missing_schedule_id(self): with self.assertRaises(RequiredArgument) as cm: self.gmp.modify_schedule(schedule_id=None) ex = cm.exception self.assertEqual(ex.argument, "schedule_id") with self.assertRaises(RequiredArgument) as cm: self.gmp.modify_schedule(schedule_id='') ex = cm.exception self.assertEqual(ex.argument, "schedule_id") def test_modify_schedule_with_name(self): self.gmp.modify_schedule(schedule_id='s1', name='foo') self.connection.send.has_been_called_with( '' "foo" "" ) def test_modify_schedule_with_comment(self): self.gmp.modify_schedule(schedule_id="s1", comment="bar") self.connection.send.has_been_called_with( '' "bar" "" ) def test_modify_schedule_with_icalendar(self): self.gmp.modify_schedule(schedule_id="s1", icalendar=ICAL) self.connection.send.has_been_called_with( '' f'{ICAL}' '' ) def test_modify_schedule_with_timezone(self): self.gmp.modify_schedule(schedule_id="s1", timezone="Europe/Berlin") self.connection.send.has_been_called_with( '' 'Europe/Berlin' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/000077500000000000000000000000001413122500400236165ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/__init__.py000066400000000000000000000035131413122500400257310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_cert_bund_advisory import GmpGetCertBundTestMixin from .test_get_cert_bund_advisories import GmpGetCertBundListTestMixin from .test_get_cpe import GmpGetCpeTestMixin from .test_get_cpes import GmpGetCpeListTestMixin from .test_get_cve import GmpGetCveTestMixin from .test_get_cves import GmpGetCveListTestMixin from .test_get_dfn_cert_advisory import GmpGetDfnCertTestMixin from .test_get_dfn_cert_advisories import GmpGetDfnCertListTestMixin from .test_get_info import GmpGetInfoTestMixin from .test_get_info_list import GmpGetInfoListTestMixin from .test_get_nvt import GmpGetNvtTestMixin from .test_get_nvt_families import GmpGetNvtFamiliesTestMixin from .test_get_nvts import GmpGetNvtListTestMixin from .test_get_nvt_preference import GmpGetNvtPreferenceTestMixin from .test_get_nvt_preferences import GmpGetNvtPreferencesTestMixin from .test_get_oval_definition import GmpGetOvalDefTestMixin from .test_get_oval_definitions import GmpGetOvalDefListTestMixin from .test_get_scan_config_nvt import GmpGetScanConfigNvtTestMixin from .test_get_scan_config_nvts import GmpGetScanConfigNvtsTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_cert_bund_advisories.py000066400000000000000000000040071413122500400322640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetCertBundListTestMixin: def test_get_cpes(self): self.gmp.get_cert_bund_advisories() self.connection.send.has_been_called_with( '' ) def test_get_cves_with_filter_string(self): self.gmp.get_cert_bund_advisories(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_filter_id(self): self.gmp.get_cert_bund_advisories(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_name(self): self.gmp.get_cert_bund_advisories(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_details(self): self.gmp.get_cert_bund_advisories(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_cert_bund_advisories(details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_cert_bund_advisory.py000066400000000000000000000031201413122500400317470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetCertBundTestMixin: def test_get_cert_bund_advisory(self): self.gmp.get_cert_bund_advisory(cert_id='i1') self.connection.send.has_been_called_with( '' ) self.gmp.get_cert_bund_advisory('i1') self.connection.send.has_been_called_with( '' ) def test_get_cert_bund_advisory_missing_cert_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_cert_bund_advisory(cert_id='') with self.assertRaises(RequiredArgument): self.gmp.get_cert_bund_advisory('') with self.assertRaises(RequiredArgument): self.gmp.get_cert_bund_advisory(cert_id=None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_cpe.py000066400000000000000000000027121413122500400266370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetCpeTestMixin: def test_get_cpe(self): self.gmp.get_cpe(cpe_id='i1') self.connection.send.has_been_called_with( '' ) self.gmp.get_cpe('i1') self.connection.send.has_been_called_with( '' ) def test_get_cpe_missing_cpe_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_cpe(cpe_id='') with self.assertRaises(RequiredArgument): self.gmp.get_cpe('') with self.assertRaises(RequiredArgument): self.gmp.get_cpe(cpe_id=None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_cpes.py000066400000000000000000000035201413122500400270200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetCpeListTestMixin: def test_get_cpes(self): self.gmp.get_cpes() self.connection.send.has_been_called_with('') def test_get_cpes_with_filter_string(self): self.gmp.get_cpes(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_cpes_with_filter_id(self): self.gmp.get_cpes(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_cpes_with_name(self): self.gmp.get_cpes(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_cpes_with_details(self): self.gmp.get_cpes(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_cpes(details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_cve.py000066400000000000000000000027121413122500400266450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetCveTestMixin: def test_get_cve(self): self.gmp.get_cve(cve_id='i1') self.connection.send.has_been_called_with( '' ) self.gmp.get_cve('i1') self.connection.send.has_been_called_with( '' ) def test_get_cve_missing_cve_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_cve(cve_id='') with self.assertRaises(RequiredArgument): self.gmp.get_cve('') with self.assertRaises(RequiredArgument): self.gmp.get_cve(cve_id=None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_cves.py000066400000000000000000000035201413122500400270260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetCveListTestMixin: def test_get_cpes(self): self.gmp.get_cves() self.connection.send.has_been_called_with('') def test_get_cves_with_filter_string(self): self.gmp.get_cves(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_filter_id(self): self.gmp.get_cves(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_name(self): self.gmp.get_cves(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_details(self): self.gmp.get_cves(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_cves(details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_dfn_cert_advisories.py000066400000000000000000000037721413122500400321130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetDfnCertListTestMixin: def test_get_cpes(self): self.gmp.get_dfn_cert_advisories() self.connection.send.has_been_called_with( '' ) def test_get_cves_with_filter_string(self): self.gmp.get_dfn_cert_advisories(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_filter_id(self): self.gmp.get_dfn_cert_advisories(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_name(self): self.gmp.get_dfn_cert_advisories(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_cves_with_details(self): self.gmp.get_dfn_cert_advisories(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_dfn_cert_advisories(details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_dfn_cert_advisory.py000066400000000000000000000031101413122500400315650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetDfnCertTestMixin: def test_get_cert_bund_advisory(self): self.gmp.get_dfn_cert_advisory(cert_id='i1') self.connection.send.has_been_called_with( '' ) self.gmp.get_dfn_cert_advisory('i1') self.connection.send.has_been_called_with( '' ) def test_get_cert_bund_advisory_missing_cert_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_dfn_cert_advisory(cert_id='') with self.assertRaises(RequiredArgument): self.gmp.get_dfn_cert_advisory('') with self.assertRaises(RequiredArgument): self.gmp.get_dfn_cert_advisory(cert_id=None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_info.py000066400000000000000000000060111413122500400270170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import InfoType class GmpGetInfoTestMixin: def test_get_info(self): self.gmp.get_info(info_type=InfoType.CERT_BUND_ADV, info_id='i1') self.connection.send.has_been_called_with( '' ) self.gmp.get_info('i1', InfoType.CPE) self.connection.send.has_been_called_with( '' ) self.gmp.get_info('i1', InfoType.CVE) self.connection.send.has_been_called_with( '' ) self.gmp.get_info('i1', InfoType.DFN_CERT_ADV) self.connection.send.has_been_called_with( '' ) self.gmp.get_info('i1', InfoType.OVALDEF) self.connection.send.has_been_called_with( '' ) self.gmp.get_info('i1', InfoType.NVT) self.connection.send.has_been_called_with( '' ) with self.assertRaises(AttributeError): self.gmp.get_info( 'i1', InfoType.ALLINFO # pylint: disable=no-member ) def test_get_info_missing_info_type(self): with self.assertRaises(RequiredArgument): self.gmp.get_info(info_id='i1', info_type=None) with self.assertRaises(RequiredArgument): self.gmp.get_info(info_id='i1', info_type='') with self.assertRaises(RequiredArgument): self.gmp.get_info('i1', '') def test_get_info_invalid_info_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.get_info(info_id='i1', info_type='foo') def test_get_info_missing_info_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_info(info_id='', info_type=InfoType.CPE) with self.assertRaises(RequiredArgument): self.gmp.get_info('', info_type=InfoType.CPE) with self.assertRaises(RequiredArgument): self.gmp.get_info(info_id=None, info_type=InfoType.CPE) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_info_list.py000066400000000000000000000071111413122500400300540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import InfoType class GmpGetInfoListTestMixin: def test_get_info_list(self): self.gmp.get_info_list(InfoType.CERT_BUND_ADV) self.connection.send.has_been_called_with( '' ) self.gmp.get_info_list(InfoType.CPE) self.connection.send.has_been_called_with('') self.gmp.get_info_list(info_type=InfoType.CPE) self.connection.send.has_been_called_with('') self.gmp.get_info_list(InfoType.CVE) self.connection.send.has_been_called_with('') self.gmp.get_info_list(InfoType.DFN_CERT_ADV) self.connection.send.has_been_called_with( '' ) self.gmp.get_info_list(InfoType.OVALDEF) self.connection.send.has_been_called_with('') self.gmp.get_info_list(InfoType.NVT) self.connection.send.has_been_called_with('') with self.assertRaises(AttributeError): self.gmp.get_info_list( InfoType.ALLINFO # pylint: disable=no-member ) def test_get_info_list_missing_info_type(self): with self.assertRaises(RequiredArgument): self.gmp.get_info_list(info_type=None) with self.assertRaises(RequiredArgument): self.gmp.get_info_list(info_type='') with self.assertRaises(RequiredArgument): self.gmp.get_info_list('') def test_get_info_list_invalid_info_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.get_info_list(info_type='foo') def test_get_info_list_with_filter_string(self): self.gmp.get_info_list(InfoType.CPE, filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_info_list_with_filter_id(self): self.gmp.get_info_list(info_type=InfoType.CPE, filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_info_list_with_name(self): self.gmp.get_info_list(info_type=InfoType.CPE, name='foo') self.connection.send.has_been_called_with( '' ) def test_get_info_list_with_details(self): self.gmp.get_info_list(info_type=InfoType.CPE, details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_info_list(info_type=InfoType.CPE, details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_nvt.py000066400000000000000000000027121413122500400266770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetNvtTestMixin: def test_get_nvt(self): self.gmp.get_nvt(nvt_id='i1') self.connection.send.has_been_called_with( '' ) self.gmp.get_nvt('i1') self.connection.send.has_been_called_with( '' ) def test_get_nvt_missing_nvt_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_nvt(nvt_id='') with self.assertRaises(RequiredArgument): self.gmp.get_nvt('') with self.assertRaises(RequiredArgument): self.gmp.get_nvt(nvt_id=None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_nvt_families.py000066400000000000000000000022061413122500400305460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetNvtFamiliesTestMixin: def test_get_nvt_families(self): self.gmp.get_nvt_families() self.connection.send.has_been_called_with('') def test_get_nvt_families_with_sort_order(self): self.gmp.get_nvt_families(sort_order='foo') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_nvt_preference.py000066400000000000000000000031251413122500400310740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetNvtPreferenceTestMixin: def test_get_preference(self): self.gmp.get_nvt_preference(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_nvt_preference_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.get_nvt_preference(name=None) with self.assertRaises(RequiredArgument): self.gmp.get_nvt_preference(name='') with self.assertRaises(RequiredArgument): self.gmp.get_nvt_preference('') def test_get_nvt_preference_with_nvt_oid(self): self.gmp.get_nvt_preference(name='foo', nvt_oid='oid') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_nvt_preferences.py000066400000000000000000000022121413122500400312530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetNvtPreferencesTestMixin: def test_get_nvt_preferences(self): self.gmp.get_nvt_preferences() self.connection.send.has_been_called_with('') def test_get_nvt_preferences_with_nvt_oid(self): self.gmp.get_nvt_preferences(nvt_oid='oid') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_nvts.py000066400000000000000000000035201413122500400270600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetNvtListTestMixin: def test_get_cpes(self): self.gmp.get_nvts() self.connection.send.has_been_called_with('') def test_get_nvts_with_filter_string(self): self.gmp.get_nvts(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_nvts_with_filter_id(self): self.gmp.get_nvts(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_nvts_with_name(self): self.gmp.get_nvts(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_nvts_with_details(self): self.gmp.get_nvts(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_nvts(details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_oval_definition.py000066400000000000000000000030561413122500400312430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetOvalDefTestMixin: def test_get_oval_definition(self): self.gmp.get_oval_definition(oval_id='i1') self.connection.send.has_been_called_with( '' ) self.gmp.get_oval_definition('i1') self.connection.send.has_been_called_with( '' ) def test_get_oval_definition_missing_oval_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_oval_definition(oval_id='') with self.assertRaises(RequiredArgument): self.gmp.get_oval_definition('') with self.assertRaises(RequiredArgument): self.gmp.get_oval_definition(oval_id=None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_oval_definitions.py000066400000000000000000000037601413122500400314300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetOvalDefListTestMixin: def test_get_oval_definitions(self): self.gmp.get_oval_definitions() self.connection.send.has_been_called_with('') def test_get_oval_definitions_with_filter_string(self): self.gmp.get_oval_definitions(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_oval_definitions_with_filter_id(self): self.gmp.get_oval_definitions(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_oval_definitions_with_name(self): self.gmp.get_oval_definitions(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_oval_definitions_with_details(self): self.gmp.get_oval_definitions(details=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_oval_definitions(details=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_scan_config_nvt.py000066400000000000000000000027501413122500400312320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetScanConfigNvtTestMixin: def test_get_scan_config_nvt_with_nvt_oid(self): self.gmp.get_scan_config_nvt(nvt_oid='nvt_oid') self.connection.send.has_been_called_with( ( '' ) ) def test_get_scan_config_nvt_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): self.gmp.get_scan_config_nvt(nvt_oid=None) with self.assertRaises(RequiredArgument): self.gmp.get_scan_config_nvt(nvt_oid='') with self.assertRaises(RequiredArgument): self.gmp.get_scan_config_nvt('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/secinfo/test_get_scan_config_nvts.py000066400000000000000000000064251413122500400314200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetScanConfigNvtsTestMixin: def test_get_scan_config_nvts_simple(self): self.gmp.get_scan_config_nvts() self.connection.send.has_been_called_with('') def test_get_scan_config_nvts_with_details(self): self.gmp.get_scan_config_nvts(details=True) self.connection.send.has_been_called_with('') self.gmp.get_scan_config_nvts(details=False) self.connection.send.has_been_called_with('') def test_get_scan_config_nvts_with_preferences(self): self.gmp.get_scan_config_nvts(preferences=True) self.connection.send.has_been_called_with('') self.gmp.get_scan_config_nvts(preferences=False) self.connection.send.has_been_called_with('') def test_get_scan_config_nvts_with_preference_count(self): self.gmp.get_scan_config_nvts(preference_count=True) self.connection.send.has_been_called_with( '' ) def test_get_scan_config_nvts_with_timeout(self): self.gmp.get_scan_config_nvts(timeout=True) self.connection.send.has_been_called_with('') self.gmp.get_scan_config_nvts(timeout=False) self.connection.send.has_been_called_with('') def test_get_scan_config_nvts_with_config_id(self): self.gmp.get_scan_config_nvts(config_id='config_id') self.connection.send.has_been_called_with( '' ) def test_get_scan_config_nvts_with_preferences_config_id(self): self.gmp.get_scan_config_nvts( preferences_config_id='preferences_config_id' ) self.connection.send.has_been_called_with( '' ) def test_get_scan_config_nvts_with_family(self): self.gmp.get_scan_config_nvts(family='family') self.connection.send.has_been_called_with('') def test_get_scan_config_nvts_with_sort_order(self): self.gmp.get_scan_config_nvts(sort_order='sort_order') self.connection.send.has_been_called_with( '' ) def test_get_scan_config_nvts_with_sort_field(self): self.gmp.get_scan_config_nvts(sort_field='sort_field') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tags/000077500000000000000000000000001413122500400231265ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/tags/__init__.py000066400000000000000000000020261413122500400252370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_tag import GmpCloneTagTestMixin from .test_create_tag import GmpCreateTagTestMixin from .test_delete_tag import GmpDeleteTagTestMixin from .test_get_tag import GmpGetTagTestMixin from .test_get_tags import GmpGetTagsTestMixin from .test_modify_tag import GmpModifyTagTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/tags/test_clone_tag.py000066400000000000000000000022761413122500400265010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneTagTestMixin: def test_clone(self): self.gmp.clone_tag('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_tag('') with self.assertRaises(RequiredArgument): self.gmp.clone_tag(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tags/test_create_tag.py000066400000000000000000000175541413122500400266510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import InvalidArgument, RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import EntityType class GmpCreateTagTestMixin: def test_create_tag_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_tag( name=None, resource_ids=['foo'], resource_type=EntityType.TASK ) with self.assertRaises(RequiredArgument): self.gmp.create_tag( name='', resource_ids=['foo'], resource_type=EntityType.TASK ) def test_create_tag_missing_resource_filter_and_ids(self): self.gmp.create_tag( name='foo', resource_filter=None, resource_ids=None, resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( '' 'foo' '' 'task' '' '' ) self.gmp.create_tag( name='foo', resource_filter=None, resource_ids=[], resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( '' 'foo' '' 'task' '' '' ) self.gmp.create_tag(name='foo', resource_type=EntityType.TASK) self.connection.send.has_been_called_with( '' 'foo' '' 'task' '' '' ) def test_create_tag_both_resource_filter_and_ids(self): with self.assertRaises(InvalidArgument): self.gmp.create_tag( name='foo', resource_filter='name=foo', resource_ids=['foo'], resource_type=EntityType.TASK, ) def test_create_tag_invalid_resource_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_tag( name='foo', resource_type="Foo", resource_filter=None, resource_ids=['foo'], ) def test_create_tag_missing_resource_type(self): with self.assertRaises(RequiredArgument): self.gmp.create_tag( name='foo', resource_type=None, resource_filter=None, resource_ids=['foo'], ) with self.assertRaises(RequiredArgument): self.gmp.create_tag( name='foo', resource_type=None, resource_filter="name=foo", resource_ids=None, ) with self.assertRaises(RequiredArgument): self.gmp.create_tag( name='foo', resource_type='', resource_ids=['foo'] ) def test_create_tag_with_resource_filter(self): self.gmp.create_tag( name='foo', resource_filter='name=foo', resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( '' 'foo' '' 'task' '' '' ) def test_create_tag_with_resource_filter_audit(self): self.gmp.create_tag( name='foo', resource_filter='name=foo', resource_type=EntityType.AUDIT, ) self.connection.send.has_been_called_with( '' 'foo' '' 'task' '' '' ) def test_create_tag_with_resource_filter_policy(self): self.gmp.create_tag( name='foo', resource_filter='name=foo', resource_type=EntityType.POLICY, ) self.connection.send.has_been_called_with( '' 'foo' '' 'config' '' '' ) def test_create_tag_with_resource_ids(self): self.gmp.create_tag( name='foo', resource_ids=['foo'], resource_type=EntityType.TASK ) self.connection.send.has_been_called_with( '' 'foo' '' '' 'task' '' '' ) self.gmp.create_tag( name='foo', resource_ids=['foo', 'bar'], resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( '' 'foo' '' '' '' 'task' '' '' ) def test_create_tag_with_comment(self): self.gmp.create_tag( name='foo', resource_ids=['foo'], resource_type=EntityType.TASK, comment='bar', ) self.connection.send.has_been_called_with( '' 'foo' '' '' 'task' '' 'bar' '' ) def test_create_tag_with_value(self): self.gmp.create_tag( name='foo', resource_ids=['foo'], resource_type=EntityType.TASK, value='bar', ) self.connection.send.has_been_called_with( '' 'foo' '' '' 'task' '' 'bar' '' ) def test_create_tag_with_active(self): self.gmp.create_tag( name='foo', resource_ids=['foo'], resource_type=EntityType.TASK, active=True, ) self.connection.send.has_been_called_with( '' 'foo' '' '' 'task' '' '1' '' ) self.gmp.create_tag( name='foo', resource_ids=['foo'], resource_type=EntityType.TASK, active=False, ) self.connection.send.has_been_called_with( '' 'foo' '' '' 'task' '' '0' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tags/test_delete_tag.py000066400000000000000000000025541413122500400266420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteTagTestMixin: def test_delete(self): self.gmp.delete_tag('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_tag('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_tag(None) with self.assertRaises(GvmError): self.gmp.delete_tag('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tags/test_get_tag.py000066400000000000000000000024231413122500400261520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetTagTestMixin: def test_get_tag(self): self.gmp.get_tag('t1') self.connection.send.has_been_called_with('') self.gmp.get_tag(tag_id='t1') self.connection.send.has_been_called_with('') def test_get_tag_missing_tag_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_tag(tag_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_tag('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tags/test_get_tags.py000066400000000000000000000034661413122500400263450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetTagsTestMixin: def test_get_tags(self): self.gmp.get_tags() self.connection.send.has_been_called_with('') def test_get_tags_with_filter_string(self): self.gmp.get_tags(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_tags_with_filter_id(self): self.gmp.get_tags(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_tags_with_trash(self): self.gmp.get_tags(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_tags(trash=False) self.connection.send.has_been_called_with('') def test_get_tags_with_names_only(self): self.gmp.get_tags(names_only=True) self.connection.send.has_been_called_with('') self.gmp.get_tags(names_only=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tags/test_modify_tag.py000066400000000000000000000145611413122500400266700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import EntityType class GmpModifyTagTestMixin: def test_modify_tag(self): self.gmp.modify_tag(tag_id='t1') self.connection.send.has_been_called_with('') def test_modify_tag_missing_tag_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_tag(tag_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_tag(tag_id='') def test_modify_tag_with_comment(self): self.gmp.modify_tag(tag_id='t1', comment='foo') self.connection.send.has_been_called_with( 'foo' ) def test_modify_tag_with_value(self): self.gmp.modify_tag(tag_id='t1', value='foo') self.connection.send.has_been_called_with( 'foo' ) def test_modify_tag_with_name(self): self.gmp.modify_tag(tag_id='t1', name='foo') self.connection.send.has_been_called_with( 'foo' ) def test_modify_tag_with_active(self): self.gmp.modify_tag(tag_id='t1', active=True) self.connection.send.has_been_called_with( '1' ) self.gmp.modify_tag(tag_id='t1', active=False) self.connection.send.has_been_called_with( '0' ) def test_modify_tag_with_resource_filter_and_type(self): self.gmp.modify_tag( tag_id='t1', resource_filter='name=foo', resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( '' '' 'task' '' '' ) def test_modify_tag_with_resource_filter_and_type_audit(self): self.gmp.modify_tag( tag_id='t1', resource_filter='name=foo', resource_type=EntityType.AUDIT, ) self.connection.send.has_been_called_with( '' '' 'task' '' '' ) def test_modify_tag_with_resource_filter_and_type_policy(self): self.gmp.modify_tag( tag_id='t1', resource_filter='name=foo', resource_type=EntityType.POLICY, ) self.connection.send.has_been_called_with( '' '' 'config' '' '' ) def test_modify_tag_with_resource_action_filter_and_type(self): self.gmp.modify_tag( tag_id='t1', resource_action='set', resource_filter='name=foo', resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( '' '' 'task' '' '' ) def test_modify_tag_with_resource_ids_and_type(self): self.gmp.modify_tag( tag_id='t1', resource_ids=['r1'], resource_type=EntityType.TASK ) self.connection.send.has_been_called_with( '' '' '' 'task' '' '' ) def test_modify_tag_with_resource_action_ids_and_type(self): self.gmp.modify_tag( tag_id='t1', resource_action="set", resource_ids=['r1'], resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( '' '' '' 'task' '' '' ) def test_modify_tag_with_missing_resource_filter_or_ids_andtype(self): self.gmp.modify_tag(tag_id='t1', resource_action='add') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_tag_with_missing_resource_type(self): self.gmp.modify_tag(tag_id='t1', resource_ids=['r1']) self.connection.send.has_been_called_with( '' '' '' '' '' ) with self.assertRaises(RequiredArgument): self.gmp.modify_tag(tag_id='t1', resource_filter='name=foo') def test_modify_tag_with_invalid_resource_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_tag( tag_id='t1', resource_type="foo", resource_filter='name=foo' ) def test_modify_tag_with_missing_resource_filter_and_ids(self): self.gmp.modify_tag(tag_id='t1', resource_type=EntityType.TASK) self.connection.send.has_been_called_with( '' '' 'task' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/targets/000077500000000000000000000000001413122500400236415ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/targets/__init__.py000066400000000000000000000020721413122500400257530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_target import GmpCloneTargetTestMixin from .test_create_target import GmpCreateTargetTestMixin from .test_delete_target import GmpDeleteTargetTestMixin from .test_get_target import GmpGetTargetTestMixin from .test_get_targets import GmpGetTargetsTestMixin from .test_modify_target import GmpModifyTargetTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/targets/test_clone_target.py000066400000000000000000000024721413122500400277250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneTargetTestMixin: TARGET_ID = '00000000-0000-0000-0000-000000000000' def test_clone(self): self.gmp.clone_target(self.TARGET_ID) self.connection.send.has_been_called_with( '' f'{self.TARGET_ID}' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_target('') with self.assertRaises(RequiredArgument): self.gmp.clone_target(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/targets/test_create_target.py000066400000000000000000000203521413122500400300650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208.entities.targets import AliveTest class GmpCreateTargetTestMixin: def test_create_target_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_target(None, hosts=['foo']) with self.assertRaises(RequiredArgument): self.gmp.create_target(name=None, hosts=['foo']) with self.assertRaises(RequiredArgument): self.gmp.create_target('', hosts=['foo']) def test_create_target_with_asset_hosts_filter(self): self.gmp.create_target( 'foo', port_list_id='pl1', asset_hosts_filter='name=foo' ) self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_target_missing_hosts(self): with self.assertRaises(RequiredArgument): self.gmp.create_target(name='foo') def test_create_target_with_comment(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', comment='bar' ) self.connection.send.has_been_called_with( '' 'foo' 'foo' 'bar' '' '' ) def test_create_target_with_exclude_hosts(self): self.gmp.create_target( 'foo', hosts=['foo', 'bar'], port_list_id='pl1', exclude_hosts=['bar', 'ipsum'], ) self.connection.send.has_been_called_with( '' 'foo' 'foo,bar' 'bar,ipsum' '' '' ) def test_create_target_with_ssh_credential(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', ssh_credential_id='c1' ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' '' ) def test_create_target_with_ssh_credential_port(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', ssh_credential_id='c1', ssh_credential_port=123, ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '123' '' '' '' ) def test_create_target_with_smb_credential_id(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', smb_credential_id='c1' ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' '' ) def test_create_target_with_esxi_credential_id(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', esxi_credential_id='c1' ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' '' ) def test_create_target_with_snmp_credential_id(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', snmp_credential_id='c1' ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' '' ) def test_create_target_with_alive_tests(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', alive_test=AliveTest.ICMP_PING, ) self.connection.send.has_been_called_with( '' 'foo' 'foo' 'ICMP Ping' '' '' ) def test_create_target_invalid_alive_tests(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', alive_test='foo' ) def test_create_target_with_reverse_lookup_only(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', reverse_lookup_only=True ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '1' '' '' ) self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', reverse_lookup_only=False ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '0' '' '' ) def test_create_target_with_reverse_lookup_unify(self): self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', reverse_lookup_unify=True ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '1' '' '' ) self.gmp.create_target( 'foo', hosts=['foo'], port_list_id='pl1', reverse_lookup_unify=False ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '0' '' '' ) def test_create_target_with_port_range(self): self.gmp.create_target('foo', hosts=['foo'], port_range='bar') self.connection.send.has_been_called_with( '' 'foo' 'foo' 'bar' '' ) def test_create_target_with_port_list_id(self): self.gmp.create_target('foo', hosts=['foo'], port_list_id='pl1') self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' ) def test_create_target_without_ports(self): with self.assertRaises(RequiredArgument): self.gmp.create_target('foo', hosts=['foo']) python-gvm-21.10.0/tests/protocols/gmpv208/entities/targets/test_delete_target.py000066400000000000000000000026071413122500400300670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteTargetTestMixin: def test_delete(self): self.gmp.delete_target('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_target('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_target(None) with self.assertRaises(GvmError): self.gmp.delete_target('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/targets/test_get_target.py000066400000000000000000000033561413122500400274060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetTargetTestMixin: def test_get_target(self): self.gmp.get_target('t1') self.connection.send.has_been_called_with( '' ) self.gmp.get_target(target_id='t1') self.connection.send.has_been_called_with( '' ) def test_get_target_missing_target_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_target(target_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_target('') def test_get_target_with_tasks(self): self.gmp.get_target(target_id='t1', tasks=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_target(target_id='t1', tasks=False) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/targets/test_get_targets.py000066400000000000000000000035311413122500400275640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetTargetsTestMixin: def test_get_targets(self): self.gmp.get_targets() self.connection.send.has_been_called_with('') def test_get_targets_with_filter_string(self): self.gmp.get_targets(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_targets_with_filter_id(self): self.gmp.get_targets(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_targets_with_trash(self): self.gmp.get_targets(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_targets(trash=False) self.connection.send.has_been_called_with('') def test_get_targets_with_tasks(self): self.gmp.get_targets(tasks=True) self.connection.send.has_been_called_with('') self.gmp.get_targets(tasks=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/targets/test_modify_target.py000066400000000000000000000157741413122500400301250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208.entities.targets import AliveTest class GmpModifyTargetTestMixin: def test_modify_target(self): self.gmp.modify_target(target_id='t1') self.connection.send.has_been_called_with( '' ) def test_modify_target_missing_target_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_target(target_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_target(target_id='') def test_modify_target_with_comment(self): self.gmp.modify_target(target_id='t1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_target_with_hosts(self): self.gmp.modify_target(target_id='t1', hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' '' ) self.gmp.modify_target(target_id='t1', hosts=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' '' ) def test_modify_target_with_hosts_and_exclude_hosts(self): self.gmp.modify_target( target_id='t1', hosts=['foo', 'bar'], exclude_hosts=['foo'] ) self.connection.send.has_been_called_with( '' 'foo,bar' 'foo' '' ) def test_modify_target_with_name(self): self.gmp.modify_target(target_id='t1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_target_with_exclude_hosts(self): self.gmp.modify_target(target_id='t1', exclude_hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_target(target_id='t1', exclude_hosts=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) def test_modify_target_with_ssh_credential(self): self.gmp.modify_target(target_id='t1', ssh_credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_target_with_ssh_credential_port(self): self.gmp.modify_target( target_id='t1', ssh_credential_id='c1', ssh_credential_port=123 ) self.connection.send.has_been_called_with( '' '' '123' '' '' ) def test_modify_target_with_smb_credential_id(self): self.gmp.modify_target(target_id='t1', smb_credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_target_with_esxi_credential_id(self): self.gmp.modify_target(target_id='t1', esxi_credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_target_with_snmp_credential_id(self): self.gmp.modify_target(target_id='t1', snmp_credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_target_with_alive_tests(self): self.gmp.modify_target(target_id='t1', alive_test=AliveTest.ICMP_PING) self.connection.send.has_been_called_with( '' 'ICMP Ping' '' ) def test_modify_target_invalid_alive_tests(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_target(target_id='t1', alive_test='foo') def test_modify_target_with_reverse_lookup_only(self): self.gmp.modify_target(target_id='t1', reverse_lookup_only=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_target(target_id='t1', reverse_lookup_only=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_target_with_reverse_lookup_unify(self): self.gmp.modify_target(target_id='t1', reverse_lookup_unify=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_target(target_id='t1', reverse_lookup_unify=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_target_with_port_list_id(self): self.gmp.modify_target(target_id='t1', port_list_id='pl1') self.connection.send.has_been_called_with( '' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/000077500000000000000000000000001413122500400233155ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/__init__.py000066400000000000000000000024641413122500400254340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_task import GmpCloneTaskTestMixin from .test_create_container_task import GmpCreateContainerTaskTestMixin from .test_create_task import GmpCreateTaskTestMixin from .test_delete_task import GmpDeleteTaskTestMixin from .test_get_task import GmpGetTaskTestMixin from .test_get_tasks import GmpGetTasksTestMixin from .test_modify_task import GmpModifyTaskTestMixin from .test_move_task import GmpMoveTaskTestMixin from .test_resume_task import GmpResumeTaskTestMixin from .test_start_task import GmpStartTaskTestMixin from .test_stop_task import GmpStopTaskTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_clone_task.py000066400000000000000000000022761413122500400270570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneTaskTestMixin: def test_clone(self): self.gmp.clone_task('a1') self.connection.send.has_been_called_with( 'a1' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_task('') with self.assertRaises(RequiredArgument): self.gmp.clone_task(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_create_container_task.py000066400000000000000000000032251413122500400312570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateContainerTaskTestMixin: def test_create_task(self): self.gmp.create_container_task(name='foo') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_task_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_container_task(name=None) with self.assertRaises(RequiredArgument): self.gmp.create_container_task(name='') def test_create_task_with_comment(self): self.gmp.create_container_task(name='foo', comment='bar') self.connection.send.has_been_called_with( '' 'foo' '' 'bar' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_create_task.py000066400000000000000000000316561413122500400272260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from collections import OrderedDict from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.protocols.gmpv208 import HostsOrdering class GmpCreateTaskTestMixin: def test_create_task(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1' ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '' ) def test_create_task_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_task( name=None, config_id='c1', target_id='t1', scanner_id='s1' ) with self.assertRaises(RequiredArgument): self.gmp.create_task( name='', config_id='c1', target_id='t1', scanner_id='s1' ) def test_create_task_missing_config_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_task( name='foo', config_id=None, target_id='t1', scanner_id='s1' ) with self.assertRaises(RequiredArgument): self.gmp.create_task( name='foo', config_id='', target_id='t1', scanner_id='s1' ) def test_create_task_missing_target_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_task( name='foo', config_id='c1', target_id=None, scanner_id='s1' ) with self.assertRaises(RequiredArgument): self.gmp.create_task( name='foo', config_id='c1', target_id='', scanner_id='s1' ) def test_create_task_missing_scanner_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id=None ) with self.assertRaises(RequiredArgument): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='' ) def test_create_task_with_comment(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', comment='bar', ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' 'bar' '' ) def test_create_task_single_alert(self): # pylint: disable=invalid-name self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', alert_ids=['a1'], ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '' '' ) def test_create_task_multiple_alerts(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', alert_ids=['a1', 'a2', 'a3'], ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '' '' '' '' ) def test_create_task_invalid_alerts(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', alert_ids='invalid', ) def test_create_task_with_empty_alert_ids(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', alert_ids=[], ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '' ) def test_create_task_with_alterable(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', alterable=True, ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '1' '' ) self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', alterable=False, ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '0' '' ) def test_create_task_with_hosts_ordering(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', hosts_ordering=HostsOrdering.REVERSE, ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' 'reverse' '' ) def test_create_task_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', hosts_ordering='foo', ) def test_create_task_with_schedule(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '' '' ) def test_create_task_with_schedule_and_schedule_periods(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', schedule_periods=0, ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '' '0' '' ) self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', schedule_periods=5, ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '' '5' '' ) def test_create_task_with_schedule_and_invalid_schedule_periods(self): with self.assertRaises(InvalidArgument): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', schedule_periods='foo', ) with self.assertRaises(InvalidArgument): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', schedule_id='s1', schedule_periods=-1, ) def test_create_task_with_observers(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', observers=['u1', 'u2'], ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' 'u1,u2' '' ) def test_create_task_invalid_observers(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', observers='', ) with self.assertRaises(InvalidArgumentType): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', observers='foo', ) def test_create_task_with_preferences(self): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', preferences=OrderedDict([('foo', 'bar'), ('lorem', 'ipsum')]), ) self.connection.send.has_been_called_with( '' 'foo' 'scan' '' '' '' '' '' 'foo' 'bar' '' '' 'lorem' 'ipsum' '' '' '' ) def test_create_task_invalid_preferences(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', preferences='', ) with self.assertRaises(InvalidArgumentType): self.gmp.create_task( name='foo', config_id='c1', target_id='t1', scanner_id='s1', preferences=['foo', 'bar'], ) def test_create_task_don_t_allow_container_task(self): with self.assertRaises(InvalidArgument): self.gmp.create_task( name='foo', config_id='c1', target_id='0', scanner_id='s1', observers='', ) # target_id=0 is considered as False with self.assertRaises(RequiredArgument): self.gmp.create_task( name='foo', config_id='c1', target_id=0, scanner_id='s1', observers='', ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_delete_task.py000066400000000000000000000025651413122500400272220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteTaskTestMixin: def test_delete(self): self.gmp.delete_task('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_task('a1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_task(None) with self.assertRaises(GvmError): self.gmp.delete_task('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_get_task.py000066400000000000000000000022701413122500400265300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpGetTaskTestMixin: def test_get_task(self): self.gmp.get_task('a1') self.connection.send.has_been_called_with( '' ) def test_fail_without_task_id(self): with self.assertRaises(GvmError): self.gmp.get_task(None) with self.assertRaises(GvmError): self.gmp.get_task('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_get_tasks.py000066400000000000000000000042671413122500400267230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetTasksTestMixin: def test_get_tasks_simple(self): self.gmp.get_tasks() self.connection.send.has_been_called_with( '' ) def test_get_tasks_with_filter_string(self): self.gmp.get_tasks(filter_string='name=foo') self.connection.send.has_been_called_with( '' ) def test_get_tasks_with_filter_id(self): self.gmp.get_tasks(filter_id='f1') self.connection.send.has_been_called_with( '' ) def test_get_tasks_from_trash(self): self.gmp.get_tasks(trash=True) self.connection.send.has_been_called_with( '' ) def test_get_tasks_with_details(self): self.gmp.get_tasks(details=True) self.connection.send.has_been_called_with( '' ) def test_get_tasks_without_details(self): self.gmp.get_tasks(details=False) self.connection.send.has_been_called_with( '' ) def test_get_tasks_with_schedules_only(self): self.gmp.get_tasks(schedules_only=True) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_modify_task.py000066400000000000000000000164221413122500400272440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from collections import OrderedDict from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.protocols.gmpv208 import HostsOrdering class GmpModifyTaskTestMixin: def test_modify_task(self): self.gmp.modify_task('t1') self.connection.send.has_been_called_with('') def test_modify_task_missing_task_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_task(None) with self.assertRaises(RequiredArgument): self.gmp.modify_task('') with self.assertRaises(RequiredArgument): self.gmp.modify_task(task_id='') def test_modify_task_with_name(self): self.gmp.modify_task(task_id='t1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_task_with_config_id(self): self.gmp.modify_task(task_id='t1', config_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_task_with_target_id(self): self.gmp.modify_task(task_id='t1', target_id='t1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_task_with_scanner_id(self): self.gmp.modify_task(task_id='t1', scanner_id='s1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_task_with_schedule_id(self): self.gmp.modify_task(task_id='t1', schedule_id='s1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_task_with_comment(self): self.gmp.modify_task(task_id='t1', comment='bar') self.connection.send.has_been_called_with( '' 'bar' '' ) def test_modify_task_with_alerts_ids(self): self.gmp.modify_task(task_id='t1', alert_ids=['a1', 'a2', 'a3']) self.connection.send.has_been_called_with( '' '' '' '' '' ) def test_modify_task_invalid_alerts_ids(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_task(task_id='t1', alert_ids='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_task(task_id='t1', alert_ids='a1') def test_modify_task_with_empty_alert_ids(self): self.gmp.modify_task(task_id='t1', alert_ids=[]) self.connection.send.has_been_called_with( '' '' '' ) def test_modify_task_with_alterable(self): self.gmp.modify_task(task_id='t1', alterable=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_task(task_id='t1', alterable=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_task_with_hosts_ordering(self): self.gmp.modify_task(task_id='t1', hosts_ordering=HostsOrdering.REVERSE) self.connection.send.has_been_called_with( '' 'reverse' '' ) def test_modify_task_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_task(task_id='t1', hosts_ordering='foo') def test_modify_task_with_schedule(self): self.gmp.modify_task(task_id='t1', schedule_id='s1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_task_with_schedule_periods(self): self.gmp.modify_task(task_id='t1', schedule_periods=0) self.connection.send.has_been_called_with( '' '0' '' ) self.gmp.modify_task(task_id='t1', schedule_periods=5) self.connection.send.has_been_called_with( '' '5' '' ) def test_modify_task_invalid_schedule_periods(self): with self.assertRaises(InvalidArgument): self.gmp.modify_task(task_id='t1', schedule_periods='foo') with self.assertRaises(InvalidArgument): self.gmp.modify_task(task_id='t1', schedule_periods=-1) def test_modify_task_with_observers(self): self.gmp.modify_task(task_id='t1', observers=['u1', 'u2']) self.connection.send.has_been_called_with( '' 'u1,u2' '' ) def test_modify_task_invalid_observers(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_task(task_id='t1', observers='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_task(task_id='t1', observers='foo') def test_modify_task_with_preferences(self): self.gmp.modify_task( task_id='t1', preferences=OrderedDict([('foo', 'bar'), ('lorem', 'ipsum')]), ) self.connection.send.has_been_called_with( '' '' '' 'foo' 'bar' '' '' 'lorem' 'ipsum' '' '' '' ) def test_modify_task_invalid_preferences(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_task(task_id='t1', preferences='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_task(task_id='t1', preferences=['foo', 'bar']) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_move_task.py000066400000000000000000000025131413122500400267170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpMoveTaskTestMixin: def test_move_task(self): self.gmp.move_task('a1') self.connection.send.has_been_called_with('') def test_move_task_to_slave(self): self.gmp.move_task('a1', slave_id='s1') self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.move_task(None) with self.assertRaises(GvmError): self.gmp.move_task('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_resume_task.py000066400000000000000000000022131413122500400272460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpResumeTaskTestMixin: def test_resume_task(self): self.gmp.resume_task('a1') self.connection.send.has_been_called_with('') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.resume_task(None) with self.assertRaises(GvmError): self.gmp.resume_task('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_start_task.py000066400000000000000000000022051413122500400271040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpStartTaskTestMixin: def test_start_task(self): self.gmp.start_task('a1') self.connection.send.has_been_called_with('') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.start_task(None) with self.assertRaises(GvmError): self.gmp.start_task('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tasks/test_stop_task.py000066400000000000000000000021771413122500400267440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpStopTaskTestMixin: def test_stop_task(self): self.gmp.stop_task('a1') self.connection.send.has_been_called_with('') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.stop_task(None) with self.assertRaises(GvmError): self.gmp.stop_task('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_alerts.py000066400000000000000000000032721413122500400250770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .alerts import ( GmpCloneAlertTestMixin, GmpCreateAlertTestMixin, GmpDeleteAlertTestMixin, GmpGetAlertsTestMixin, GmpGetAlertTestMixin, GmpModifyAlertTestMixin, GmpTestAlertTestMixin, GmpTriggerAlertTestMixin, ) class Gmpv208CloneAlertTestCase(GmpCloneAlertTestMixin, Gmpv208TestCase): pass class Gmpv208CreateAlertTestCase(GmpCreateAlertTestMixin, Gmpv208TestCase): pass class Gmpv208DeleteAlertTestCase(GmpDeleteAlertTestMixin, Gmpv208TestCase): pass class Gmpv208GetAlertTestCase(GmpGetAlertTestMixin, Gmpv208TestCase): pass class Gmpv208GetAlertsTestCase(GmpGetAlertsTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyAlertTestCase(GmpModifyAlertTestMixin, Gmpv208TestCase): pass class Gmpv208TestAlertTestCase(GmpTestAlertTestMixin, Gmpv208TestCase): pass class Gmpv208TriggerAlertTestCase(GmpTriggerAlertTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_audits.py000066400000000000000000000034501413122500400250740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .audits import ( GmpCloneAuditTestMixin, GmpCreateAuditTestMixin, GmpDeleteAuditTestMixin, GmpGetAuditsTestMixin, GmpGetAuditTestMixin, GmpModifyAuditTestMixin, GmpResumeAuditTestMixin, GmpStartAuditTestMixin, GmpStopAuditTestMixin, ) class Gmpv208CloneAuditTestCase(GmpCloneAuditTestMixin, Gmpv208TestCase): pass class Gmpv208CreateAuditTestCase(GmpCreateAuditTestMixin, Gmpv208TestCase): pass class Gmpv208DeleteAuditTestCase(GmpDeleteAuditTestMixin, Gmpv208TestCase): pass class Gmpv208GetAuditTestCase(GmpGetAuditTestMixin, Gmpv208TestCase): pass class Gmpv208GetAuditsTestCase(GmpGetAuditsTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyAuditTestCase(GmpModifyAuditTestMixin, Gmpv208TestCase): pass class Gmpv208ResumeAuditTestCase(GmpResumeAuditTestMixin, Gmpv208TestCase): pass class Gmpv208StartAuditTestCase(GmpStartAuditTestMixin, Gmpv208TestCase): pass class Gmpv208StopAuditTestCase(GmpStopAuditTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_credentials.py000066400000000000000000000031221413122500400260740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .credentials import ( GmpCloneCredentialTestMixin, GmpCreateCredentialTestMixin, GmpDeleteCredentialTestMixin, GmpGetCredentialsTestMixin, GmpGetCredentialTestMixin, GmpModifyCredentialTestMixin, ) class Gmpv208CloneCredentialTestCase( GmpCloneCredentialTestMixin, Gmpv208TestCase ): pass class Gmpv208CreateCredentialTestCase( GmpCreateCredentialTestMixin, Gmpv208TestCase ): pass class Gmpv208DeleteCredentialTestCase( GmpDeleteCredentialTestMixin, Gmpv208TestCase ): pass class Gmpv208GetCredentialTestCase(GmpGetCredentialTestMixin, Gmpv208TestCase): pass class Gmpv208GetCredentialsTestCase( GmpGetCredentialsTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyCredentialTestCase( GmpModifyCredentialTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_filters.py000066400000000000000000000027501413122500400252550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .filters import ( GmpCloneFilterTestMixin, GmpCreateFilterTestMixin, GmpDeleteFilterTestMixin, GmpGetFilterTestMixin, GmpGetFiltersTestMixin, GmpModifyFilterTestMixin, ) class Gmpv208DeleteFilterTestCase(GmpDeleteFilterTestMixin, Gmpv208TestCase): pass class Gmpv208GetFilterTestCase(GmpGetFilterTestMixin, Gmpv208TestCase): pass class Gmpv208GetFiltersTestCase(GmpGetFiltersTestMixin, Gmpv208TestCase): pass class Gmpv208CloneFilterTestCase(GmpCloneFilterTestMixin, Gmpv208TestCase): pass class Gmpv208CreateFilterTestCase(GmpCreateFilterTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyFilterTestCase(GmpModifyFilterTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_groups.py000066400000000000000000000027251413122500400251260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .groups import ( GmpCloneGroupTestMixin, GmpCreateGroupTestMixin, GmpDeleteGroupTestMixin, GmpGetGroupTestMixin, GmpGetGroupsTestMixin, GmpModifyGroupTestMixin, ) class Gmpv208DeleteGroupTestCase(GmpDeleteGroupTestMixin, Gmpv208TestCase): pass class Gmpv208GetGroupTestCase(GmpGetGroupTestMixin, Gmpv208TestCase): pass class Gmpv208GetGroupsTestCase(GmpGetGroupsTestMixin, Gmpv208TestCase): pass class Gmpv208CloneGroupTestCase(GmpCloneGroupTestMixin, Gmpv208TestCase): pass class Gmpv208CreateGroupTestCase(GmpCreateGroupTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyGroupTestCase(GmpModifyGroupTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_hosts.py000066400000000000000000000025241413122500400247440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .hosts import ( GmpCreateHostTestMixin, GmpDeleteHostTestMixin, GmpGetHostsTestMixin, GmpGetHostTestMixin, GmpModifyHostTestMixin, ) class Gmpv208CreateHostTestCase(GmpCreateHostTestMixin, Gmpv208TestCase): pass class Gmpv208DeleteHostTestCase(GmpDeleteHostTestMixin, Gmpv208TestCase): pass class Gmpv208GetHostTestCase(GmpGetHostTestMixin, Gmpv208TestCase): pass class Gmpv208GetHostsTestCase(GmpGetHostsTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyHostTestCase(GmpModifyHostTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_notes.py000066400000000000000000000027021413122500400247320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .notes import ( GmpCloneNoteTestMixin, GmpCreateNoteTestMixin, GmpDeleteNoteTestMixin, GmpGetNoteTestMixin, GmpGetNotesTestMixin, GmpModifyNoteTestMixin, ) class Gmpv208DeleteNoteTestCase(GmpDeleteNoteTestMixin, Gmpv208TestCase): pass class Gmpv208GetNoteTestCase(GmpGetNoteTestMixin, Gmpv208TestCase): pass class Gmpv208GetNotesTestCase(GmpGetNotesTestMixin, Gmpv208TestCase): pass class Gmpv208CloneNoteTestCase(GmpCloneNoteTestMixin, Gmpv208TestCase): pass class Gmpv208CreateNoteTestCase(GmpCreateNoteTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyNoteTestCase(GmpModifyNoteTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_operating_systems.py000066400000000000000000000026131413122500400273620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .operating_systems import ( GmpDeleteOperatingSystemTestMixin, GmpGetOperatingSystemsTestMixin, GmpGetOperatingSystemTestMixin, GmpModifyOperatingSystemTestMixin, ) class Gmpv208DeleteOperatingSystemTestCase( GmpDeleteOperatingSystemTestMixin, Gmpv208TestCase ): pass class Gmpv208GetOperatingSystemTestCase( GmpGetOperatingSystemTestMixin, Gmpv208TestCase ): pass class Gmpv208GetOperatingSystemsTestCase( GmpGetOperatingSystemsTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyOperatingSystemTestCase( GmpModifyOperatingSystemTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_overrides.py000066400000000000000000000030401413122500400256000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .overrides import ( GmpCloneOverrideTestMixin, GmpCreateOverrideTestMixin, GmpDeleteOverrideTestMixin, GmpGetOverridesTestMixin, GmpGetOverrideTestMixin, GmpModifyOverrideTestMixin, ) class Gmpv208CloneOverrideTestCase(GmpCloneOverrideTestMixin, Gmpv208TestCase): pass class Gmpv208CreateOverrideTestCase( GmpCreateOverrideTestMixin, Gmpv208TestCase ): pass class Gmpv208DeleteOverrideTestCase( GmpDeleteOverrideTestMixin, Gmpv208TestCase ): pass class Gmpv208GetOverrideTestCase(GmpGetOverrideTestMixin, Gmpv208TestCase): pass class Gmpv208GetOverridesTestCase(GmpGetOverridesTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyOverrideTestCase( GmpModifyOverrideTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_permissions.py000066400000000000000000000031221413122500400261520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .permissions import ( GmpClonePermissionTestMixin, GmpCreatePermissionTestMixin, GmpDeletePermissionTestMixin, GmpGetPermissionTestMixin, GmpGetPermissionsTestMixin, GmpModifyPermissionTestMixin, ) class Gmpv208DeletePermissionTestCase( GmpDeletePermissionTestMixin, Gmpv208TestCase ): pass class Gmpv208GetPermissionTestCase(GmpGetPermissionTestMixin, Gmpv208TestCase): pass class Gmpv208GetPermissionsTestCase( GmpGetPermissionsTestMixin, Gmpv208TestCase ): pass class Gmpv208ClonePermissionTestCase( GmpClonePermissionTestMixin, Gmpv208TestCase ): pass class Gmpv208CreatePermissionTestCase( GmpCreatePermissionTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyPermissionTestCase( GmpModifyPermissionTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_policies.py000066400000000000000000000047341413122500400254200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .policies import ( GmpClonePolicyTestMixin, GmpCreatePolicyTestMixin, GmpDeletePolicyTestMixin, GmpGetPolicyTestMixin, GmpGetPoliciesTestMixin, GmpImportPolicyTestMixin, GmpModifyPolicySetCommentTestMixin, GmpModifyPolicySetFamilySelectionTestMixin, GmpModifyPolicySetNameTestMixin, GmpModifyPolicySetNvtPreferenceTestMixin, GmpModifyPolicySetNvtSelectionTestMixin, GmpModifyPolicySetScannerPreferenceTestMixin, ) class Gmpv208ClonePolicyTestCase(GmpClonePolicyTestMixin, Gmpv208TestCase): pass class Gmpv208CreatePolicyTestCase(GmpCreatePolicyTestMixin, Gmpv208TestCase): pass class Gmpv208DeletePolicyTestCase(GmpDeletePolicyTestMixin, Gmpv208TestCase): pass class Gmpv208GetPolicyTestCase(GmpGetPolicyTestMixin, Gmpv208TestCase): pass class Gmpv208GetPoliciesTestCase(GmpGetPoliciesTestMixin, Gmpv208TestCase): pass class Gmpv208ImportPolicyTestCase(GmpImportPolicyTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyPolicySetCommentTestCase( GmpModifyPolicySetCommentTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyPolicySetFamilySelectionTestCase( GmpModifyPolicySetFamilySelectionTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyPolicySetNvtSelectionTestCase( GmpModifyPolicySetNvtSelectionTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyPolicySetNameTestCase( GmpModifyPolicySetNameTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyPolicySetNvtPreferenceTestCase( GmpModifyPolicySetNvtPreferenceTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyPolicySetScannerPreferenceTestCase( GmpModifyPolicySetScannerPreferenceTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_port_lists.py000066400000000000000000000034611413122500400260070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .port_lists import ( GmpClonePortListTestMixin, GmpCreatePortListTestMixin, GmpCreatePortRangeTestMixin, GmpDeletePortListTestMixin, GmpDeletePortRangeTestMixin, GmpGetPortListsTestMixin, GmpGetPortListTestMixin, GmpModifyPortListTestMixin, ) class Gmpv208ClonePortListTestCase(GmpClonePortListTestMixin, Gmpv208TestCase): pass class Gmpv208CreatePortListTestCase( GmpCreatePortListTestMixin, Gmpv208TestCase ): pass class Gmpv208CreatePortRangeListTestCase( GmpCreatePortRangeTestMixin, Gmpv208TestCase ): pass class Gmpv208DeletePortListTestCase( GmpDeletePortListTestMixin, Gmpv208TestCase ): pass class Gmpv208DeletePortRangeTestCase( GmpDeletePortRangeTestMixin, Gmpv208TestCase ): pass class Gmpv208GetPortListTestCase(GmpGetPortListTestMixin, Gmpv208TestCase): pass class Gmpv208GetPortListsTestCase(GmpGetPortListsTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyPortListTestCase( GmpModifyPortListTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_report_formats.py000066400000000000000000000034161413122500400266530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .report_formats import ( GmpCloneReportFormatTestMixin, GmpImportReportFormatTestMixin, GmpDeleteReportFormatTestMixin, GmpGetReportFormatTestMixin, GmpGetReportFormatsTestMixin, GmpModifyReportFormatTestMixin, GmpVerifyReportFormatTestMixin, ) class Gmpv208DeleteReportFormatTestCase( GmpDeleteReportFormatTestMixin, Gmpv208TestCase ): pass class Gmpv208GetReportFormatTestCase( GmpGetReportFormatTestMixin, Gmpv208TestCase ): pass class Gmpv208GetReportFormatsTestCase( GmpGetReportFormatsTestMixin, Gmpv208TestCase ): pass class Gmpv208CloneReportFormatTestCase( GmpCloneReportFormatTestMixin, Gmpv208TestCase ): pass class Gmpv208ImportReportFormatTestCase( GmpImportReportFormatTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyReportFormatTestCase( GmpModifyReportFormatTestMixin, Gmpv208TestCase ): pass class Gmpv208VerifyReportFormatTestCase( GmpVerifyReportFormatTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_reports.py000066400000000000000000000023751413122500400253060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .reports import ( GmpDeleteReportTestMixin, GmpGetReportsTestMixin, GmpGetReportTestMixin, GmpImportReportTestMixin, ) class Gmpv208DeleteReportTestCase(GmpDeleteReportTestMixin, Gmpv208TestCase): pass class Gmpv208GetReportTestCase(GmpGetReportTestMixin, Gmpv208TestCase): pass class Gmpv208GetReportsTestCase(GmpGetReportsTestMixin, Gmpv208TestCase): pass class Gmpv208ImportReportTestCase(GmpImportReportTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_results.py000066400000000000000000000020171413122500400253020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .results import ( GmpGetResultsTestMixin, GmpGetResultTestMixin, ) class Gmpv208GetResultTestCase(GmpGetResultTestMixin, Gmpv208TestCase): pass class Gmpv208GetResultsTestCase(GmpGetResultsTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_roles.py000066400000000000000000000027021413122500400247260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .roles import ( GmpCloneRoleTestMixin, GmpCreateRoleTestMixin, GmpDeleteRoleTestMixin, GmpGetRoleTestMixin, GmpGetRolesTestMixin, GmpModifyRoleTestMixin, ) class Gmpv208DeleteRoleTestCase(GmpDeleteRoleTestMixin, Gmpv208TestCase): pass class Gmpv208GetRoleTestCase(GmpGetRoleTestMixin, Gmpv208TestCase): pass class Gmpv208GetRolesTestCase(GmpGetRolesTestMixin, Gmpv208TestCase): pass class Gmpv208CloneRoleTestCase(GmpCloneRoleTestMixin, Gmpv208TestCase): pass class Gmpv208CreateRoleTestCase(GmpCreateRoleTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyRoleTestCase(GmpModifyRoleTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_scan_configs.py000066400000000000000000000066111413122500400262410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .scan_configs import ( GmpCloneScanConfigTestMixin, GmpCreateScanConfigTestMixin, GmpCreateScanConfigFromOSPScannerTestMixin, GmpDeleteScanConfigTestMixin, GmpGetScanConfigTestMixin, GmpGetScanConfigsTestMixin, GmpGetScanConfigPreferencesTestMixin, GmpGetScanConfigPreferenceTestMixin, GmpImportScanConfigTestMixin, GmpModifyScanConfigSetCommentTestMixin, GmpModifyScanConfigSetFamilySelectionTestMixin, GmpModifyScanConfigSetNameTestMixin, GmpModifyScanConfigSetNvtPreferenceTestMixin, GmpModifyScanConfigSetNvtSelectionTestMixin, GmpModifyScanConfigSetScannerPreferenceTestMixin, GmpModifyScanConfigTestMixin, GmpSyncScanConfigTestMixin, ) class Gmpv208CloneScanConfigTestCase( GmpCloneScanConfigTestMixin, Gmpv208TestCase ): pass class Gmpv208CreateScanConfigTestCase( GmpCreateScanConfigTestMixin, Gmpv208TestCase ): pass class Gmpv208CreateScanConfigFromOSPScannerTestCase( GmpCreateScanConfigFromOSPScannerTestMixin, Gmpv208TestCase ): pass class Gmpv208DeleteScanConfigTestCase( GmpDeleteScanConfigTestMixin, Gmpv208TestCase ): pass class Gmpv208GetScanConfigTestCase(GmpGetScanConfigTestMixin, Gmpv208TestCase): pass class Gmpv208GetScanConfigsTestCase( GmpGetScanConfigsTestMixin, Gmpv208TestCase ): pass class Gmpv208GetScanConfigPreferenceTestCase( GmpGetScanConfigPreferenceTestMixin, Gmpv208TestCase ): pass class Gmpv208GetScanConfigPreferencesTestCase( GmpGetScanConfigPreferencesTestMixin, Gmpv208TestCase ): pass class Gmpv208ImportScanConfigTestCase( GmpImportScanConfigTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyScanConfigSetCommentTestCase( GmpModifyScanConfigSetCommentTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyScanConfigSetFamilySelectionTestCase( GmpModifyScanConfigSetFamilySelectionTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyScanConfigSetNvtSelectionTestCase( GmpModifyScanConfigSetNvtSelectionTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyScanConfigSetNameTestCase( GmpModifyScanConfigSetNameTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyScanConfigSetNvtPreferenceTestCase( GmpModifyScanConfigSetNvtPreferenceTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyScanConfigSetScannerPreferenceTestCase( GmpModifyScanConfigSetScannerPreferenceTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyScanConfigTestCase( GmpModifyScanConfigTestMixin, Gmpv208TestCase ): pass class Gmpv208SyncScanConfigTestCase( GmpSyncScanConfigTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_scanners.py000066400000000000000000000031661413122500400254230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .scanners import ( GmpCloneScannerTestMixin, GmpCreateScannerTestMixin, GmpDeleteScannerTestMixin, GmpGetScannersTestMixin, GmpGetScannerTestMixin, GmpModifyScannerTestMixin, GmpVerifyScannerTestMixin, ) class Gmpv208CloneScannerTestCase(GmpCloneScannerTestMixin, Gmpv208TestCase): pass class Gmpv208CreateScannerTestCase(GmpCreateScannerTestMixin, Gmpv208TestCase): pass class Gmpv208DeleteScannerTestCase(GmpDeleteScannerTestMixin, Gmpv208TestCase): pass class Gmpv208GetScannerTestCase(GmpGetScannerTestMixin, Gmpv208TestCase): pass class Gmpv208GetScannersTestCase(GmpGetScannersTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyScannerTestCase(GmpModifyScannerTestMixin, Gmpv208TestCase): pass class Gmpv208VerifyScannerTestMixin(GmpVerifyScannerTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_schedules.py000066400000000000000000000030401413122500400255550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .schedules import ( GmpCloneScheduleTestMixin, GmpCreateScheduleTestMixin, GmpDeleteScheduleTestMixin, GmpGetScheduleTestMixin, GmpGetSchedulesTestMixin, GmpModifyScheduleTestMixin, ) class Gmpv208DeleteScheduleTestCase( GmpDeleteScheduleTestMixin, Gmpv208TestCase ): pass class Gmpv208GetScheduleTestCase(GmpGetScheduleTestMixin, Gmpv208TestCase): pass class Gmpv208GetSchedulesTestCase(GmpGetSchedulesTestMixin, Gmpv208TestCase): pass class Gmpv208CloneScheduleTestCase(GmpCloneScheduleTestMixin, Gmpv208TestCase): pass class Gmpv208CreateScheduleTestCase( GmpCreateScheduleTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyScheduleTestCase( GmpModifyScheduleTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_secinfo.py000066400000000000000000000060131413122500400252270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .secinfo import ( GmpGetCertBundTestMixin, GmpGetCertBundListTestMixin, GmpGetCpeTestMixin, GmpGetCpeListTestMixin, GmpGetCveTestMixin, GmpGetCveListTestMixin, GmpGetDfnCertTestMixin, GmpGetDfnCertListTestMixin, GmpGetInfoListTestMixin, GmpGetInfoTestMixin, GmpGetNvtFamiliesTestMixin, GmpGetNvtListTestMixin, GmpGetNvtPreferencesTestMixin, GmpGetNvtPreferenceTestMixin, GmpGetNvtTestMixin, GmpGetOvalDefTestMixin, GmpGetOvalDefListTestMixin, GmpGetScanConfigNvtsTestMixin, GmpGetScanConfigNvtTestMixin, ) class Gmpv208GetCertBundTestCase(GmpGetCertBundTestMixin, Gmpv208TestCase): pass class Gmpv208GetCpeTestCase(GmpGetCpeTestMixin, Gmpv208TestCase): pass class Gmpv208GetCveTestCase(GmpGetCveTestMixin, Gmpv208TestCase): pass class Gmpv208GetDfnCertCase(GmpGetDfnCertTestMixin, Gmpv208TestCase): pass class Gmpv208GetOvalDefCase(GmpGetOvalDefTestMixin, Gmpv208TestCase): pass class Gmpv208GetInfoListTestCase(GmpGetInfoListTestMixin, Gmpv208TestCase): pass class Gmpv208GetInfoTestCase(GmpGetInfoTestMixin, Gmpv208TestCase): pass class Gmpv208GetNvtTestCase(GmpGetNvtTestMixin, Gmpv208TestCase): pass class Gmpv208GetNvtPreferenceTestCase( GmpGetNvtPreferenceTestMixin, Gmpv208TestCase ): pass class Gmpv208GetNvtPreferencesTestCase( GmpGetNvtPreferencesTestMixin, Gmpv208TestCase ): pass class Gmpv208GetScanConfigNvtTestCase( GmpGetScanConfigNvtTestMixin, Gmpv208TestCase ): pass class Gmpv208GetNvtFamiliesTestCase( GmpGetNvtFamiliesTestMixin, Gmpv208TestCase ): pass class Gmpv208GetScanConfigNvtsTestCase( GmpGetScanConfigNvtsTestMixin, Gmpv208TestCase ): pass class Gmpv208GetCertBundListTestCase( GmpGetCertBundListTestMixin, Gmpv208TestCase ): pass class Gmpv208GetCpeListTestCase(GmpGetCpeListTestMixin, Gmpv208TestCase): pass class Gmpv208GetCveListTestCase(GmpGetCveListTestMixin, Gmpv208TestCase): pass class Gmpv208GetDfnCertListCase(GmpGetDfnCertListTestMixin, Gmpv208TestCase): pass class Gmpv208GetNvtListTestCase(GmpGetNvtListTestMixin, Gmpv208TestCase): pass class Gmpv208GetOvalDefListTestCase( GmpGetOvalDefListTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_secinfo.py.rej000066400000000000000000000006061413122500400260100ustar00rootroot00000000000000diff a/tests/protocols/gmpv208/entities/test_secinfo.py b/tests/protocols/gmpv208/entities/test_secinfo.py (rejected hunks) @@ -74 +74,4 @@ class Gmpv208GetNvtTestCase(GmpGetNvtTestMixin, Gmpv208TestCase): -class Gmpv208GetNvtPreferenceTestCase(GmpGetNvtPreferenceTestMixin, Gmpv208TestCase): + +class Gmpv208GetNvtPreferenceTestCase( + GmpGetNvtPreferenceTestMixin, Gmpv208TestCase +): python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_tags.py000066400000000000000000000026571413122500400245510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .tags import ( GmpCloneTagTestMixin, GmpCreateTagTestMixin, GmpDeleteTagTestMixin, GmpGetTagTestMixin, GmpGetTagsTestMixin, GmpModifyTagTestMixin, ) class Gmpv208DeleteTagTestCase(GmpDeleteTagTestMixin, Gmpv208TestCase): pass class Gmpv208GetTagTestCase(GmpGetTagTestMixin, Gmpv208TestCase): pass class Gmpv208GetTagsTestCase(GmpGetTagsTestMixin, Gmpv208TestCase): pass class Gmpv208CloneTagTestCase(GmpCloneTagTestMixin, Gmpv208TestCase): pass class Gmpv208CreateTagTestCase(GmpCreateTagTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyTagTestCase(GmpModifyTagTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_targets.py000066400000000000000000000027501413122500400252560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .targets import ( GmpCloneTargetTestMixin, GmpCreateTargetTestMixin, GmpDeleteTargetTestMixin, GmpGetTargetsTestMixin, GmpGetTargetTestMixin, GmpModifyTargetTestMixin, ) class Gmpv208CloneTargetTestCase(GmpCloneTargetTestMixin, Gmpv208TestCase): pass class Gmpv208CreateTargetTestCase(GmpCreateTargetTestMixin, Gmpv208TestCase): pass class Gmpv208DeleteTargetTestCase(GmpDeleteTargetTestMixin, Gmpv208TestCase): pass class Gmpv208GetTargetTestCase(GmpGetTargetTestMixin, Gmpv208TestCase): pass class Gmpv208GetTargetsTestCase(GmpGetTargetsTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyTargetTestCase(GmpModifyTargetTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_tasks.py000066400000000000000000000040111413122500400247220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .tasks import ( GmpCloneTaskTestMixin, GmpCreateContainerTaskTestMixin, GmpCreateTaskTestMixin, GmpDeleteTaskTestMixin, GmpGetTasksTestMixin, GmpGetTaskTestMixin, GmpModifyTaskTestMixin, GmpMoveTaskTestMixin, GmpResumeTaskTestMixin, GmpStartTaskTestMixin, GmpStopTaskTestMixin, ) class Gmpv208CloneTaskTestCase(GmpCloneTaskTestMixin, Gmpv208TestCase): pass class Gmpv208CreateContainerTaskTestCase( GmpCreateContainerTaskTestMixin, Gmpv208TestCase ): pass class Gmpv208CreateTaskTestCase(GmpCreateTaskTestMixin, Gmpv208TestCase): pass class Gmpv208DeleteTaskTestCase(GmpDeleteTaskTestMixin, Gmpv208TestCase): pass class Gmpv208GetTaskTestCase(GmpGetTaskTestMixin, Gmpv208TestCase): pass class Gmpv208GetTasksTestCase(GmpGetTasksTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyTaskTestCase(GmpModifyTaskTestMixin, Gmpv208TestCase): pass class Gmpv208MoveTaskTestCase(GmpMoveTaskTestMixin, Gmpv208TestCase): pass class Gmpv208ResumeTaskTestCase(GmpResumeTaskTestMixin, Gmpv208TestCase): pass class Gmpv208StartTaskTestCase(GmpStartTaskTestMixin, Gmpv208TestCase): pass class Gmpv208StopTaskTestCase(GmpStopTaskTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_tickets.py000066400000000000000000000027501413122500400252530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .tickets import ( GmpCloneTicketTestMixin, GmpCreateTicketTestMixin, GmpDeleteTicketTestMixin, GmpGetTicketTestMixin, GmpGetTicketsTestMixin, GmpModifyTicketTestMixin, ) class Gmpv208DeleteTicketTestCase(GmpDeleteTicketTestMixin, Gmpv208TestCase): pass class Gmpv208GetTicketTestCase(GmpGetTicketTestMixin, Gmpv208TestCase): pass class Gmpv208GetTicketsTestCase(GmpGetTicketsTestMixin, Gmpv208TestCase): pass class Gmpv208CloneTicketTestCase(GmpCloneTicketTestMixin, Gmpv208TestCase): pass class Gmpv208CreateTicketTestCase(GmpCreateTicketTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyTicketTestCase(GmpModifyTicketTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_tls_certificates.py000066400000000000000000000032451413122500400271340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .tls_certificates import ( GmpCloneTLSCertificateTestMixin, GmpCreateTLSCertificateTestMixin, GmpDeleteTLSCertificateTestMixin, GmpGetTLSCertificatesTestMixin, GmpGetTLSCertificateTestMixin, GmpModifyTLSCertificateTestMixin, ) class Gmpv208CloneTLSCertificateTestCase( GmpCloneTLSCertificateTestMixin, Gmpv208TestCase ): pass class Gmpv208CreateTLSCertificateTestCase( GmpCreateTLSCertificateTestMixin, Gmpv208TestCase ): pass class Gmpv208DeleteTLSCertificateTestCase( GmpDeleteTLSCertificateTestMixin, Gmpv208TestCase ): pass class Gmpv208GetTLSCertificateTestCase( GmpGetTLSCertificateTestMixin, Gmpv208TestCase ): pass class Gmpv208GetTLSCertificatesTestCase( GmpGetTLSCertificatesTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyTLSCertificateTestCase( GmpModifyTLSCertificateTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_users.py000066400000000000000000000027021413122500400247430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .users import ( GmpCloneUserTestMixin, GmpCreateUserTestMixin, GmpDeleteUserTestMixin, GmpGetUserTestMixin, GmpGetUsersTestMixin, GmpModifyUserTestMixin, ) class Gmpv208DeleteUserTestCase(GmpDeleteUserTestMixin, Gmpv208TestCase): pass class Gmpv208GetUserTestCase(GmpGetUserTestMixin, Gmpv208TestCase): pass class Gmpv208GetUsersTestCase(GmpGetUsersTestMixin, Gmpv208TestCase): pass class Gmpv208CloneUserTestCase(GmpCloneUserTestMixin, Gmpv208TestCase): pass class Gmpv208CreateUserTestCase(GmpCreateUserTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyUserTestCase(GmpModifyUserTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/test_vulnerabilities.py000066400000000000000000000021201413122500400267750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .vulnerabilities import ( GmpGetVulnerabilitiesTestMixin, GmpGetVulnerabilityTestMixin, ) class Gmpv208GetVulnerabilityTestCase( GmpGetVulnerabilityTestMixin, Gmpv208TestCase ): pass class Gmpv208GetVulnerabilitiesTestCase( GmpGetVulnerabilitiesTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/entities/tickets/000077500000000000000000000000001413122500400236365ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/tickets/__init__.py000066400000000000000000000020721413122500400257500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_ticket import GmpCloneTicketTestMixin from .test_create_ticket import GmpCreateTicketTestMixin from .test_delete_ticket import GmpDeleteTicketTestMixin from .test_get_ticket import GmpGetTicketTestMixin from .test_get_tickets import GmpGetTicketsTestMixin from .test_modify_ticket import GmpModifyTicketTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/tickets/test_clone_ticket.py000066400000000000000000000027451413122500400277220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneTicketTestMixin: def test_clone(self): self.gmp.clone_ticket('t1') self.connection.send.has_been_called_with( '' 't1' '' ) self.gmp.clone_ticket(ticket_id='t1') self.connection.send.has_been_called_with( '' 't1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_ticket('') with self.assertRaises(RequiredArgument): self.gmp.clone_ticket(None) with self.assertRaises(RequiredArgument): self.gmp.clone_ticket(ticket_id=None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tickets/test_create_ticket.py000066400000000000000000000047031413122500400300610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateTicketTestMixin: def test_create_ticket(self): self.gmp.create_ticket( result_id='r1', assigned_to_user_id='u1', note='lorem ipsum' ) self.connection.send.has_been_called_with( '' '' '' '' '' 'lorem ipsum' '' ) def test_create_ticket_with_comment(self): self.gmp.create_ticket( result_id='r1', assigned_to_user_id='u1', note='lorem ipsum', comment='bar', ) self.connection.send.has_been_called_with( '' '' '' '' '' 'lorem ipsum' 'bar' '' ) def test_create_ticket_missing_result_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_ticket( result_id='', assigned_to_user_id='u1', note='lorem ipsum' ) def test_create_ticket_missing_assigned_to_user_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_ticket( result_id='r1', assigned_to_user_id='', note='lorem ipsum' ) def test_create_ticket_missing_open_note(self): with self.assertRaises(RequiredArgument): self.gmp.create_ticket( result_id='r1', assigned_to_user_id='u1', note='' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tickets/test_delete_ticket.py000066400000000000000000000026371413122500400300640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpDeleteTicketTestMixin: def test_delete(self): self.gmp.delete_ticket('t1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): self.gmp.delete_ticket('t1', ultimate=True) self.connection.send.has_been_called_with( '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.delete_ticket(None) with self.assertRaises(RequiredArgument): self.gmp.delete_ticket('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tickets/test_get_ticket.py000066400000000000000000000025471413122500400274010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetTicketTestMixin: def test_get_ticket(self): self.gmp.get_ticket('t1') self.connection.send.has_been_called_with( '' ) self.gmp.get_ticket(ticket_id='t1') self.connection.send.has_been_called_with( '' ) def test_get_ticket_missing_user_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_ticket(ticket_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_ticket('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tickets/test_get_tickets.py000066400000000000000000000030731413122500400275570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetTicketsTestMixin: def test_get_tickets(self): self.gmp.get_tickets() self.connection.send.has_been_called_with('') def test_get_tickets_with_filter_string(self): self.gmp.get_tickets(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_tickets_with_filter_id(self): self.gmp.get_tickets(filter_id='f1') self.connection.send.has_been_called_with('') def test_get_tickets_with_trash(self): self.gmp.get_tickets(trash=True) self.connection.send.has_been_called_with('') self.gmp.get_tickets(trash=False) self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tickets/test_modify_ticket.py000066400000000000000000000074531413122500400301120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import TicketStatus class GmpModifyTicketTestMixin: def test_modify_ticket(self): self.gmp.modify_ticket('t1') self.connection.send.has_been_called_with( '' ) self.gmp.modify_ticket(ticket_id='t1') self.connection.send.has_been_called_with( '' ) def test_missing_ticket_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_ticket('') with self.assertRaises(RequiredArgument): self.gmp.modify_ticket(None) with self.assertRaises(RequiredArgument): self.gmp.modify_ticket(ticket_id=None) def test_modify_ticket_with_comment(self): self.gmp.modify_ticket(ticket_id='t1', comment='bar') self.connection.send.has_been_called_with( '' 'bar' '' ) def test_modify_ticket_with_assigned_to_user_id(self): self.gmp.modify_ticket(ticket_id='t1', assigned_to_user_id='u1') self.connection.send.has_been_called_with( '' '' '' '' '' ) def test_modify_ticket_invalid_status(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_ticket(ticket_id='t1', status='foobar', note='bar') def test_modify_ticket_open(self): self.gmp.modify_ticket( ticket_id='t1', status=TicketStatus.OPEN, note='lorem ipsum' ) self.connection.send.has_been_called_with( '' 'Open' 'lorem ipsum' '' ) def test_modify_ticket_fixed(self): self.gmp.modify_ticket( ticket_id='t1', status=TicketStatus.FIXED, note='lorem ipsum' ) self.connection.send.has_been_called_with( '' 'Fixed' 'lorem ipsum' '' ) def test_modify_ticket_closed(self): self.gmp.modify_ticket( ticket_id='t1', status=TicketStatus.CLOSED, note='lorem ipsum' ) self.connection.send.has_been_called_with( '' 'Closed' 'lorem ipsum' '' ) def test_modify_ticket_status_without_note(self): with self.assertRaises(RequiredArgument): self.gmp.modify_ticket(ticket_id='t1', status=TicketStatus.CLOSED) def test_modify_ticket_note_without_status(self): with self.assertRaises(RequiredArgument): self.gmp.modify_ticket(ticket_id='t1', note='foo') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tls_certificates/000077500000000000000000000000001413122500400255175ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/tls_certificates/__init__.py000066400000000000000000000022401413122500400276260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_tls_certificate import GmpCloneTLSCertificateTestMixin from .test_create_tls_certificate import GmpCreateTLSCertificateTestMixin from .test_delete_tls_certificate import GmpDeleteTLSCertificateTestMixin from .test_get_tls_certificate import GmpGetTLSCertificateTestMixin from .test_get_tls_certificates import GmpGetTLSCertificatesTestMixin from .test_modify_tls_certificate import GmpModifyTLSCertificateTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/tls_certificates/test_clone_tls_certificate.py000066400000000000000000000024351413122500400334600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneTLSCertificateTestMixin: def test_clone(self): self.gmp.clone_tls_certificate('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_tls_certificate('') with self.assertRaises(RequiredArgument): self.gmp.clone_tls_certificate(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tls_certificates/test_create_tls_certificate.py000066400000000000000000000040601413122500400336170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateTLSCertificateTestMixin: def test_create_tls_certificate(self): self.gmp.create_tls_certificate('foo', 'c1', comment='bar', trust=True) self.connection.send.has_been_called_with( '' 'bar' 'foo' 'c1' '1' '' ) self.gmp.create_tls_certificate('foo', 'c1', trust=False) self.connection.send.has_been_called_with( '' 'foo' 'c1' '' ) def test_missing_certificate(self): with self.assertRaises(RequiredArgument): self.gmp.create_tls_certificate(name='foo', certificate='') with self.assertRaises(RequiredArgument): self.gmp.create_tls_certificate(name='foo', certificate=None) def test_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_tls_certificate(name=None, certificate='c1') with self.assertRaises(RequiredArgument): self.gmp.create_tls_certificate(name='', certificate='c1') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tls_certificates/test_delete_tls_certificate.py000066400000000000000000000025761413122500400336300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpDeleteTLSCertificateTestMixin: def test_delete(self): self.gmp.delete_tls_certificate('a1') self.connection.send.has_been_called_with( '' ) def test_delete_ultimate(self): with self.assertRaises(TypeError): self.gmp.delete_tls_certificate('a1', ultimate=True) def test_missing_tls_certificate_id(self): with self.assertRaises(GvmError): self.gmp.delete_tls_certificate(None) with self.assertRaises(GvmError): self.gmp.delete_tls_certificate('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tls_certificates/test_get_tls_certificate.py000066400000000000000000000024511413122500400331350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpGetTLSCertificateTestMixin: def test_get_tls_certificate(self): self.gmp.get_tls_certificate('t1') self.connection.send.has_been_called_with( '' ) def test_fail_without_tls_certificate_id(self): with self.assertRaises(GvmError): self.gmp.get_tls_certificate(None) with self.assertRaises(GvmError): self.gmp.get_tls_certificate('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/tls_certificates/test_get_tls_certificates.py000066400000000000000000000032251413122500400333200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetTLSCertificatesTestMixin: def test_get_tls_certificates(self): self.gmp.get_tls_certificates() self.connection.send.has_been_called_with('') def test_get_tls_certificates_with_filter_string(self): self.gmp.get_tls_certificates(filter_string='name=foo') self.connection.send.has_been_called_with( '' ) def test_get_tls_certificates_with_include_certificate_data(self): self.gmp.get_tls_certificates(include_certificate_data='1') self.connection.send.has_been_called_with( '' ) def test_get_tls_certificates_with_details(self): self.gmp.get_tls_certificates(details='1') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/tls_certificates/test_modify_tls_certificate.py000066400000000000000000000046661413122500400336570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyTLSCertificateTestMixin: def test_modify_tls_certificate(self): self.gmp.modify_tls_certificate('c1') self.connection.send.has_been_called_with( '' ) def test_modify_tls_certificate_with_name(self): self.gmp.modify_tls_certificate('c1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_tls_certificate_with_comment(self): self.gmp.modify_tls_certificate('c1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_tls_certificate_with_trust(self): self.gmp.modify_tls_certificate('c1', trust=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_tls_certificate('c1', trust=False) self.connection.send.has_been_called_with( '' ) def test_missing_tls_certificate_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_tls_certificate(name='foo', tls_certificate_id='') with self.assertRaises(RequiredArgument): self.gmp.modify_tls_certificate(name='foo', tls_certificate_id=None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/users/000077500000000000000000000000001413122500400233315ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/users/__init__.py000066400000000000000000000020421413122500400254400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_clone_user import GmpCloneUserTestMixin from .test_create_user import GmpCreateUserTestMixin from .test_delete_user import GmpDeleteUserTestMixin from .test_get_user import GmpGetUserTestMixin from .test_get_users import GmpGetUsersTestMixin from .test_modify_user import GmpModifyUserTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/users/test_clone_user.py000066400000000000000000000023041413122500400270770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCloneUserTestMixin: def test_clone(self): self.gmp.clone_user('a1') self.connection.send.has_been_called_with( '' 'a1' '' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_user('') with self.assertRaises(RequiredArgument): self.gmp.clone_user(None) python-gvm-21.10.0/tests/protocols/gmpv208/entities/users/test_create_user.py000066400000000000000000000070331413122500400272460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpCreateUserTestMixin: def test_create_user_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_user(name=None) with self.assertRaises(RequiredArgument): self.gmp.create_user(name='') def test_create_user(self): self.gmp.create_user(name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_create_user_with_password(self): self.gmp.create_user(name='foo', password='bar') self.connection.send.has_been_called_with( '' 'foo' 'bar' '' ) def test_create_user_with_hosts(self): self.gmp.create_user(name='foo', hosts=['h1', 'h2'], hosts_allow=True) self.connection.send.has_been_called_with( '' 'foo' 'h1,h2' '' ) self.gmp.create_user(name='foo', hosts=['h1', 'h2']) self.connection.send.has_been_called_with( '' 'foo' 'h1,h2' '' ) self.gmp.create_user(name='foo', hosts=['h1', 'h2'], hosts_allow=False) self.connection.send.has_been_called_with( '' 'foo' 'h1,h2' '' ) def test_create_user_with_ifaces(self): self.gmp.create_user(name='foo', ifaces=['h1', 'h2'], ifaces_allow=True) self.connection.send.has_been_called_with( '' 'foo' 'h1,h2' '' ) self.gmp.create_user(name='foo', ifaces=['h1', 'h2']) self.connection.send.has_been_called_with( '' 'foo' 'h1,h2' '' ) self.gmp.create_user( name='foo', ifaces=['h1', 'h2'], ifaces_allow=False ) self.connection.send.has_been_called_with( '' 'foo' 'h1,h2' '' ) def test_create_user_with_role_ids(self): self.gmp.create_user(name='foo', role_ids=['r1', 'r2']) self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/users/test_delete_user.py000066400000000000000000000040431413122500400272430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpDeleteUserTestMixin: def test_delete_user_with_user_id(self): self.gmp.delete_user('a1') self.connection.send.has_been_called_with('') self.gmp.delete_user(user_id='a1') self.connection.send.has_been_called_with('') def test_delete_user_with_inheritor_id(self): self.gmp.delete_user('a1', inheritor_id='u1') self.connection.send.has_been_called_with( '' ) def test_delete_user_with_name(self): self.gmp.delete_user(name='foo') self.connection.send.has_been_called_with('') def test_delete_user_with_inheritor_name(self): self.gmp.delete_user('a1', inheritor_name='foo') self.connection.send.has_been_called_with( '' ) def test_delete_user_missing_user_id_and_name(self): with self.assertRaises(RequiredArgument): self.gmp.delete_user(None) with self.assertRaises(RequiredArgument): self.gmp.delete_user('') with self.assertRaises(RequiredArgument): self.gmp.delete_user(user_id='', name='') python-gvm-21.10.0/tests/protocols/gmpv208/entities/users/test_get_user.py000066400000000000000000000024411413122500400265600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetUserTestMixin: def test_get_user(self): self.gmp.get_user('u1') self.connection.send.has_been_called_with('') self.gmp.get_user(user_id='u1') self.connection.send.has_been_called_with('') def test_get_user_missing_user_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_user(user_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_user('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/users/test_get_users.py000066400000000000000000000024111413122500400267400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetUsersTestMixin: def test_get_users(self): self.gmp.get_users() self.connection.send.has_been_called_with('') def test_get_users_with_filter_string(self): self.gmp.get_users(filter_string='foo=bar') self.connection.send.has_been_called_with( '' ) def test_get_users_with_filter_id(self): self.gmp.get_users(filter_id='f1') self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/users/test_modify_user.py000066400000000000000000000153641413122500400273000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument from gvm.protocols.gmpv208 import UserAuthType class GmpModifyUserTestMixin: def test_modify_user(self): self.gmp.modify_user(user_id='u1') self.connection.send.has_been_called_with('') self.gmp.modify_user(name='u1') self.connection.send.has_been_called_with( '' 'u1' '' ) def test_modify_user_missing_user_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_user(user_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_user(user_id='') def test_modify_user_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_user(name=None) with self.assertRaises(RequiredArgument): self.gmp.modify_user(name='') def test_modify_user_with_new_name(self): self.gmp.modify_user(user_id='u1', new_name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_user_with_new_comment(self): self.gmp.modify_user(user_id='u1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_user_with_user_id_and_name(self): self.gmp.modify_user(user_id='u1', name='foo') self.connection.send.has_been_called_with('') def test_modify_user_with_role_ids(self): self.gmp.modify_user(user_id='u1', role_ids=[]) self.connection.send.has_been_called_with('') self.gmp.modify_user(user_id='u1', role_ids=['r1']) self.connection.send.has_been_called_with( '' '' '' ) self.gmp.modify_user(user_id='u1', role_ids=['r1', 'r2']) self.connection.send.has_been_called_with( '' '' '' '' ) def test_modify_user_with_group_ids(self): self.gmp.modify_user(user_id='u1', role_ids=[]) self.connection.send.has_been_called_with('') self.gmp.modify_user(user_id='u1', group_ids=['r1']) self.connection.send.has_been_called_with( '' '' '' ) self.gmp.modify_user(user_id='u1', group_ids=['r1', 'r2']) self.connection.send.has_been_called_with( '' '' '' '' '' '' ) def test_modify_user_with_password(self): self.gmp.modify_user(user_id='u1', password='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_user_with_auth_source(self): self.gmp.modify_user( user_id='u1', auth_source=UserAuthType.LDAP_CONNECT ) self.connection.send.has_been_called_with( '' 'ldap_connect' '' ) def test_modify_user_with_hosts(self): self.gmp.modify_user(user_id='u1', hosts=[]) self.connection.send.has_been_called_with('') self.gmp.modify_user(user_id='u1', hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_user(user_id='u1', hosts=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) self.gmp.modify_user( user_id='u1', hosts=['foo', 'bar'], hosts_allow=False ) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) self.gmp.modify_user( user_id='u1', hosts=['foo', 'bar'], hosts_allow=True ) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) def test_modify_user_with_ifaces(self): self.gmp.modify_user(user_id='u1', ifaces=[]) self.connection.send.has_been_called_with('') self.gmp.modify_user(user_id='u1', ifaces=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_user(user_id='u1', ifaces=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) self.gmp.modify_user( user_id='u1', ifaces=['foo', 'bar'], ifaces_allow=False ) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) self.gmp.modify_user( user_id='u1', ifaces=['foo', 'bar'], ifaces_allow=True ) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) python-gvm-21.10.0/tests/protocols/gmpv208/entities/vulnerabilities/000077500000000000000000000000001413122500400253715ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/entities/vulnerabilities/__init__.py000066400000000000000000000015661413122500400275120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_vulnerability import GmpGetVulnerabilityTestMixin from .test_get_vulnerabilities import GmpGetVulnerabilitiesTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/entities/vulnerabilities/test_get_vulnerabilities.py000066400000000000000000000025171413122500400330470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetVulnerabilitiesTestMixin: def test_get_vulnerabilities(self): self.gmp.get_vulnerabilities() self.connection.send.has_been_called_with('') def test_get_vulnerabilities_with_filter_string(self): self.gmp.get_vulnerabilities(filter_string="foo=bar") self.connection.send.has_been_called_with( '' ) def test_get_vulnerabilities_with_filter_id(self): self.gmp.get_vulnerabilities(filter_id='f1') self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/entities/vulnerabilities/test_get_vulnerability.py000066400000000000000000000026141413122500400325350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetVulnerabilityTestMixin: def test_get_vulnerability(self): self.gmp.get_vulnerability('a1') self.connection.send.has_been_called_with('') self.gmp.get_vulnerability(vulnerability_id='a1') self.connection.send.has_been_called_with('') def test_get_vulnerability_invalid_vulnerability_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_vulnerability(vulnerability_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_vulnerability(vulnerability_id='') python-gvm-21.10.0/tests/protocols/gmpv208/enums/000077500000000000000000000000001413122500400214735ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/enums/__init__.py000066400000000000000000000013641413122500400236100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_aggregate_statistic.py000066400000000000000000000047041413122500400271260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import AggregateStatistic class GetAggregateStatisticFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AggregateStatistic.from_string('foo') def test_none_or_empty(self): ct = AggregateStatistic.from_string(None) self.assertIsNone(ct) ct = AggregateStatistic.from_string('') self.assertIsNone(ct) def test_count(self): ct = AggregateStatistic.from_string('count') self.assertEqual(ct, AggregateStatistic.COUNT) def test_c_count(self): ct = AggregateStatistic.from_string('c_count') self.assertEqual(ct, AggregateStatistic.C_COUNT) def test_c_sum(self): ct = AggregateStatistic.from_string('c_sum') self.assertEqual(ct, AggregateStatistic.C_SUM) def test_max(self): ct = AggregateStatistic.from_string('max') self.assertEqual(ct, AggregateStatistic.MAX) def test_mean(self): ct = AggregateStatistic.from_string('mean') self.assertEqual(ct, AggregateStatistic.MEAN) def test_min(self): ct = AggregateStatistic.from_string('min') self.assertEqual(ct, AggregateStatistic.MIN) def test_sum(self): ct = AggregateStatistic.from_string('sum') self.assertEqual(ct, AggregateStatistic.SUM) def test_text(self): ct = AggregateStatistic.from_string('text') self.assertEqual(ct, AggregateStatistic.TEXT) def test_value(self): ct = AggregateStatistic.from_string('value') self.assertEqual(ct, AggregateStatistic.VALUE) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_alert_condition.py000066400000000000000000000042421413122500400262630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import AlertCondition class GetAlertConditionFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AlertCondition.from_string('foo') def test_none_or_empty(self): ct = AlertCondition.from_string(None) self.assertIsNone(ct) ct = AlertCondition.from_string('') self.assertIsNone(ct) def test_always(self): ct = AlertCondition.from_string('always') self.assertEqual(ct, AlertCondition.ALWAYS) def test_filter_count_at_least(self): ct = AlertCondition.from_string('filter count at least') self.assertEqual(ct, AlertCondition.FILTER_COUNT_AT_LEAST) def test_filter_count_changed(self): ct = AlertCondition.from_string('filter count changed') self.assertEqual(ct, AlertCondition.FILTER_COUNT_CHANGED) def test_severity_at_least(self): ct = AlertCondition.from_string('severity at least') self.assertEqual(ct, AlertCondition.SEVERITY_AT_LEAST) def test_severity_changed(self): ct = AlertCondition.from_string('severity changed') self.assertEqual(ct, AlertCondition.SEVERITY_CHANGED) def test_error(self): ct = AlertCondition.from_string('error') self.assertEqual(ct, AlertCondition.ERROR) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_alert_event.py000066400000000000000000000043201413122500400254130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import AlertEvent class GetAlertEventFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AlertEvent.from_string('foo') def test_none_or_empty(self): ct = AlertEvent.from_string(None) self.assertIsNone(ct) ct = AlertEvent.from_string('') self.assertIsNone(ct) def test_task_run_status_changed(self): ct = AlertEvent.from_string('Task run status changed') self.assertEqual(ct, AlertEvent.TASK_RUN_STATUS_CHANGED) def test_new_secinfo_arrived(self): ct = AlertEvent.from_string('New SecInfo arrived') self.assertEqual(ct, AlertEvent.NEW_SECINFO_ARRIVED) def test_updated_secinfo_arrived(self): ct = AlertEvent.from_string('Updated SecInfo arrived') self.assertEqual(ct, AlertEvent.UPDATED_SECINFO_ARRIVED) def test_ticket_received(self): ct = AlertEvent.from_string('ticket received') self.assertEqual(ct, AlertEvent.TICKET_RECEIVED) def test_assigned_ticket_changed(self): ct = AlertEvent.from_string('assigned ticket changed') self.assertEqual(ct, AlertEvent.ASSIGNED_TICKET_CHANGED) def test_owned_ticket_changed(self): ct = AlertEvent.from_string('owned ticket changed') self.assertEqual(ct, AlertEvent.OWNED_TICKET_CHANGED) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_alert_method.py000066400000000000000000000054631413122500400255630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import AlertMethod class GetAlertMethodFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AlertMethod.from_string('foo') def test_none_or_empty(self): ct = AlertMethod.from_string(None) self.assertIsNone(ct) ct = AlertMethod.from_string('') self.assertIsNone(ct) def test_email(self): ct = AlertMethod.from_string('email') self.assertEqual(ct, AlertMethod.EMAIL) def test_scp(self): ct = AlertMethod.from_string('scp') self.assertEqual(ct, AlertMethod.SCP) def test_send(self): ct = AlertMethod.from_string('send') self.assertEqual(ct, AlertMethod.SEND) def test_smb(self): ct = AlertMethod.from_string('smb') self.assertEqual(ct, AlertMethod.SMB) def test_snmp(self): ct = AlertMethod.from_string('snmp') self.assertEqual(ct, AlertMethod.SNMP) def test_syslog(self): ct = AlertMethod.from_string('syslog') self.assertEqual(ct, AlertMethod.SYSLOG) def test_http_get(self): ct = AlertMethod.from_string('HTTP Get') self.assertEqual(ct, AlertMethod.HTTP_GET) def test_start_task(self): ct = AlertMethod.from_string('Start Task') self.assertEqual(ct, AlertMethod.START_TASK) def test_sourcefire_connector(self): ct = AlertMethod.from_string('sourcefire Connector') self.assertEqual(ct, AlertMethod.SOURCEFIRE_CONNECTOR) def test_verinice_connector(self): ct = AlertMethod.from_string('verinice Connector') self.assertEqual(ct, AlertMethod.VERINICE_CONNECTOR) def test_tippingpoint_sms(self): ct = AlertMethod.from_string('Tippingpoint SMS') self.assertEqual(ct, AlertMethod.TIPPINGPOINT_SMS) def test_alemba_vfire(self): ct = AlertMethod.from_string('Alemba vFire') self.assertEqual(ct, AlertMethod.ALEMBA_VFIRE) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_alive_test.py000066400000000000000000000054571413122500400252560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import AliveTest class GetAliveTestFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AliveTest.from_string('foo') def test_none_or_empty(self): ct = AliveTest.from_string(None) self.assertIsNone(ct) ct = AliveTest.from_string('') self.assertIsNone(ct) def test_scan_config_default(self): ct = AliveTest.from_string('Scan Config Default') self.assertEqual(ct, AliveTest.SCAN_CONFIG_DEFAULT) def test_icmp_ping(self): ct = AliveTest.from_string('ICMP Ping') self.assertEqual(ct, AliveTest.ICMP_PING) def test_tcp_ack_service_ping(self): ct = AliveTest.from_string('TCP-ACK Service Ping') self.assertEqual(ct, AliveTest.TCP_ACK_SERVICE_PING) def test_tcp_sync_service_ping(self): ct = AliveTest.from_string('TCP-SYN Service Ping') self.assertEqual(ct, AliveTest.TCP_SYN_SERVICE_PING) def test_arp_ping(self): ct = AliveTest.from_string('ARP Ping') self.assertEqual(ct, AliveTest.ARP_PING) def test_icmp_and_tcp_ack_service_ping(self): ct = AliveTest.from_string('ICMP & TCP-ACK Service Ping') self.assertEqual(ct, AliveTest.ICMP_AND_TCP_ACK_SERVICE_PING) def test_icmp_and_arp_ping(self): ct = AliveTest.from_string('ICMP & ARP Ping') self.assertEqual(ct, AliveTest.ICMP_AND_ARP_PING) def test_tcp_ack_service_and_arp_ping(self): ct = AliveTest.from_string('TCP-ACK Service & ARP Ping') self.assertEqual(ct, AliveTest.TCP_ACK_SERVICE_AND_ARP_PING) def test_icmp_tcp_ack_service_and_arp_ping(self): ct = AliveTest.from_string('ICMP, TCP-ACK Service & ARP Ping') self.assertEqual(ct, AliveTest.ICMP_TCP_ACK_SERVICE_AND_ARP_PING) def test_consider_alive(self): ct = AliveTest.from_string('Consider Alive') self.assertEqual(ct, AliveTest.CONSIDER_ALIVE) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_credential_format.py000066400000000000000000000035761413122500400266010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import CredentialFormat class GetCredentialFromatFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): CredentialFormat.from_string('foo') def test_none_or_empty(self): ct = CredentialFormat.from_string(None) self.assertIsNone(ct) ct = CredentialFormat.from_string('') self.assertIsNone(ct) def test_key(self): ct = CredentialFormat.from_string('key') self.assertEqual(ct, CredentialFormat.KEY) def test_rpm(self): ct = CredentialFormat.from_string('rpm') self.assertEqual(ct, CredentialFormat.RPM) def test_deb(self): ct = CredentialFormat.from_string('deb') self.assertEqual(ct, CredentialFormat.DEB) def test_exe(self): ct = CredentialFormat.from_string('exe') self.assertEqual(ct, CredentialFormat.EXE) def test_pem(self): ct = CredentialFormat.from_string('pem') self.assertEqual(ct, CredentialFormat.PEM) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_credential_type.py000066400000000000000000000044411413122500400262620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import CredentialType class GetCredentialTypeFromStringTestCase(unittest.TestCase): def test_invalid_type(self): with self.assertRaises(InvalidArgument): CredentialType.from_string('foo') def test_none_or_empty_type(self): ct = CredentialType.from_string(None) self.assertIsNone(ct) ct = CredentialType.from_string('') self.assertIsNone(ct) def test_client_certificate(self): ct = CredentialType.from_string('client_certificate') self.assertEqual(ct, CredentialType.CLIENT_CERTIFICATE) def test_snmp(self): ct = CredentialType.from_string('snmp') self.assertEqual(ct, CredentialType.SNMP) def test_username_password(self): ct = CredentialType.from_string('username_password') self.assertEqual(ct, CredentialType.USERNAME_PASSWORD) def test_username_ssh_key(self): ct = CredentialType.from_string('username_ssh_key') self.assertEqual(ct, CredentialType.USERNAME_SSH_KEY) def test_smime_certificate(self): ct = CredentialType.from_string('smime_certificate') self.assertEqual(ct, CredentialType.SMIME_CERTIFICATE) def test_pgp_encryption_key(self): ct = CredentialType.from_string('pgp_encryption_key') self.assertEqual(ct, CredentialType.PGP_ENCRYPTION_KEY) def test_password_only(self): ct = CredentialType.from_string('password_only') self.assertEqual(ct, CredentialType.PASSWORD_ONLY) python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_entity_type.py000066400000000000000000000131271413122500400254650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import EntityType class GetEntityTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): EntityType.from_string('foo') def test_none_or_empty(self): ct = EntityType.from_string(None) self.assertIsNone(ct) ct = EntityType.from_string('') self.assertIsNone(ct) def test_alert(self): ct = EntityType.from_string('alert') self.assertEqual(ct, EntityType.ALERT) def test_asset(self): ct = EntityType.from_string('asset') self.assertEqual(ct, EntityType.ASSET) def test_audit(self): ct = EntityType.from_string('audit') self.assertEqual(ct, EntityType.AUDIT) def test_cert_bund_adv(self): ct = EntityType.from_string('cert_bund_adv') self.assertEqual(ct, EntityType.CERT_BUND_ADV) def test_cpe(self): ct = EntityType.from_string('cpe') self.assertEqual(ct, EntityType.CPE) def test_credential(self): ct = EntityType.from_string('credential') self.assertEqual(ct, EntityType.CREDENTIAL) def test_dfn_cert_adv(self): ct = EntityType.from_string('dfn_cert_adv') self.assertEqual(ct, EntityType.DFN_CERT_ADV) def test_filter(self): ct = EntityType.from_string('filter') self.assertEqual(ct, EntityType.FILTER) def test_group(self): ct = EntityType.from_string('group') self.assertEqual(ct, EntityType.GROUP) def test_host(self): ct = EntityType.from_string('host') self.assertEqual(ct, EntityType.HOST) def test_info(self): ct = EntityType.from_string('info') self.assertEqual(ct, EntityType.INFO) def test_note(self): ct = EntityType.from_string('note') self.assertEqual(ct, EntityType.NOTE) def test_nvt(self): ct = EntityType.from_string('nvt') self.assertEqual(ct, EntityType.NVT) def test_operating_system(self): ct = EntityType.from_string('os') self.assertEqual(ct, EntityType.OPERATING_SYSTEM) ct = EntityType.from_string('operating_system') self.assertEqual(ct, EntityType.OPERATING_SYSTEM) def test_ovaldef(self): ct = EntityType.from_string('ovaldef') self.assertEqual(ct, EntityType.OVALDEF) def test_override(self): ct = EntityType.from_string('override') self.assertEqual(ct, EntityType.OVERRIDE) def test_permission(self): ct = EntityType.from_string('permission') self.assertEqual(ct, EntityType.PERMISSION) def test_policy(self): ct = EntityType.from_string('policy') self.assertEqual(ct, EntityType.POLICY) def test_port_list(self): ct = EntityType.from_string('port_list') self.assertEqual(ct, EntityType.PORT_LIST) def test_report(self): ct = EntityType.from_string('report') self.assertEqual(ct, EntityType.REPORT) def test_report_format(self): ct = EntityType.from_string('report_format') self.assertEqual(ct, EntityType.REPORT_FORMAT) def test_result(self): ct = EntityType.from_string('result') self.assertEqual(ct, EntityType.RESULT) def test_role(self): ct = EntityType.from_string('role') self.assertEqual(ct, EntityType.ROLE) def test_scan_config(self): ct = EntityType.from_string('config') self.assertEqual(ct, EntityType.SCAN_CONFIG) ct = EntityType.from_string('scan_config') self.assertEqual(ct, EntityType.SCAN_CONFIG) def test_scanner(self): ct = EntityType.from_string('scanner') self.assertEqual(ct, EntityType.SCANNER) def test_schedule(self): ct = EntityType.from_string('schedule') self.assertEqual(ct, EntityType.SCHEDULE) def test_tag(self): ct = EntityType.from_string('tag') self.assertEqual(ct, EntityType.TAG) def test_target(self): ct = EntityType.from_string('target') self.assertEqual(ct, EntityType.TARGET) def test_task(self): ct = EntityType.from_string('task') self.assertEqual(ct, EntityType.TASK) def test_ticket(self): ct = EntityType.from_string('ticket') self.assertEqual(ct, EntityType.TICKET) def test_tls_certificate(self): ft = EntityType.from_string('tls_certificate') self.assertEqual(ft, EntityType.TLS_CERTIFICATE) def test_user(self): ct = EntityType.from_string('user') self.assertEqual(ct, EntityType.USER) def test_vulnerability(self): ct = EntityType.from_string('vuln') self.assertEqual(ct, EntityType.VULNERABILITY) ct = EntityType.from_string('vulnerability') self.assertEqual(ct, EntityType.VULNERABILITY) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_feed_type.py000066400000000000000000000032611413122500400250520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import FeedType class GetFeedTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): FeedType.from_string('foo') def test_none_or_empty(self): ct = FeedType.from_string(None) self.assertIsNone(ct) ct = FeedType.from_string('') self.assertIsNone(ct) def test_nvt(self): ct = FeedType.from_string('nvt') self.assertEqual(ct, FeedType.NVT) def test_cert(self): ct = FeedType.from_string('cert') self.assertEqual(ct, FeedType.CERT) def test_scap(self): ct = FeedType.from_string('scap') self.assertEqual(ct, FeedType.SCAP) def test_gvmd_data(self): ct = FeedType.from_string('gvmd_data') self.assertEqual(ct, FeedType.GVMD_DATA) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_filter_type.py000066400000000000000000000122221413122500400254310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import FilterType class GetFilterTypeFomStringTestCase(unittest.TestCase): def test_filter_type_alert(self): ft = FilterType.from_string('alert') self.assertEqual(ft, FilterType.ALERT) def test_filter_type_asset(self): ft = FilterType.from_string('asset') self.assertEqual(ft, FilterType.ASSET) def test_filter_type_credential(self): ft = FilterType.from_string('credential') self.assertEqual(ft, FilterType.CREDENTIAL) def test_filter_type_filter(self): ft = FilterType.from_string('filter') self.assertEqual(ft, FilterType.FILTER) def test_filter_type_group(self): ft = FilterType.from_string('group') self.assertEqual(ft, FilterType.GROUP) def test_filter_type_host(self): ft = FilterType.from_string('host') self.assertEqual(ft, FilterType.HOST) def test_filter_type_note(self): ft = FilterType.from_string('note') self.assertEqual(ft, FilterType.NOTE) def test_filter_type_override(self): ft = FilterType.from_string('override') self.assertEqual(ft, FilterType.OVERRIDE) def test_filter_type_permission(self): ft = FilterType.from_string('permission') self.assertEqual(ft, FilterType.PERMISSION) def test_filter_type_port_list(self): ft = FilterType.from_string('port_list') self.assertEqual(ft, FilterType.PORT_LIST) def test_filter_type_report(self): ft = FilterType.from_string('report') self.assertEqual(ft, FilterType.REPORT) def test_filter_type_report_format(self): ft = FilterType.from_string('report_format') self.assertEqual(ft, FilterType.REPORT_FORMAT) def test_filter_type_result(self): ft = FilterType.from_string('result') self.assertEqual(ft, FilterType.RESULT) def test_filter_type_role(self): ft = FilterType.from_string('role') self.assertEqual(ft, FilterType.ROLE) def test_filter_type_schedule(self): ft = FilterType.from_string('schedule') self.assertEqual(ft, FilterType.SCHEDULE) def test_filter_type_secinfo(self): ft = FilterType.from_string('secinfo') self.assertEqual(ft, FilterType.ALL_SECINFO) def test_filter_type_all_secinfo(self): ft = FilterType.from_string('all_secinfo') self.assertEqual(ft, FilterType.ALL_SECINFO) def test_filter_type_tag(self): ft = FilterType.from_string('tag') self.assertEqual(ft, FilterType.TAG) def test_filter_type_task(self): ft = FilterType.from_string('task') self.assertEqual(ft, FilterType.TASK) def test_filter_type_target(self): ft = FilterType.from_string('target') self.assertEqual(ft, FilterType.TARGET) def test_filter_type_ticket(self): ft = FilterType.from_string('ticket') self.assertEqual(ft, FilterType.TICKET) def test_filter_type_tls_certificate(self): ft = FilterType.from_string('tls_certificate') self.assertEqual(ft, FilterType.TLS_CERTIFICATE) def test_filter_type_operating_system(self): ft = FilterType.from_string('operating_system') self.assertEqual(ft, FilterType.OPERATING_SYSTEM) def test_filter_type_user(self): ft = FilterType.from_string('user') self.assertEqual(ft, FilterType.USER) def test_filter_type_vuln(self): ft = FilterType.from_string('vuln') self.assertEqual(ft, FilterType.VULNERABILITY) def test_filter_type_vulnerability(self): ft = FilterType.from_string('vulnerability') self.assertEqual(ft, FilterType.VULNERABILITY) def test_filter_type_config(self): ft = FilterType.from_string('config') self.assertEqual(ft, FilterType.SCAN_CONFIG) def test_filter_type_scan_config(self): ft = FilterType.from_string('scan_config') self.assertEqual(ft, FilterType.SCAN_CONFIG) def test_filter_type_os(self): ft = FilterType.from_string('os') self.assertEqual(ft, FilterType.OPERATING_SYSTEM) def test_invalid_filter_type(self): with self.assertRaises(InvalidArgument): FilterType.from_string('foo') def test_non_or_empty_filter_type(self): ft = FilterType.from_string(None) self.assertIsNone(ft) ft = FilterType.from_string('') self.assertIsNone(ft) python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_help_format.py000066400000000000000000000033731413122500400254120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import HelpFormat class GetHelpFormatFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): HelpFormat.from_string('foo') def test_none_or_empty(self): ct = HelpFormat.from_string(None) self.assertIsNone(ct) ct = HelpFormat.from_string('') self.assertIsNone(ct) def test_task_run_status_changed(self): ct = HelpFormat.from_string('HtMl') self.assertEqual(ct, HelpFormat.HTML) def test_new_secinfo_arrived(self): ct = HelpFormat.from_string('rNc') self.assertEqual(ct, HelpFormat.RNC) def test_updated_secinfo_arrived(self): ct = HelpFormat.from_string('tExT') self.assertEqual(ct, HelpFormat.TEXT) def test_ticket_received(self): ct = HelpFormat.from_string('XmL') self.assertEqual(ct, HelpFormat.XML) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_hosts_ordering.py000066400000000000000000000031341413122500400261360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import HostsOrdering class GetHostsOrderingFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): HostsOrdering.from_string('foo') def test_none_or_empty(self): ct = HostsOrdering.from_string(None) self.assertIsNone(ct) ct = HostsOrdering.from_string('') self.assertIsNone(ct) def test_sequential(self): ct = HostsOrdering.from_string("sequential") self.assertEqual(ct, HostsOrdering.SEQUENTIAL) def test_random(self): ct = HostsOrdering.from_string("random") self.assertEqual(ct, HostsOrdering.RANDOM) def test_reverse(self): ct = HostsOrdering.from_string("reverse") self.assertEqual(ct, HostsOrdering.REVERSE) python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_info_type.py000066400000000000000000000040621413122500400251020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import InfoType class GetInfoTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): InfoType.from_string('foo') def test_none_or_empty(self): ct = InfoType.from_string(None) self.assertIsNone(ct) ct = InfoType.from_string('') self.assertIsNone(ct) def test_cert_bund_adv(self): ct = InfoType.from_string('cert_bund_adv') self.assertEqual(ct, InfoType.CERT_BUND_ADV) def test_cpe(self): ct = InfoType.from_string('cpe') self.assertEqual(ct, InfoType.CPE) def test_cve(self): ct = InfoType.from_string('cve') self.assertEqual(ct, InfoType.CVE) def test_dfn_cert_adv(self): ct = InfoType.from_string('dfn_cert_adv') self.assertEqual(ct, InfoType.DFN_CERT_ADV) def test_nvt(self): ct = InfoType.from_string('nvt') self.assertEqual(ct, InfoType.NVT) def test_ovaldef(self): ct = InfoType.from_string('ovaldef') self.assertEqual(ct, InfoType.OVALDEF) def test_allinfo(self): with self.assertRaises(InvalidArgument): InfoType.from_string('allinfo') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_permission_subject_type.py000066400000000000000000000033071413122500400300570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import PermissionSubjectType class GetPermissionSubjectTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): PermissionSubjectType.from_string('foo') def test_none_or_empty(self): ct = PermissionSubjectType.from_string(None) self.assertIsNone(ct) ct = PermissionSubjectType.from_string('') self.assertIsNone(ct) def test_user(self): ct = PermissionSubjectType.from_string('user') self.assertEqual(ct, PermissionSubjectType.USER) def test_role(self): ct = PermissionSubjectType.from_string('role') self.assertEqual(ct, PermissionSubjectType.ROLE) def test_group(self): ct = PermissionSubjectType.from_string('group') self.assertEqual(ct, PermissionSubjectType.GROUP) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_port_range_type.py000066400000000000000000000027541413122500400263150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import PortRangeType class GetPortRangeTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): PortRangeType.from_string('foo') def test_none_or_empty(self): ct = PortRangeType.from_string(None) self.assertIsNone(ct) ct = PortRangeType.from_string('') self.assertIsNone(ct) def test_tcp(self): ct = PortRangeType.from_string('tcp') self.assertEqual(ct, PortRangeType.TCP) def test_udp(self): ct = PortRangeType.from_string('udp') self.assertEqual(ct, PortRangeType.UDP) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_report_format_type.py000066400000000000000000000074541413122500400270420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208.entities.report_formats import ReportFormatType class GetPortRangeTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): ReportFormatType.from_string('foo') def test_none_or_empty(self): ct = ReportFormatType.from_string(None) self.assertIsNone(ct) ct = ReportFormatType.from_string('') self.assertIsNone(ct) def test_anonymous_pdf(self): ct = ReportFormatType.from_string('anonymous xml') self.assertEqual(ct, ReportFormatType.ANONYMOUS_XML) def test_arf(self): ct = ReportFormatType.from_string('arf') self.assertEqual(ct, ReportFormatType.ARF) def test_(self): ct = ReportFormatType.from_string('cpe') self.assertEqual(ct, ReportFormatType.CPE) def test_csv_hosts(self): ct = ReportFormatType.from_string('csv hosts') self.assertEqual(ct, ReportFormatType.CSV_HOSTS) def test_csv_results(self): ct = ReportFormatType.from_string('csv results') self.assertEqual(ct, ReportFormatType.CSV_RESULTS) def test_gcr_pdf(self): ct = ReportFormatType.from_string('gcr pdf') self.assertEqual(ct, ReportFormatType.GCR_PDF) def test_gsr_html(self): ct = ReportFormatType.from_string('gsr html') self.assertEqual(ct, ReportFormatType.GSR_HTML) def test_gsr_pdf(self): ct = ReportFormatType.from_string('gsr pdf') self.assertEqual(ct, ReportFormatType.GSR_PDF) def test_gxcr_pdf(self): ct = ReportFormatType.from_string('gxcr pdf') self.assertEqual(ct, ReportFormatType.GXCR_PDF) def test_gxr_pdf(self): ct = ReportFormatType.from_string('gxr pdf') self.assertEqual(ct, ReportFormatType.GXR_PDF) def test_itg(self): ct = ReportFormatType.from_string('itg') self.assertEqual(ct, ReportFormatType.ITG) def test_latex(self): ct = ReportFormatType.from_string('latex') self.assertEqual(ct, ReportFormatType.LATEX) def test_nbe(self): ct = ReportFormatType.from_string('nbe') self.assertEqual(ct, ReportFormatType.NBE) def test_pdf(self): ct = ReportFormatType.from_string('pdf') self.assertEqual(ct, ReportFormatType.PDF) def test_svg(self): ct = ReportFormatType.from_string('svg') self.assertEqual(ct, ReportFormatType.SVG) def test_txt(self): ct = ReportFormatType.from_string('txt') self.assertEqual(ct, ReportFormatType.TXT) def test_verinice_ism(self): ct = ReportFormatType.from_string('verinice ism') self.assertEqual(ct, ReportFormatType.VERINICE_ISM) def test_verinice_itg(self): ct = ReportFormatType.from_string('verinice itg') self.assertEqual(ct, ReportFormatType.VERINICE_ITG) def test_xml(self): ct = ReportFormatType.from_string('xml') self.assertEqual(ct, ReportFormatType.XML) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_scanner_type.py000066400000000000000000000047271413122500400256100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import ScannerType class GetScannerTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): ScannerType.from_string('foo') def test_none_or_empty(self): ct = ScannerType.from_string(None) self.assertIsNone(ct) ct = ScannerType.from_string('') self.assertIsNone(ct) def test_osp_scanner(self): ct = ScannerType.from_string('1') self.assertEqual(ct, ScannerType.OSP_SCANNER_TYPE) ct = ScannerType.from_string('osp') self.assertEqual(ct, ScannerType.OSP_SCANNER_TYPE) def test_openvas_scanner(self): ct = ScannerType.from_string('2') self.assertEqual(ct, ScannerType.OPENVAS_SCANNER_TYPE) ct = ScannerType.from_string('openvas') self.assertEqual(ct, ScannerType.OPENVAS_SCANNER_TYPE) def test_cve_scanner(self): ct = ScannerType.from_string('3') self.assertEqual(ct, ScannerType.CVE_SCANNER_TYPE) ct = ScannerType.from_string('cve') self.assertEqual(ct, ScannerType.CVE_SCANNER_TYPE) def test_gmp_scanner(self): ct = ScannerType.from_string('4') self.assertEqual(ct, ScannerType.GMP_SCANNER_TYPE) ct = ScannerType.from_string('gmp') self.assertEqual(ct, ScannerType.GMP_SCANNER_TYPE) def test_greenbone_sensor_scanner(self): ct = ScannerType.from_string('5') self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) ct = ScannerType.from_string('greenbone') self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_severity_level.py000066400000000000000000000037401413122500400261510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import SeverityLevel class GetSeverityLevelFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): SeverityLevel.from_string('foo') def test_none_or_empty(self): ct = SeverityLevel.from_string(None) self.assertIsNone(ct) ct = SeverityLevel.from_string('') self.assertIsNone(ct) def test_high(self): ct = SeverityLevel.from_string('High') self.assertEqual(ct, SeverityLevel.HIGH) def test_medium(self): ct = SeverityLevel.from_string('Medium') self.assertEqual(ct, SeverityLevel.MEDIUM) def test_low(self): ct = SeverityLevel.from_string('Low') self.assertEqual(ct, SeverityLevel.LOW) def test_log(self): ct = SeverityLevel.from_string('Log') self.assertEqual(ct, SeverityLevel.LOG) def test_alarm(self): ct = SeverityLevel.from_string('Alarm') self.assertEqual(ct, SeverityLevel.ALARM) def test_debug(self): ct = SeverityLevel.from_string('Debug') self.assertEqual(ct, SeverityLevel.DEBUG) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_snmp_algorithms.py000066400000000000000000000042631413122500400263170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import ( SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, ) class GetSnmpAuthAlgorithmFromStringTestCase(unittest.TestCase): def test_invalid_status(self): with self.assertRaises(InvalidArgument): SnmpAuthAlgorithm.from_string('foo') def test_none_or_empty_type(self): ts = SnmpAuthAlgorithm.from_string(None) self.assertIsNone(ts) ts = SnmpAuthAlgorithm.from_string('') self.assertIsNone(ts) def test_sha1(self): ts = SnmpAuthAlgorithm.from_string('sha1') self.assertEqual(ts, SnmpAuthAlgorithm.SHA1) def test_md5(self): ts = SnmpAuthAlgorithm.from_string('md5') self.assertEqual(ts, SnmpAuthAlgorithm.MD5) class GetSnmpPrivacyAlgorithmFromStringTestCase(unittest.TestCase): def test_invalid_status(self): with self.assertRaises(InvalidArgument): SnmpPrivacyAlgorithm.from_string('foo') def test_none_or_empty_type(self): ts = SnmpPrivacyAlgorithm.from_string(None) self.assertIsNone(ts) ts = SnmpPrivacyAlgorithm.from_string('') self.assertIsNone(ts) def test_aes(self): ts = SnmpPrivacyAlgorithm.from_string('aes') self.assertEqual(ts, SnmpPrivacyAlgorithm.AES) def test_des(self): ts = SnmpPrivacyAlgorithm.from_string('des') self.assertEqual(ts, SnmpPrivacyAlgorithm.DES) python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_sort_order.py000066400000000000000000000027571413122500400253010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import SortOrder class GetSortOrderFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): SortOrder.from_string('foo') def test_none_or_empty(self): ct = SortOrder.from_string(None) self.assertIsNone(ct) ct = SortOrder.from_string('') self.assertIsNone(ct) def test_ascending(self): ct = SortOrder.from_string('ascending') self.assertEqual(ct, SortOrder.ASCENDING) def test_descending(self): ct = SortOrder.from_string('descending') self.assertEqual(ct, SortOrder.DESCENDING) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_ticket_status.py000066400000000000000000000031571413122500400260000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import TicketStatus class GetTicketStatusFromStringTestCase(unittest.TestCase): def test_invalid_status(self): with self.assertRaises(InvalidArgument): TicketStatus.from_string('foo') def test_none_or_empty_type(self): ts = TicketStatus.from_string(None) self.assertIsNone(ts) ts = TicketStatus.from_string('') self.assertIsNone(ts) def test_ticket_status_open(self): ts = TicketStatus.from_string('open') self.assertEqual(ts, TicketStatus.OPEN) def test_ticket_status_fixed(self): ts = TicketStatus.from_string('fixed') self.assertEqual(ts, TicketStatus.FIXED) def test_ticket_status_closed(self): ts = TicketStatus.from_string('closed') self.assertEqual(ts, TicketStatus.CLOSED) python-gvm-21.10.0/tests/protocols/gmpv208/enums/test_user_auth_type.py000066400000000000000000000032271413122500400261500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import UserAuthType class GetUserAuthTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): UserAuthType.from_string('foo') def test_none_or_empty(self): ct = UserAuthType.from_string(None) self.assertIsNone(ct) ct = UserAuthType.from_string('') self.assertIsNone(ct) def test_file(self): ct = UserAuthType.from_string('file') self.assertEqual(ct, UserAuthType.FILE) def test_radius_connect(self): ct = UserAuthType.from_string('radius_connect') self.assertEqual(ct, UserAuthType.RADIUS_CONNECT) def test_ldap_connect(self): ct = UserAuthType.from_string('ldap_connect') self.assertEqual(ct, UserAuthType.LDAP_CONNECT) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv208/system/000077500000000000000000000000001413122500400216705ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/__init__.py000066400000000000000000000013571413122500400240070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/tests/protocols/gmpv208/system/aggregates/000077500000000000000000000000001413122500400240015ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/aggregates/__init__.py000066400000000000000000000014531413122500400261150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_aggregates import GmpGetAggregatesTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/system/aggregates/test_get_aggregates.py000066400000000000000000000267471413122500400304020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgument, InvalidArgumentType from gvm.protocols.gmpv208 import EntityType, AggregateStatistic, SortOrder class GmpGetAggregatesTestMixin: def test_get_aggregates(self): """ Test basic get_aggregates calls with only resource_type except special cases for audit, policy, scan_config and task. """ self.gmp.get_aggregates(EntityType.ALERT) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(resource_type=EntityType.CERT_BUND_ADV) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.CPE) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.CVE) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.DFN_CERT_ADV) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.HOST) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.NOTE) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.NVT) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.OPERATING_SYSTEM) self.connection.send.has_been_called_with('') self.gmp.get_aggregates(EntityType.OVALDEF) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.OVERRIDE) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.REPORT) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.RESULT) self.connection.send.has_been_called_with( '' ) def test_get_aggregates_resource_types_with_usage_type(self): """ Test special cases of resource_type in get_aggregates calls that should add a usage_type parameter: audit, policy, scan_config and task. """ self.gmp.get_aggregates(EntityType.AUDIT) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.POLICY) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.SCAN_CONFIG) self.connection.send.has_been_called_with( '' ) self.gmp.get_aggregates(EntityType.TASK) self.connection.send.has_been_called_with( '' ) def test_get_aggregates_missing_resource_type(self): """ Test get_aggregates calls with missing resource_type """ with self.assertRaises(RequiredArgument): self.gmp.get_aggregates(resource_type=None) with self.assertRaises(RequiredArgument): self.gmp.get_aggregates(resource_type='') with self.assertRaises(RequiredArgument): self.gmp.get_aggregates('') def test_get_aggregates_invalid_resource_type(self): """ Test get_aggregates calls with invalid resource_type """ with self.assertRaises(InvalidArgumentType): self.gmp.get_aggregates(resource_type='foo') def test_get_aggregates_sort_criteria(self): """ Test get_aggregates calls with sort_criteria given as strings """ self.gmp.get_aggregates( EntityType.NVT, group_column='family', sort_criteria=[ {'field': 'severity', 'stat': 'mean', 'order': 'descending'}, {'stat': 'count', 'order': 'descending'}, {'field': 'family', 'order': 'ascending'}, ], data_columns=['severity'], ) self.connection.send.has_been_called_with( '' '' '' '' 'severity' '' ) def test_get_aggregates_sort_criteria_enum(self): """ Test get_aggregates calls with sort_criteria given as enums """ self.gmp.get_aggregates( EntityType.NVT, group_column='family', sort_criteria=[ { 'field': 'severity', 'stat': AggregateStatistic.MEAN, 'order': SortOrder.DESCENDING, } ], data_columns=['severity'], ) self.connection.send.has_been_called_with( '' '' 'severity' '' ) def test_get_aggregates_invalid_sort_criteria(self): """ Test get_aggregates calls with invalid sort_criteria """ with self.assertRaises(InvalidArgumentType): self.gmp.get_aggregates( resource_type=EntityType.ALERT, sort_criteria='INVALID' ) with self.assertRaises(InvalidArgumentType): self.gmp.get_aggregates( resource_type=EntityType.ALERT, sort_criteria=['INVALID'] ) with self.assertRaises(InvalidArgument): self.gmp.get_aggregates( resource_type=EntityType.ALERT, sort_criteria=[{'stat': 'INVALID'}], ) with self.assertRaises(InvalidArgument): self.gmp.get_aggregates( resource_type=EntityType.ALERT, sort_criteria=[{'order': 'INVALID'}], ) def test_get_aggregates_group_limits(self): """ Test get_aggregates calls with group limits (first_group, max_groups) """ self.gmp.get_aggregates(EntityType.CPE, first_group=20, max_groups=25) self.connection.send.has_been_called_with( '' ) def test_get_aggregates_invalid_group_limits(self): """ Test get_aggregates calls with invalid group limits """ with self.assertRaises(InvalidArgumentType): self.gmp.get_aggregates( EntityType.CPE, first_group="INVALID", max_groups=25 ) with self.assertRaises(InvalidArgumentType): self.gmp.get_aggregates( EntityType.CPE, first_group=1, max_groups="INVALID" ) def test_get_aggregates_data_columns(self): """ Test get_aggregates calls with data_columns """ self.gmp.get_aggregates( EntityType.CPE, data_columns=['severity', 'cves'] ) self.connection.send.has_been_called_with( '' 'severity' 'cves' '' ) def test_get_aggregates_invalid_data_columns(self): """ Test get_aggregates calls with invalid data_columns """ with self.assertRaises(InvalidArgumentType): self.gmp.get_aggregates( resource_type=EntityType.ALERT, data_columns='INVALID' ) def test_get_aggregates_group_column(self): """ Test get_aggregates calls with group_column """ self.gmp.get_aggregates(EntityType.NVT, group_column='family') self.connection.send.has_been_called_with( '' ) def test_get_aggregates_subgroup_column(self): """ Test get_aggregates calls with subgroup_column """ self.gmp.get_aggregates( EntityType.NVT, group_column='family', subgroup_column='solution_type', ) self.connection.send.has_been_called_with( '' ) def test_get_aggregates_missing_group_column(self): """ Test get_aggregates calls with group_column missing if subgroup_column was given. """ with self.assertRaises(RequiredArgument): self.gmp.get_aggregates( resource_type=EntityType.NVT, subgroup_column='solution_type' ) with self.assertRaises(RequiredArgument): self.gmp.get_aggregates( resource_type=EntityType.NVT, group_column='', subgroup_column='solution_type', ) def test_get_aggregates_text_columns(self): """ Test get_aggregates calls with text_columns """ self.gmp.get_aggregates( EntityType.SCAN_CONFIG, group_column="uuid", text_columns=['name', 'comment'], ) self.connection.send.has_been_called_with( '' 'name' 'comment' '' ) def test_get_aggregates_invalid_text_columns(self): """ Test get_aggregates calls with invalid text_columns """ with self.assertRaises(InvalidArgumentType): self.gmp.get_aggregates( resource_type=EntityType.ALERT, text_columns='INVALID' ) def test_get_aggregates_mode(self): """ Test get_aggregates calls with mode """ self.gmp.get_aggregates( EntityType.NVT, group_column='name', mode='word_counts' ) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/system/authentication/000077500000000000000000000000001413122500400247075ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/authentication/__init__.py000066400000000000000000000016261413122500400270250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_authenticate import GmpAuthenticateTestMixin from .test_describe_auth import GmpDescribeAuthTestMixin from .test_modify_auth import GmpModifyAuthTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/system/authentication/test_authenticate.py000066400000000000000000000044351413122500400310040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpAuthenticateTestMixin: def test_missing_username(self): with self.assertRaises(RequiredArgument): self.gmp.authenticate(None, 'foo') with self.assertRaises(RequiredArgument): self.gmp.authenticate('', 'foo') def test_missing_password(self): with self.assertRaises(RequiredArgument): self.gmp.authenticate('bar', None) with self.assertRaises(RequiredArgument): self.gmp.authenticate('bar', '') def test_authentication_success(self): self.assertFalse(self.gmp.is_authenticated()) self.gmp.authenticate('foo', 'bar') self.connection.send.has_been_called_with( '' '' 'foo' 'bar' '' '' ) self.assertTrue(self.gmp.is_authenticated()) def test_authentication_failure(self): self.connection.read.return_value( '' ) self.assertFalse(self.gmp.is_authenticated()) self.gmp.authenticate('foo', 'bar') self.connection.send.has_been_called_with( '' '' 'foo' 'bar' '' '' ) self.assertFalse(self.gmp.is_authenticated()) python-gvm-21.10.0/tests/protocols/gmpv208/system/authentication/test_describe_auth.py000066400000000000000000000016401413122500400311220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpDescribeAuthTestMixin: def test_describe_auth(self): self.gmp.describe_auth() self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/system/authentication/test_modify_auth.py000066400000000000000000000046151413122500400306360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from collections import OrderedDict from gvm.errors import RequiredArgument class GmpModifyAuthTestMixin: def test_modify_auth(self): self.gmp.modify_auth( 'foo', OrderedDict([('foo', 'bar'), ('lorem', 'ipsum')]) ) self.connection.send.has_been_called_with( '' '' '' 'foo' 'bar' '' '' 'lorem' 'ipsum' '' '' '' ) def test_modify_auth_missing_group_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_auth( group_name=None, auth_conf_settings={'foo': 'bar'} ) with self.assertRaises(RequiredArgument): self.gmp.modify_auth( group_name='', auth_conf_settings={'foo': 'bar'} ) with self.assertRaises(RequiredArgument): self.gmp.modify_auth('', auth_conf_settings={'foo': 'bar'}) def test_modify_auth_auth_conf_settings(self): with self.assertRaises(RequiredArgument): self.gmp.modify_auth(group_name='foo', auth_conf_settings=None) with self.assertRaises(RequiredArgument): self.gmp.modify_auth(group_name='foo', auth_conf_settings='') with self.assertRaises(RequiredArgument): self.gmp.modify_auth('foo', '') with self.assertRaises(RequiredArgument): self.gmp.modify_auth('foo', {}) python-gvm-21.10.0/tests/protocols/gmpv208/system/feed/000077500000000000000000000000001413122500400225735ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/feed/__init__.py000066400000000000000000000015201413122500400247020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_feed import GmpGetFeedTestMixin from .test_get_feeds import GmpGetFeedsTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/system/feed/test_get_feed.py000066400000000000000000000042231413122500400257470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv208 import FeedType class GmpGetFeedTestMixin: def test_get_feed(self): """ Test basic get_feed calls with only resource_type except special cases for audit, policy, scan_config and task. """ self.gmp.get_feed(FeedType.NVT) self.connection.send.has_been_called_with('') self.gmp.get_feed(FeedType.CERT) self.connection.send.has_been_called_with('') self.gmp.get_feed(FeedType.SCAP) self.connection.send.has_been_called_with('') self.gmp.get_feed(FeedType.GVMD_DATA) self.connection.send.has_been_called_with( '' ) def test_get_feed_missing_type(self): """ Test get_feed calls with missing resource_type """ with self.assertRaises(RequiredArgument): self.gmp.get_feed(feed_type=None) with self.assertRaises(RequiredArgument): self.gmp.get_feed(feed_type='') with self.assertRaises(RequiredArgument): self.gmp.get_feed('') def test_get_feed_invalid_type(self): """ Test get_feed calls with invalid resource_type """ with self.assertRaises(InvalidArgumentType): self.gmp.get_feed('foo') python-gvm-21.10.0/tests/protocols/gmpv208/system/feed/test_get_feeds.py000066400000000000000000000016201413122500400261300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetFeedsTestMixin: def test_get_feeds(self): self.gmp.get_feeds() self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/system/help/000077500000000000000000000000001413122500400226205ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/help/__init__.py000066400000000000000000000014301413122500400247270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_help import GmpHelpTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/system/help/test_help.py000066400000000000000000000026711413122500400251670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import InvalidArgumentType from gvm.protocols.gmpv208 import HelpFormat class GmpHelpTestMixin: def test_help(self): self.gmp.help() self.connection.send.has_been_called_with('') def test_help_type_brief(self): self.gmp.help(brief=True) self.connection.send.has_been_called_with('') def test_invalid_help_format(self): with self.assertRaises(InvalidArgumentType): self.gmp.help(help_format='foo') def test_html_format(self): self.gmp.help(help_format=HelpFormat.HTML) self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/system/system_reports/000077500000000000000000000000001413122500400247725ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/system_reports/__init__.py000066400000000000000000000014621413122500400271060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_system_reports import GmpGetSystemReportsTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/system/system_reports/test_get_system_reports.py000066400000000000000000000051071413122500400323470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import InvalidArgument class GmpGetSystemReportsTestMixin: def test_get_system_reports(self): self.gmp.get_system_reports() self.connection.send.has_been_called_with('') def test_get_system_reports_with_name(self): self.gmp.get_system_reports(name='foo') self.connection.send.has_been_called_with( '' ) def test_get_system_reports_with_slave_id(self): self.gmp.get_system_reports(slave_id='s1') self.connection.send.has_been_called_with( '' ) def test_get_system_reports_with_brief(self): self.gmp.get_system_reports(brief=True) self.connection.send.has_been_called_with( '' ) self.gmp.get_system_reports(brief=False) self.connection.send.has_been_called_with( '' ) def test_get_system_reports_with_duration(self): self.gmp.get_system_reports(duration=3600) self.connection.send.has_been_called_with( '' ) def test_get_system_reports_with_invalid_duration(self): with self.assertRaises(InvalidArgument): self.gmp.get_system_reports(duration='') def test_get_system_reports_with_start_time(self): self.gmp.get_system_reports(start_time='01-01-2019') self.connection.send.has_been_called_with( '' ) def test_get_system_reports_with_end_time(self): self.gmp.get_system_reports(end_time='01-01-2019') self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/system/test_aggregates.py000066400000000000000000000016551413122500400254210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .aggregates import ( GmpGetAggregatesTestMixin, ) class Gmpv208GetAggregatesTestCase(GmpGetAggregatesTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/system/test_authentication.py000066400000000000000000000022431413122500400263210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .authentication import ( GmpAuthenticateTestMixin, GmpDescribeAuthTestMixin, GmpModifyAuthTestMixin, ) class Gmpv208AuthenticateTestCase(GmpAuthenticateTestMixin, Gmpv208TestCase): pass class Gmpv208ModifyAuthTestCase(GmpModifyAuthTestMixin, Gmpv208TestCase): pass class Gmpv208DescribeAuthCommandTestCase( GmpDescribeAuthTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/system/test_feed.py000066400000000000000000000020001413122500400241740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .feed import ( GmpGetFeedsTestMixin, GmpGetFeedTestMixin, ) class Gmpv208GetFeedTestCase(GmpGetFeedTestMixin, Gmpv208TestCase): pass class Gmpv208GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/system/test_help.py000066400000000000000000000016141413122500400242330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .help import ( GmpHelpTestMixin, ) class Gmpv208HelpTestCase(GmpHelpTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv208/system/test_system_reports.py000066400000000000000000000016741413122500400264130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .system_reports import GmpGetSystemReportsTestMixin class Gmpv208GetSystemReportsTestCase( GmpGetSystemReportsTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/system/test_trashcan.py000066400000000000000000000020751413122500400251100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .trashcan import ( GmpEmptyTrashcanTestMixin, GmpRestoreFromTrashcanTestMixin, ) class Gmpv208EmptyTrashcanTestCase(GmpEmptyTrashcanTestMixin, Gmpv208TestCase): pass class Gmpv208RestoreFromTrashcanTestCase( GmpRestoreFromTrashcanTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/system/test_user_settings.py000066400000000000000000000023131413122500400261760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .user_settings import ( GmpGetUserSettingTestMixin, GmpGetUserSettingsTestMixin, GmpModifyUserSettingTestMixin, ) class Gmpv208GetUserSettingTestCase( GmpGetUserSettingTestMixin, Gmpv208TestCase ): pass class Gmpv208GetUserSettingsTestCase( GmpGetUserSettingsTestMixin, Gmpv208TestCase ): pass class Gmpv208ModifyUserSettingTestCase( GmpModifyUserSettingTestMixin, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/system/test_versions.py000066400000000000000000000020521413122500400251500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv208 import Gmpv208TestCase from .versions import GmpGetVersionTestCase, GmpGetProtocolVersionTestCase class Gmpv208GetVersionCommandTestCase(GmpGetVersionTestCase, Gmpv208TestCase): pass class Gmpv208GmpGetProtocolVersionTestCase( GmpGetProtocolVersionTestCase, Gmpv208TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv208/system/trashcan/000077500000000000000000000000001413122500400234735ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/trashcan/__init__.py000066400000000000000000000015631413122500400256110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_empty_trashcan import GmpEmptyTrashcanTestMixin from .test_restore_from_trashcan import GmpRestoreFromTrashcanTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/system/trashcan/test_empty_trashcan.py000066400000000000000000000016441413122500400301320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpEmptyTrashcanTestMixin: def test_empty_trashcan(self): self.gmp.empty_trashcan() self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/system/trashcan/test_restore_from_trashcan.py000066400000000000000000000023111413122500400314720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import GvmError class GmpRestoreFromTrashcanTestMixin: def test_restore_from_trashcan(self): self.gmp.restore_from_trashcan('a1') self.connection.send.has_been_called_with('') def test_restore_from_trashcan_missing_id(self): with self.assertRaises(GvmError): self.gmp.restore_from_trashcan(None) with self.assertRaises(GvmError): self.gmp.restore_from_trashcan('') python-gvm-21.10.0/tests/protocols/gmpv208/system/user_settings/000077500000000000000000000000001413122500400245665ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/user_settings/__init__.py000066400000000000000000000016621413122500400267040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_user_setting import GmpGetUserSettingTestMixin from .test_get_user_settings import GmpGetUserSettingsTestMixin from .test_modify_user_setting import GmpModifyUserSettingTestMixin python-gvm-21.10.0/tests/protocols/gmpv208/system/user_settings/test_get_user_setting.py000066400000000000000000000023661413122500400315600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpGetUserSettingTestMixin: def test_get_setting_simple(self): self.gmp.get_user_setting('id') self.connection.send.has_been_called_with( '' ) def test_get_setting_missing_setting_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_user_setting(setting_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_user_setting('') python-gvm-21.10.0/tests/protocols/gmpv208/system/user_settings/test_get_user_settings.py000066400000000000000000000022031413122500400317310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetUserSettingsTestMixin: def test_get_settings(self): self.gmp.get_user_settings() self.connection.send.has_been_called_with('') def test_get_settings_with_filter_string(self): self.gmp.get_user_settings(filter_string="foo=bar") self.connection.send.has_been_called_with( '' ) python-gvm-21.10.0/tests/protocols/gmpv208/system/user_settings/test_modify_user_setting.py000066400000000000000000000044031413122500400322620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument class GmpModifyUserSettingTestMixin: def test_modify_user_setting(self): self.gmp.modify_user_setting(setting_id='s1', value='bar') self.connection.send.has_been_called_with( '' 'YmFy' '' ) self.gmp.modify_user_setting(name='s1', value='bar') self.connection.send.has_been_called_with( '' 's1' 'YmFy' '' ) self.gmp.modify_user_setting(setting_id='s1', value='') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_user_setting_missing_setting_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_user_setting(setting_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_user_setting(setting_id='') def test_modify_setting_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.modify_user_setting(name=None) with self.assertRaises(RequiredArgument): self.gmp.modify_user_setting(name='') def test_modify_user_setting_missing_value(self): with self.assertRaises(RequiredArgument): self.gmp.modify_user_setting(setting_id='s1', value=None) python-gvm-21.10.0/tests/protocols/gmpv208/system/versions/000077500000000000000000000000001413122500400235405ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv208/system/versions/__init__.py000066400000000000000000000015511413122500400256530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_protocol_version import GmpGetProtocolVersionTestCase from .test_get_version import GmpGetVersionTestCase python-gvm-21.10.0/tests/protocols/gmpv208/system/versions/test_get_protocol_version.py000066400000000000000000000016031413122500400314160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetProtocolVersionTestCase: def test_protocol_version(self): self.assertEqual(self.gmp.get_protocol_version(), (20, 8)) python-gvm-21.10.0/tests/protocols/gmpv208/system/versions/test_get_version.py000066400000000000000000000020471413122500400275000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetVersionTestCase: def test_get_version(self): self.gmp.get_version() self.connection.connect.has_been_called() self.connection.read.has_been_called() self.connection.send.has_been_called() self.connection.send.has_been_called_with('') python-gvm-21.10.0/tests/protocols/gmpv208/test_with_statement.py000066400000000000000000000022641413122500400250200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import Gmpv208TestCase class GmpWithStatementTestMixin: def test_with_statement(self): self.connection.connect.has_not_been_called() self.connection.disconnect.has_not_been_called() with self.gmp: pass self.connection.connect.has_been_called() self.connection.disconnect.has_been_called() class Gmpv208WithStatementTestCase(GmpWithStatementTestMixin, Gmpv208TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/000077500000000000000000000000001413122500400203415ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/__init__.py000066400000000000000000000015631413122500400224570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.protocols.gmpv214 import Gmp from .. import GmpTestCase class Gmpv214TestCase(GmpTestCase): gmp_class = Gmp python-gvm-21.10.0/tests/protocols/gmpv214/entities/000077500000000000000000000000001413122500400221655ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/entities/__init__.py000066400000000000000000000013571413122500400243040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/tests/protocols/gmpv214/entities/notes/000077500000000000000000000000001413122500400233155ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/entities/notes/__init__.py000066400000000000000000000015321413122500400254270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_create_note import GmpCreateNoteTestMixin from .test_modify_note import GmpModifyNoteTestMixin python-gvm-21.10.0/tests/protocols/gmpv214/entities/notes/test_create_note.py000066400000000000000000000127541413122500400272270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from decimal import Decimal from gvm.errors import RequiredArgument from gvm.protocols.gmpv214 import SeverityLevel class GmpCreateNoteTestMixin: def test_create_note(self): self.gmp.create_note('foo', nvt_oid='oid1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_note_missing_text(self): with self.assertRaises(RequiredArgument): self.gmp.create_note(None, 'od1') with self.assertRaises(RequiredArgument): self.gmp.create_note('', 'oid1') def test_create_note_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): self.gmp.create_note('foo', None) with self.assertRaises(RequiredArgument): self.gmp.create_note('foo', '') def test_create_note_with_hosts(self): self.gmp.create_note('foo', nvt_oid='oid1', hosts=[]) self.connection.send.has_been_called_with( '' 'foo' '' '' ) self.gmp.create_note('foo', nvt_oid='oid1', hosts=['h1', 'h2']) self.connection.send.has_been_called_with( '' 'foo' '' 'h1,h2' '' ) def test_create_note_with_port(self): self.gmp.create_note('foo', nvt_oid='oid1', port='666') self.connection.send.has_been_called_with( '' 'foo' '' '666' '' ) self.gmp.create_note('foo', nvt_oid='oid1', port=666) self.connection.send.has_been_called_with( '' 'foo' '' '666' '' ) def test_create_note_with_result_id(self): self.gmp.create_note('foo', nvt_oid='oid1', result_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_note_with_task_id(self): self.gmp.create_note('foo', nvt_oid='oid1', task_id='t1') self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_note_with_severity(self): self.gmp.create_note('foo', nvt_oid='oid1', severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_note('foo', nvt_oid='oid1', severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_note('foo', nvt_oid='oid1', severity=Decimal(5.5)) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) def test_create_note_with_threat(self): self.gmp.create_note('foo', nvt_oid='oid1', threat=SeverityLevel.HIGH) self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_note_with_days_active(self): self.gmp.create_note('foo', nvt_oid='oid1', days_active=0) self.connection.send.has_been_called_with( '' 'foo' '' '0' '' ) self.gmp.create_note('foo', nvt_oid='oid1', days_active=-1) self.connection.send.has_been_called_with( '' 'foo' '' '-1' '' ) self.gmp.create_note('foo', nvt_oid='oid1', days_active=3600) self.connection.send.has_been_called_with( '' 'foo' '' '3600' '' ) python-gvm-21.10.0/tests/protocols/gmpv214/entities/notes/test_modify_note.py000066400000000000000000000130151413122500400272420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from decimal import Decimal from gvm.errors import RequiredArgument from gvm.protocols.gmpv214 import SeverityLevel class GmpModifyNoteTestMixin: def test_modify_note(self): self.gmp.modify_note(note_id='n1', text='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_note_missing_note_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_note(note_id=None, text='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_note(note_id='', text='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_note('', text='foo') def test_modify_note_missing_text(self): with self.assertRaises(RequiredArgument): self.gmp.modify_note(note_id='n1', text='') with self.assertRaises(RequiredArgument): self.gmp.modify_note(note_id='n1', text=None) with self.assertRaises(RequiredArgument): self.gmp.modify_note('n1', '') def test_modify_note_with_days_active(self): self.gmp.modify_note(note_id='n1', text='foo', days_active=0) self.connection.send.has_been_called_with( '' 'foo' '0' '' ) self.gmp.modify_note(note_id='n1', text='foo', days_active=-1) self.connection.send.has_been_called_with( '' 'foo' '-1' '' ) self.gmp.modify_note(note_id='n1', text='foo', days_active=600) self.connection.send.has_been_called_with( '' 'foo' '600' '' ) def test_modify_note_with_port(self): self.gmp.modify_note(note_id='n1', text='foo', port='123') self.connection.send.has_been_called_with( '' 'foo' '123' '' ) self.gmp.modify_note(note_id='n1', text='foo', port=123) self.connection.send.has_been_called_with( '' 'foo' '123' '' ) def test_modify_note_with_hosts(self): self.gmp.modify_note(note_id='n1', text='foo', hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' ) self.gmp.modify_note(note_id='n1', text='foo', hosts=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo' 'foo,bar' '' ) def test_modify_note_with_result_id(self): self.gmp.modify_note(note_id='n1', text='foo', result_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_modify_note_with_task_id(self): self.gmp.modify_note(note_id='n1', text='foo', task_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_modify_note_with_severity(self): self.gmp.modify_note(note_id='n1', text='foo', severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_note(note_id='n1', text='foo', severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_note(note_id='n1', text='foo', severity=Decimal(5.5)) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) def test_modify_note_with_threat(self): self.gmp.modify_note( note_id='n1', text='foo', threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' '' ) python-gvm-21.10.0/tests/protocols/gmpv214/entities/overrides/000077500000000000000000000000001413122500400241675ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/entities/overrides/__init__.py000066400000000000000000000015521413122500400263030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_create_override import GmpCreateOverrideTestMixin from .test_modify_override import GmpModifyOverrideTestMixin python-gvm-21.10.0/tests/protocols/gmpv214/entities/overrides/test_create_override.py000066400000000000000000000161051413122500400307450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from decimal import Decimal from gvm.errors import RequiredArgument from gvm.protocols.gmpv214 import SeverityLevel class GmpCreateOverrideTestMixin: def test_create_override(self): self.gmp.create_override('foo', nvt_oid='oid1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_override_missing_text(self): with self.assertRaises(RequiredArgument): self.gmp.create_override(None, 'od1') with self.assertRaises(RequiredArgument): self.gmp.create_override('', 'oid1') def test_create_override_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): self.gmp.create_override('foo', None) with self.assertRaises(RequiredArgument): self.gmp.create_override('foo', '') def test_create_override_with_hosts(self): self.gmp.create_override('foo', nvt_oid='oid1', hosts=[]) self.connection.send.has_been_called_with( '' 'foo' '' '' ) self.gmp.create_override('foo', nvt_oid='oid1', hosts=['h1', 'h2']) self.connection.send.has_been_called_with( '' 'foo' '' 'h1,h2' '' ) def test_create_override_with_port(self): self.gmp.create_override('foo', nvt_oid='oid1', port='666') self.connection.send.has_been_called_with( '' 'foo' '' '666' '' ) self.gmp.create_override('foo', nvt_oid='oid1', port=666) self.connection.send.has_been_called_with( '' 'foo' '' '666' '' ) def test_create_override_with_result_id(self): self.gmp.create_override('foo', nvt_oid='oid1', result_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_override_with_task_id(self): self.gmp.create_override('foo', nvt_oid='oid1', task_id='t1') self.connection.send.has_been_called_with( '' 'foo' '' '' '' ) def test_create_override_with_severity(self): self.gmp.create_override('foo', nvt_oid='oid1', severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_override('foo', nvt_oid='oid1', severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_override('foo', nvt_oid='oid1', severity=Decimal(5.5)) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) def test_create_override_with_new_severity(self): self.gmp.create_override('foo', nvt_oid='oid1', new_severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_override('foo', nvt_oid='oid1', new_severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) self.gmp.create_override( 'foo', nvt_oid='oid1', new_severity=Decimal(5.5) ) self.connection.send.has_been_called_with( '' 'foo' '' '5.5' '' ) def test_create_override_with_threat(self): self.gmp.create_override( 'foo', nvt_oid='oid1', threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_override_with_new_threat(self): self.gmp.create_override( 'foo', nvt_oid='oid1', new_threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_override_with_days_active(self): self.gmp.create_override('foo', nvt_oid='oid1', days_active=0) self.connection.send.has_been_called_with( '' 'foo' '' '0' '' ) self.gmp.create_override('foo', nvt_oid='oid1', days_active=-1) self.connection.send.has_been_called_with( '' 'foo' '' '-1' '' ) self.gmp.create_override('foo', nvt_oid='oid1', days_active=3600) self.connection.send.has_been_called_with( '' 'foo' '' '3600' '' ) python-gvm-21.10.0/tests/protocols/gmpv214/entities/overrides/test_modify_override.py000066400000000000000000000164561413122500400310020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from decimal import Decimal from gvm.errors import RequiredArgument from gvm.protocols.gmpv214 import SeverityLevel class GmpModifyOverrideTestMixin: def test_modify_override(self): self.gmp.modify_override(override_id='o1', text='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_override_missing_override_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_override(override_id=None, text='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_override(override_id='', text='foo') with self.assertRaises(RequiredArgument): self.gmp.modify_override('', text='foo') def test_modify_override_missing_text(self): with self.assertRaises(RequiredArgument): self.gmp.modify_override(override_id='o1', text='') with self.assertRaises(RequiredArgument): self.gmp.modify_override(override_id='o1', text=None) with self.assertRaises(RequiredArgument): self.gmp.modify_override('o1', '') def test_modify_override_with_days_active(self): self.gmp.modify_override(override_id='o1', text='foo', days_active=0) self.connection.send.has_been_called_with( '' 'foo' '0' '' ) self.gmp.modify_override(override_id='o1', text='foo', days_active=-1) self.connection.send.has_been_called_with( '' 'foo' '-1' '' ) self.gmp.modify_override(override_id='o1', text='foo', days_active=600) self.connection.send.has_been_called_with( '' 'foo' '600' '' ) def test_modify_override_with_port(self): self.gmp.modify_override(override_id='o1', text='foo', port='123') self.connection.send.has_been_called_with( '' 'foo' '123' '' ) self.gmp.modify_override(override_id='o1', text='foo', port=123) self.connection.send.has_been_called_with( '' 'foo' '123' '' ) def test_modify_override_with_hosts(self): self.gmp.modify_override(override_id='o1', text='foo', hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' ) self.gmp.modify_override( override_id='o1', text='foo', hosts=['foo', 'bar'] ) self.connection.send.has_been_called_with( '' 'foo' 'foo,bar' '' ) def test_modify_override_with_result_id(self): self.gmp.modify_override(override_id='o1', text='foo', result_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_modify_override_with_task_id(self): self.gmp.modify_override(override_id='o1', text='foo', task_id='r1') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_modify_override_with_severity(self): self.gmp.modify_override(override_id='o1', text='foo', severity='5.5') self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_override(override_id='o1', text='foo', severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_override( override_id='o1', text='foo', severity=Decimal(5.5) ) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) def test_modify_override_with_new_severity(self): self.gmp.modify_override( override_id='o1', text='foo', new_severity='5.5' ) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_override(override_id='o1', text='foo', new_severity=5.5) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) self.gmp.modify_override( override_id='o1', text='foo', new_severity=Decimal(5.5) ) self.connection.send.has_been_called_with( '' 'foo' '5.5' '' ) def test_modify_override_with_threat(self): self.gmp.modify_override( override_id='o1', text='foo', threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_override_with_new_threat(self): self.gmp.modify_override( override_id='o1', text='foo', new_threat=SeverityLevel.HIGH ) self.connection.send.has_been_called_with( '' 'foo' '' ) python-gvm-21.10.0/tests/protocols/gmpv214/entities/scanners/000077500000000000000000000000001413122500400240015ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/entities/scanners/__init__.py000066400000000000000000000015461413122500400261200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_create_scanner import GmpCreateScannerTestMixin from .test_modify_scanner import GmpModifyScannerTestMixin python-gvm-21.10.0/tests/protocols/gmpv214/entities/scanners/test_create_scanner.py000066400000000000000000000146411413122500400303740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv214 import ScannerType class GmpCreateScannerTestMixin: def test_create_scanner(self): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) self.connection.send.has_been_called_with( '' 'foo' 'localhost' '1234' '1' '' '' ) def test_create_scanner_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name=None, host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='', host='localhost', port=1234, scanner_type='1', credential_id='c1', ) def test_create_scanner_missing_host(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host=None, port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) def test_create_scanner_missing_port(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=None, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port='', scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) def test_create_scanner_missing_scanner_type(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=None, credential_id='c1', ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type='', credential_id='c1', ) def test_create_scanner_missing_credential_id(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id=None, ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='', ) def test_create_scanner_invalid_scanner_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type='bar', credential_id='c1', ) with self.assertRaises(AttributeError): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.GMP_SCANNER_TYPE, # pylint: disable=no-member credential_id='c1', ) with self.assertRaises(InvalidArgumentType): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type='55', credential_id='c1', ) def test_create_scanner_with_ca_pub(self): self.gmp.create_scanner( name='foo', host='localhost', port=1234, ca_pub='foo', scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', ) self.connection.send.has_been_called_with( '' 'foo' 'localhost' '1234' '1' 'foo' '' '' ) def test_create_scanner_with_comment(self): self.gmp.create_scanner( name='foo', host='localhost', port=1234, scanner_type=ScannerType.OSP_SCANNER_TYPE, credential_id='c1', comment='bar', ) self.connection.send.has_been_called_with( '' 'foo' 'localhost' '1234' '1' '' 'bar' '' ) python-gvm-21.10.0/tests/protocols/gmpv214/entities/scanners/test_modify_scanner.py000066400000000000000000000115301413122500400304120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv214 import ScannerType class GmpModifyScannerTestMixin: def test_modify_scanner(self): self.gmp.modify_scanner(scanner_id='s1') self.connection.send.has_been_called_with( '' ) def test_modify_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_scanner(scanner_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_scanner(scanner_id='') def test_modify_scanner_with_comment(self): self.gmp.modify_scanner(scanner_id='s1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scanner_with_host(self): self.gmp.modify_scanner(scanner_id='s1', host='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scanner_with_port(self): self.gmp.modify_scanner(scanner_id='s1', port=1234) self.connection.send.has_been_called_with( '' '1234' '' ) self.gmp.modify_scanner(scanner_id='s1', port='1234') self.connection.send.has_been_called_with( '' '1234' '' ) def test_modify_scanner_with_name(self): self.gmp.modify_scanner(scanner_id='s1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scanner_with_ca_pub(self): self.gmp.modify_scanner(scanner_id='s1', ca_pub='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_scanner_with_credential_id(self): self.gmp.modify_scanner(scanner_id='s1', credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_scanner_with_scanner_type(self): self.gmp.modify_scanner( scanner_id='s1', scanner_type=ScannerType.OSP_SCANNER_TYPE ) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_scanner( scanner_id='s1', scanner_type=ScannerType.OPENVAS_SCANNER_TYPE ) self.connection.send.has_been_called_with( '' '2' '' ) self.gmp.modify_scanner( scanner_id='s1', scanner_type=ScannerType.CVE_SCANNER_TYPE ) self.connection.send.has_been_called_with( '' '3' '' ) self.gmp.modify_scanner( scanner_id='s1', scanner_type=ScannerType.GREENBONE_SENSOR_SCANNER_TYPE, ) self.connection.send.has_been_called_with( '' '5' '' ) def test_modify_scanner_invalid_scanner_type(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_scanner(scanner_id='s1', scanner_type='') with self.assertRaises(InvalidArgumentType): self.gmp.modify_scanner(scanner_id='s1', scanner_type='-1') with self.assertRaises(InvalidArgumentType): self.gmp.modify_scanner(scanner_id='s1', scanner_type=1) python-gvm-21.10.0/tests/protocols/gmpv214/entities/targets/000077500000000000000000000000001413122500400236365ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/entities/targets/__init__.py000066400000000000000000000015421413122500400257510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_create_target import GmpCreateTargetTestMixin from .test_modify_target import GmpModifyTargetTestMixin python-gvm-21.10.0/tests/protocols/gmpv214/entities/targets/test_create_target.py000066400000000000000000000174261413122500400300720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv214.entities.targets import AliveTest class GmpCreateTargetTestMixin: def test_create_target_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_target(None, hosts=['foo']) with self.assertRaises(RequiredArgument): self.gmp.create_target(name=None, hosts=['foo']) with self.assertRaises(RequiredArgument): self.gmp.create_target('', hosts=['foo']) def test_create_target_with_asset_hosts_filter(self): self.gmp.create_target('foo', asset_hosts_filter='name=foo') self.connection.send.has_been_called_with( '' 'foo' '' '' ) def test_create_target_missing_hosts(self): with self.assertRaises(RequiredArgument): self.gmp.create_target(name='foo') def test_create_target_with_comment(self): self.gmp.create_target('foo', hosts=['foo'], comment='bar') self.connection.send.has_been_called_with( '' 'foo' 'foo' 'bar' '' ) def test_create_target_with_exclude_hosts(self): self.gmp.create_target( 'foo', hosts=['foo', 'bar'], exclude_hosts=['bar', 'ipsum'] ) self.connection.send.has_been_called_with( '' 'foo' 'foo,bar' 'bar,ipsum' '' ) def test_create_target_with_ssh_credential(self): self.gmp.create_target('foo', hosts=['foo'], ssh_credential_id='c1') self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' ) def test_create_target_with_ssh_credential_port(self): self.gmp.create_target( 'foo', hosts=['foo'], ssh_credential_id='c1', ssh_credential_port=123, ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '123' '' '' ) def test_create_target_with_smb_credential_id(self): self.gmp.create_target('foo', hosts=['foo'], smb_credential_id='c1') self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' ) def test_create_target_with_esxi_credential_id(self): self.gmp.create_target('foo', hosts=['foo'], esxi_credential_id='c1') self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' ) def test_create_target_with_snmp_credential_id(self): self.gmp.create_target('foo', hosts=['foo'], snmp_credential_id='c1') self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' ) def test_create_target_with_alive_tests(self): self.gmp.create_target( 'foo', hosts=['foo'], alive_test=AliveTest.ICMP_PING ) self.connection.send.has_been_called_with( '' 'foo' 'foo' 'ICMP Ping' '' ) def test_create_target_invalid_alive_tests(self): with self.assertRaises(InvalidArgumentType): self.gmp.create_target('foo', hosts=['foo'], alive_test='foo') def test_create_target_with_allow_simultaneous_ips(self): self.gmp.create_target( 'foo', hosts=['foo'], allow_simultaneous_ips=True ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '1' '' ) self.gmp.create_target( 'foo', hosts=['foo'], allow_simultaneous_ips=False ) self.connection.send.has_been_called_with( '' 'foo' 'foo' '0' '' ) def test_create_target_with_reverse_lookup_only(self): self.gmp.create_target('foo', hosts=['foo'], reverse_lookup_only=True) self.connection.send.has_been_called_with( '' 'foo' 'foo' '1' '' ) self.gmp.create_target('foo', hosts=['foo'], reverse_lookup_only=False) self.connection.send.has_been_called_with( '' 'foo' 'foo' '0' '' ) def test_create_target_with_reverse_lookup_unify(self): self.gmp.create_target('foo', hosts=['foo'], reverse_lookup_unify=True) self.connection.send.has_been_called_with( '' 'foo' 'foo' '1' '' ) self.gmp.create_target('foo', hosts=['foo'], reverse_lookup_unify=False) self.connection.send.has_been_called_with( '' 'foo' 'foo' '0' '' ) def test_create_target_with_port_range(self): self.gmp.create_target('foo', hosts=['foo'], port_range='bar') self.connection.send.has_been_called_with( '' 'foo' 'foo' 'bar' '' ) def test_create_target_with_port_list_id(self): self.gmp.create_target('foo', hosts=['foo'], port_list_id='pl1') self.connection.send.has_been_called_with( '' 'foo' 'foo' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv214/entities/targets/test_modify_target.py000066400000000000000000000171461413122500400301150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument, InvalidArgumentType from gvm.protocols.gmpv214.entities.targets import AliveTest class GmpModifyTargetTestMixin: def test_modify_target(self): self.gmp.modify_target(target_id='t1') self.connection.send.has_been_called_with( '' ) def test_modify_target_missing_target_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_target(target_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_target(target_id='') def test_modify_target_with_comment(self): self.gmp.modify_target(target_id='t1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_target_with_hosts(self): self.gmp.modify_target(target_id='t1', hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' '' ) self.gmp.modify_target(target_id='t1', hosts=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' '' ) def test_modify_target_with_hosts_and_exclude_hosts(self): self.gmp.modify_target( target_id='t1', hosts=['foo', 'bar'], exclude_hosts=['foo'] ) self.connection.send.has_been_called_with( '' 'foo,bar' 'foo' '' ) def test_modify_target_with_name(self): self.gmp.modify_target(target_id='t1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_target_with_exclude_hosts(self): self.gmp.modify_target(target_id='t1', exclude_hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_target(target_id='t1', exclude_hosts=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) def test_modify_target_with_ssh_credential(self): self.gmp.modify_target(target_id='t1', ssh_credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_target_with_ssh_credential_port(self): self.gmp.modify_target( target_id='t1', ssh_credential_id='c1', ssh_credential_port=123 ) self.connection.send.has_been_called_with( '' '' '123' '' '' ) def test_modify_target_with_smb_credential_id(self): self.gmp.modify_target(target_id='t1', smb_credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_target_with_esxi_credential_id(self): self.gmp.modify_target(target_id='t1', esxi_credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_target_with_snmp_credential_id(self): self.gmp.modify_target(target_id='t1', snmp_credential_id='c1') self.connection.send.has_been_called_with( '' '' '' ) def test_modify_target_with_alive_tests(self): self.gmp.modify_target(target_id='t1', alive_test=AliveTest.ICMP_PING) self.connection.send.has_been_called_with( '' 'ICMP Ping' '' ) def test_modify_target_invalid_alive_tests(self): with self.assertRaises(InvalidArgumentType): self.gmp.modify_target(target_id='t1', alive_test='foo') def test_modify_target_with_allow_simultaneous_ips(self): self.gmp.modify_target(target_id='t1', allow_simultaneous_ips=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_target(target_id='t1', allow_simultaneous_ips=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_target_with_reverse_lookup_only(self): self.gmp.modify_target(target_id='t1', reverse_lookup_only=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_target(target_id='t1', reverse_lookup_only=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_target_with_reverse_lookup_unify(self): self.gmp.modify_target(target_id='t1', reverse_lookup_unify=True) self.connection.send.has_been_called_with( '' '1' '' ) self.gmp.modify_target(target_id='t1', reverse_lookup_unify=False) self.connection.send.has_been_called_with( '' '0' '' ) def test_modify_target_with_port_list_id(self): self.gmp.modify_target(target_id='t1', port_list_id='pl1') self.connection.send.has_been_called_with( '' '' '' ) python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_alerts.py000066400000000000000000000033151413122500400250720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.alerts import ( GmpCloneAlertTestMixin, GmpCreateAlertTestMixin, GmpDeleteAlertTestMixin, GmpGetAlertsTestMixin, GmpGetAlertTestMixin, GmpModifyAlertTestMixin, GmpTestAlertTestMixin, GmpTriggerAlertTestMixin, ) class Gmpv214CloneAlertTestCase(GmpCloneAlertTestMixin, Gmpv214TestCase): pass class Gmpv214CreateAlertTestCase(GmpCreateAlertTestMixin, Gmpv214TestCase): pass class Gmpv214DeleteAlertTestCase(GmpDeleteAlertTestMixin, Gmpv214TestCase): pass class Gmpv214GetAlertTestCase(GmpGetAlertTestMixin, Gmpv214TestCase): pass class Gmpv214GetAlertsTestCase(GmpGetAlertsTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyAlertTestCase(GmpModifyAlertTestMixin, Gmpv214TestCase): pass class Gmpv214TestAlertTestCase(GmpTestAlertTestMixin, Gmpv214TestCase): pass class Gmpv214TriggerAlertTestCase(GmpTriggerAlertTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_audits.py000066400000000000000000000034731413122500400250760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.audits import ( GmpCloneAuditTestMixin, GmpCreateAuditTestMixin, GmpDeleteAuditTestMixin, GmpGetAuditsTestMixin, GmpGetAuditTestMixin, GmpModifyAuditTestMixin, GmpResumeAuditTestMixin, GmpStartAuditTestMixin, GmpStopAuditTestMixin, ) class Gmpv214CloneAuditTestCase(GmpCloneAuditTestMixin, Gmpv214TestCase): pass class Gmpv214CreateAuditTestCase(GmpCreateAuditTestMixin, Gmpv214TestCase): pass class Gmpv214DeleteAuditTestCase(GmpDeleteAuditTestMixin, Gmpv214TestCase): pass class Gmpv214GetAuditTestCase(GmpGetAuditTestMixin, Gmpv214TestCase): pass class Gmpv214GetAuditsTestCase(GmpGetAuditsTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyAuditTestCase(GmpModifyAuditTestMixin, Gmpv214TestCase): pass class Gmpv214ResumeAuditTestCase(GmpResumeAuditTestMixin, Gmpv214TestCase): pass class Gmpv214StartAuditTestCase(GmpStartAuditTestMixin, Gmpv214TestCase): pass class Gmpv214StopAuditTestCase(GmpStopAuditTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_credentials.py000066400000000000000000000031451413122500400260760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.credentials import ( GmpCloneCredentialTestMixin, GmpCreateCredentialTestMixin, GmpDeleteCredentialTestMixin, GmpGetCredentialsTestMixin, GmpGetCredentialTestMixin, GmpModifyCredentialTestMixin, ) class Gmpv214CloneCredentialTestCase( GmpCloneCredentialTestMixin, Gmpv214TestCase ): pass class Gmpv214CreateCredentialTestCase( GmpCreateCredentialTestMixin, Gmpv214TestCase ): pass class Gmpv214DeleteCredentialTestCase( GmpDeleteCredentialTestMixin, Gmpv214TestCase ): pass class Gmpv214GetCredentialTestCase(GmpGetCredentialTestMixin, Gmpv214TestCase): pass class Gmpv214GetCredentialsTestCase( GmpGetCredentialsTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyCredentialTestCase( GmpModifyCredentialTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_filters.py000066400000000000000000000027731413122500400252570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.filters import ( GmpCloneFilterTestMixin, GmpCreateFilterTestMixin, GmpDeleteFilterTestMixin, GmpGetFilterTestMixin, GmpGetFiltersTestMixin, GmpModifyFilterTestMixin, ) class Gmpv214DeleteFilterTestCase(GmpDeleteFilterTestMixin, Gmpv214TestCase): pass class Gmpv214GetFilterTestCase(GmpGetFilterTestMixin, Gmpv214TestCase): pass class Gmpv214GetFiltersTestCase(GmpGetFiltersTestMixin, Gmpv214TestCase): pass class Gmpv214CloneFilterTestCase(GmpCloneFilterTestMixin, Gmpv214TestCase): pass class Gmpv214CreateFilterTestCase(GmpCreateFilterTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyFilterTestCase(GmpModifyFilterTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_groups.py000066400000000000000000000027501413122500400251210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.groups import ( GmpCloneGroupTestMixin, GmpCreateGroupTestMixin, GmpDeleteGroupTestMixin, GmpGetGroupTestMixin, GmpGetGroupsTestMixin, GmpModifyGroupTestMixin, ) class Gmpv214DeleteGroupTestCase(GmpDeleteGroupTestMixin, Gmpv214TestCase): pass class Gmpv214GetGroupTestCase(GmpGetGroupTestMixin, Gmpv214TestCase): pass class Gmpv214GetGroupsTestCase(GmpGetGroupsTestMixin, Gmpv214TestCase): pass class Gmpv214CloneGroupTestCase(GmpCloneGroupTestMixin, Gmpv214TestCase): pass class Gmpv214CreateGroupTestCase(GmpCreateGroupTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyGroupTestCase(GmpModifyGroupTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_hosts.py000066400000000000000000000025471413122500400247460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.hosts import ( GmpCreateHostTestMixin, GmpDeleteHostTestMixin, GmpGetHostsTestMixin, GmpGetHostTestMixin, GmpModifyHostTestMixin, ) class Gmpv214CreateHostTestCase(GmpCreateHostTestMixin, Gmpv214TestCase): pass class Gmpv214DeleteHostTestCase(GmpDeleteHostTestMixin, Gmpv214TestCase): pass class Gmpv214GetHostTestCase(GmpGetHostTestMixin, Gmpv214TestCase): pass class Gmpv214GetHostsTestCase(GmpGetHostsTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyHostTestCase(GmpModifyHostTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_notes.py000066400000000000000000000027541413122500400247360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.notes import ( GmpCloneNoteTestMixin, GmpDeleteNoteTestMixin, GmpGetNoteTestMixin, GmpGetNotesTestMixin, ) from .notes import ( GmpCreateNoteTestMixin, GmpModifyNoteTestMixin, ) class Gmpv214DeleteNoteTestCase(GmpDeleteNoteTestMixin, Gmpv214TestCase): pass class Gmpv214GetNoteTestCase(GmpGetNoteTestMixin, Gmpv214TestCase): pass class Gmpv214GetNotesTestCase(GmpGetNotesTestMixin, Gmpv214TestCase): pass class Gmpv214CloneNoteTestCase(GmpCloneNoteTestMixin, Gmpv214TestCase): pass class Gmpv214CreateNoteTestCase(GmpCreateNoteTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyNoteTestCase(GmpModifyNoteTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_operating_systems.py000066400000000000000000000026361413122500400273640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.operating_systems import ( GmpDeleteOperatingSystemTestMixin, GmpGetOperatingSystemsTestMixin, GmpGetOperatingSystemTestMixin, GmpModifyOperatingSystemTestMixin, ) class Gmpv214DeleteOperatingSystemTestCase( GmpDeleteOperatingSystemTestMixin, Gmpv214TestCase ): pass class Gmpv214GetOperatingSystemTestCase( GmpGetOperatingSystemTestMixin, Gmpv214TestCase ): pass class Gmpv214GetOperatingSystemsTestCase( GmpGetOperatingSystemsTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyOperatingSystemTestCase( GmpModifyOperatingSystemTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_overrides.py000066400000000000000000000031161413122500400256010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.overrides import ( GmpCloneOverrideTestMixin, GmpDeleteOverrideTestMixin, GmpGetOverridesTestMixin, GmpGetOverrideTestMixin, ) from .overrides import ( GmpCreateOverrideTestMixin, GmpModifyOverrideTestMixin, ) class Gmpv214CloneOverrideTestCase(GmpCloneOverrideTestMixin, Gmpv214TestCase): pass class Gmpv214CreateOverrideTestCase( GmpCreateOverrideTestMixin, Gmpv214TestCase ): pass class Gmpv214DeleteOverrideTestCase( GmpDeleteOverrideTestMixin, Gmpv214TestCase ): pass class Gmpv214GetOverrideTestCase(GmpGetOverrideTestMixin, Gmpv214TestCase): pass class Gmpv214GetOverridesTestCase(GmpGetOverridesTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyOverrideTestCase( GmpModifyOverrideTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_permissions.py000066400000000000000000000031451413122500400261540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.permissions import ( GmpClonePermissionTestMixin, GmpCreatePermissionTestMixin, GmpDeletePermissionTestMixin, GmpGetPermissionTestMixin, GmpGetPermissionsTestMixin, GmpModifyPermissionTestMixin, ) class Gmpv214DeletePermissionTestCase( GmpDeletePermissionTestMixin, Gmpv214TestCase ): pass class Gmpv214GetPermissionTestCase(GmpGetPermissionTestMixin, Gmpv214TestCase): pass class Gmpv214GetPermissionsTestCase( GmpGetPermissionsTestMixin, Gmpv214TestCase ): pass class Gmpv214ClonePermissionTestCase( GmpClonePermissionTestMixin, Gmpv214TestCase ): pass class Gmpv214CreatePermissionTestCase( GmpCreatePermissionTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyPermissionTestCase( GmpModifyPermissionTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_policies.py000066400000000000000000000047571413122500400254220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.policies import ( GmpClonePolicyTestMixin, GmpCreatePolicyTestMixin, GmpDeletePolicyTestMixin, GmpGetPolicyTestMixin, GmpGetPoliciesTestMixin, GmpImportPolicyTestMixin, GmpModifyPolicySetCommentTestMixin, GmpModifyPolicySetFamilySelectionTestMixin, GmpModifyPolicySetNameTestMixin, GmpModifyPolicySetNvtPreferenceTestMixin, GmpModifyPolicySetNvtSelectionTestMixin, GmpModifyPolicySetScannerPreferenceTestMixin, ) class Gmpv214ClonePolicyTestCase(GmpClonePolicyTestMixin, Gmpv214TestCase): pass class Gmpv214CreatePolicyTestCase(GmpCreatePolicyTestMixin, Gmpv214TestCase): pass class Gmpv214DeletePolicyTestCase(GmpDeletePolicyTestMixin, Gmpv214TestCase): pass class Gmpv214GetPolicyTestCase(GmpGetPolicyTestMixin, Gmpv214TestCase): pass class Gmpv214GetPoliciesTestCase(GmpGetPoliciesTestMixin, Gmpv214TestCase): pass class Gmpv214ImportPolicyTestCase(GmpImportPolicyTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyPolicySetCommentTestCase( GmpModifyPolicySetCommentTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyPolicySetFamilySelectionTestCase( GmpModifyPolicySetFamilySelectionTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyPolicySetNvtSelectionTestCase( GmpModifyPolicySetNvtSelectionTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyPolicySetNameTestCase( GmpModifyPolicySetNameTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyPolicySetNvtPreferenceTestCase( GmpModifyPolicySetNvtPreferenceTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyPolicySetScannerPreferenceTestCase( GmpModifyPolicySetScannerPreferenceTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_port_lists.py000066400000000000000000000035041413122500400260020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.port_lists import ( GmpClonePortListTestMixin, GmpCreatePortListTestMixin, GmpCreatePortRangeTestMixin, GmpDeletePortListTestMixin, GmpDeletePortRangeTestMixin, GmpGetPortListsTestMixin, GmpGetPortListTestMixin, GmpModifyPortListTestMixin, ) class Gmpv214ClonePortListTestCase(GmpClonePortListTestMixin, Gmpv214TestCase): pass class Gmpv214CreatePortListTestCase( GmpCreatePortListTestMixin, Gmpv214TestCase ): pass class Gmpv214CreatePortRangeListTestCase( GmpCreatePortRangeTestMixin, Gmpv214TestCase ): pass class Gmpv214DeletePortListTestCase( GmpDeletePortListTestMixin, Gmpv214TestCase ): pass class Gmpv214DeletePortRangeTestCase( GmpDeletePortRangeTestMixin, Gmpv214TestCase ): pass class Gmpv214GetPortListTestCase(GmpGetPortListTestMixin, Gmpv214TestCase): pass class Gmpv214GetPortListsTestCase(GmpGetPortListsTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyPortListTestCase( GmpModifyPortListTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_report_formats.py000066400000000000000000000034411413122500400266460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.report_formats import ( GmpCloneReportFormatTestMixin, GmpImportReportFormatTestMixin, GmpDeleteReportFormatTestMixin, GmpGetReportFormatTestMixin, GmpGetReportFormatsTestMixin, GmpModifyReportFormatTestMixin, GmpVerifyReportFormatTestMixin, ) class Gmpv214DeleteReportFormatTestCase( GmpDeleteReportFormatTestMixin, Gmpv214TestCase ): pass class Gmpv214GetReportFormatTestCase( GmpGetReportFormatTestMixin, Gmpv214TestCase ): pass class Gmpv214GetReportFormatsTestCase( GmpGetReportFormatsTestMixin, Gmpv214TestCase ): pass class Gmpv214CloneReportFormatTestCase( GmpCloneReportFormatTestMixin, Gmpv214TestCase ): pass class Gmpv214ImportReportFormatTestCase( GmpImportReportFormatTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyReportFormatTestCase( GmpModifyReportFormatTestMixin, Gmpv214TestCase ): pass class Gmpv214VerifyReportFormatTestCase( GmpVerifyReportFormatTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_reports.py000066400000000000000000000024201413122500400252720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.reports import ( GmpDeleteReportTestMixin, GmpGetReportsTestMixin, GmpGetReportTestMixin, GmpImportReportTestMixin, ) class Gmpv214DeleteReportTestCase(GmpDeleteReportTestMixin, Gmpv214TestCase): pass class Gmpv214GetReportTestCase(GmpGetReportTestMixin, Gmpv214TestCase): pass class Gmpv214GetReportsTestCase(GmpGetReportsTestMixin, Gmpv214TestCase): pass class Gmpv214ImportReportTestCase(GmpImportReportTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_results.py000066400000000000000000000020421413122500400252750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.results import ( GmpGetResultsTestMixin, GmpGetResultTestMixin, ) class Gmpv214GetResultTestCase(GmpGetResultTestMixin, Gmpv214TestCase): pass class Gmpv214GetResultsTestCase(GmpGetResultsTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_roles.py000066400000000000000000000027251413122500400247300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.roles import ( GmpCloneRoleTestMixin, GmpCreateRoleTestMixin, GmpDeleteRoleTestMixin, GmpGetRoleTestMixin, GmpGetRolesTestMixin, GmpModifyRoleTestMixin, ) class Gmpv214DeleteRoleTestCase(GmpDeleteRoleTestMixin, Gmpv214TestCase): pass class Gmpv214GetRoleTestCase(GmpGetRoleTestMixin, Gmpv214TestCase): pass class Gmpv214GetRolesTestCase(GmpGetRolesTestMixin, Gmpv214TestCase): pass class Gmpv214CloneRoleTestCase(GmpCloneRoleTestMixin, Gmpv214TestCase): pass class Gmpv214CreateRoleTestCase(GmpCreateRoleTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyRoleTestCase(GmpModifyRoleTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_scan_configs.py000066400000000000000000000061351413122500400262370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.scan_configs import ( GmpCloneScanConfigTestMixin, GmpCreateScanConfigTestMixin, GmpCreateScanConfigFromOSPScannerTestMixin, GmpDeleteScanConfigTestMixin, GmpGetScanConfigTestMixin, GmpGetScanConfigsTestMixin, GmpImportScanConfigTestMixin, GmpModifyScanConfigSetCommentTestMixin, GmpModifyScanConfigSetFamilySelectionTestMixin, GmpModifyScanConfigSetNameTestMixin, GmpModifyScanConfigSetNvtPreferenceTestMixin, GmpModifyScanConfigSetNvtSelectionTestMixin, GmpModifyScanConfigSetScannerPreferenceTestMixin, GmpModifyScanConfigTestMixin, GmpSyncScanConfigTestMixin, ) class Gmpv214CloneScanConfigTestCase( GmpCloneScanConfigTestMixin, Gmpv214TestCase ): pass class Gmpv214CreateScanConfigTestCase( GmpCreateScanConfigTestMixin, Gmpv214TestCase ): pass class Gmpv214CreateScanConfigFromOSPScannerTestCase( GmpCreateScanConfigFromOSPScannerTestMixin, Gmpv214TestCase ): pass class Gmpv214DeleteScanConfigTestCase( GmpDeleteScanConfigTestMixin, Gmpv214TestCase ): pass class Gmpv214GetScanConfigTestCase(GmpGetScanConfigTestMixin, Gmpv214TestCase): pass class Gmpv214GetScanConfigsTestCase( GmpGetScanConfigsTestMixin, Gmpv214TestCase ): pass class Gmpv214ImportScanConfigTestCase( GmpImportScanConfigTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyScanConfigSetCommentTestCase( GmpModifyScanConfigSetCommentTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyScanConfigSetFamilySelectionTestCase( GmpModifyScanConfigSetFamilySelectionTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyScanConfigSetNvtSelectionTestCase( GmpModifyScanConfigSetNvtSelectionTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyScanConfigSetNameTestCase( GmpModifyScanConfigSetNameTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyScanConfigSetNvtPreferenceTestCase( GmpModifyScanConfigSetNvtPreferenceTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyScanConfigSetScannerPreferenceTestCase( GmpModifyScanConfigSetScannerPreferenceTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyScanConfigTestCase( GmpModifyScanConfigTestMixin, Gmpv214TestCase ): pass class Gmpv214SyncScanConfigTestCase( GmpSyncScanConfigTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_scanners.py000066400000000000000000000030501413122500400254100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.scanners import ( GmpCloneScannerTestMixin, GmpDeleteScannerTestMixin, GmpGetScannerTestMixin, GmpGetScannersTestMixin, ) from .scanners import ( GmpCreateScannerTestMixin, GmpModifyScannerTestMixin, ) class Gmpv214DeleteScannerTestCase(GmpDeleteScannerTestMixin, Gmpv214TestCase): pass class Gmpv214GetScannerTestCase(GmpGetScannerTestMixin, Gmpv214TestCase): pass class Gmpv214GetScannersTestCase(GmpGetScannersTestMixin, Gmpv214TestCase): pass class Gmpv214CloneScannerTestCase(GmpCloneScannerTestMixin, Gmpv214TestCase): pass class Gmpv214CreateScannerTestCase(GmpCreateScannerTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyScannerTestCase(GmpModifyScannerTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_schedules.py000066400000000000000000000030631413122500400255570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.schedules import ( GmpCloneScheduleTestMixin, GmpCreateScheduleTestMixin, GmpDeleteScheduleTestMixin, GmpGetScheduleTestMixin, GmpGetSchedulesTestMixin, GmpModifyScheduleTestMixin, ) class Gmpv214DeleteScheduleTestCase( GmpDeleteScheduleTestMixin, Gmpv214TestCase ): pass class Gmpv214GetScheduleTestCase(GmpGetScheduleTestMixin, Gmpv214TestCase): pass class Gmpv214GetSchedulesTestCase(GmpGetSchedulesTestMixin, Gmpv214TestCase): pass class Gmpv214CloneScheduleTestCase(GmpCloneScheduleTestMixin, Gmpv214TestCase): pass class Gmpv214CreateScheduleTestCase( GmpCreateScheduleTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyScheduleTestCase( GmpModifyScheduleTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_secinfo.py000066400000000000000000000054111413122500400252250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.secinfo import ( GmpGetCertBundTestMixin, GmpGetCertBundListTestMixin, GmpGetCpeTestMixin, GmpGetCpeListTestMixin, GmpGetCveTestMixin, GmpGetCveListTestMixin, GmpGetDfnCertTestMixin, GmpGetDfnCertListTestMixin, GmpGetInfoListTestMixin, GmpGetInfoTestMixin, GmpGetNvtFamiliesTestMixin, GmpGetNvtTestMixin, GmpGetNvtListTestMixin, GmpGetOvalDefTestMixin, GmpGetOvalDefListTestMixin, GmpGetScanConfigNvtsTestMixin, GmpGetScanConfigNvtTestMixin, ) class Gmpv214GetCertBundTestCase(GmpGetCertBundTestMixin, Gmpv214TestCase): pass class Gmpv214GetCpeTestCase(GmpGetCpeTestMixin, Gmpv214TestCase): pass class Gmpv214GetCveTestCase(GmpGetCveTestMixin, Gmpv214TestCase): pass class Gmpv214GetDfnCertCase(GmpGetDfnCertTestMixin, Gmpv214TestCase): pass class Gmpv214GetOvalDefCase(GmpGetOvalDefTestMixin, Gmpv214TestCase): pass class Gmpv214GetInfoListTestCase(GmpGetInfoListTestMixin, Gmpv214TestCase): pass class Gmpv214GetInfoTestCase(GmpGetInfoTestMixin, Gmpv214TestCase): pass class Gmpv214GetNvtTestCase(GmpGetNvtTestMixin, Gmpv214TestCase): pass class Gmpv214GetScanConfigNvtTestCase( GmpGetScanConfigNvtTestMixin, Gmpv214TestCase ): pass class Gmpv214GetNvtFamiliesTestCase( GmpGetNvtFamiliesTestMixin, Gmpv214TestCase ): pass class Gmpv214GetScanConfigNvtsTestCase( GmpGetScanConfigNvtsTestMixin, Gmpv214TestCase ): pass class Gmpv214GetCertBundListTestCase( GmpGetCertBundListTestMixin, Gmpv214TestCase ): pass class Gmpv214GetCpeListTestCase(GmpGetCpeListTestMixin, Gmpv214TestCase): pass class Gmpv214GetCveListTestCase(GmpGetCveListTestMixin, Gmpv214TestCase): pass class Gmpv214GetDfnCertListCase(GmpGetDfnCertListTestMixin, Gmpv214TestCase): pass class Gmpv214GetNvtListTestCase(GmpGetNvtListTestMixin, Gmpv214TestCase): pass class Gmpv214GetOvalDefListTestCase( GmpGetOvalDefListTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_tags.py000066400000000000000000000027021413122500400245350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.tags import ( GmpCloneTagTestMixin, GmpCreateTagTestMixin, GmpDeleteTagTestMixin, GmpGetTagTestMixin, GmpGetTagsTestMixin, GmpModifyTagTestMixin, ) class Gmpv214DeleteTagTestCase(GmpDeleteTagTestMixin, Gmpv214TestCase): pass class Gmpv214GetTagTestCase(GmpGetTagTestMixin, Gmpv214TestCase): pass class Gmpv214GetTagsTestCase(GmpGetTagsTestMixin, Gmpv214TestCase): pass class Gmpv214CloneTagTestCase(GmpCloneTagTestMixin, Gmpv214TestCase): pass class Gmpv214CreateTagTestCase(GmpCreateTagTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyTagTestCase(GmpModifyTagTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_targets.py000066400000000000000000000030071413122500400252470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from .targets import GmpCreateTargetTestMixin, GmpModifyTargetTestMixin from ...gmpv208.entities.targets import ( GmpCloneTargetTestMixin, GmpDeleteTargetTestMixin, GmpGetTargetsTestMixin, GmpGetTargetTestMixin, ) class Gmpv214CloneTargetTestCase(GmpCloneTargetTestMixin, Gmpv214TestCase): pass class Gmpv214CreateTargetTestCase(GmpCreateTargetTestMixin, Gmpv214TestCase): pass class Gmpv214DeleteTargetTestCase(GmpDeleteTargetTestMixin, Gmpv214TestCase): pass class Gmpv214GetTargetTestCase(GmpGetTargetTestMixin, Gmpv214TestCase): pass class Gmpv214GetTargetsTestCase(GmpGetTargetsTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyTargetTestCase(GmpModifyTargetTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_tasks.py000066400000000000000000000040341413122500400247240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.tasks import ( GmpCloneTaskTestMixin, GmpCreateContainerTaskTestMixin, GmpCreateTaskTestMixin, GmpDeleteTaskTestMixin, GmpGetTasksTestMixin, GmpGetTaskTestMixin, GmpModifyTaskTestMixin, GmpMoveTaskTestMixin, GmpResumeTaskTestMixin, GmpStartTaskTestMixin, GmpStopTaskTestMixin, ) class Gmpv214CloneTaskTestCase(GmpCloneTaskTestMixin, Gmpv214TestCase): pass class Gmpv214CreateContainerTaskTestCase( GmpCreateContainerTaskTestMixin, Gmpv214TestCase ): pass class Gmpv214CreateTaskTestCase(GmpCreateTaskTestMixin, Gmpv214TestCase): pass class Gmpv214DeleteTaskTestCase(GmpDeleteTaskTestMixin, Gmpv214TestCase): pass class Gmpv214GetTaskTestCase(GmpGetTaskTestMixin, Gmpv214TestCase): pass class Gmpv214GetTasksTestCase(GmpGetTasksTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyTaskTestCase(GmpModifyTaskTestMixin, Gmpv214TestCase): pass class Gmpv214MoveTaskTestCase(GmpMoveTaskTestMixin, Gmpv214TestCase): pass class Gmpv214ResumeTaskTestCase(GmpResumeTaskTestMixin, Gmpv214TestCase): pass class Gmpv214StartTaskTestCase(GmpStartTaskTestMixin, Gmpv214TestCase): pass class Gmpv214StopTaskTestCase(GmpStopTaskTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_tickets.py000066400000000000000000000027731413122500400252550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.tickets import ( GmpCloneTicketTestMixin, GmpCreateTicketTestMixin, GmpDeleteTicketTestMixin, GmpGetTicketTestMixin, GmpGetTicketsTestMixin, GmpModifyTicketTestMixin, ) class Gmpv214DeleteTicketTestCase(GmpDeleteTicketTestMixin, Gmpv214TestCase): pass class Gmpv214GetTicketTestCase(GmpGetTicketTestMixin, Gmpv214TestCase): pass class Gmpv214GetTicketsTestCase(GmpGetTicketsTestMixin, Gmpv214TestCase): pass class Gmpv214CloneTicketTestCase(GmpCloneTicketTestMixin, Gmpv214TestCase): pass class Gmpv214CreateTicketTestCase(GmpCreateTicketTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyTicketTestCase(GmpModifyTicketTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_tls_certificates.py000066400000000000000000000032701413122500400271270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.tls_certificates import ( GmpCloneTLSCertificateTestMixin, GmpCreateTLSCertificateTestMixin, GmpDeleteTLSCertificateTestMixin, GmpGetTLSCertificatesTestMixin, GmpGetTLSCertificateTestMixin, GmpModifyTLSCertificateTestMixin, ) class Gmpv214CloneTLSCertificateTestCase( GmpCloneTLSCertificateTestMixin, Gmpv214TestCase ): pass class Gmpv214CreateTLSCertificateTestCase( GmpCreateTLSCertificateTestMixin, Gmpv214TestCase ): pass class Gmpv214DeleteTLSCertificateTestCase( GmpDeleteTLSCertificateTestMixin, Gmpv214TestCase ): pass class Gmpv214GetTLSCertificateTestCase( GmpGetTLSCertificateTestMixin, Gmpv214TestCase ): pass class Gmpv214GetTLSCertificatesTestCase( GmpGetTLSCertificatesTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyTLSCertificateTestCase( GmpModifyTLSCertificateTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_users.py000066400000000000000000000027431413122500400247450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from .users import GmpModifyUserTestMixin from ...gmpv208.entities.users import ( GmpCreateUserTestMixin, GmpCloneUserTestMixin, GmpDeleteUserTestMixin, GmpGetUsersTestMixin, GmpGetUserTestMixin, ) class Gmpv214CloneUserTestCase(GmpCloneUserTestMixin, Gmpv214TestCase): pass class Gmpv214CreateUserTestCase(GmpCreateUserTestMixin, Gmpv214TestCase): pass class Gmpv214DeleteUserTestCase(GmpDeleteUserTestMixin, Gmpv214TestCase): pass class Gmpv214GetUserTestCase(GmpGetUserTestMixin, Gmpv214TestCase): pass class Gmpv214GetUsersTestCase(GmpGetUsersTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyUserTestCase(GmpModifyUserTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/test_vulnerabilities.py000066400000000000000000000021431413122500400267770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.entities.vulnerabilities import ( GmpGetVulnerabilitiesTestMixin, GmpGetVulnerabilityTestMixin, ) class Gmpv214GetVulnerabilityTestCase( GmpGetVulnerabilityTestMixin, Gmpv214TestCase ): pass class Gmpv214GetVulnerabilitiesTestCase( GmpGetVulnerabilitiesTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/entities/users/000077500000000000000000000000001413122500400233265ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/entities/users/__init__.py000066400000000000000000000014451413122500400254430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_modify_user import GmpModifyUserTestMixin python-gvm-21.10.0/tests/protocols/gmpv214/entities/users/test_modify_user.py000066400000000000000000000142411413122500400272660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from gvm.errors import RequiredArgument from gvm.protocols.gmpv214 import UserAuthType class GmpModifyUserTestMixin: def test_modify_user(self): self.gmp.modify_user(user_id='u1') self.connection.send.has_been_called_with('') def test_modify_user_missing_user_id(self): with self.assertRaises(RequiredArgument): self.gmp.modify_user(user_id=None) with self.assertRaises(RequiredArgument): self.gmp.modify_user(user_id='') def test_modify_user_with_new_name(self): self.gmp.modify_user(user_id='u1', name='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_user_with_new_comment(self): self.gmp.modify_user(user_id='u1', comment='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_user_with_role_ids(self): self.gmp.modify_user(user_id='u1', role_ids=[]) self.connection.send.has_been_called_with('') self.gmp.modify_user(user_id='u1', role_ids=['r1']) self.connection.send.has_been_called_with( '' '' '' ) self.gmp.modify_user(user_id='u1', role_ids=['r1', 'r2']) self.connection.send.has_been_called_with( '' '' '' '' ) def test_modify_user_with_group_ids(self): self.gmp.modify_user(user_id='u1', role_ids=[]) self.connection.send.has_been_called_with('') self.gmp.modify_user(user_id='u1', group_ids=['r1']) self.connection.send.has_been_called_with( '' '' '' ) self.gmp.modify_user(user_id='u1', group_ids=['r1', 'r2']) self.connection.send.has_been_called_with( '' '' '' '' '' '' ) def test_modify_user_with_password(self): self.gmp.modify_user(user_id='u1', password='foo') self.connection.send.has_been_called_with( '' 'foo' '' ) def test_modify_user_with_auth_source(self): self.gmp.modify_user( user_id='u1', auth_source=UserAuthType.LDAP_CONNECT ) self.connection.send.has_been_called_with( '' 'ldap_connect' '' ) def test_modify_user_with_hosts(self): self.gmp.modify_user(user_id='u1', hosts=[]) self.connection.send.has_been_called_with('') self.gmp.modify_user(user_id='u1', hosts=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_user(user_id='u1', hosts=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) self.gmp.modify_user( user_id='u1', hosts=['foo', 'bar'], hosts_allow=False ) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) self.gmp.modify_user( user_id='u1', hosts=['foo', 'bar'], hosts_allow=True ) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) def test_modify_user_with_ifaces(self): self.gmp.modify_user(user_id='u1', ifaces=[]) self.connection.send.has_been_called_with('') self.gmp.modify_user(user_id='u1', ifaces=['foo']) self.connection.send.has_been_called_with( '' 'foo' '' ) self.gmp.modify_user(user_id='u1', ifaces=['foo', 'bar']) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) self.gmp.modify_user( user_id='u1', ifaces=['foo', 'bar'], ifaces_allow=False ) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) self.gmp.modify_user( user_id='u1', ifaces=['foo', 'bar'], ifaces_allow=True ) self.connection.send.has_been_called_with( '' 'foo,bar' '' ) python-gvm-21.10.0/tests/protocols/gmpv214/enums/000077500000000000000000000000001413122500400214705ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/enums/__init__.py000066400000000000000000000013641413122500400236050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_aggregate_statistic.py000066400000000000000000000046771413122500400271340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv208 import AggregateStatistic class GetAggregateStatisticFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AggregateStatistic.from_string('foo') def test_none_or_empty(self): ct = AggregateStatistic.from_string(None) self.assertIsNone(ct) ct = AggregateStatistic.from_string('') self.assertIsNone(ct) def test_count(self): ct = AggregateStatistic.from_string('count') self.assertEqual(ct, AggregateStatistic.COUNT) def test_c_count(self): ct = AggregateStatistic.from_string('c_count') self.assertEqual(ct, AggregateStatistic.C_COUNT) def test_c_sum(self): ct = AggregateStatistic.from_string('c_sum') self.assertEqual(ct, AggregateStatistic.C_SUM) def test_max(self): ct = AggregateStatistic.from_string('max') self.assertEqual(ct, AggregateStatistic.MAX) def test_mean(self): ct = AggregateStatistic.from_string('mean') self.assertEqual(ct, AggregateStatistic.MEAN) def test_min(self): ct = AggregateStatistic.from_string('min') self.assertEqual(ct, AggregateStatistic.MIN) def test_sum(self): ct = AggregateStatistic.from_string('sum') self.assertEqual(ct, AggregateStatistic.SUM) def test_text(self): ct = AggregateStatistic.from_string('text') self.assertEqual(ct, AggregateStatistic.TEXT) def test_value(self): ct = AggregateStatistic.from_string('value') self.assertEqual(ct, AggregateStatistic.VALUE) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_alert_condition.py000066400000000000000000000042351413122500400262620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import AlertCondition class GetAlertConditionFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AlertCondition.from_string('foo') def test_none_or_empty(self): ct = AlertCondition.from_string(None) self.assertIsNone(ct) ct = AlertCondition.from_string('') self.assertIsNone(ct) def test_always(self): ct = AlertCondition.from_string('always') self.assertEqual(ct, AlertCondition.ALWAYS) def test_filter_count_at_least(self): ct = AlertCondition.from_string('filter count at least') self.assertEqual(ct, AlertCondition.FILTER_COUNT_AT_LEAST) def test_filter_count_changed(self): ct = AlertCondition.from_string('filter count changed') self.assertEqual(ct, AlertCondition.FILTER_COUNT_CHANGED) def test_severity_at_least(self): ct = AlertCondition.from_string('severity at least') self.assertEqual(ct, AlertCondition.SEVERITY_AT_LEAST) def test_severity_changed(self): ct = AlertCondition.from_string('severity changed') self.assertEqual(ct, AlertCondition.SEVERITY_CHANGED) def test_error(self): ct = AlertCondition.from_string('error') self.assertEqual(ct, AlertCondition.ERROR) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_alert_event.py000066400000000000000000000043131413122500400254120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import AlertEvent class GetAlertEventFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AlertEvent.from_string('foo') def test_none_or_empty(self): ct = AlertEvent.from_string(None) self.assertIsNone(ct) ct = AlertEvent.from_string('') self.assertIsNone(ct) def test_task_run_status_changed(self): ct = AlertEvent.from_string('Task run status changed') self.assertEqual(ct, AlertEvent.TASK_RUN_STATUS_CHANGED) def test_new_secinfo_arrived(self): ct = AlertEvent.from_string('New SecInfo arrived') self.assertEqual(ct, AlertEvent.NEW_SECINFO_ARRIVED) def test_updated_secinfo_arrived(self): ct = AlertEvent.from_string('Updated SecInfo arrived') self.assertEqual(ct, AlertEvent.UPDATED_SECINFO_ARRIVED) def test_ticket_received(self): ct = AlertEvent.from_string('ticket received') self.assertEqual(ct, AlertEvent.TICKET_RECEIVED) def test_assigned_ticket_changed(self): ct = AlertEvent.from_string('assigned ticket changed') self.assertEqual(ct, AlertEvent.ASSIGNED_TICKET_CHANGED) def test_owned_ticket_changed(self): ct = AlertEvent.from_string('owned ticket changed') self.assertEqual(ct, AlertEvent.OWNED_TICKET_CHANGED) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_alert_method.py000066400000000000000000000054561413122500400255620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import AlertMethod class GetAlertMethodFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AlertMethod.from_string('foo') def test_none_or_empty(self): ct = AlertMethod.from_string(None) self.assertIsNone(ct) ct = AlertMethod.from_string('') self.assertIsNone(ct) def test_email(self): ct = AlertMethod.from_string('email') self.assertEqual(ct, AlertMethod.EMAIL) def test_scp(self): ct = AlertMethod.from_string('scp') self.assertEqual(ct, AlertMethod.SCP) def test_send(self): ct = AlertMethod.from_string('send') self.assertEqual(ct, AlertMethod.SEND) def test_smb(self): ct = AlertMethod.from_string('smb') self.assertEqual(ct, AlertMethod.SMB) def test_snmp(self): ct = AlertMethod.from_string('snmp') self.assertEqual(ct, AlertMethod.SNMP) def test_syslog(self): ct = AlertMethod.from_string('syslog') self.assertEqual(ct, AlertMethod.SYSLOG) def test_http_get(self): ct = AlertMethod.from_string('HTTP Get') self.assertEqual(ct, AlertMethod.HTTP_GET) def test_start_task(self): ct = AlertMethod.from_string('Start Task') self.assertEqual(ct, AlertMethod.START_TASK) def test_sourcefire_connector(self): ct = AlertMethod.from_string('sourcefire Connector') self.assertEqual(ct, AlertMethod.SOURCEFIRE_CONNECTOR) def test_verinice_connector(self): ct = AlertMethod.from_string('verinice Connector') self.assertEqual(ct, AlertMethod.VERINICE_CONNECTOR) def test_tippingpoint_sms(self): ct = AlertMethod.from_string('Tippingpoint SMS') self.assertEqual(ct, AlertMethod.TIPPINGPOINT_SMS) def test_alemba_vfire(self): ct = AlertMethod.from_string('Alemba vFire') self.assertEqual(ct, AlertMethod.ALEMBA_VFIRE) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_alive_test.py000066400000000000000000000054571413122500400252530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import AliveTest class GetAliveTestFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): AliveTest.from_string('foo') def test_none_or_empty(self): ct = AliveTest.from_string(None) self.assertIsNone(ct) ct = AliveTest.from_string('') self.assertIsNone(ct) def test_scan_config_default(self): ct = AliveTest.from_string('Scan Config Default') self.assertEqual(ct, AliveTest.SCAN_CONFIG_DEFAULT) def test_icmp_ping(self): ct = AliveTest.from_string('ICMP Ping') self.assertEqual(ct, AliveTest.ICMP_PING) def test_tcp_ack_service_ping(self): ct = AliveTest.from_string('TCP-ACK Service Ping') self.assertEqual(ct, AliveTest.TCP_ACK_SERVICE_PING) def test_tcp_sync_service_ping(self): ct = AliveTest.from_string('TCP-SYN Service Ping') self.assertEqual(ct, AliveTest.TCP_SYN_SERVICE_PING) def test_arp_ping(self): ct = AliveTest.from_string('ARP Ping') self.assertEqual(ct, AliveTest.ARP_PING) def test_icmp_and_tcp_ack_service_ping(self): ct = AliveTest.from_string('ICMP & TCP-ACK Service Ping') self.assertEqual(ct, AliveTest.ICMP_AND_TCP_ACK_SERVICE_PING) def test_icmp_and_arp_ping(self): ct = AliveTest.from_string('ICMP & ARP Ping') self.assertEqual(ct, AliveTest.ICMP_AND_ARP_PING) def test_tcp_ack_service_and_arp_ping(self): ct = AliveTest.from_string('TCP-ACK Service & ARP Ping') self.assertEqual(ct, AliveTest.TCP_ACK_SERVICE_AND_ARP_PING) def test_icmp_tcp_ack_service_and_arp_ping(self): ct = AliveTest.from_string('ICMP, TCP-ACK Service & ARP Ping') self.assertEqual(ct, AliveTest.ICMP_TCP_ACK_SERVICE_AND_ARP_PING) def test_consider_alive(self): ct = AliveTest.from_string('Consider Alive') self.assertEqual(ct, AliveTest.CONSIDER_ALIVE) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_credential_format.py000066400000000000000000000035761413122500400265760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import CredentialFormat class GetCredentialFromatFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): CredentialFormat.from_string('foo') def test_none_or_empty(self): ct = CredentialFormat.from_string(None) self.assertIsNone(ct) ct = CredentialFormat.from_string('') self.assertIsNone(ct) def test_key(self): ct = CredentialFormat.from_string('key') self.assertEqual(ct, CredentialFormat.KEY) def test_rpm(self): ct = CredentialFormat.from_string('rpm') self.assertEqual(ct, CredentialFormat.RPM) def test_deb(self): ct = CredentialFormat.from_string('deb') self.assertEqual(ct, CredentialFormat.DEB) def test_exe(self): ct = CredentialFormat.from_string('exe') self.assertEqual(ct, CredentialFormat.EXE) def test_pem(self): ct = CredentialFormat.from_string('pem') self.assertEqual(ct, CredentialFormat.PEM) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_credential_type.py000066400000000000000000000044341413122500400262610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import CredentialType class GetCredentialTypeFromStringTestCase(unittest.TestCase): def test_invalid_type(self): with self.assertRaises(InvalidArgument): CredentialType.from_string('foo') def test_none_or_empty_type(self): ct = CredentialType.from_string(None) self.assertIsNone(ct) ct = CredentialType.from_string('') self.assertIsNone(ct) def test_client_certificate(self): ct = CredentialType.from_string('client_certificate') self.assertEqual(ct, CredentialType.CLIENT_CERTIFICATE) def test_snmp(self): ct = CredentialType.from_string('snmp') self.assertEqual(ct, CredentialType.SNMP) def test_username_password(self): ct = CredentialType.from_string('username_password') self.assertEqual(ct, CredentialType.USERNAME_PASSWORD) def test_username_ssh_key(self): ct = CredentialType.from_string('username_ssh_key') self.assertEqual(ct, CredentialType.USERNAME_SSH_KEY) def test_smime_certificate(self): ct = CredentialType.from_string('smime_certificate') self.assertEqual(ct, CredentialType.SMIME_CERTIFICATE) def test_pgp_encryption_key(self): ct = CredentialType.from_string('pgp_encryption_key') self.assertEqual(ct, CredentialType.PGP_ENCRYPTION_KEY) def test_password_only(self): ct = CredentialType.from_string('password_only') self.assertEqual(ct, CredentialType.PASSWORD_ONLY) python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_entity_type.py000066400000000000000000000131221413122500400254550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import EntityType class GetEntityTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): EntityType.from_string('foo') def test_none_or_empty(self): ct = EntityType.from_string(None) self.assertIsNone(ct) ct = EntityType.from_string('') self.assertIsNone(ct) def test_audit(self): ct = EntityType.from_string('audit') self.assertEqual(ct, EntityType.AUDIT) def test_alert(self): ct = EntityType.from_string('alert') self.assertEqual(ct, EntityType.ALERT) def test_asset(self): ct = EntityType.from_string('asset') self.assertEqual(ct, EntityType.ASSET) def test_cert_bund_adv(self): ct = EntityType.from_string('cert_bund_adv') self.assertEqual(ct, EntityType.CERT_BUND_ADV) def test_cpe(self): ct = EntityType.from_string('cpe') self.assertEqual(ct, EntityType.CPE) def test_credential(self): ct = EntityType.from_string('credential') self.assertEqual(ct, EntityType.CREDENTIAL) def test_dfn_cert_adv(self): ct = EntityType.from_string('dfn_cert_adv') self.assertEqual(ct, EntityType.DFN_CERT_ADV) def test_filter(self): ct = EntityType.from_string('filter') self.assertEqual(ct, EntityType.FILTER) def test_group(self): ct = EntityType.from_string('group') self.assertEqual(ct, EntityType.GROUP) def test_host(self): ct = EntityType.from_string('host') self.assertEqual(ct, EntityType.HOST) def test_info(self): ct = EntityType.from_string('info') self.assertEqual(ct, EntityType.INFO) def test_note(self): ct = EntityType.from_string('note') self.assertEqual(ct, EntityType.NOTE) def test_nvt(self): ct = EntityType.from_string('nvt') self.assertEqual(ct, EntityType.NVT) def test_operating_system(self): ct = EntityType.from_string('os') self.assertEqual(ct, EntityType.OPERATING_SYSTEM) ct = EntityType.from_string('operating_system') self.assertEqual(ct, EntityType.OPERATING_SYSTEM) def test_ovaldef(self): ct = EntityType.from_string('ovaldef') self.assertEqual(ct, EntityType.OVALDEF) def test_override(self): ct = EntityType.from_string('override') self.assertEqual(ct, EntityType.OVERRIDE) def test_permission(self): ct = EntityType.from_string('permission') self.assertEqual(ct, EntityType.PERMISSION) def test_policy(self): ct = EntityType.from_string('policy') self.assertEqual(ct, EntityType.POLICY) def test_port_list(self): ct = EntityType.from_string('port_list') self.assertEqual(ct, EntityType.PORT_LIST) def test_report(self): ct = EntityType.from_string('report') self.assertEqual(ct, EntityType.REPORT) def test_report_format(self): ct = EntityType.from_string('report_format') self.assertEqual(ct, EntityType.REPORT_FORMAT) def test_result(self): ct = EntityType.from_string('result') self.assertEqual(ct, EntityType.RESULT) def test_role(self): ct = EntityType.from_string('role') self.assertEqual(ct, EntityType.ROLE) def test_scan_config(self): ct = EntityType.from_string('config') self.assertEqual(ct, EntityType.SCAN_CONFIG) ct = EntityType.from_string('scan_config') self.assertEqual(ct, EntityType.SCAN_CONFIG) def test_scanner(self): ct = EntityType.from_string('scanner') self.assertEqual(ct, EntityType.SCANNER) def test_schedule(self): ct = EntityType.from_string('schedule') self.assertEqual(ct, EntityType.SCHEDULE) def test_tag(self): ct = EntityType.from_string('tag') self.assertEqual(ct, EntityType.TAG) def test_target(self): ct = EntityType.from_string('target') self.assertEqual(ct, EntityType.TARGET) def test_task(self): ct = EntityType.from_string('task') self.assertEqual(ct, EntityType.TASK) def test_ticket(self): ct = EntityType.from_string('ticket') self.assertEqual(ct, EntityType.TICKET) def test_tls_certificate(self): ft = EntityType.from_string('tls_certificate') self.assertEqual(ft, EntityType.TLS_CERTIFICATE) def test_user(self): ct = EntityType.from_string('user') self.assertEqual(ct, EntityType.USER) def test_vulnerability(self): ct = EntityType.from_string('vuln') self.assertEqual(ct, EntityType.VULNERABILITY) ct = EntityType.from_string('vulnerability') self.assertEqual(ct, EntityType.VULNERABILITY) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_feed_type.py000066400000000000000000000032611413122500400250470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import FeedType class GetFeedTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): FeedType.from_string('foo') def test_none_or_empty(self): ct = FeedType.from_string(None) self.assertIsNone(ct) ct = FeedType.from_string('') self.assertIsNone(ct) def test_nvt(self): ct = FeedType.from_string('nvt') self.assertEqual(ct, FeedType.NVT) def test_cert(self): ct = FeedType.from_string('cert') self.assertEqual(ct, FeedType.CERT) def test_scap(self): ct = FeedType.from_string('scap') self.assertEqual(ct, FeedType.SCAP) def test_gvmd_data(self): ct = FeedType.from_string('gvmd_data') self.assertEqual(ct, FeedType.GVMD_DATA) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_filter_type.py000066400000000000000000000122151413122500400254300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import FilterType class GetFilterTypeFomStringTestCase(unittest.TestCase): def test_filter_type_alert(self): ft = FilterType.from_string('alert') self.assertEqual(ft, FilterType.ALERT) def test_filter_type_asset(self): ft = FilterType.from_string('asset') self.assertEqual(ft, FilterType.ASSET) def test_filter_type_credential(self): ft = FilterType.from_string('credential') self.assertEqual(ft, FilterType.CREDENTIAL) def test_filter_type_filter(self): ft = FilterType.from_string('filter') self.assertEqual(ft, FilterType.FILTER) def test_filter_type_group(self): ft = FilterType.from_string('group') self.assertEqual(ft, FilterType.GROUP) def test_filter_type_host(self): ft = FilterType.from_string('host') self.assertEqual(ft, FilterType.HOST) def test_filter_type_note(self): ft = FilterType.from_string('note') self.assertEqual(ft, FilterType.NOTE) def test_filter_type_override(self): ft = FilterType.from_string('override') self.assertEqual(ft, FilterType.OVERRIDE) def test_filter_type_permission(self): ft = FilterType.from_string('permission') self.assertEqual(ft, FilterType.PERMISSION) def test_filter_type_port_list(self): ft = FilterType.from_string('port_list') self.assertEqual(ft, FilterType.PORT_LIST) def test_filter_type_report(self): ft = FilterType.from_string('report') self.assertEqual(ft, FilterType.REPORT) def test_filter_type_report_format(self): ft = FilterType.from_string('report_format') self.assertEqual(ft, FilterType.REPORT_FORMAT) def test_filter_type_result(self): ft = FilterType.from_string('result') self.assertEqual(ft, FilterType.RESULT) def test_filter_type_role(self): ft = FilterType.from_string('role') self.assertEqual(ft, FilterType.ROLE) def test_filter_type_schedule(self): ft = FilterType.from_string('schedule') self.assertEqual(ft, FilterType.SCHEDULE) def test_filter_type_secinfo(self): ft = FilterType.from_string('secinfo') self.assertEqual(ft, FilterType.ALL_SECINFO) def test_filter_type_all_secinfo(self): ft = FilterType.from_string('all_secinfo') self.assertEqual(ft, FilterType.ALL_SECINFO) def test_filter_type_tag(self): ft = FilterType.from_string('tag') self.assertEqual(ft, FilterType.TAG) def test_filter_type_task(self): ft = FilterType.from_string('task') self.assertEqual(ft, FilterType.TASK) def test_filter_type_target(self): ft = FilterType.from_string('target') self.assertEqual(ft, FilterType.TARGET) def test_filter_type_ticket(self): ft = FilterType.from_string('ticket') self.assertEqual(ft, FilterType.TICKET) def test_filter_type_tls_certificate(self): ft = FilterType.from_string('tls_certificate') self.assertEqual(ft, FilterType.TLS_CERTIFICATE) def test_filter_type_operating_system(self): ft = FilterType.from_string('operating_system') self.assertEqual(ft, FilterType.OPERATING_SYSTEM) def test_filter_type_user(self): ft = FilterType.from_string('user') self.assertEqual(ft, FilterType.USER) def test_filter_type_vuln(self): ft = FilterType.from_string('vuln') self.assertEqual(ft, FilterType.VULNERABILITY) def test_filter_type_vulnerability(self): ft = FilterType.from_string('vulnerability') self.assertEqual(ft, FilterType.VULNERABILITY) def test_filter_type_config(self): ft = FilterType.from_string('config') self.assertEqual(ft, FilterType.SCAN_CONFIG) def test_filter_type_scan_config(self): ft = FilterType.from_string('scan_config') self.assertEqual(ft, FilterType.SCAN_CONFIG) def test_filter_type_os(self): ft = FilterType.from_string('os') self.assertEqual(ft, FilterType.OPERATING_SYSTEM) def test_invalid_filter_type(self): with self.assertRaises(InvalidArgument): FilterType.from_string('foo') def test_non_or_empty_filter_type(self): ft = FilterType.from_string(None) self.assertIsNone(ft) ft = FilterType.from_string('') self.assertIsNone(ft) python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_help_format.py000066400000000000000000000033731413122500400254070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import HelpFormat class GetHelpFormatFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): HelpFormat.from_string('foo') def test_none_or_empty(self): ct = HelpFormat.from_string(None) self.assertIsNone(ct) ct = HelpFormat.from_string('') self.assertIsNone(ct) def test_task_run_status_changed(self): ct = HelpFormat.from_string('HtMl') self.assertEqual(ct, HelpFormat.HTML) def test_new_secinfo_arrived(self): ct = HelpFormat.from_string('rNc') self.assertEqual(ct, HelpFormat.RNC) def test_updated_secinfo_arrived(self): ct = HelpFormat.from_string('tExT') self.assertEqual(ct, HelpFormat.TEXT) def test_ticket_received(self): ct = HelpFormat.from_string('XmL') self.assertEqual(ct, HelpFormat.XML) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_hosts_ordering.py000066400000000000000000000031271413122500400261350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import HostsOrdering class GetHostsOrderingFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): HostsOrdering.from_string('foo') def test_none_or_empty(self): ct = HostsOrdering.from_string(None) self.assertIsNone(ct) ct = HostsOrdering.from_string('') self.assertIsNone(ct) def test_sequential(self): ct = HostsOrdering.from_string("sequential") self.assertEqual(ct, HostsOrdering.SEQUENTIAL) def test_random(self): ct = HostsOrdering.from_string("random") self.assertEqual(ct, HostsOrdering.RANDOM) def test_reverse(self): ct = HostsOrdering.from_string("reverse") self.assertEqual(ct, HostsOrdering.REVERSE) python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_info_type.py000066400000000000000000000040551413122500400251010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import InfoType class GetInfoTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): InfoType.from_string('foo') def test_none_or_empty(self): ct = InfoType.from_string(None) self.assertIsNone(ct) ct = InfoType.from_string('') self.assertIsNone(ct) def test_cert_bund_adv(self): ct = InfoType.from_string('cert_bund_adv') self.assertEqual(ct, InfoType.CERT_BUND_ADV) def test_cpe(self): ct = InfoType.from_string('cpe') self.assertEqual(ct, InfoType.CPE) def test_cve(self): ct = InfoType.from_string('cve') self.assertEqual(ct, InfoType.CVE) def test_dfn_cert_adv(self): ct = InfoType.from_string('dfn_cert_adv') self.assertEqual(ct, InfoType.DFN_CERT_ADV) def test_nvt(self): ct = InfoType.from_string('nvt') self.assertEqual(ct, InfoType.NVT) def test_ovaldef(self): ct = InfoType.from_string('ovaldef') self.assertEqual(ct, InfoType.OVALDEF) def test_allinfo(self): with self.assertRaises(InvalidArgument): InfoType.from_string('allinfo') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_permission_subject_type.py000066400000000000000000000033071413122500400300540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import PermissionSubjectType class GetPermissionSubjectTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): PermissionSubjectType.from_string('foo') def test_none_or_empty(self): ct = PermissionSubjectType.from_string(None) self.assertIsNone(ct) ct = PermissionSubjectType.from_string('') self.assertIsNone(ct) def test_user(self): ct = PermissionSubjectType.from_string('user') self.assertEqual(ct, PermissionSubjectType.USER) def test_role(self): ct = PermissionSubjectType.from_string('role') self.assertEqual(ct, PermissionSubjectType.ROLE) def test_group(self): ct = PermissionSubjectType.from_string('group') self.assertEqual(ct, PermissionSubjectType.GROUP) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_port_range_type.py000066400000000000000000000027471413122500400263140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import PortRangeType class GetPortRangeTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): PortRangeType.from_string('foo') def test_none_or_empty(self): ct = PortRangeType.from_string(None) self.assertIsNone(ct) ct = PortRangeType.from_string('') self.assertIsNone(ct) def test_tcp(self): ct = PortRangeType.from_string('tcp') self.assertEqual(ct, PortRangeType.TCP) def test_udp(self): ct = PortRangeType.from_string('udp') self.assertEqual(ct, PortRangeType.UDP) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_report_format_type.py000066400000000000000000000074241413122500400270340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import ReportFormatType class GetPortRangeTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): ReportFormatType.from_string('foo') def test_none_or_empty(self): ct = ReportFormatType.from_string(None) self.assertIsNone(ct) ct = ReportFormatType.from_string('') self.assertIsNone(ct) def test_anonymous_pdf(self): ct = ReportFormatType.from_string('anonymous xml') self.assertEqual(ct, ReportFormatType.ANONYMOUS_XML) def test_arf(self): ct = ReportFormatType.from_string('arf') self.assertEqual(ct, ReportFormatType.ARF) def test_(self): ct = ReportFormatType.from_string('cpe') self.assertEqual(ct, ReportFormatType.CPE) def test_csv_hosts(self): ct = ReportFormatType.from_string('csv hosts') self.assertEqual(ct, ReportFormatType.CSV_HOSTS) def test_csv_results(self): ct = ReportFormatType.from_string('csv results') self.assertEqual(ct, ReportFormatType.CSV_RESULTS) def test_gcr_pdf(self): ct = ReportFormatType.from_string('gcr pdf') self.assertEqual(ct, ReportFormatType.GCR_PDF) def test_gsr_html(self): ct = ReportFormatType.from_string('gsr html') self.assertEqual(ct, ReportFormatType.GSR_HTML) def test_gsr_pdf(self): ct = ReportFormatType.from_string('gsr pdf') self.assertEqual(ct, ReportFormatType.GSR_PDF) def test_gxcr_pdf(self): ct = ReportFormatType.from_string('gxcr pdf') self.assertEqual(ct, ReportFormatType.GXCR_PDF) def test_gxr_pdf(self): ct = ReportFormatType.from_string('gxr pdf') self.assertEqual(ct, ReportFormatType.GXR_PDF) def test_itg(self): ct = ReportFormatType.from_string('itg') self.assertEqual(ct, ReportFormatType.ITG) def test_latex(self): ct = ReportFormatType.from_string('latex') self.assertEqual(ct, ReportFormatType.LATEX) def test_nbe(self): ct = ReportFormatType.from_string('nbe') self.assertEqual(ct, ReportFormatType.NBE) def test_pdf(self): ct = ReportFormatType.from_string('pdf') self.assertEqual(ct, ReportFormatType.PDF) def test_svg(self): ct = ReportFormatType.from_string('svg') self.assertEqual(ct, ReportFormatType.SVG) def test_txt(self): ct = ReportFormatType.from_string('txt') self.assertEqual(ct, ReportFormatType.TXT) def test_verinice_ism(self): ct = ReportFormatType.from_string('verinice ism') self.assertEqual(ct, ReportFormatType.VERINICE_ISM) def test_verinice_itg(self): ct = ReportFormatType.from_string('verinice itg') self.assertEqual(ct, ReportFormatType.VERINICE_ITG) def test_xml(self): ct = ReportFormatType.from_string('xml') self.assertEqual(ct, ReportFormatType.XML) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_scanner_type.py000066400000000000000000000047011413122500400255750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import ScannerType class GetScannerTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): ScannerType.from_string('foo') def test_none_or_empty(self): ct = ScannerType.from_string(None) self.assertIsNone(ct) ct = ScannerType.from_string('') self.assertIsNone(ct) def test_osp_scanner(self): ct = ScannerType.from_string('1') self.assertEqual(ct, ScannerType.OSP_SCANNER_TYPE) ct = ScannerType.from_string('osp') self.assertEqual(ct, ScannerType.OSP_SCANNER_TYPE) def test_openvas_scanner(self): ct = ScannerType.from_string('2') self.assertEqual(ct, ScannerType.OPENVAS_SCANNER_TYPE) ct = ScannerType.from_string('openvas') self.assertEqual(ct, ScannerType.OPENVAS_SCANNER_TYPE) def test_cve_scanner(self): ct = ScannerType.from_string('3') self.assertEqual(ct, ScannerType.CVE_SCANNER_TYPE) ct = ScannerType.from_string('cve') self.assertEqual(ct, ScannerType.CVE_SCANNER_TYPE) def test_gmp_scanner(self): with self.assertRaises(InvalidArgument): ScannerType.from_string('4') with self.assertRaises(InvalidArgument): ScannerType.from_string('gmp') def test_greenbone_sensor_scanner(self): ct = ScannerType.from_string('5') self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) ct = ScannerType.from_string('greenbone') self.assertEqual(ct, ScannerType.GREENBONE_SENSOR_SCANNER_TYPE) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_severity_level.py000066400000000000000000000035431413122500400261470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2020-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import SeverityLevel class GetSeverityLevelFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): SeverityLevel.from_string('foo') def test_none_or_empty(self): ct = SeverityLevel.from_string(None) self.assertIsNone(ct) ct = SeverityLevel.from_string('') self.assertIsNone(ct) def test_high(self): ct = SeverityLevel.from_string('High') self.assertEqual(ct, SeverityLevel.HIGH) def test_medium(self): ct = SeverityLevel.from_string('Medium') self.assertEqual(ct, SeverityLevel.MEDIUM) def test_low(self): ct = SeverityLevel.from_string('Low') self.assertEqual(ct, SeverityLevel.LOW) def test_log(self): ct = SeverityLevel.from_string('Log') self.assertEqual(ct, SeverityLevel.LOG) def test_alarm(self): ct = SeverityLevel.from_string('Alarm') self.assertEqual(ct, SeverityLevel.ALARM) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_snmp_algorithms.py000066400000000000000000000042561413122500400263160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import ( SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, ) class GetSnmpAuthAlgorithmFromStringTestCase(unittest.TestCase): def test_invalid_status(self): with self.assertRaises(InvalidArgument): SnmpAuthAlgorithm.from_string('foo') def test_none_or_empty_type(self): ts = SnmpAuthAlgorithm.from_string(None) self.assertIsNone(ts) ts = SnmpAuthAlgorithm.from_string('') self.assertIsNone(ts) def test_sha1(self): ts = SnmpAuthAlgorithm.from_string('sha1') self.assertEqual(ts, SnmpAuthAlgorithm.SHA1) def test_md5(self): ts = SnmpAuthAlgorithm.from_string('md5') self.assertEqual(ts, SnmpAuthAlgorithm.MD5) class GetSnmpPrivacyAlgorithmFromStringTestCase(unittest.TestCase): def test_invalid_status(self): with self.assertRaises(InvalidArgument): SnmpPrivacyAlgorithm.from_string('foo') def test_none_or_empty_type(self): ts = SnmpPrivacyAlgorithm.from_string(None) self.assertIsNone(ts) ts = SnmpPrivacyAlgorithm.from_string('') self.assertIsNone(ts) def test_aes(self): ts = SnmpPrivacyAlgorithm.from_string('aes') self.assertEqual(ts, SnmpPrivacyAlgorithm.AES) def test_des(self): ts = SnmpPrivacyAlgorithm.from_string('des') self.assertEqual(ts, SnmpPrivacyAlgorithm.DES) python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_sort_order.py000066400000000000000000000027521413122500400252710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import SortOrder class GetSortOrderFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): SortOrder.from_string('foo') def test_none_or_empty(self): ct = SortOrder.from_string(None) self.assertIsNone(ct) ct = SortOrder.from_string('') self.assertIsNone(ct) def test_ascending(self): ct = SortOrder.from_string('ascending') self.assertEqual(ct, SortOrder.ASCENDING) def test_descending(self): ct = SortOrder.from_string('descending') self.assertEqual(ct, SortOrder.DESCENDING) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_ticket_status.py000066400000000000000000000031521413122500400257700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import TicketStatus class GetTicketStatusFromStringTestCase(unittest.TestCase): def test_invalid_status(self): with self.assertRaises(InvalidArgument): TicketStatus.from_string('foo') def test_none_or_empty_type(self): ts = TicketStatus.from_string(None) self.assertIsNone(ts) ts = TicketStatus.from_string('') self.assertIsNone(ts) def test_ticket_status_open(self): ts = TicketStatus.from_string('open') self.assertEqual(ts, TicketStatus.OPEN) def test_ticket_status_fixed(self): ts = TicketStatus.from_string('fixed') self.assertEqual(ts, TicketStatus.FIXED) def test_ticket_status_closed(self): ts = TicketStatus.from_string('closed') self.assertEqual(ts, TicketStatus.CLOSED) python-gvm-21.10.0/tests/protocols/gmpv214/enums/test_user_auth_type.py000066400000000000000000000032271413122500400261450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmpv214 import UserAuthType class GetUserAuthTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): UserAuthType.from_string('foo') def test_none_or_empty(self): ct = UserAuthType.from_string(None) self.assertIsNone(ct) ct = UserAuthType.from_string('') self.assertIsNone(ct) def test_file(self): ct = UserAuthType.from_string('file') self.assertEqual(ct, UserAuthType.FILE) def test_radius_connect(self): ct = UserAuthType.from_string('radius_connect') self.assertEqual(ct, UserAuthType.RADIUS_CONNECT) def test_ldap_connect(self): ct = UserAuthType.from_string('ldap_connect') self.assertEqual(ct, UserAuthType.LDAP_CONNECT) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/gmpv214/system/000077500000000000000000000000001413122500400216655ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/system/__init__.py000066400000000000000000000013571413122500400240040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/tests/protocols/gmpv214/system/test_aggregates.py000066400000000000000000000016761413122500400254210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.system.aggregates import ( GmpGetAggregatesTestMixin, ) class Gmpv214GetAggregatesTestCase(GmpGetAggregatesTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/system/test_authentication.py000066400000000000000000000022641413122500400263210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.system.authentication import ( GmpAuthenticateTestMixin, GmpDescribeAuthTestMixin, GmpModifyAuthTestMixin, ) class Gmpv214AuthenticateTestCase(GmpAuthenticateTestMixin, Gmpv214TestCase): pass class Gmpv214ModifyAuthTestCase(GmpModifyAuthTestMixin, Gmpv214TestCase): pass class Gmpv214DescribeAuthCommandTestCase( GmpDescribeAuthTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/system/test_feed.py000066400000000000000000000020211413122500400241740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.system.feed import ( GmpGetFeedsTestMixin, GmpGetFeedTestMixin, ) class Gmpv214GetFeedTestCase(GmpGetFeedTestMixin, Gmpv214TestCase): pass class Gmpv214GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/system/test_help.py000066400000000000000000000016351413122500400242330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.system.help import ( GmpHelpTestMixin, ) class Gmpv214HelpTestCase(GmpHelpTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/gmpv214/system/test_system_reports.py000066400000000000000000000017151413122500400264040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.system.system_reports import GmpGetSystemReportsTestMixin class Gmpv214GetSystemReportsTestCase( GmpGetSystemReportsTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/system/test_trashcan.py000066400000000000000000000021161413122500400251010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.system.trashcan import ( GmpEmptyTrashcanTestMixin, GmpRestoreFromTrashcanTestMixin, ) class Gmpv214EmptyTrashcanTestCase(GmpEmptyTrashcanTestMixin, Gmpv214TestCase): pass class Gmpv214RestoreFromTrashcanTestCase( GmpRestoreFromTrashcanTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/system/test_user_settings.py000066400000000000000000000023341413122500400261760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.system.user_settings import ( GmpGetUserSettingTestMixin, GmpGetUserSettingsTestMixin, GmpModifyUserSettingTestMixin, ) class Gmpv214GetUserSettingTestCase( GmpGetUserSettingTestMixin, Gmpv214TestCase ): pass class Gmpv214GetUserSettingsTestCase( GmpGetUserSettingsTestMixin, Gmpv214TestCase ): pass class Gmpv214ModifyUserSettingTestCase( GmpModifyUserSettingTestMixin, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/system/test_versions.py000066400000000000000000000021201413122500400251410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from ...gmpv214 import Gmpv214TestCase from ...gmpv208.system.versions import GmpGetVersionTestCase from .versions import GmpGetProtocolVersionTestCase class Gmpv214GetVersionCommandTestCase(GmpGetVersionTestCase, Gmpv214TestCase): pass class Gmpv214GmpGetProtocolVersionTestCase( GmpGetProtocolVersionTestCase, Gmpv214TestCase ): pass python-gvm-21.10.0/tests/protocols/gmpv214/system/versions/000077500000000000000000000000001413122500400235355ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/gmpv214/system/versions/__init__.py000066400000000000000000000014651413122500400256540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from .test_get_protocol_version import GmpGetProtocolVersionTestCase python-gvm-21.10.0/tests/protocols/gmpv214/system/versions/test_get_protocol_version.py000066400000000000000000000016031413122500400314130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . class GmpGetProtocolVersionTestCase: def test_protocol_version(self): self.assertEqual(self.gmp.get_protocol_version(), (21, 4)) python-gvm-21.10.0/tests/protocols/gmpv214/test_with_statement.py000066400000000000000000000022641413122500400250150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from . import Gmpv214TestCase class GmpWithStatementTestMixin: def test_with_statement(self): self.connection.connect.has_not_been_called() self.connection.disconnect.has_not_been_called() with self.gmp: pass self.connection.connect.has_been_called() self.connection.disconnect.has_been_called() class Gmpv214WithStatementTestCase(GmpWithStatementTestMixin, Gmpv214TestCase): pass python-gvm-21.10.0/tests/protocols/osp/000077500000000000000000000000001413122500400177425ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/osp/__init__.py000066400000000000000000000000001413122500400220410ustar00rootroot00000000000000python-gvm-21.10.0/tests/protocols/osp/test_osp_delete_scan.py000066400000000000000000000025151413122500400245050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.protocols.ospv1 import Osp from .. import MockConnection class OSPDeleteScanTestCase(unittest.TestCase): def setUp(self): self.connection = MockConnection() self.osp = Osp(self.connection) def test_delete_scan(self): self.osp.delete_scan(scan_id='123-456') self.connection.send.has_been_called_with( '' ) def test_delete_scan_without_id(self): with self.assertRaises(ValueError): self.osp.delete_scan() if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/osp/test_osp_get_scanner_details.py000066400000000000000000000023041413122500400262300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.protocols.ospv1 import Osp from .. import MockConnection class OSPGetScannerDetailsTestCase(unittest.TestCase): def setUp(self): self.connection = MockConnection() self.osp = Osp(self.connection) def test_get_scanner_details_with_params(self): self.osp.get_scanner_details() self.connection.send.has_been_called_with('') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/osp/test_osp_get_scans.py000066400000000000000000000027231413122500400242060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.protocols.ospv1 import Osp from .. import MockConnection class OSPGetScanTestCase(unittest.TestCase): def setUp(self): self.connection = MockConnection() self.osp = Osp(self.connection) def test_get_scans_with_params(self): self.osp.get_scans(scan_id='123-456', details=False, pop_results=False) self.connection.send.has_been_called_with( '' ) def test_get_scans_default_params(self): self.osp.get_scans() self.connection.send.has_been_called_with( '' ) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/osp/test_osp_get_version.py000066400000000000000000000022311413122500400245560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.protocols.ospv1 import Osp from .. import MockConnection class OSPGetVersionTestCase(unittest.TestCase): def setUp(self): self.connection = MockConnection() self.osp = Osp(self.connection) def test_get_version(self): self.osp.get_version() self.connection.send.has_been_called_with('') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/osp/test_osp_get_vts.py000066400000000000000000000025071413122500400237130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.protocols.ospv1 import Osp from .. import MockConnection class OSPGetVtsTestCase(unittest.TestCase): def setUp(self): self.connection = MockConnection() self.osp = Osp(self.connection) def test_get_vts_with_vt(self): self.osp.get_vts(vt_id="1.1.1.1.1.1") self.connection.send.has_been_called_with( '' ) def test_get_vts(self): self.osp.get_vts() self.connection.send.has_been_called_with('') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/osp/test_osp_help.py000066400000000000000000000021761413122500400231720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.protocols.ospv1 import Osp from .. import MockConnection class OSPHelpTestCase(unittest.TestCase): def setUp(self): self.connection = MockConnection() self.osp = Osp(self.connection) def test_help(self): self.osp.help() self.connection.send.has_been_called_with('') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/osp/test_osp_start_scan.py000066400000000000000000000065611413122500400244050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from collections import OrderedDict from gvm.errors import RequiredArgument from gvm.protocols.ospv1 import Osp from .. import MockConnection class OSPStartScanTestCase(unittest.TestCase): def setUp(self): self.connection = MockConnection() self.osp = Osp(self.connection) def test_start_scan(self): scanner_params = OrderedDict() scanner_params['key1'] = 'value1' targets = list() _target1 = OrderedDict() _target1['hosts'] = 'localhost' _target1['ports'] = '22,80' targets.append(_target1) _target2 = OrderedDict() _target2['hosts'] = '192.168.10.1' _target2['ports'] = '443' _smb = OrderedDict() _smb['username'] = 'username' _smb['password'] = 'pass' _smb['port'] = 'port' _smb['type'] = 'type' _credential1 = {'smb': _smb} _target2['credentials'] = _credential1 targets.append(_target2) vts = OrderedDict() vts['vt1'] = {'value_id': 'value'} vts['vt_groups'] = ['family=A', 'family=B'] self.osp.start_scan( scan_id='123-456', parallel=10, scanner_params=scanner_params, targets=targets, vt_selection=vts, ) self.connection.send.has_been_called_with( '' '' 'localhost' '22,80' '192.168.10.1' '443' '' '' 'username' 'pass' '' '' '' 'value' '' '' ) def test_start_scan_without_target(self): with self.assertRaises(RequiredArgument): self.osp.start_scan() def test_start_scan_legacy(self): self.osp.start_scan( scan_id='123-456', parallel=10, target="localhost", ports="22" ) self.connection.send.has_been_called_with( '' '' ) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/osp/test_osp_stop_scan.py000066400000000000000000000027111413122500400242260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import RequiredArgument from gvm.protocols.ospv1 import Osp from .. import MockConnection class OSPStopScanTestCase(unittest.TestCase): def setUp(self): self.connection = MockConnection() self.osp = Osp(self.connection) def test_stop_scan(self): self.osp.stop_scan(scan_id="123-456") self.connection.send.has_been_called_with( '' ) def test_stop_scan_without_id(self): with self.assertRaises(RequiredArgument): self.osp.stop_scan(None) with self.assertRaises(RequiredArgument): self.osp.stop_scan('') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/test_latest.py000066400000000000000000000021561413122500400220520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # pylint: disable=no-member import unittest from gvm.protocols.latest import Gmp, Osp class LatestProtocolsTestCase(unittest.TestCase): def test_gmp_version(self): self.assertEqual(Gmp.get_protocol_version(), (20, 8)) def test_osp_version(self): self.assertEqual(Osp.get_protocol_version(), (1, 2)) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/protocols/test_next.py000066400000000000000000000021541413122500400215320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # pylint: disable=no-member import unittest from gvm.protocols.next import Gmp, Osp class LatestProtocolsTestCase(unittest.TestCase): def test_gmp_version(self): self.assertEqual(Gmp.get_protocol_version(), (21, 4)) def test_osp_version(self): self.assertEqual(Osp.get_protocol_version(), (1, 2)) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/test_errors.py000066400000000000000000000166051413122500400200520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import ( InvalidArgument, InvalidArgumentType, RequiredArgument, GvmError, GvmServerError, GvmResponseError, ) class InvalidArgumentTestCase(unittest.TestCase): def test_raise_with_message(self): with self.assertRaisesRegex(InvalidArgument, '^foo bar$'): raise InvalidArgument('foo bar') def test_message_precedence(self): with self.assertRaisesRegex(InvalidArgument, '^foo bar$') as cm: raise InvalidArgument('foo bar', argument='foo', function='bar') ex = cm.exception self.assertEqual(ex.argument, 'foo') self.assertEqual(ex.function, 'bar') self.assertEqual(str(ex), 'foo bar') def test_raise_with_argument(self): with self.assertRaises(InvalidArgument) as cm: raise InvalidArgument(argument='foo') ex = cm.exception self.assertEqual(ex.argument, 'foo') self.assertIsNone(ex.function) def test_raise_with_function(self): with self.assertRaises(InvalidArgument) as cm: raise InvalidArgument(function='foo') ex = cm.exception self.assertEqual(ex.function, 'foo') self.assertIsNone(ex.argument) def test_raise_with_argument_and_function(self): with self.assertRaises(InvalidArgument) as cm: raise InvalidArgument(argument='foo', function='bar') ex = cm.exception self.assertEqual(ex.argument, 'foo') self.assertEqual(ex.function, 'bar') def test_string_conversion(self): with self.assertRaises(InvalidArgument) as cm: raise InvalidArgument('foo bar', argument='foo') ex = cm.exception self.assertEqual(str(ex), 'foo bar') with self.assertRaises(InvalidArgument) as cm: raise InvalidArgument(argument='foo') ex = cm.exception self.assertEqual(str(ex), 'Invalid argument foo') with self.assertRaises(InvalidArgument) as cm: raise InvalidArgument(function='foo') ex = cm.exception self.assertEqual(str(ex), 'Invalid argument for foo') with self.assertRaises(InvalidArgument) as cm: raise InvalidArgument(argument='foo', function='bar') ex = cm.exception self.assertEqual(str(ex), 'Invalid argument foo for bar') def test_is_gvm_error(self): with self.assertRaises(GvmError): raise InvalidArgument('foo bar') class RequiredArgumentTestCase(unittest.TestCase): def test_raise_with_message(self): with self.assertRaisesRegex(RequiredArgument, '^foo bar$'): raise RequiredArgument('foo bar') def test_message_precedence(self): with self.assertRaisesRegex(RequiredArgument, '^foo bar$') as cm: raise RequiredArgument('foo bar', argument='foo', function='bar') ex = cm.exception self.assertEqual(ex.argument, 'foo') self.assertEqual(ex.function, 'bar') self.assertEqual(str(ex), 'foo bar') def test_raise_with_argument(self): with self.assertRaises(RequiredArgument) as cm: raise RequiredArgument(argument='foo') ex = cm.exception self.assertEqual(ex.argument, 'foo') self.assertIsNone(ex.function) def test_raise_with_function(self): with self.assertRaises(RequiredArgument) as cm: raise RequiredArgument(function='foo') ex = cm.exception self.assertEqual(ex.function, 'foo') self.assertIsNone(ex.argument) def test_raise_with_argument_and_function(self): with self.assertRaises(RequiredArgument) as cm: raise RequiredArgument(argument='foo', function='bar') ex = cm.exception self.assertEqual(ex.argument, 'foo') self.assertEqual(ex.function, 'bar') def test_string_conversion(self): with self.assertRaises(RequiredArgument) as cm: raise RequiredArgument('foo bar') ex = cm.exception self.assertEqual(str(ex), 'foo bar') with self.assertRaises(RequiredArgument) as cm: raise RequiredArgument(argument='foo') ex = cm.exception self.assertEqual(str(ex), 'Required argument foo') with self.assertRaises(RequiredArgument) as cm: raise RequiredArgument(function='foo') ex = cm.exception self.assertEqual(str(ex), 'Required argument missing for foo') with self.assertRaises(RequiredArgument) as cm: raise RequiredArgument(argument='foo', function='bar') ex = cm.exception self.assertEqual(str(ex), 'bar requires a foo argument') def test_is_gvm_error(self): with self.assertRaises(GvmError): raise RequiredArgument('foo bar') class GvmServerErrorTestCase(unittest.TestCase): def test_raise_with_message_and_status(self): with self.assertRaisesRegex(GvmServerError, '^Server Error foo. bar$'): raise GvmServerError('foo', 'bar') def test_is_gvm_error(self): with self.assertRaises(GvmError): raise GvmServerError('foo', 'bar') class GvmResponseErrorTestCase(unittest.TestCase): def test_raise_with_message_and_status(self): with self.assertRaisesRegex( GvmResponseError, '^Response Error foo. bar$' ): raise GvmResponseError('foo', 'bar') def test_is_gvm_error(self): with self.assertRaises(GvmError): raise GvmResponseError('foo', 'bar') class InvalidArgumentTypeTestCase(unittest.TestCase): def test_raise_with_argument_and_arg_type(self): with self.assertRaisesRegex( InvalidArgumentType, '^The argument foo must be of type bar.$' ): raise InvalidArgumentType('foo', 'bar') def test_raise_with_function(self): with self.assertRaisesRegex( InvalidArgumentType, '^In baz the argument foo must be of type bar.$', ): raise InvalidArgumentType('foo', 'bar', function='baz') def test_string_conversion(self): with self.assertRaises(InvalidArgumentType) as cm: raise InvalidArgumentType('foo', 'bar') ex = cm.exception self.assertEqual(str(ex), 'The argument foo must be of type bar.') self.assertIsNone(ex.function) with self.assertRaises(InvalidArgumentType) as cm: raise InvalidArgumentType('foo', 'bar', function='baz') ex = cm.exception self.assertEqual( str(ex), 'In baz the argument foo must be of type bar.' ) def test_is_gvm_error(self): with self.assertRaises(GvmError): raise InvalidArgumentType('foo', 'bar') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/transforms/000077500000000000000000000000001413122500400173135ustar00rootroot00000000000000python-gvm-21.10.0/tests/transforms/__init__.py000066400000000000000000000000001413122500400214120ustar00rootroot00000000000000python-gvm-21.10.0/tests/transforms/test_check_command_transform.py000066400000000000000000000047051413122500400256000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from lxml import etree from gvm.errors import GvmError, GvmResponseError, GvmServerError from gvm.transforms import CheckCommandTransform class CheckCommandTransformTestCase(unittest.TestCase): def test_no_status_transform(self): transform = CheckCommandTransform() with self.assertRaises(GvmError): transform('') def test_no_success_300status_transform(self): transform = CheckCommandTransform() root = etree.Element('foo_response') root.set('status', '300') root.set('status_text', 'Foo error') response = etree.tostring(root).decode('utf-8') with self.assertRaises(GvmError): transform(response) def test_no_success_400status_transform(self): transform = CheckCommandTransform() root = etree.Element('foo_response') root.set('status', '400') root.set('status_text', 'Foo error') response = etree.tostring(root).decode('utf-8') with self.assertRaises(GvmResponseError): transform(response) def test_no_success_500status_transform(self): transform = CheckCommandTransform() root = etree.Element('foo_response') root.set('status', '500') root.set('status_text', 'Foo error') response = etree.tostring(root).decode('utf-8') with self.assertRaises(GvmServerError): transform(response) def test_success_response(self): transform = CheckCommandTransform() root = etree.Element('foo_response') root.set('status', '200') response = etree.tostring(root).decode('utf-8') self.assertEqual(transform(response), '') python-gvm-21.10.0/tests/transforms/test_etree_check_command_transform.py000066400000000000000000000035351413122500400267640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from lxml import etree from gvm.errors import GvmError from gvm.transforms import EtreeCheckCommandTransform class EtreeCheckCommandTransformTestCase(unittest.TestCase): def test_no_status_transform(self): transform = EtreeCheckCommandTransform() with self.assertRaises(GvmError): transform('') def test_no_success_status_transform(self): transform = EtreeCheckCommandTransform() root = etree.Element('foo_response') root.set('status', '400') root.set('status_text', 'Foo error') response = etree.tostring(root).decode('utf-8') with self.assertRaises(GvmError): transform(response) def test_success_response(self): transform = EtreeCheckCommandTransform() root = etree.Element('foo_response') root.set('status', '200') response = etree.tostring(root).decode('utf-8') result = transform(response) self.assertTrue(etree.iselement(result)) self.assertEqual(result.tag, 'foo_response') self.assertEqual(result.get('status'), '200') python-gvm-21.10.0/tests/transforms/test_etree_transform.py000066400000000000000000000025641413122500400241320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from lxml import etree from gvm.transforms import EtreeTransform class EtreeTransformTestCase(unittest.TestCase): def test_transform_response(self): transform = EtreeTransform() result = transform('') self.assertTrue(etree.iselement(result)) def test_transform_more_complex_response(self): transform = EtreeTransform() result = transform('') self.assertTrue(etree.iselement(result)) self.assertEqual(result.tag, 'foo') self.assertEqual(result.get('id'), 'bar') self.assertEqual(len(result), 2) python-gvm-21.10.0/tests/utils/000077500000000000000000000000001413122500400162555ustar00rootroot00000000000000python-gvm-21.10.0/tests/utils/__init__.py000066400000000000000000000000001413122500400203540ustar00rootroot00000000000000python-gvm-21.10.0/tests/utils/test_add_filter.py000066400000000000000000000025471413122500400217730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.utils import add_filter from gvm.xml import XmlCommand class TestAddFilter(unittest.TestCase): def test_add_filter(self): cmd = XmlCommand("test") filter_string = "foo" add_filter(cmd, filter_string=filter_string, filter_id=None) self.assertEqual(cmd.to_string(), '') def test_add_filter_id(self): cmd = XmlCommand("test") filter_id = "foo" add_filter(cmd, filter_string=None, filter_id=filter_id) self.assertEqual(cmd.to_string(), '') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/utils/test_check_command_status.py000066400000000000000000000050621413122500400240470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.utils import check_command_status class TestCheckCommandStatus(unittest.TestCase): def test_check_command_status_empty(self): with self.assertLogs('gvm.utils', level="ERROR") as error_logger: false = check_command_status(xml=False) self.assertFalse(false) false = check_command_status(xml=0) self.assertFalse(false) self.assertEqual( error_logger.output, [ "ERROR:gvm.utils:XML Command is empty.", "ERROR:gvm.utils:XML Command is empty.", ], ) def test_check_command_status_failed(self): response = ( '' ) with self.assertLogs('gvm.utils', level="ERROR") as error_logger: self.assertFalse(check_command_status(xml=response)) self.assertEqual( error_logger.output, [ 'ERROR:gvm.utils:etree.XML(xml): error parsing attribute name, ' 'line 1, column 36 (, line 1)' ], ) def test_check_command_status_error(self): response = '' with self.assertLogs('gvm.utils', level="ERROR") as error_logger: self.assertFalse(check_command_status(xml=response)) self.assertEqual( error_logger.output, [ 'ERROR:gvm.utils:Not received an ' 'status code within the response.' ], ) def test_check_command_status(self): response = ( '' ) self.assertTrue(check_command_status(xml=response)) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/utils/test_deprecation.py000066400000000000000000000025111413122500400221620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest import warnings from gvm.utils import deprecation class TestDeprecation(unittest.TestCase): def test_deprecation(self): # pylint: disable=invalid-name with warnings.catch_warnings(record=True) as w: self.assertEqual(len(w), 0) warnings.simplefilter("always") deprecation('I am deprecated') self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[0].category, DeprecationWarning)) self.assertIn(str(w[0].message), 'I am deprecated') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/utils/test_is_list_like.py000066400000000000000000000022731413122500400223440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.utils import is_list_like class TestIsListLike(unittest.TestCase): def test_is_list_like(self): self.assertFalse(is_list_like(True)) self.assertFalse(is_list_like("foo")) self.assertFalse(is_list_like(13)) self.assertTrue(is_list_like([1])) self.assertTrue(is_list_like(["1", "2"])) self.assertTrue(is_list_like(('2', '3'))) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/utils/test_to_base64.py000066400000000000000000000020561413122500400214570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.utils import to_base64 class TestToBase64(unittest.TestCase): def test_to_base64(self): foo64 = to_base64("foo") self.assertEqual(b"Zm9v", foo64) bar64 = to_base64("bar") self.assertEqual(b'YmFy', bar64) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/utils/test_to_bool.py000066400000000000000000000020311413122500400213170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.utils import to_bool class TestToBool(unittest.TestCase): def test_to_bool(self): true = to_bool(True) self.assertEqual("1", true) false = to_bool(False) self.assertEqual("0", false) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/utils/test_to_comma_list.py000066400000000000000000000021351413122500400225200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.utils import to_comma_list class TestToCoCommaList(unittest.TestCase): def test_to_comma_list(self): # pylint: disable=invalid-name the_list = ['foo', 'bar', 'baz'] comma_string = to_comma_list(the_list) self.assertEqual('foo,bar,baz', comma_string) if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/xml/000077500000000000000000000000001413122500400157155ustar00rootroot00000000000000python-gvm-21.10.0/tests/xml/__init__.py000066400000000000000000000013641413122500400200320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . python-gvm-21.10.0/tests/xml/test.file000066400000000000000000000000001413122500400175230ustar00rootroot00000000000000python-gvm-21.10.0/tests/xml/test_pretty_print.py000066400000000000000000000127511413122500400220770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2019-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import sys import unittest from unittest.mock import patch from io import StringIO import defusedxml.lxml as secET from gvm.errors import InvalidArgumentType from gvm.xml import pretty_print class PrettyPrintTestCase(unittest.TestCase): def test_pretty_print_to_file(self): xml_str = 'and text' elem = secET.fromstring(xml_str) expected_xml_string = ( '\n' ' \n' ' and text\n' ' \n' '\n' ) with open('test.file', 'w', encoding="utf-8") as f: pretty_print(elem, file=f) with open('test.file', 'r', encoding="utf-8") as f: xml_string = f.read() self.assertEqual(xml_string, expected_xml_string) def test_pretty_print_to_stringio(self): xml_str = 'and text' elem = secET.fromstring(xml_str) expected_xml_string = ( '\n' ' \n' ' and text\n' ' \n' '\n' ) stringio = StringIO() pretty_print(elem, file=stringio) xml_string = stringio.getvalue() self.assertEqual(xml_string, expected_xml_string) # I don't know why: But this test is only working if sys.stdout is passed. # But printing to sys.stdout is working, too using the default argument ... @patch('sys.stdout', new_callable=StringIO) def test_pretty_print_to_stdout(self, mock_stdout): xml_str = 'and text' elem = secET.fromstring(xml_str) expected_xml_string = ( '\n' ' \n' ' and text\n' ' \n' '\n' ) pretty_print(elem, sys.stdout) xml_string = mock_stdout.getvalue() self.assertEqual(xml_string, expected_xml_string) def test_pretty_print_with_string(self): xml_str = 'and text' expected_xml_string = ( '\n' ' \n' ' and text\n' ' \n' '\n' ) stringio = StringIO() pretty_print(xml_str, file=stringio) xml_string = stringio.getvalue() self.assertEqual(xml_string, expected_xml_string) @patch('sys.stdout', new_callable=StringIO) def test_pretty_print_with_string_to_stdout(self, mock_stdout): xml_str = 'and text' expected_xml_string = ( '\n' ' \n' ' and text\n' ' \n' '\n' ) pretty_print(xml_str, sys.stdout) xml_string = mock_stdout.getvalue() self.assertEqual(xml_string, expected_xml_string) def test_pretty_print_with_dict(self): xml_str = 'and text' elem = secET.fromstring(xml_str) expected_xml_string = ( '\n' ' \n' ' and text\n' ' \n' '\n' '\n' ' \n' ' and text\n' ' \n' '\n' ) stringio = StringIO() pretty_print([elem, elem], file=stringio) xml_string = stringio.getvalue() self.assertEqual(xml_string, expected_xml_string) def test_pretty_print_with_dict_str(self): xml_str = 'and text' no_xml = '' elem = secET.fromstring(xml_str) expected_xml_string = ( '\n' ' \n' ' and text\n' ' \n' '\n' '\n' ) stringio = StringIO() pretty_print([elem, no_xml], file=stringio) xml_string = stringio.getvalue() self.assertEqual(xml_string, expected_xml_string) def test_pretty_print_no_xml(self): number = 1 stringio = StringIO() with self.assertRaises(InvalidArgumentType): pretty_print(number, file=stringio) def test_pretty_print_type_error(self): xml_str = 'and text' elem = secET.fromstring(xml_str) with self.assertRaises(TypeError): pretty_print(elem, file='string') if __name__ == '__main__': unittest.main() python-gvm-21.10.0/tests/xml/test_valid_xml_string.py000066400000000000000000000030251413122500400226730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from gvm.errors import GvmError from gvm.xml import validate_xml_string class ValidXmlStringTestCase(unittest.TestCase): def test_missing_closing_tag(self): with self.assertRaises(GvmError): validate_xml_string('') def test_invalid_tag(self): with self.assertRaises(GvmError): validate_xml_string('') def test_xml_bomb(self): xml = ( '' '' '' '' ']>' '&c;' ) with self.assertRaises(GvmError): validate_xml_string(xml) python-gvm-21.10.0/tests/xml/test_xml_command.py000066400000000000000000000050261413122500400216270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (C) 2018-2021 Greenbone Networks GmbH # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import unittest from collections import OrderedDict from gvm.xml import XmlCommand class XmlCommandTestCase(unittest.TestCase): def test_should_create_command(self): cmd = XmlCommand('foo') self.assertEqual(cmd.to_string(), '') def test_should_allow_to_add_element(self): cmd = XmlCommand('foo') cmd.add_element('bar') self.assertEqual(cmd.to_string(), '') def test_should_allow_to_add_element_with_text(self): cmd = XmlCommand('foo') cmd.add_element('bar', '1') self.assertEqual(cmd.to_string(), '1') def test_should_allow_to_set_attribute(self): cmd = XmlCommand('foo') cmd.set_attribute('bar', '1') self.assertEqual(cmd.to_string(), '') def test_should_allow_to_set_attributes(self): cmd = XmlCommand('foo') cmd.set_attributes(OrderedDict([('bar', '1'), ('baz', '2')])) self.assertEqual(cmd.to_string(), '') def test_should_convert_to_string(self): cmd = XmlCommand('foo') self.assertEqual(str(cmd), '') def test_invalid_xml(self): with self.assertRaises(ValueError): XmlCommand('Foo & Bar') def test_xml_escaping(self): cmd = XmlCommand('foo') cmd.add_element('bar', 'Foo & Bar') self.assertEqual(cmd.to_string(), 'Foo & Bar') cmd = XmlCommand('foo') cmd.set_attribute('bar', 'Foo & Bar') self.assertEqual(cmd.to_string(), '') cmd = XmlCommand('foo') cmd.set_attribute('bar', 'Foo "Bar"') self.assertEqual(cmd.to_string(), '') if __name__ == '__main__': unittest.main()